1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/settings/thumbnail/thumbanil.settings.component.ts

66 lines
2.3 KiB
TypeScript
Raw Normal View History

2017-07-15 18:47:11 +08:00
import {Component} from "@angular/core";
import {SettingsComponent} from "../_abstract/abstract.settings.component";
import {AuthenticationService} from "../../model/network/authentication.service";
import {NavigationService} from "../../model/navigation.service";
import {NotificationService} from "../../model/notification.service";
import {ThumbnailConfig, ThumbnailProcessingLib} from "../../../../common/config/private/IPrivateConfig";
import {ClientConfig} from "../../../../common/config/public/ConfigClass";
import {ThumbnailSettingsService} from "./thumbanil.settings.service";
import {Utils} from "../../../../common/Utils";
@Component({
selector: 'settings-thumbnail',
templateUrl: './thumbanil.settings.component.html',
styleUrls: ['./thumbanil.settings.component.css',
'./../_abstract/abstract.settings.component.css'],
providers: [ThumbnailSettingsService],
})
export class ThumbnailSettingsComponent extends SettingsComponent<{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }> {
public settings: { server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig } = <{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }> {
server: {
folder: "",
processingLibrary: ThumbnailProcessingLib.Jimp,
qualityPriority: true
},
client: {
iconSize: null,
thumbnailSizes: []
}
};
types: Array<any> = [];
ThumbnailProcessingLib: any;
constructor(_authService: AuthenticationService,
_navigation: NavigationService,
_settingsSettings: ThumbnailSettingsService,
notification: NotificationService) {
super("Thumbnail", _authService, _navigation, _settingsSettings, notification);
}
get ThumbnailSizes(): string {
return this.settings.client.thumbnailSizes.join("; ");
}
set ThumbnailSizes(value: string) {
value = value.replace(new RegExp(',', 'g'), ";");
value = value.replace(new RegExp(' ', 'g'), ";");
this.settings.client.thumbnailSizes = value.split(";").map(s => parseInt(s)).filter(i => !isNaN(i) && i > 0);
}
ngOnInit() {
super.ngOnInit();
this.types = Utils
.enumToArray(ThumbnailProcessingLib).map((v) => {
if (v.value.toLowerCase() == "sharp") {
v.value += " (recommended)";
}
return v;
});
this.ThumbnailProcessingLib = ThumbnailProcessingLib;
}
}