mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-10 04:07:35 +02:00
finishing settings implementation
This commit is contained in:
parent
836f20eea4
commit
3f9852a70c
@ -32,6 +32,10 @@ export class AdminMWs {
|
||||
//only updating explicitly set config (not saving config set by the diagnostics)
|
||||
const original = Config.original();
|
||||
original.Server.database = databaseSettings;
|
||||
if (databaseSettings.type == DatabaseType.memory) {
|
||||
original.Client.Sharing.enabled = false;
|
||||
original.Client.Search.enabled = false;
|
||||
}
|
||||
original.save();
|
||||
await ConfigDiagnostics.runDiagnostics();
|
||||
Logger.info(LOG_TAG, "new config:");
|
||||
@ -46,7 +50,10 @@ export class AdminMWs {
|
||||
|
||||
return next();
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.SETTINGS_ERROR, "ErrorDTO saving database settings", err));
|
||||
if (err instanceof Error) {
|
||||
return next(new ErrorDTO(ErrorCodes.SETTINGS_ERROR, "Error while saving database settings: " + err.toString(), err));
|
||||
}
|
||||
return next(new ErrorDTO(ErrorCodes.SETTINGS_ERROR, "Error while saving database settings", err));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ export class GalleryMWs {
|
||||
return next();
|
||||
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during listing the directory", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during listing the directory", err));
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ export class GalleryMWs {
|
||||
req.resultPipe = new ContentWrapper(null, result);
|
||||
return next();
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during searching", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during searching", err));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ export class GalleryMWs {
|
||||
req.resultPipe = new ContentWrapper(null, result);
|
||||
return next();
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during searching", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during searching", err));
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ export class GalleryMWs {
|
||||
req.resultPipe = await ObjectManagerRepository.getInstance().SearchManager.autocomplete(req.params.text);
|
||||
return next();
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during searching", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during searching", err));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class SharingMWs {
|
||||
return next();
|
||||
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during retrieving sharing link", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during retrieving sharing link", err));
|
||||
}
|
||||
|
||||
}
|
||||
@ -68,7 +68,7 @@ export class SharingMWs {
|
||||
return next();
|
||||
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during creating sharing link", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during creating sharing link", err));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ export class SharingMWs {
|
||||
return next();
|
||||
|
||||
} catch (err) {
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "ErrorDTO during creating sharing link", err));
|
||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, "Error during creating sharing link", err));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ export class ThumbnailGeneratorMWs {
|
||||
return next();
|
||||
}
|
||||
} catch (error) {
|
||||
return next(new ErrorDTO(ErrorCodes.THUMBNAIL_GENERATION_ERROR, "ErrorDTO during generating thumbnail", error));
|
||||
return next(new ErrorDTO(ErrorCodes.THUMBNAIL_GENERATION_ERROR, "Error during generating thumbnail", error));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ export class ConfigDiagnostics {
|
||||
await new Promise((resolve, reject) => {
|
||||
fs.access(folder, fs.constants.W_OK, (err) => {
|
||||
if (err) {
|
||||
reject({message: "ErrorDTO during getting write access to temp folder", error: err.toString()});
|
||||
reject({message: "Error during getting write access to temp folder", error: err.toString()});
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
@ -61,7 +61,7 @@ export class ConfigDiagnostics {
|
||||
}
|
||||
fs.access(folder, fs.constants.R_OK, (err) => {
|
||||
if (err) {
|
||||
reject({message: "ErrorDTO during getting read access to images folder", error: err.toString()});
|
||||
reject({message: "Error during getting read access to images folder", error: err.toString()});
|
||||
}
|
||||
});
|
||||
resolve();
|
||||
@ -117,8 +117,8 @@ export class ConfigDiagnostics {
|
||||
await ConfigDiagnostics.testDatabase(Config.Server.database);
|
||||
} catch (err) {
|
||||
Logger.warn(LOG_TAG, "[MYSQL error]", err);
|
||||
Logger.warn(LOG_TAG, "ErrorDTO during initializing mysql falling back temporally to memory DB");
|
||||
NotificationManager.warning("ErrorDTO during initializing mysql falling back temporally to memory DB", err);
|
||||
Logger.warn(LOG_TAG, "Error during initializing mysql falling back temporally to memory DB");
|
||||
NotificationManager.warning("Error during initializing mysql falling back temporally to memory DB", err);
|
||||
Config.setDatabaseType(DatabaseType.memory);
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
|
||||
this.Server.database.type = type;
|
||||
if (type === DatabaseType.memory) {
|
||||
this.Client.Search.enabled = false;
|
||||
this.Client.Search.instantSearchEnabled = false;
|
||||
this.Client.Search.autocompleteEnabled = false;
|
||||
this.Client.Sharing.enabled = false;
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,35 @@
|
||||
To dismiss these notifications, restart the server.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<settings-basic></settings-basic>
|
||||
<div class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-10 control-label" for="simplifiedMode">Mode</label>
|
||||
<div class="col-sm-2">
|
||||
<bSwitch
|
||||
id="simplifiedMode"
|
||||
class="switch"
|
||||
name="simplifiedMode"
|
||||
[switch-off-color]="'warning'"
|
||||
[switch-on-color]="'primary'"
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Advanced'"
|
||||
[switch-on-text]="'Simplified'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="simplifiedMode">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<settings-basic [simplifiedMode]="simplifiedMode"></settings-basic>
|
||||
<settings-usermanager></settings-usermanager>
|
||||
<settings-database></settings-database>
|
||||
<settings-thumbnail></settings-thumbnail>
|
||||
<settings-search></settings-search>
|
||||
<settings-share></settings-share>
|
||||
<settings-map></settings-map>
|
||||
<settings-other></settings-other>
|
||||
<settings-database [simplifiedMode]="simplifiedMode"></settings-database>
|
||||
<settings-thumbnail #thumbnail [hidden]="!thumbnail.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></settings-thumbnail>
|
||||
<settings-search #search [hidden]="!search.hasAvailableSettings"
|
||||
[simplifiedMode]="simplifiedMode"></settings-search>
|
||||
<settings-share #share [hidden]="!share.hasAvailableSettings" [simplifiedMode]="simplifiedMode"></settings-share>
|
||||
<settings-map #map [hidden]="!map.hasAvailableSettings" [simplifiedMode]="simplifiedMode"></settings-map>
|
||||
<settings-other #other [hidden]="!other.hasAvailableSettings" [simplifiedMode]="simplifiedMode"></settings-other>
|
||||
</div>
|
||||
</app-frame>
|
||||
|
@ -11,6 +11,8 @@ import {NavigationService} from "../model/navigation.service";
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
|
||||
simplifiedMode = true;
|
||||
|
||||
constructor(private _authService: AuthenticationService,
|
||||
private _navigation: NavigationService,
|
||||
public notificationService: NotificationService) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {OnDestroy, OnInit, ViewChild} from "@angular/core";
|
||||
import {Input, OnChanges, OnDestroy, OnInit, Output, ViewChild} from "@angular/core";
|
||||
import {AuthenticationService} from "../../model/network/authentication.service";
|
||||
import {UserRoles} from "../../../../common/entities/UserDTO";
|
||||
import {Utils} from "../../../../common/Utils";
|
||||
@ -6,23 +6,44 @@ import {ErrorDTO} from "../../../../common/entities/Error";
|
||||
import {NotificationService} from "../../model/notification.service";
|
||||
import {NavigationService} from "../../model/navigation.service";
|
||||
import {AbstractSettingsService} from "./abstract.settings.service";
|
||||
import {IPrivateConfig} from "../../../../common/config/private/IPrivateConfig";
|
||||
|
||||
|
||||
export abstract class SettingsComponent<T> implements OnInit, OnDestroy {
|
||||
export abstract class SettingsComponent<T> implements OnInit, OnDestroy, OnChanges {
|
||||
|
||||
@Input()
|
||||
public simplifiedMode: boolean = true;
|
||||
|
||||
@ViewChild('settingsForm')
|
||||
form: HTMLFormElement;
|
||||
|
||||
@Output('hasAvailableSettings')
|
||||
hasAvailableSettings: boolean = true;
|
||||
|
||||
@ViewChild('settingsForm') form;
|
||||
public inProgress = false;
|
||||
public error: string = null;
|
||||
public changed: boolean = false;
|
||||
private subscription = null;
|
||||
|
||||
public settings: T = <any>{};
|
||||
public original: T = <any>{};
|
||||
|
||||
constructor(private name,
|
||||
private _authService: AuthenticationService,
|
||||
private _navigation: NavigationService,
|
||||
public _settingsService: AbstractSettingsService<T>,
|
||||
protected notification: NotificationService) {
|
||||
protected notification: NotificationService,
|
||||
private sliceFN: (s: IPrivateConfig) => T) {
|
||||
this._settingsService.Settings.subscribe(this.onNewSettings);
|
||||
this.onNewSettings(this._settingsService._settingsService.settings.value);
|
||||
}
|
||||
|
||||
onNewSettings = (s) => {
|
||||
this.settings = Utils.clone(this.sliceFN(s));
|
||||
this.original = Utils.clone(this.settings);
|
||||
this.ngOnChanges();
|
||||
};
|
||||
|
||||
ngOnInit() {
|
||||
if (!this._authService.isAuthenticated() ||
|
||||
this._authService.user.value.role < UserRoles.Admin) {
|
||||
@ -32,10 +53,16 @@ export abstract class SettingsComponent<T> implements OnInit, OnDestroy {
|
||||
this.getSettings();
|
||||
|
||||
this.subscription = this.form.valueChanges.subscribe((data) => {
|
||||
this.changed = !Utils.equalsFilter(this._settingsService.settings, this._settingsService.original);
|
||||
this.changed = !Utils.equalsFilter(this.settings, this.original);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.hasAvailableSettings = (this._settingsService.isSupported() || !this.simplifiedMode);
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.subscription != null) {
|
||||
this.subscription.unsubscribe();
|
||||
@ -56,7 +83,7 @@ export abstract class SettingsComponent<T> implements OnInit, OnDestroy {
|
||||
this.inProgress = true;
|
||||
this.error = "";
|
||||
try {
|
||||
await this._settingsService.updateSettings(this._settingsService.settings);
|
||||
await this._settingsService.updateSettings(this.settings);
|
||||
await this.getSettings();
|
||||
this.notification.success(this.name + ' settings saved', "Success");
|
||||
this.inProgress = false;
|
||||
|
@ -1,20 +1,13 @@
|
||||
import {Utils} from "../../../../common/Utils";
|
||||
import {SettingsService} from "../settings.service";
|
||||
import {IPrivateConfig} from "../../../../common/config/private/IPrivateConfig";
|
||||
export abstract class AbstractSettingsService<T> {
|
||||
public settings: T = <any>{};
|
||||
public original: T = <any>{};
|
||||
|
||||
constructor(protected _settingsService: SettingsService, private sliceFN: (s: IPrivateConfig) => T) {
|
||||
this.original = Utils.clone(this.settings);
|
||||
this._settingsService.settings.subscribe(this.onNewSettings);
|
||||
this.onNewSettings(this._settingsService.settings.value);
|
||||
constructor(public _settingsService: SettingsService) {
|
||||
|
||||
}
|
||||
|
||||
onNewSettings = (s) => {
|
||||
this.settings = Utils.clone(this.sliceFN(s));
|
||||
this.original = Utils.clone(this.settings);
|
||||
};
|
||||
get Settings() {
|
||||
return this._settingsService.settings;
|
||||
}
|
||||
|
||||
|
||||
public getSettings(): Promise<void> {
|
||||
|
@ -7,16 +7,16 @@
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="applicationTitle">Page title</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" placeholder="Pigallery 2"
|
||||
id="applicationTitle"
|
||||
[(ngModel)]="_settingsService.settings.applicationTitle"
|
||||
[(ngModel)]="settings.applicationTitle"
|
||||
name="applicationTitle" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="port">Port</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" placeholder="80"
|
||||
@ -24,7 +24,7 @@
|
||||
min="0"
|
||||
step="1"
|
||||
max="65535"
|
||||
[(ngModel)]="_settingsService.settings.port"
|
||||
[(ngModel)]="settings.port"
|
||||
name="port" required>
|
||||
<span class="help-block">Port number. Port 80 is usually what you need.</span>
|
||||
</div>
|
||||
@ -35,18 +35,18 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" placeholder="path"
|
||||
id="folder"
|
||||
[(ngModel)]="_settingsService.settings.imagesFolder"
|
||||
[(ngModel)]="settings.imagesFolder"
|
||||
name="folder" required>
|
||||
<span class="help-block">Images are loaded from this folder (read permission required)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="publicUrl">Page public url</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="url" class="form-control" placeholder="{{urlPlaceholder}}"
|
||||
id="publicUrl"
|
||||
[(ngModel)]="_settingsService.settings.publicUrl"
|
||||
[(ngModel)]="settings.publicUrl"
|
||||
name="publicUrl">
|
||||
<span class="help-block">If you access the page form local network its good to know the public url for creating sharing link</span>
|
||||
</div>
|
||||
|
@ -21,7 +21,12 @@ export class BasicSettingsComponent extends SettingsComponent<BasicConfigDTO> {
|
||||
_navigation: NavigationService,
|
||||
_settingsService: BasicSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Basic", _authService, _navigation, _settingsService, notification);
|
||||
super("Basic", _authService, _navigation, _settingsService, notification, s => ({
|
||||
port: s.Server.port,
|
||||
imagesFolder: s.Server.imagesFolder,
|
||||
applicationTitle: s.Client.applicationTitle,
|
||||
publicUrl: s.Client.publicUrl
|
||||
}));
|
||||
}
|
||||
|
||||
public async save(): Promise<boolean> {
|
||||
|
@ -8,12 +8,7 @@ import {BasicConfigDTO} from "../../../../common/entities/settings/BasicConfigDT
|
||||
export class BasicSettingsService extends AbstractSettingsService<BasicConfigDTO> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => ({
|
||||
port: s.Server.port,
|
||||
imagesFolder: s.Server.imagesFolder,
|
||||
applicationTitle: s.Client.applicationTitle,
|
||||
publicUrl: s.Client.publicUrl
|
||||
}));
|
||||
super(_settingsService);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,20 +6,20 @@
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
<form #settingsForm="ngForm">
|
||||
<p class="title">Type:</p>
|
||||
<select class="form-control" [(ngModel)]="_settingsService.settings.type" name="type" required>
|
||||
<select class="form-control" [(ngModel)]="settings.type" name="type" required>
|
||||
<option *ngFor="let type of types" [ngValue]="type.key">{{type.value}}
|
||||
</option>
|
||||
</select>
|
||||
<ng-container *ngIf="_settingsService.settings.type == DatabaseType.mysql">
|
||||
<ng-container *ngIf="settings.type == DatabaseType.mysql">
|
||||
<p class="title">MySQL settings:</p>
|
||||
<input type="text" class="form-control" placeholder="Host" autofocus
|
||||
[(ngModel)]="_settingsService.settings.mysql.host" name="host" required>
|
||||
[(ngModel)]="settings.mysql.host" name="host" required>
|
||||
<input type="text" class="form-control" placeholder="Database" autofocus
|
||||
[(ngModel)]="_settingsService.settings.mysql.database" name="database" required>
|
||||
[(ngModel)]="settings.mysql.database" name="database" required>
|
||||
<input type="text" class="form-control" placeholder="Username"
|
||||
[(ngModel)]="_settingsService.settings.mysql.username" name="username">
|
||||
[(ngModel)]="settings.mysql.username" name="username">
|
||||
<input type="password" class="form-control" placeholder="Password"
|
||||
[(ngModel)]="_settingsService.settings.mysql.password" name="password">
|
||||
[(ngModel)]="settings.mysql.password" name="password">
|
||||
</ng-container>
|
||||
|
||||
</form>
|
||||
|
@ -23,7 +23,7 @@ export class DatabaseSettingsComponent extends SettingsComponent<DataBaseConfig>
|
||||
_navigation: NavigationService,
|
||||
_settingsService: DatabaseSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Database", _authService, _navigation, _settingsService, notification);
|
||||
super("Database", _authService, _navigation, _settingsService, notification, s => s.Server.database);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -8,7 +8,7 @@ import {SettingsService} from "../settings.service";
|
||||
export class DatabaseSettingsService extends AbstractSettingsService<DataBaseConfig> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => s.Server.database);
|
||||
super(_settingsService);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
[switch-disabled]="inProgress"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enabled">
|
||||
[(ngModel)]="settings.enabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
@ -22,8 +22,8 @@
|
||||
|
||||
|
||||
<input type="text" class="form-control" placeholder="Google api key"
|
||||
[(ngModel)]="_settingsService.settings.googleApiKey"
|
||||
[disabled]="!_settingsService.settings.enabled"
|
||||
[(ngModel)]="settings.googleApiKey"
|
||||
[disabled]="!settings.enabled"
|
||||
name="googleApiKey" required>
|
||||
<span class="help-block">To show the images on a map, <a
|
||||
href="https://developers.google.com/maps/documentation/javascript/get-api-key">google api key</a> is need</span>
|
||||
|
@ -19,7 +19,7 @@ export class MapSettingsComponent extends SettingsComponent<ClientConfig.MapConf
|
||||
_navigation: NavigationService,
|
||||
_settingsService: MapSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Map", _authService, _navigation, <any>_settingsService, notification);
|
||||
super("Map", _authService, _navigation, <any>_settingsService, notification, s => s.Client.Map);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ import {AbstractSettingsService} from "../_abstract/abstract.settings.service";
|
||||
export class MapSettingsService extends AbstractSettingsService<ClientConfig.MapConfig> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => s.Client.Map);
|
||||
super(_settingsService);
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enableThreading">
|
||||
[(ngModel)]="settings.enableThreading">
|
||||
</bSwitch>
|
||||
<span class="help-block">Runs directory scanning and thumbnail generation (only for Jimp) in a different thread</span>
|
||||
</div>
|
||||
@ -40,7 +40,7 @@
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enableOnScrollThumbnailPrioritising">
|
||||
[(ngModel)]="settings.enableOnScrollThumbnailPrioritising">
|
||||
</bSwitch>
|
||||
<span class="help-block">Those thumbnails get higher priority that are visible on the screen</span>
|
||||
</div>
|
||||
@ -59,7 +59,7 @@
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enableOnScrollRendering">
|
||||
[(ngModel)]="settings.enableOnScrollRendering">
|
||||
</bSwitch>
|
||||
<span class="help-block">Shows only the required amount of photos at once. Renders more if page bottom is reached</span>
|
||||
</div>
|
||||
@ -79,7 +79,7 @@
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enableCache">
|
||||
[(ngModel)]="settings.enableCache">
|
||||
</bSwitch>
|
||||
<span class="help-block">Caches directory contents and search results for better performance</span>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component} from "@angular/core";
|
||||
import {Component, OnChanges} from "@angular/core";
|
||||
import {SettingsComponent} from "../_abstract/abstract.settings.component";
|
||||
import {AuthenticationService} from "../../model/network/authentication.service";
|
||||
import {NavigationService} from "../../model/navigation.service";
|
||||
@ -13,13 +13,22 @@ import {OtherConfigDTO} from "../../../../common/entities/settings/OtherConfigDT
|
||||
'./../_abstract/abstract.settings.component.css'],
|
||||
providers: [OtherSettingsService],
|
||||
})
|
||||
export class OtherSettingsComponent extends SettingsComponent<OtherConfigDTO> {
|
||||
export class OtherSettingsComponent extends SettingsComponent<OtherConfigDTO> implements OnChanges {
|
||||
|
||||
constructor(_authService: AuthenticationService,
|
||||
_navigation: NavigationService,
|
||||
_settingsService: OtherSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Other", _authService, _navigation, _settingsService, notification);
|
||||
super("Other", _authService, _navigation, _settingsService, notification, s => ({
|
||||
enableThreading: s.Server.enableThreading,
|
||||
enableOnScrollThumbnailPrioritising: s.Client.enableOnScrollThumbnailPrioritising,
|
||||
enableOnScrollRendering: s.Client.enableOnScrollRendering,
|
||||
enableCache: s.Client.enableCache
|
||||
}));
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.hasAvailableSettings = !this.simplifiedMode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,12 +8,7 @@ import {OtherConfigDTO} from "../../../../common/entities/settings/OtherConfigDT
|
||||
export class OtherSettingsService extends AbstractSettingsService<OtherConfigDTO> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => ({
|
||||
enableThreading: s.Server.enableThreading,
|
||||
enableOnScrollThumbnailPrioritising: s.Client.enableOnScrollThumbnailPrioritising,
|
||||
enableOnScrollRendering: s.Client.enableOnScrollRendering,
|
||||
enableCache: s.Client.enableCache
|
||||
}));
|
||||
super(_settingsService);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<form #settingsForm="ngForm">
|
||||
<div class="panel panel-default"
|
||||
[ngClass]="_settingsService.settings.enabled && !_settingsService.isSupported()?'panel-warning':''">
|
||||
[ngClass]="settings.enabled && !_settingsService.isSupported()?'panel-warning':''">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title col-sm-4">Search settings</h3>
|
||||
<div class="switch-wrapper col-sm-8">
|
||||
@ -11,17 +11,17 @@
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Disabled'"
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-disabled]="inProgress || (!_settingsService.settings.enabled && !_settingsService.isSupported())"
|
||||
[switch-disabled]="inProgress || (!settings.enabled && !_settingsService.isSupported())"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enabled">
|
||||
[(ngModel)]="settings.enabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
|
||||
<ng-container *ngIf="_settingsService.settings.enabled || _settingsService.isSupported()">
|
||||
<ng-container *ngIf="settings.enabled || _settingsService.isSupported()">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="autocompleteEnabled">Autocomplete</label>
|
||||
@ -31,13 +31,13 @@
|
||||
class="switch"
|
||||
name="autocompleteEnabled"
|
||||
[switch-on-color]="'primary'"
|
||||
[switch-disabled]="!_settingsService.settings.enabled"
|
||||
[switch-disabled]="!settings.enabled"
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Disabled'"
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.autocompleteEnabled">
|
||||
[(ngModel)]="settings.autocompleteEnabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
@ -51,19 +51,19 @@
|
||||
class="switch"
|
||||
name="instantSearchEnabled"
|
||||
[switch-on-color]="'primary'"
|
||||
[switch-disabled]="!_settingsService.settings.enabled"
|
||||
[switch-disabled]="!settings.enabled"
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Disabled'"
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.instantSearchEnabled">
|
||||
[(ngModel)]="settings.instantSearchEnabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-container>
|
||||
<div class="panel-info" *ngIf="(!_settingsService.settings.enabled && !_settingsService.isSupported())">
|
||||
<div class="panel-info" *ngIf="(!settings.enabled && !_settingsService.isSupported())">
|
||||
Search is not supported with these settings
|
||||
</div>
|
||||
<button class="btn btn-success pull-right"
|
||||
|
@ -19,7 +19,7 @@ export class SearchSettingsComponent extends SettingsComponent<ClientConfig.Sear
|
||||
_navigation: NavigationService,
|
||||
_settingsService: SearchSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Search", _authService, _navigation, _settingsService, notification);
|
||||
super("Search", _authService, _navigation, _settingsService, notification, s => s.Client.Search);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,11 +9,9 @@ import {AbstractSettingsService} from "../_abstract/abstract.settings.service";
|
||||
export class SearchSettingsService extends AbstractSettingsService<ClientConfig.SearchConfig> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => s.Client.Search);
|
||||
|
||||
super(_settingsService)
|
||||
}
|
||||
|
||||
|
||||
public isSupported(): boolean {
|
||||
return this._settingsService.settings.value.Server.database.type != DatabaseType.memory;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<form #settingsForm="ngForm">
|
||||
<div class="panel panel-default"
|
||||
[ngClass]="_settingsService.settings.enabled && !_settingsService.isSupported()?'panel-warning':''">
|
||||
[ngClass]="settings.enabled && !_settingsService.isSupported()?'panel-warning':''">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title col-sm-4">Share settings</h3>
|
||||
<div class="switch-wrapper col-sm-8">
|
||||
@ -11,17 +11,17 @@
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Disabled'"
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-disabled]="inProgress || (!_settingsService.settings.enabled && !_settingsService.isSupported())"
|
||||
[switch-disabled]="inProgress || (!settings.enabled && !_settingsService.isSupported())"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.enabled">
|
||||
[(ngModel)]="settings.enabled">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
|
||||
<ng-container *ngIf="_settingsService.settings.enabled || _settingsService.isSupported()">
|
||||
<ng-container *ngIf="settings.enabled || _settingsService.isSupported()">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="passwordProtected">Password protected</label>
|
||||
<div class="col-sm-10">
|
||||
@ -30,19 +30,19 @@
|
||||
class="switch"
|
||||
name="passwordProtected"
|
||||
[switch-on-color]="'primary'"
|
||||
[switch-disabled]="!_settingsService.settings.enabled"
|
||||
[switch-disabled]="!settings.enabled"
|
||||
[switch-inverse]="'inverse'"
|
||||
[switch-off-text]="'Disabled'"
|
||||
[switch-on-text]="'Enabled'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.passwordProtected">
|
||||
[(ngModel)]="settings.passwordProtected">
|
||||
</bSwitch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-container>
|
||||
<div class="panel-info" *ngIf="(!_settingsService.settings.enabled && !_settingsService.isSupported())">
|
||||
<div class="panel-info" *ngIf="(!settings.enabled && !_settingsService.isSupported())">
|
||||
Sharing is not supported with these settings
|
||||
</div>
|
||||
<button class="btn btn-success pull-right"
|
||||
|
@ -19,7 +19,7 @@ export class ShareSettingsComponent extends SettingsComponent<ClientConfig.Shari
|
||||
_navigation: NavigationService,
|
||||
_settingsService: ShareSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Share", _authService, _navigation, _settingsService, notification);
|
||||
super("Share", _authService, _navigation, _settingsService, notification, s => s.Client.Sharing);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {AbstractSettingsService} from "../_abstract/abstract.settings.service";
|
||||
export class ShareSettingsService extends AbstractSettingsService<ClientConfig.SharingConfig> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => s.Client.Sharing);
|
||||
super(_settingsService);
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div [hidden]="!error" class="alert alert-danger" role="alert"><strong>Error: </strong>{{error}}</div>
|
||||
<div [hidden]="_settingsService.settings.server.processingLibrary!=ThumbnailProcessingLib.Jimp"
|
||||
<div [hidden]="settings.server.processingLibrary!=ThumbnailProcessingLib.Jimp"
|
||||
class="alert alert-warning"
|
||||
role="alert">It is highly recommended to use hardware accelerated (sharp or gm) lib for thumbnail generation
|
||||
</div>
|
||||
@ -14,14 +14,14 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="lib">Thumbnail generation library</label>
|
||||
<div class="col-sm-10">
|
||||
<select id="lib" class="form-control" [(ngModel)]="_settingsService.settings.server.processingLibrary"
|
||||
<select id="lib" class="form-control" [(ngModel)]="settings.server.processingLibrary"
|
||||
name="type" required>
|
||||
<option *ngFor="let type of types" [ngValue]="type.key">{{type.value}}
|
||||
</option>
|
||||
</select>
|
||||
<span *ngIf="_settingsService.settings.server.processingLibrary==ThumbnailProcessingLib.sharp"
|
||||
<span *ngIf="settings.server.processingLibrary==ThumbnailProcessingLib.sharp"
|
||||
class="help-block">Make sure that sharp node module is installed (npm install sharp)</span>
|
||||
<span *ngIf="_settingsService.settings.server.processingLibrary==ThumbnailProcessingLib.gm"
|
||||
<span *ngIf="settings.server.processingLibrary==ThumbnailProcessingLib.gm"
|
||||
class="help-block">Make sure that gm node module and <a
|
||||
href="http://www.graphicsmagick.org/">GraphicsMagick</a> are installed (npm install sharp)</span>
|
||||
|
||||
@ -33,13 +33,13 @@
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" placeholder="path"
|
||||
id="folder"
|
||||
[(ngModel)]="_settingsService.settings.server.folder"
|
||||
[(ngModel)]="settings.server.folder"
|
||||
name="path" required>
|
||||
<span class="help-block">Thumbnails will be saved in this folder. Write access is required</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="quality">Thumbnail Quality</label>
|
||||
<div class="col-sm-10">
|
||||
<bSwitch
|
||||
@ -52,19 +52,19 @@
|
||||
[switch-on-text]="'High'"
|
||||
[switch-handle-width]="'100'"
|
||||
[switch-label-width]="'20'"
|
||||
[(ngModel)]="_settingsService.settings.server.qualityPriority">
|
||||
[(ngModel)]="settings.server.qualityPriority">
|
||||
</bSwitch>
|
||||
<span class="help-block">High quality may be slow. Especially with Jimp.</span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="icon">Icon size</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="number" class="form-control" placeholder="30"
|
||||
id="icon"
|
||||
[(ngModel)]="_settingsService.settings.client.iconSize"
|
||||
[(ngModel)]="settings.client.iconSize"
|
||||
min="1"
|
||||
max="100"
|
||||
step="1"
|
||||
@ -74,7 +74,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" [hidden]="simplifiedMode">
|
||||
<label class="col-sm-2 control-label" for="thumbnailSizes">Thumbnail sizes</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" placeholder="200; 400"
|
||||
|
@ -23,17 +23,20 @@ export class ThumbnailSettingsComponent extends SettingsComponent<{ server: Thum
|
||||
_navigation: NavigationService,
|
||||
_settingsService: ThumbnailSettingsService,
|
||||
notification: NotificationService) {
|
||||
super("Thumbnail", _authService, _navigation, _settingsService, notification);
|
||||
super("Thumbnail", _authService, _navigation, _settingsService, notification, s => ({
|
||||
client: s.Client.Thumbnail,
|
||||
server: s.Server.thumbnail
|
||||
}));
|
||||
}
|
||||
|
||||
get ThumbnailSizes(): string {
|
||||
return this._settingsService.settings.client.thumbnailSizes.join("; ");
|
||||
return this.settings.client.thumbnailSizes.join("; ");
|
||||
}
|
||||
|
||||
set ThumbnailSizes(value: string) {
|
||||
value = value.replace(new RegExp(',', 'g'), ";");
|
||||
value = value.replace(new RegExp(' ', 'g'), ";");
|
||||
this._settingsService.settings.client.thumbnailSizes = value.split(";").map(s => parseInt(s)).filter(i => !isNaN(i) && i > 0);
|
||||
this.settings.client.thumbnailSizes = value.split(";").map(s => parseInt(s)).filter(i => !isNaN(i) && i > 0);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -9,7 +9,7 @@ import {SettingsService} from "../settings.service";
|
||||
export class ThumbnailSettingsService extends AbstractSettingsService<{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }> {
|
||||
constructor(private _networkService: NetworkService,
|
||||
_settingsService: SettingsService) {
|
||||
super(_settingsService, s => ({client: s.Client.Thumbnail, server: s.Server.thumbnail}));
|
||||
super(_settingsService);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user