1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-12 04:23:09 +02:00

fixing spelling

This commit is contained in:
Patrik J. Braun 2019-12-12 19:11:49 +01:00
parent 6315e62368
commit 8479be8aaa
27 changed files with 91 additions and 95 deletions

View File

@ -10,6 +10,7 @@ const exec = require('child_process').exec;
const translationFolder = 'translate';
const tsBackendProject = ts.createProject('tsconfig.json');
declare var process: NodeJS.Process;
gulp.task('build-backend', function () {
return gulp.src([

View File

@ -1,7 +1,7 @@
import {NextFunction, Request, Response} from 'express';
import {ObjectManagers} from '../model/ObjectManagers';
import {ErrorCodes, ErrorDTO} from '../../common/entities/Error';
import {CostumHeaders} from '../../common/CostumHeaders';
import {CustomHeaders} from '../../common/CustomHeaders';
const LOG_TAG = '[VersionMWs]';
@ -17,7 +17,7 @@ export class VersionMWs {
*/
public static async injectGalleryVersion(req: Request, res: Response, next: NextFunction) {
try {
res.header(CostumHeaders.dataVersion, await ObjectManagers.getInstance().VersionManager.getDataVersion());
res.header(CustomHeaders.dataVersion, await ObjectManagers.getInstance().VersionManager.getDataVersion());
next();
} catch (err) {
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'Can not get data version', err.toString()));

View File

@ -68,7 +68,7 @@ export class ConfigDiagnostics {
return resolve();
}
} catch (e) {
return reject(new Error('unkown video error: ' + e.toString()));
return reject(new Error('unknown video error: ' + e.toString()));
}
});
}

View File

@ -1,6 +1,6 @@
import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
import {OrientationType, RandomQueryDTO} from '../../../common/entities/RandomQueryDTO';
import {OrientationType} from '../../../common/entities/RandomQueryDTO';
export interface RandomQuery {
directory?: string;

View File

@ -1,5 +1,4 @@
import {PersonEntry} from '../sql/enitites/PersonEntry';
import {MediaDTO} from '../../../common/entities/MediaDTO';
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
import {PersonDTO} from '../../../common/entities/PersonDTO';

View File

@ -30,7 +30,7 @@ export class SharingManager implements ISharingManager {
if (sharing.password) {
sharing.password = PasswordHelper.cryptPassword(sharing.password);
}
return await connection.getRepository(SharingEntity).save(sharing);
return connection.getRepository(SharingEntity).save(sharing);
}
async updateSharing(inSharing: SharingDTO): Promise<SharingDTO> {
@ -53,7 +53,7 @@ export class SharingManager implements ISharingManager {
sharing.includeSubfolders = inSharing.includeSubfolders;
sharing.expires = inSharing.expires;
return await connection.getRepository(SharingEntity).save(sharing);
return connection.getRepository(SharingEntity).save(sharing);
}

View File

@ -17,7 +17,7 @@ export class UserManager implements IUserManager {
delete filter.password;
const user = (await connection.getRepository(UserEntity).findOne(filter));
if (user.permissions && user.permissions != null) {
if (user.permissions) {
user.permissions = <any>JSON.parse(<any>user.permissions);
}
@ -31,7 +31,7 @@ export class UserManager implements IUserManager {
public async find(filter: any) {
const connection = await SQLConnection.getConnection();
return (await connection.getRepository(UserEntity).find(filter)).map(user => {
if (user.permissions && user.permissions != null) {
if (user.permissions) {
user.permissions = <any>JSON.parse(<any>user.permissions);
}
return user;
@ -40,11 +40,11 @@ export class UserManager implements IUserManager {
public async createUser(user: UserDTO) {
const connection = await SQLConnection.getConnection();
if (user.permissions && user.permissions != null) {
if (user.permissions) {
user.permissions = <any>JSON.stringify(<any>user.permissions);
}
user.password = PasswordHelper.cryptPassword(user.password);
return await connection.getRepository(UserEntity).save(user);
return connection.getRepository(UserEntity).save(user);
}
public async deleteUser(id: number) {
@ -59,7 +59,7 @@ export class UserManager implements IUserManager {
const userRepository = connection.getRepository(UserEntity);
const user = await userRepository.findOne({id: id});
user.role = newRole;
return await userRepository.save(user);
return userRepository.save(user);
}

View File

@ -6,6 +6,8 @@ import {Config} from '../../../common/config/private/Config';
import {TaskScheduleDTO, TaskTriggerType} from '../../../common/entities/task/TaskScheduleDTO';
import {Logger} from '../../Logger';
declare var global: NodeJS.Global;
const LOG_TAG = '[TaskManager]';
export class TaskManager implements ITaskManager {

View File

@ -12,7 +12,7 @@ import {Task} from './Task';
import {ConfigTemplateEntry, DefaultsTasks} from '../../../../common/entities/task/TaskDTO';
import {ServerConfig} from '../../../../common/config/private/IPrivateConfig';
declare const global: any;
declare var global: NodeJS.Global;
const LOG_TAG = '[IndexingTask]';
export class IndexingTask extends Task<{ createThumbnails: boolean }> {

View File

@ -11,6 +11,9 @@ import * as util from 'util';
import {DiskManager} from '../../DiskManger';
import {VideoConverterMWs} from '../../../middlewares/VideoConverterMWs';
declare var global: NodeJS.Global;
const LOG_TAG = '[VideoConvertingTask]';
const existsPr = util.promisify(fs.exists);

View File

@ -5,10 +5,11 @@ import {DirectoryDTO} from '../../../common/entities/DirectoryDTO';
import {Utils} from '../../../common/Utils';
import {ServerConfig} from '../../../common/config/private/IPrivateConfig';
declare var process: NodeJS.Process;
declare var global: NodeJS.Global;
export class Worker {
public static process() {
public static process(): void {
Logger.debug('Worker is waiting for tasks');
process.on('message', async (task: WorkerTask) => {
try {

View File

@ -19,6 +19,8 @@ import {ServerConfig} from '../common/config/private/IPrivateConfig';
const _session = require('cookie-session');
declare var process: NodeJS.Process;
const LOG_TAG = '[server]';
export class Server {

View File

@ -1,3 +1,3 @@
export class CostumHeaders {
export class CustomHeaders {
public static dataVersion = 'PI-GALLERY2-DATA-VERSION';
}

View File

@ -5,6 +5,8 @@ import {Utils} from '../../Utils';
import {UserRoles} from '../../entities/UserDTO';
import {PrivateConfigDefaultsClass} from './PrivateConfigDefaultsClass';
declare var process: NodeJS.Process;
/**
* This configuration will be only at backend
*/
@ -12,7 +14,6 @@ export class ConfigClass extends PrivateConfigDefaultsClass implements IPrivateC
private static readonly CONFIG_PATH = path.join(__dirname, './../../../../config.json');
private ConfigLoader: any;
public setDatabaseType(type: ServerConfig.DatabaseType) {
this.Server.Database.type = type;

View File

@ -61,7 +61,7 @@ export module ClientConfig {
defaultPhotoSortingMethod: SortingMethods;
enableOnScrollThumbnailPrioritising: boolean;
NavBar: NavBarConfig;
captionFirstNaming: boolean; // shows the caption instead of the filename in the phot grid
captionFirstNaming: boolean; // shows the caption instead of the filename in the photo grid
}
export interface VideoConfig {

View File

@ -1,5 +1,4 @@
import {MediaDTO} from './MediaDTO';
import {PhotoDTO} from './PhotoDTO';
import {FileDTO} from './FileDTO';
export interface DirectoryDTO {

View File

@ -1,7 +1,4 @@
import {DirectoryDTO} from './DirectoryDTO';
import {PhotoDTO} from './PhotoDTO';
import {OrientationTypes} from 'ts-exif-parser';
import {VideoDTO} from './VideoDTO';
export interface FileDTO {
id: number;

View File

@ -21,9 +21,9 @@ export class AuthenticationService {
constructor(private _userService: UserService,
private _networkService: NetworkService,
private shareSerice: ShareService) {
private shareService: ShareService) {
this.user = new BehaviorSubject(null);
this.shareSerice.setUserObs(this.user);
this.shareService.setUserObs(this.user);
// picking up session..
if (this.isAuthenticated() === false && Cookie.get(CookieNames.session) != null) {
if (typeof ServerInject !== 'undefined' && typeof ServerInject.user !== 'undefined') {

View File

@ -5,7 +5,7 @@ import {SlimLoadingBarService} from 'ng2-slim-loading-bar';
import {ErrorCodes, ErrorDTO} from '../../../../common/entities/Error';
import {Config} from '../../../../common/config/public/Config';
import {Utils} from '../../../../common/Utils';
import {CostumHeaders} from '../../../../common/CostumHeaders';
import {CustomHeaders} from '../../../../common/CustomHeaders';
import {VersionService} from '../version.service';
@Injectable()
@ -90,8 +90,8 @@ export class NetworkService {
const process = (res: HttpResponse<Message<T>>): T => {
this.slimLoadingBarService.complete();
const msg = res.body;
if (res.headers.has(CostumHeaders.dataVersion)) {
this.versionService.onNewVersion(res.headers.get(CostumHeaders.dataVersion));
if (res.headers.has(CustomHeaders.dataVersion)) {
this.versionService.onNewVersion(res.headers.get(CustomHeaders.dataVersion));
}
if (!!msg.error) {
if (msg.error.code) {

View File

@ -1,7 +1,6 @@
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
import {Media} from '../../gallery/Media';
import {IconThumbnail, Thumbnail, ThumbnailManagerService} from '../../gallery/thumbnailManager.service';
import {IconThumbnail, ThumbnailManagerService} from '../../gallery/thumbnailManager.service';
import {PhotoDTO} from '../../../../../common/entities/PhotoDTO';
import {OrientationTypes} from 'ts-exif-parser';
import {MediaIcon} from '../../gallery/MediaIcon';

View File

@ -28,7 +28,7 @@ export class GalleryCacheService {
const onNewVersion = (ver: string) => {
if (ver !== null &&
localStorage.getItem(GalleryCacheService.VERSION) !== ver) {
this.deleteCache();
GalleryCacheService.deleteCache();
localStorage.setItem(GalleryCacheService.VERSION, ver);
}
};
@ -36,6 +36,41 @@ export class GalleryCacheService {
onNewVersion(this.versionService.version.value);
}
private static loadCacheItem(key: string): SearchResultDTO {
const tmp = localStorage.getItem(key);
if (tmp != null) {
const value: CacheItem<SearchResultDTO> = JSON.parse(tmp);
if (value.timestamp < Date.now() - Config.Client.Search.instantSearchCacheTimeout) {
localStorage.removeItem(key);
return null;
}
return value.item;
}
return null;
}
private static deleteCache() {
try {
const toRemove = [];
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith(GalleryCacheService.CONTENT_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.SEARCH_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.INSTANT_SEARCH_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.AUTO_COMPLETE_PREFIX)
) {
toRemove.push(localStorage.key(i));
}
}
for (let i = 0; i < toRemove.length; i++) {
localStorage.removeItem(toRemove[i]);
}
} catch (e) {
}
}
public getSorting(dir: DirectoryDTO): SortingMethods {
const key = GalleryCacheService.SORTING_PREFIX + dir.path + '/' + dir.name;
const tmp = localStorage.getItem(key);
@ -104,16 +139,7 @@ export class GalleryCacheService {
return null;
}
const key = GalleryCacheService.INSTANT_SEARCH_PREFIX + text;
const tmp = localStorage.getItem(key);
if (tmp != null) {
const value: CacheItem<SearchResultDTO> = JSON.parse(tmp);
if (value.timestamp < Date.now() - Config.Client.Search.instantSearchCacheTimeout) {
localStorage.removeItem(key);
return null;
}
return value.item;
}
return null;
return GalleryCacheService.loadCacheItem(key);
}
public setInstantSearch(text: string, searchResult: SearchResultDTO): void {
@ -140,16 +166,8 @@ export class GalleryCacheService {
if (typeof type !== 'undefined' && type !== null) {
key += GalleryCacheService.SEARCH_TYPE_PREFIX + type;
}
const tmp = localStorage.getItem(key);
if (tmp != null) {
const value: CacheItem<SearchResultDTO> = JSON.parse(tmp);
if (value.timestamp < Date.now() - Config.Client.Search.searchCacheTimeout) {
localStorage.removeItem(key);
return null;
}
return value.item;
}
return null;
return GalleryCacheService.loadCacheItem(key);
}
public setSearch(text: string, type: SearchTypes, searchResult: SearchResultDTO): void {
@ -243,27 +261,6 @@ export class GalleryCacheService {
}
private deleteCache() {
try {
const toRemove = [];
for (let i = 0; i < localStorage.length; i++) {
if (localStorage.key(i).startsWith(GalleryCacheService.CONTENT_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.SEARCH_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.INSTANT_SEARCH_PREFIX) ||
localStorage.key(i).startsWith(GalleryCacheService.AUTO_COMPLETE_PREFIX)
) {
toRemove.push(localStorage.key(i));
}
}
for (let i = 0; i < toRemove.length; i++) {
localStorage.removeItem(toRemove[i]);
}
} catch (e) {
}
}
private reset() {
try {
localStorage.clear();

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, Input, OnChanges, OnInit} from '@angular/core';
import {Component, ElementRef, Input, OnChanges} from '@angular/core';
import {DirectoryDTO} from '../../../../../common/entities/DirectoryDTO';
@Component({

View File

@ -1,4 +1,3 @@
import {PhotoDTO} from '../../../../../common/entities/PhotoDTO';
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
export class GridRowBuilder {
@ -24,15 +23,6 @@ export class GridRowBuilder {
}
}
private addPhoto(): boolean {
if (this.photoIndex + 1 > this.photos.length) {
return false;
}
this.photoRow.push(this.photos[this.photoIndex]);
this.photoIndex++;
return true;
}
public removePhoto(): boolean {
if (this.photoIndex - 1 < this.startIndex) {
return false;
@ -69,4 +59,13 @@ export class GridRowBuilder {
return height + (this.photoMargin * 2);
}
private addPhoto(): boolean {
if (this.photoIndex + 1 > this.photos.length) {
return false;
}
this.photoRow.push(this.photos[this.photoIndex]);
this.photoIndex++;
return true;
}
}

View File

@ -315,7 +315,7 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
/**
* Returns true, if scroll is >= 70% to render more images.
* Or of onscroll rendering is off: return always to render all the images at once
* @param offset Add height to the client height (conent is not yet added to the dom, but calculate with it)
* @param offset Add height to the client height (content is not yet added to the dom, but calculate with it)
* @returns {boolean}
*/
private shouldRenderMore(offset: number = 0): boolean {

View File

@ -425,8 +425,8 @@ export class GalleryLightboxComponent implements OnDestroy, OnInit {
}
private calcLightBoxPhotoDimension(photo: MediaDTO): Dimension {
let width = 0;
let height = 0;
let width: number;
let height: number;
const photoAspect = photo.metadata.size.width / photo.metadata.size.height;
const windowAspect = this.photoFrameDim.aspect;
if (photoAspect < windowAspect) {

View File

@ -1,4 +1,4 @@
import {Component, HostListener, Input, OnChanges} from '@angular/core';
import {Component, Input, OnChanges} from '@angular/core';
import {DirectoryDTO} from '../../../../../common/entities/DirectoryDTO';
import {Router, RouterLink} from '@angular/router';
import {UserDTO} from '../../../../../common/entities/UserDTO';
@ -27,9 +27,8 @@ export class GalleryNavigatorComponent implements OnChanges {
sortingMethodsType: { key: number; value: string }[] = [];
config = Config;
DefaultSorting = Config.Client.Other.defaultPhotoSortingMethod;
private readonly RootFolderName: string;
readonly SearchTypes = SearchTypes;
private readonly RootFolderName: string;
constructor(private _authService: AuthenticationService,
public queryService: QueryService,
@ -40,6 +39,9 @@ export class GalleryNavigatorComponent implements OnChanges {
this.RootFolderName = this.i18n('Images');
}
get ItemCount(): number {
return this.directory ? this.directory.mediaCount : this.searchResult.media.length;
}
ngOnChanges() {
this.getPath();
@ -93,10 +95,6 @@ export class GalleryNavigatorComponent implements OnChanges {
this.galleryService.setSorting(sorting);
}
get ItemCount(): number {
return this.directory ? this.directory.mediaCount : this.searchResult.media.length;
}
/*
@HostListener('window:keydown', ['$event'])

View File

@ -1,6 +1,4 @@
import {expect} from 'chai';
import {PersonManager} from '../../../../../src/backend/model/sql/PersonManager';
import {FaceRegion, PhotoDTO} from '../../../../../src/common/entities/PhotoDTO';
// to help WebStorm to handle the test cases