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

60 lines
2.2 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";
2018-03-30 08:30:23 +08:00
import {I18n} from "@ngx-translate/i18n-polyfill";
2017-07-15 18:47:11 +08:00
@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 }> {
types: Array<any> = [];
ThumbnailProcessingLib: any;
constructor(_authService: AuthenticationService,
_navigation: NavigationService,
2017-07-15 20:27:12 +08:00
_settingsService: ThumbnailSettingsService,
2018-03-30 08:30:23 +08:00
notification: NotificationService,
i18n: I18n) {
super(i18n("Thumbnail"), _authService, _navigation, _settingsService, notification, i18n, s => ({
2017-07-15 23:29:40 +08:00
client: s.Client.Thumbnail,
server: s.Server.thumbnail
}));
2017-07-15 18:47:11 +08:00
}
get ThumbnailSizes(): string {
2017-07-15 23:29:40 +08:00
return this.settings.client.thumbnailSizes.join("; ");
2017-07-15 18:47:11 +08:00
}
set ThumbnailSizes(value: string) {
value = value.replace(new RegExp(',', 'g'), ";");
value = value.replace(new RegExp(' ', 'g'), ";");
2017-07-15 23:29:40 +08:00
this.settings.client.thumbnailSizes = value.split(";").map(s => parseInt(s)).filter(i => !isNaN(i) && i > 0);
2017-07-15 18:47:11 +08:00
}
ngOnInit() {
super.ngOnInit();
this.types = Utils
.enumToArray(ThumbnailProcessingLib).map((v) => {
if (v.value.toLowerCase() == "sharp") {
2018-03-30 08:30:23 +08:00
v.value += " " + this.i18n("(recommended)");
2017-07-15 18:47:11 +08:00
}
return v;
});
this.ThumbnailProcessingLib = ThumbnailProcessingLib;
}
}