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

64 lines
2.2 KiB
TypeScript
Raw Normal View History

2018-05-04 07:17:08 +08:00
import {Component, OnInit} from '@angular/core';
2018-03-31 03:30:30 +08:00
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';
import {I18n} from '@ngx-translate/i18n-polyfill';
2017-07-15 18:47:11 +08:00
@Component({
2018-05-04 07:17:08 +08:00
selector: 'app-settings-thumbnail',
2017-07-15 18:47:11 +08:00
templateUrl: './thumbanil.settings.component.html',
styleUrls: ['./thumbanil.settings.component.css',
'./../_abstract/abstract.settings.component.css'],
providers: [ThumbnailSettingsService],
})
2018-05-04 07:17:08 +08:00
export class ThumbnailSettingsComponent
extends SettingsComponent<{ server: ThumbnailConfig, client: ClientConfig.ThumbnailConfig }>
implements OnInit {
2017-07-15 18:47:11 +08:00
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) {
2018-03-31 03:30:30 +08:00
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 {
2018-03-31 03:30:30 +08:00
return this.settings.client.thumbnailSizes.join('; ');
2017-07-15 18:47:11 +08:00
}
set ThumbnailSizes(value: string) {
2018-03-31 03:30:30 +08:00
value = value.replace(new RegExp(',', 'g'), ';');
value = value.replace(new RegExp(' ', 'g'), ';');
2018-05-04 07:17:08 +08:00
this.settings.client.thumbnailSizes = value.split(';')
.map(s => parseInt(s, 10))
.filter(i => !isNaN(i) && i > 0);
2017-07-15 18:47:11 +08:00
}
ngOnInit() {
super.ngOnInit();
this.types = Utils
.enumToArray(ThumbnailProcessingLib).map((v) => {
2018-05-04 07:17:08 +08:00
if (v.value.toLowerCase() === 'sharp') {
2018-03-31 03:30:30 +08:00
v.value += ' ' + this.i18n('(recommended)');
2017-07-15 18:47:11 +08:00
}
return v;
});
this.ThumbnailProcessingLib = ThumbnailProcessingLib;
}
}