1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-06-17 00:07:36 +02:00

restucturing project

This commit is contained in:
Patrik J. Braun
2019-12-10 10:44:35 +01:00
parent 1be392e7da
commit 358a7834e0
345 changed files with 181 additions and 202 deletions
.gitignoreangular.json
benchmark
frontend
gulpfile.tspackage.json
src
backend
common
frontend
app
app.component.tsapp.module.tsapp.routing.ts
model
pipes
ui
admin
duplicates
faces
frame
gallery
Media.tsMediaIcon.tscache.gallery.service.ts
directories
fullscreen.service.tsgallery.component.cssgallery.component.htmlgallery.component.tsgallery.service.ts
grid
lightbox
map
navigator
overlay.service.ts
random-query-builder
search
share.service.ts
share
thumbnailLoader.service.tsthumbnailManager.service.ts
language
login
settings
_abstract
basic
database
faces
indexing
map
metafiles
other
random-photo
scheduled-tasks.service.ts
search
settings.service.ts
share
tasks
thumbnail
usermanager
video
sharelogin
utils
assets
environments
index.htmlmain.tspolyfills.tsstyles.css
translate
tsconfig.app.jsontsconfig.spec.jsontypings.d.ts
test

14
.gitignore vendored

@ -2,13 +2,13 @@
PiGallery2.iml PiGallery2.iml
node_modules/ node_modules/
pigallery2.zip pigallery2.zip
frontend/**/*.js src/frontend/**/*.js
frontend/**/*.js.map src/frontend/**/*.js.map
frontend/dist src/frontend/dist
backend/**/*.js src/backend/**/*.js
backend/**/*.js.map src/backend/**/*.js.map
common/**/*.js src/common/**/*.js
common/**/*.js.map src/common/**/*.js.map
test/coverage test/coverage
test/backend/**/*.js test/backend/**/*.js
test/backend/**/*.js.map test/backend/**/*.js.map

@ -5,26 +5,26 @@
"projects": { "projects": {
"pigallery2": { "pigallery2": {
"root": "", "root": "",
"sourceRoot": "frontend", "sourceRoot": "src/frontend",
"projectType": "application", "projectType": "application",
"architect": { "architect": {
"build": { "build": {
"builder": "@angular-devkit/build-angular:browser", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist", "outputPath": "dist",
"index": "frontend/index.html", "index": "src/frontend/index.html",
"main": "frontend/main.ts", "main": "src/frontend/main.ts",
"tsConfig": "frontend/tsconfig.app.json", "tsConfig": "src/frontend/tsconfig.app.json",
"polyfills": "frontend/polyfills.ts", "polyfills": "src/frontend/polyfills.ts",
"assets": [ "assets": [
"frontend/assets" "src/frontend/assets"
], ],
"styles": [ "styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css", "./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css", "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"./node_modules/open-iconic/font/css/open-iconic-bootstrap.css", "./node_modules/open-iconic/font/css/open-iconic-bootstrap.css",
"./node_modules/ngx-toastr/toastr.css", "./node_modules/ngx-toastr/toastr.css",
"frontend/styles.css" "src/frontend/styles.css"
], ],
"scripts": [] "scripts": []
}, },
@ -41,8 +41,8 @@
"buildOptimizer": true, "buildOptimizer": true,
"fileReplacements": [ "fileReplacements": [
{ {
"replace": "frontend/environments/environment.ts", "replace": "src/frontend/environments/environment.ts",
"with": "frontend/environments/environment.prod.ts" "with": "src/frontend/environments/environment.prod.ts"
} }
] ]
} }
@ -68,10 +68,10 @@
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
"main": "frontend/test.ts", "main": "src/frontend/test.ts",
"karmaConfig": "./karma.conf.js", "karmaConfig": "./karma.conf.js",
"polyfills": "frontend/polyfills.ts", "polyfills": "src/frontend/polyfills.ts",
"tsConfig": "frontend/tsconfig.spec.json", "tsConfig": "src/frontend/tsconfig.spec.json",
"scripts": [], "scripts": [],
"styles": [ "styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css", "./node_modules/bootstrap/dist/css/bootstrap.min.css",
@ -79,10 +79,10 @@
"node_modules/bootstrap/dist/css/bootstrap.css", "node_modules/bootstrap/dist/css/bootstrap.css",
"node_modules/open-iconic/font/css/open-iconic-bootstrap.css", "node_modules/open-iconic/font/css/open-iconic-bootstrap.css",
"node_modules/ngx-bootstrap/datepicker/bs-datepicker.css", "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"frontend/styles.css" "src/frontend/styles.css"
], ],
"assets": [ "assets": [
"frontend/assets" "src/frontend/assets"
] ]
} }
}, },
@ -132,4 +132,4 @@
"prefix": "app" "prefix": "app"
} }
} }
} }

