mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
restucturing project
This commit is contained in:
parent
1be392e7da
commit
358a7834e0
14
.gitignore
vendored
14
.gitignore
vendored
@ -2,13 +2,13 @@
|
||||
PiGallery2.iml
|
||||
node_modules/
|
||||
pigallery2.zip
|
||||
frontend/**/*.js
|
||||
frontend/**/*.js.map
|
||||
frontend/dist
|
||||
backend/**/*.js
|
||||
backend/**/*.js.map
|
||||
common/**/*.js
|
||||
common/**/*.js.map
|
||||
src/frontend/**/*.js
|
||||
src/frontend/**/*.js.map
|
||||
src/frontend/dist
|
||||
src/backend/**/*.js
|
||||
src/backend/**/*.js.map
|
||||
src/common/**/*.js
|
||||
src/common/**/*.js.map
|
||||
test/coverage
|
||||
test/backend/**/*.js
|
||||
test/backend/**/*.js.map
|
||||
|
30
angular.json
30
angular.json
@ -5,26 +5,26 @@
|
||||
"projects": {
|
||||
"pigallery2": {
|
||||
"root": "",
|
||||
"sourceRoot": "frontend",
|
||||
"sourceRoot": "src/frontend",
|
||||
"projectType": "application",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist",
|
||||
"index": "frontend/index.html",
|
||||
"main": "frontend/main.ts",
|
||||
"tsConfig": "frontend/tsconfig.app.json",
|
||||
"polyfills": "frontend/polyfills.ts",
|
||||
"index": "src/frontend/index.html",
|
||||
"main": "src/frontend/main.ts",
|
||||
"tsConfig": "src/frontend/tsconfig.app.json",
|
||||
"polyfills": "src/frontend/polyfills.ts",
|
||||
"assets": [
|
||||
"frontend/assets"
|
||||
"src/frontend/assets"
|
||||
],
|
||||
"styles": [
|
||||
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
|
||||
"./node_modules/open-iconic/font/css/open-iconic-bootstrap.css",
|
||||
"./node_modules/ngx-toastr/toastr.css",
|
||||
"frontend/styles.css"
|
||||
"src/frontend/styles.css"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
@ -41,8 +41,8 @@
|
||||
"buildOptimizer": true,
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "frontend/environments/environment.ts",
|
||||
"with": "frontend/environments/environment.prod.ts"
|
||||
"replace": "src/frontend/environments/environment.ts",
|
||||
"with": "src/frontend/environments/environment.prod.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -68,10 +68,10 @@
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "frontend/test.ts",
|
||||
"main": "src/frontend/test.ts",
|
||||
"karmaConfig": "./karma.conf.js",
|
||||
"polyfills": "frontend/polyfills.ts",
|
||||
"tsConfig": "frontend/tsconfig.spec.json",
|
||||
"polyfills": "src/frontend/polyfills.ts",
|
||||
"tsConfig": "src/frontend/tsconfig.spec.json",
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
@ -79,10 +79,10 @@
|
||||
"node_modules/bootstrap/dist/css/bootstrap.css",
|
||||
"node_modules/open-iconic/font/css/open-iconic-bootstrap.css",
|
||||
"node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
|
||||
"frontend/styles.css"
|
||||
"src/frontend/styles.css"
|
||||
],
|
||||
"assets": [
|
||||
"frontend/assets"
|
||||
"src/frontend/assets"
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -132,4 +132,4 @@
|
||||
"prefix": "app"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import {SQLConnection} from '../backend/model/sql/SQLConnection';
|
||||
import {Config} from '../common/config/private/Config';
|
||||
import {ObjectManagers} from '../backend/model/ObjectManagers';
|
||||
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker';
|
||||
import {IndexingManager} from '../backend/model/sql/IndexingManager';
|
||||
import {SearchManager} from '../backend/model/sql/SearchManager';
|
||||
import {SQLConnection} from '../src/backend/model/sql/SQLConnection';
|
||||
import {Config} from '../src/common/config/private/Config';
|
||||
import {ObjectManagers} from '../src/backend/model/ObjectManagers';
|
||||
import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
|
||||
import {IndexingManager} from '../src/backend/model/sql/IndexingManager';
|
||||
import {SearchManager} from '../src/backend/model/sql/SearchManager';
|
||||
import * as fs from 'fs';
|
||||
import {SearchTypes} from '../common/entities/AutoCompleteItem';
|
||||
import {Utils} from '../common/Utils';
|
||||
import {GalleryManager} from '../backend/model/sql/GalleryManager';
|
||||
import {DirectoryDTO} from '../common/entities/DirectoryDTO';
|
||||
import {ServerConfig} from '../common/config/private/IPrivateConfig';
|
||||
import {SearchTypes} from '../src/common/entities/AutoCompleteItem';
|
||||
import {Utils} from '../src/common/Utils';
|
||||
import {GalleryManager} from '../src/backend/model/sql/GalleryManager';
|
||||
import {DirectoryDTO} from '../src/common/entities/DirectoryDTO';
|
||||
import {ServerConfig} from '../src/common/config/private/IPrivateConfig';
|
||||
|
||||
export interface BenchmarkResult {
|
||||
duration: number;
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {Config} from '../common/config/private/Config';
|
||||
import {Config} from '../src/common/config/private/Config';
|
||||
import * as path from 'path';
|
||||
import {ProjectPath} from '../backend/ProjectPath';
|
||||
import {ProjectPath} from '../src/backend/ProjectPath';
|
||||
import {BenchmarkResult, Benchmarks} from './Benchmarks';
|
||||
import {SearchTypes} from '../common/entities/AutoCompleteItem';
|
||||
import {Utils} from '../common/Utils';
|
||||
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker';
|
||||
import {SearchTypes} from '../src/common/entities/AutoCompleteItem';
|
||||
import {Utils} from '../src/common/Utils';
|
||||
import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
|
||||
|
||||
const config: { path: string, system: string } = require(path.join(__dirname, 'config.json'));
|
||||
Config.Server.imagesFolder = config.path;
|
||||
|
@ -1,30 +0,0 @@
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/dist/long-stack-trace-zone';
|
||||
import 'zone.js/dist/proxy.js';
|
||||
import 'zone.js/dist/sync-test';
|
||||
import 'zone.js/dist/jasmine-patch';
|
||||
import 'zone.js/dist/async-test';
|
||||
import 'zone.js/dist/fake-async-test';
|
||||
import {getTestBed} from '@angular/core/testing';
|
||||
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
||||
declare const __karma__: any;
|
||||
declare const require: any;
|
||||
|
||||
// Prevent Karma from running prematurely.
|
||||
__karma__.loaded = function () {
|
||||
};
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
// Finally, start Karma to run the tests.
|
||||
__karma__.start();
|
26
gulpfile.ts
26
gulpfile.ts
@ -13,8 +13,8 @@ const tsBackendProject = ts.createProject('tsconfig.json');
|
||||
|
||||
gulp.task('build-backend', function () {
|
||||
return gulp.src([
|
||||
'common/**/*.ts',
|
||||
'backend/**/*.ts'], {base: '.'})
|
||||
'src/common/**/*.ts',
|
||||
'src/backend/**/*.ts'], {base: '.'})
|
||||
.pipe(tsBackendProject())
|
||||
.js
|
||||
.pipe(gulp.dest('./release'));
|
||||
@ -36,10 +36,10 @@ const createFrontendTask = (type: string, script: string) => {
|
||||
};
|
||||
|
||||
const getLanguages = () => {
|
||||
if (!fs.existsSync('./frontend/' + translationFolder)) {
|
||||
if (!fs.existsSync('./src/frontend/' + translationFolder)) {
|
||||
return [];
|
||||
}
|
||||
const dirCont = fs.readdirSync('./frontend/' + translationFolder);
|
||||
const dirCont = fs.readdirSync('./src/frontend/' + translationFolder);
|
||||
const files: string[] = dirCont.filter((elm) => {
|
||||
return elm.match(/.*\.[a-zA-Z]+\.(xlf)/ig);
|
||||
});
|
||||
@ -71,14 +71,14 @@ gulp.task('build-frontend', (() => {
|
||||
const tasks = [];
|
||||
createFrontendTask('build-frontend-release default',
|
||||
'ng build --aot --prod --output-path=./release/dist --no-progress --i18n-locale=en' +
|
||||
' --i18n-format xlf --i18n-file frontend/' + translationFolder + '/messages.en.xlf' +
|
||||
' --i18n-format xlf --i18n-file src/frontend/' + translationFolder + '/messages.en.xlf' +
|
||||
' --i18n-missing-translation warning');
|
||||
tasks.push('build-frontend-release default');
|
||||
for (let i = 0; i < languages.length; i++) {
|
||||
createFrontendTask('build-frontend-release ' + languages[i],
|
||||
'ng build --aot --prod --output-path=./release/dist/' + languages[i] +
|
||||
' --no-progress --i18n-locale=' + languages[i] +
|
||||
' --i18n-format xlf --i18n-file frontend/' + translationFolder + '/messages.' + languages[i] + '.xlf' +
|
||||
' --i18n-format xlf --i18n-file src/frontend/' + translationFolder + '/messages.' + languages[i] + '.xlf' +
|
||||
' --i18n-missing-translation warning');
|
||||
tasks.push('build-frontend-release ' + languages[i]);
|
||||
}
|
||||
@ -87,7 +87,7 @@ gulp.task('build-frontend', (() => {
|
||||
|
||||
gulp.task('copy-static', function () {
|
||||
return gulp.src([
|
||||
'backend/model/diagnostics/blank.jpg',
|
||||
'src/backend/model/diagnostics/blank.jpg',
|
||||
'README.md',
|
||||
'LICENSE'], {base: '.'})
|
||||
.pipe(gulp.dest('./release'));
|
||||
@ -102,7 +102,7 @@ gulp.task('copy-package', function () {
|
||||
}))
|
||||
.pipe(jsonModify({
|
||||
key: 'scripts',
|
||||
value: {'start': 'node ./backend/index.js'}
|
||||
value: {'start': 'node ./src/backend/index.js'}
|
||||
}))
|
||||
.pipe(gulp.dest('./release'));
|
||||
});
|
||||
@ -127,14 +127,14 @@ const simpleBuild = (isProd: boolean) => {
|
||||
cmd += ' --prod --no-extract-licenses ';
|
||||
}
|
||||
createFrontendTask('build-frontend default', cmd + '--output-path=./dist --no-progress --no-progress --i18n-locale en' +
|
||||
' --i18n-format=xlf --i18n-file=frontend/' + translationFolder + '/messages.en.xlf' + ' --i18n-missing-translation warning');
|
||||
' --i18n-format=xlf --i18n-file=src/frontend/' + translationFolder + '/messages.en.xlf' + ' --i18n-missing-translation warning');
|
||||
tasks.push('build-frontend default');
|
||||
if (!process.env.CI) { // don't build languages if running in CI
|
||||
for (let i = 0; i < languages.length; i++) {
|
||||
createFrontendTask('build-frontend ' + languages[i], cmd +
|
||||
'--output-path=./dist/' + languages[i] +
|
||||
' --no-progress --i18n-locale ' + languages[i] +
|
||||
' --i18n-format=xlf --i18n-file=frontend/' + translationFolder +
|
||||
' --i18n-format=xlf --i18n-file=src/frontend/' + translationFolder +
|
||||
'/messages.' + languages[i] + '.xlf' + ' --i18n-missing-translation warning');
|
||||
tasks.push('build-frontend ' + languages[i]);
|
||||
}
|
||||
@ -151,20 +151,20 @@ gulp.task('extract-locale', (cb) => {
|
||||
if (error) {
|
||||
return cb(error);
|
||||
}
|
||||
exec('ngx-extractor -i frontend/**/*.ts -f xlf --out-file locale.source.xlf',
|
||||
exec('ngx-extractor -i src/frontend/**/*.ts -f xlf --out-file locale.source.xlf',
|
||||
handleError(cb));
|
||||
});
|
||||
});
|
||||
|
||||
const translate = (list: any[], cb: (err: any) => void) => {
|
||||
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"';
|
||||
exec('xlf-google-translate --source-lang="en" --source-file="./locale.source.xlf" --destination-folder="./frontend/"' +
|
||||
exec('xlf-google-translate --source-lang="en" --source-file="./locale.source.xlf" --destination-folder="./src/frontend/"' +
|
||||
translationFolder + ' --destination-languages=' + localsStr,
|
||||
handleError(cb));
|
||||
};
|
||||
const merge = (list: any[], cb: (err: any) => void) => {
|
||||
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"';
|
||||
exec('xlf-google-translate --method="extend-only" --source-lang="en" --source-file="./locale.source.xlf" --destination-folder="./frontend/"' +
|
||||
exec('xlf-google-translate --method="extend-only" --source-lang="en" --source-file="./locale.source.xlf" --destination-folder="./src/frontend/"' +
|
||||
translationFolder + ' --destination-languages=' + localsStr,
|
||||
handleError(cb));
|
||||
};
|
||||
|
@ -5,8 +5,8 @@
|
||||
"author": "Patrik J. Braun",
|
||||
"homepage": "https://github.com/bpatrik/PiGallery2",
|
||||
"license": "MIT",
|
||||
"main": "./backend/index.js",
|
||||
"bin": "./backend/index.js",
|
||||
"main": "./src/backend/index.js",
|
||||
"bin": "./src/backend/index.js",
|
||||
"scripts": {
|
||||
"install": "npm run build-prod",
|
||||
"build-prod": "tsc && gulp build-prod",
|
||||
@ -15,8 +15,8 @@
|
||||
"pretest": "tsc",
|
||||
"test": "ng test && mocha --recursive test/backend/unit && mocha --recursive test/backend/integration && mocha --recursive test/common/unit ",
|
||||
"start": "node ./backend/index",
|
||||
"run-dev": "ng build --aot --watch --output-path=./dist --i18n-locale en --i18n-file frontend/translate/messages.en.xlf --i18n-missing-translation warning",
|
||||
"build-stats": "ng build --aot --prod --stats-json --output-path=./dist --i18n-locale en --i18n-file frontend/translate/messages.en.xlf --i18n-missing-translation warning",
|
||||
"run-dev": "ng build --aot --watch --output-path=./dist --i18n-locale en --i18n-file src/frontend/translate/messages.en.xlf --i18n-missing-translation warning",
|
||||
"build-stats": "ng build --aot --prod --stats-json --output-path=./dist --i18n-locale en --i18n-file src/frontend/translate/messages.en.xlf --i18n-missing-translation warning",
|
||||
"merge-new-translation": "gulp merge-new-translation",
|
||||
"add-translation": "gulp add-translation"
|
||||
},
|
||||
|
@ -30,7 +30,7 @@ class ProjectPathClass {
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.Root = path.join(__dirname, '/../');
|
||||
this.Root = path.join(__dirname, '/../../');
|
||||
this.ImageFolder = this.getAbsolutePath(Config.Server.imagesFolder);
|
||||
this.ThumbnailFolder = this.getAbsolutePath(Config.Server.Thumbnail.folder);
|
||||
this.TranscendedFolder = path.join(this.ThumbnailFolder, 'tc');
|
@ -231,7 +231,7 @@ export class ConfigDiagnostics {
|
||||
|
||||
|
||||
try {
|
||||
await ConfigDiagnostics.testClientVideoConfig(Config.Server.Video);
|
||||
await ConfigDiagnostics.testClientVideoConfig(Config.Client.Video);
|
||||
await ConfigDiagnostics.testServerVideoConfig(Config.Server.Video, Config);
|
||||
} catch (ex) {
|
||||
const err: Error = ex;
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 631 B |
@ -9,4 +9,6 @@ export interface ITask<T> extends TaskDTO {
|
||||
start(config: T): Promise<void>;
|
||||
|
||||
stop(): void;
|
||||
|
||||
toJSON(): TaskDTO;
|
||||
}
|
@ -9,7 +9,7 @@ import {MediaDTO} from '../../../../common/entities/MediaDTO';
|
||||
import {ProjectPath} from '../../../ProjectPath';
|
||||
import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs';
|
||||
import {Task} from './Task';
|
||||
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
|
||||
import {ConfigTemplateEntry, DefaultsTasks, TaskDTO} from '../../../../common/entities/task/TaskDTO';
|
||||
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
|
||||
|
||||
declare const global: any;
|
||||
@ -29,6 +29,7 @@ export class IndexingTask extends Task<{ createThumbnails: boolean }> {
|
||||
return Config.Server.Database.type !== ServerConfig.DatabaseType.memory;
|
||||
}
|
||||
|
||||
|
||||
protected async init() {
|
||||
this.directoriesToIndex.push('/');
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import {TaskProgressDTO} from '../../../../common/entities/settings/TaskProgressDTO';
|
||||
import {Logger} from '../../../Logger';
|
||||
import {ITask} from './ITask';
|
||||
import {ConfigTemplateEntry} from '../../../../common/entities/task/TaskDTO';
|
||||
import {ConfigTemplateEntry, TaskDTO} from '../../../../common/entities/task/TaskDTO';
|
||||
|
||||
declare const process: any;
|
||||
|
||||
@ -55,6 +55,13 @@ export abstract class Task<T = void> implements ITask<T> {
|
||||
this.onFinish();
|
||||
}
|
||||
|
||||
public toJSON(): TaskDTO {
|
||||
return {
|
||||
Name: this.Name,
|
||||
ConfigTemplate: this.ConfigTemplate
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract async step(): Promise<TaskProgressDTO>;
|
||||
|
||||
protected abstract async init(): Promise<void>;
|
@ -30,15 +30,14 @@ export class Server {
|
||||
if (!(process.env.NODE_ENV === 'production')) {
|
||||
Logger.info(LOG_TAG, 'Running in DEBUG mode, set env variable NODE_ENV=production to disable ');
|
||||
}
|
||||
this.init();
|
||||
this.init().catch(console.error);
|
||||
}
|
||||
|
||||
async init() {
|
||||
async init(): Promise<void> {
|
||||
Logger.info(LOG_TAG, 'running diagnostics...');
|
||||
await ConfigDiagnostics.runDiagnostics();
|
||||
Logger.verbose(LOG_TAG, 'using config:');
|
||||
const appVer = require('../package.json').version;
|
||||
Config.Client.appVersion = appVer;
|
||||
Config.Client.appVersion = require('../../package.json').version;
|
||||
Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t'));
|
||||
|
||||
this.app = _express();
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user