@ -1,15 +1,15 @@
import {SQLConnection} from '../backend/model/sql/SQLConnection'; import {SQLConnection} from '../src/backend/model/sql/SQLConnection';
import {Config} from '../common/config/private/Config'; import {Config} from '../src/common/config/private/Config';
import {ObjectManagers} from '../backend/model/ObjectManagers'; import {ObjectManagers} from '../src/backend/model/ObjectManagers';
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker'; import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
import {IndexingManager} from '../backend/model/sql/IndexingManager'; import {IndexingManager} from '../src/backend/model/sql/IndexingManager';
import {SearchManager} from '../backend/model/sql/SearchManager'; import {SearchManager} from '../src/backend/model/sql/SearchManager';
import * as fs from 'fs'; import * as fs from 'fs';
import {SearchTypes} from '../common/entities/AutoCompleteItem'; import {SearchTypes} from '../src/common/entities/AutoCompleteItem';
import {Utils} from '../common/Utils'; import {Utils} from '../src/common/Utils';
import {GalleryManager} from '../backend/model/sql/GalleryManager'; import {GalleryManager} from '../src/backend/model/sql/GalleryManager';
import {DirectoryDTO} from '../common/entities/DirectoryDTO'; import {DirectoryDTO} from '../src/common/entities/DirectoryDTO';
import {ServerConfig} from '../common/config/private/IPrivateConfig'; import {ServerConfig} from '../src/common/config/private/IPrivateConfig';
export interface BenchmarkResult { export interface BenchmarkResult {
duration: number; 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 * as path from 'path';
import {ProjectPath} from '../backend/ProjectPath'; import {ProjectPath} from '../src/backend/ProjectPath';
import {BenchmarkResult, Benchmarks} from './Benchmarks'; import {BenchmarkResult, Benchmarks} from './Benchmarks';
import {SearchTypes} from '../common/entities/AutoCompleteItem'; import {SearchTypes} from '../src/common/entities/AutoCompleteItem';
import {Utils} from '../common/Utils'; import {Utils} from '../src/common/Utils';
import {DiskMangerWorker} from '../backend/model/threading/DiskMangerWorker'; import {DiskMangerWorker} from '../src/backend/model/threading/DiskMangerWorker';
const config: { path: string, system: string } = require(path.join(__dirname, 'config.json')); const config: { path: string, system: string } = require(path.join(__dirname, 'config.json'));
Config.Server.imagesFolder = config.path; 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();

@ -13,8 +13,8 @@ const tsBackendProject = ts.createProject('tsconfig.json');
gulp.task('build-backend', function () { gulp.task('build-backend', function () {
return gulp.src([ return gulp.src([
'common/**/*.ts', 'src/common/**/*.ts',
'backend/**/*.ts'], {base: '.'}) 'src/backend/**/*.ts'], {base: '.'})
.pipe(tsBackendProject()) .pipe(tsBackendProject())
.js .js
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release'));
@ -36,10 +36,10 @@ const createFrontendTask = (type: string, script: string) => {
}; };
const getLanguages = () => { const getLanguages = () => {
if (!fs.existsSync('./frontend/' + translationFolder)) { if (!fs.existsSync('./src/frontend/' + translationFolder)) {
return []; return [];
} }
const dirCont = fs.readdirSync('./frontend/' + translationFolder); const dirCont = fs.readdirSync('./src/frontend/' + translationFolder);
const files: string[] = dirCont.filter((elm) => { const files: string[] = dirCont.filter((elm) => {
return elm.match(/.*\.[a-zA-Z]+\.(xlf)/ig); return elm.match(/.*\.[a-zA-Z]+\.(xlf)/ig);
}); });
@ -71,14 +71,14 @@ gulp.task('build-frontend', (() => {
const tasks = []; const tasks = [];
createFrontendTask('build-frontend-release default', createFrontendTask('build-frontend-release default',
'ng build --aot --prod --output-path=./release/dist --no-progress --i18n-locale=en' + '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'); ' --i18n-missing-translation warning');
tasks.push('build-frontend-release default'); tasks.push('build-frontend-release default');
for (let i = 0; i < languages.length; i++) { for (let i = 0; i < languages.length; i++) {
createFrontendTask('build-frontend-release ' + languages[i], createFrontendTask('build-frontend-release ' + languages[i],
'ng build --aot --prod --output-path=./release/dist/' + languages[i] + 'ng build --aot --prod --output-path=./release/dist/' + languages[i] +
' --no-progress --i18n-locale=' + 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'); ' --i18n-missing-translation warning');
tasks.push('build-frontend-release ' + languages[i]); tasks.push('build-frontend-release ' + languages[i]);
} }
@ -87,7 +87,7 @@ gulp.task('build-frontend', (() => {
gulp.task('copy-static', function () { gulp.task('copy-static', function () {
return gulp.src([ return gulp.src([
'backend/model/diagnostics/blank.jpg', 'src/backend/model/diagnostics/blank.jpg',
'README.md', 'README.md',
'LICENSE'], {base: '.'}) 'LICENSE'], {base: '.'})
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release'));
@ -102,7 +102,7 @@ gulp.task('copy-package', function () {
})) }))
.pipe(jsonModify({ .pipe(jsonModify({
key: 'scripts', key: 'scripts',
value: {'start': 'node ./backend/index.js'} value: {'start': 'node ./src/backend/index.js'}
})) }))
.pipe(gulp.dest('./release')); .pipe(gulp.dest('./release'));
}); });
@ -127,14 +127,14 @@ const simpleBuild = (isProd: boolean) => {
cmd += ' --prod --no-extract-licenses '; cmd += ' --prod --no-extract-licenses ';
} }
createFrontendTask('build-frontend default', cmd + '--output-path=./dist --no-progress --no-progress --i18n-locale en' + 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'); tasks.push('build-frontend default');
if (!process.env.CI) { // don't build languages if running in CI if (!process.env.CI) { // don't build languages if running in CI
for (let i = 0; i < languages.length; i++) { for (let i = 0; i < languages.length; i++) {
createFrontendTask('build-frontend ' + languages[i], cmd + createFrontendTask('build-frontend ' + languages[i], cmd +
'--output-path=./dist/' + languages[i] + '--output-path=./dist/' + languages[i] +
' --no-progress --i18n-locale ' + 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'); '/messages.' + languages[i] + '.xlf' + ' --i18n-missing-translation warning');
tasks.push('build-frontend ' + languages[i]); tasks.push('build-frontend ' + languages[i]);
} }
@ -151,20 +151,20 @@ gulp.task('extract-locale', (cb) => {
if (error) { if (error) {
return cb(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)); handleError(cb));
}); });
}); });
const translate = (list: any[], cb: (err: any) => void) => { const translate = (list: any[], cb: (err: any) => void) => {
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"'; 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, translationFolder + ' --destination-languages=' + localsStr,
handleError(cb)); handleError(cb));
}; };
const merge = (list: any[], cb: (err: any) => void) => { const merge = (list: any[], cb: (err: any) => void) => {
const localsStr = '"[\\"' + list.join('\\",\\"') + '\\"]"'; 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, translationFolder + ' --destination-languages=' + localsStr,
handleError(cb)); handleError(cb));
}; };

@ -5,8 +5,8 @@
"author": "Patrik J. Braun", "author": "Patrik J. Braun",
"homepage": "https://github.com/bpatrik/PiGallery2", "homepage": "https://github.com/bpatrik/PiGallery2",
"license": "MIT", "license": "MIT",
"main": "./backend/index.js", "main": "./src/backend/index.js",
"bin": "./backend/index.js", "bin": "./src/backend/index.js",
"scripts": { "scripts": {
"install": "npm run build-prod", "install": "npm run build-prod",
"build-prod": "tsc && gulp build-prod", "build-prod": "tsc && gulp build-prod",
@ -15,8 +15,8 @@
"pretest": "tsc", "pretest": "tsc",
"test": "ng test && mocha --recursive test/backend/unit && mocha --recursive test/backend/integration && mocha --recursive test/common/unit ", "test": "ng test && mocha --recursive test/backend/unit && mocha --recursive test/backend/integration && mocha --recursive test/common/unit ",
"start": "node ./backend/index", "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", "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 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", "merge-new-translation": "gulp merge-new-translation",
"add-translation": "gulp add-translation" "add-translation": "gulp add-translation"
}, },

@ -30,7 +30,7 @@ class ProjectPathClass {
} }
reset() { reset() {
this.Root = path.join(__dirname, '/../'); this.Root = path.join(__dirname, '/../../');
this.ImageFolder = this.getAbsolutePath(Config.Server.imagesFolder); this.ImageFolder = this.getAbsolutePath(Config.Server.imagesFolder);
this.ThumbnailFolder = this.getAbsolutePath(Config.Server.Thumbnail.folder); this.ThumbnailFolder = this.getAbsolutePath(Config.Server.Thumbnail.folder);
this.TranscendedFolder = path.join(this.ThumbnailFolder, 'tc'); this.TranscendedFolder = path.join(this.ThumbnailFolder, 'tc');

@ -231,7 +231,7 @@ export class ConfigDiagnostics {
try { try {
await ConfigDiagnostics.testClientVideoConfig(Config.Server.Video); await ConfigDiagnostics.testClientVideoConfig(Config.Client.Video);
await ConfigDiagnostics.testServerVideoConfig(Config.Server.Video, Config); await ConfigDiagnostics.testServerVideoConfig(Config.Server.Video, Config);
} catch (ex) { } catch (ex) {
const err: Error = ex; const err: Error = ex;

Before

(image error) Size: 631 B

After

(image error) Size: 631 B

@ -9,4 +9,6 @@ export interface ITask<T> extends TaskDTO {
start(config: T): Promise<void>; start(config: T): Promise<void>;
stop(): void; stop(): void;
toJSON(): TaskDTO;
} }

@ -9,7 +9,7 @@ import {MediaDTO} from '../../../../common/entities/MediaDTO';
import {ProjectPath} from '../../../ProjectPath'; import {ProjectPath} from '../../../ProjectPath';
import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs'; import {ThumbnailGeneratorMWs} from '../../../middlewares/thumbnail/ThumbnailGeneratorMWs';
import {Task} from './Task'; 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'; import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
declare const global: any; declare const global: any;
@ -29,6 +29,7 @@ export class IndexingTask extends Task<{ createThumbnails: boolean }> {
return Config.Server.Database.type !== ServerConfig.DatabaseType.memory; return Config.Server.Database.type !== ServerConfig.DatabaseType.memory;
} }
protected async init() { protected async init() {
this.directoriesToIndex.push('/'); this.directoriesToIndex.push('/');
} }

@ -1,7 +1,7 @@
import {TaskProgressDTO} from '../../../../common/entities/settings/TaskProgressDTO'; import {TaskProgressDTO} from '../../../../common/entities/settings/TaskProgressDTO';
import {Logger} from '../../../Logger'; import {Logger} from '../../../Logger';
import {ITask} from './ITask'; import {ITask} from './ITask';
import {ConfigTemplateEntry} from '../../../../common/entities/task/TaskDTO'; import {ConfigTemplateEntry, TaskDTO} from '../../../../common/entities/task/TaskDTO';
declare const process: any; declare const process: any;
@ -55,6 +55,13 @@ export abstract class Task<T = void> implements ITask<T> {
this.onFinish(); this.onFinish();
} }
public toJSON(): TaskDTO {
return {
Name: this.Name,
ConfigTemplate: this.ConfigTemplate
};
}
protected abstract async step(): Promise<TaskProgressDTO>; protected abstract async step(): Promise<TaskProgressDTO>;
protected abstract async init(): Promise<void>; protected abstract async init(): Promise<void>;

@ -30,15 +30,14 @@ export class Server {
if (!(process.env.NODE_ENV === 'production')) { if (!(process.env.NODE_ENV === 'production')) {
Logger.info(LOG_TAG, 'Running in DEBUG mode, set env variable NODE_ENV=production to disable '); 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...'); Logger.info(LOG_TAG, 'running diagnostics...');
await ConfigDiagnostics.runDiagnostics(); await ConfigDiagnostics.runDiagnostics();
Logger.verbose(LOG_TAG, 'using config:'); Logger.verbose(LOG_TAG, 'using config:');
const appVer = require('../package.json').version; Config.Client.appVersion = require('../../package.json').version;
Config.Client.appVersion = appVer;
Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t')); Logger.verbose(LOG_TAG, JSON.stringify(Config, null, '\t'));
this.app = _express(); this.app = _express();

Some files were not shown because too many files have changed in this diff Show More