From de30430e63f4345184564f58e186d7c3e3439081 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 5 Aug 2023 15:55:52 +0200 Subject: [PATCH] Add compact settings view #587 --- src/common/CookieNames.ts | 1 + src/common/config/private/PrivateConfig.ts | 2 +- src/common/config/public/ClientConfig.ts | 2 +- src/frontend/app/app.module.ts | 4 +- .../app/pipes/StringifyConfigPriority.ts | 13 ------ src/frontend/app/pipes/StringifyEnum.ts | 12 ++++++ src/frontend/app/ui/EnumTranslations.ts | 5 +++ .../app/ui/admin/admin.component.html | 23 ++++++++-- src/frontend/app/ui/admin/admin.component.ts | 5 ++- .../app/ui/settings/settings.service.ts | 19 +++++++- .../settings-entry.component.html | 5 ++- .../settings-entry.component.ts | 3 +- .../settings/template/template.component.html | 4 +- .../settings/template/template.component.ts | 4 +- .../settings/workflow/workflow.component.html | 43 ++++++++++++------- .../settings/workflow/workflow.component.ts | 5 ++- 16 files changed, 104 insertions(+), 46 deletions(-) delete mode 100644 src/frontend/app/pipes/StringifyConfigPriority.ts create mode 100644 src/frontend/app/pipes/StringifyEnum.ts diff --git a/src/common/CookieNames.ts b/src/common/CookieNames.ts index 0098d49e..eba729ee 100644 --- a/src/common/CookieNames.ts +++ b/src/common/CookieNames.ts @@ -2,4 +2,5 @@ export class CookieNames { public static lang = 'pigallery2-lang'; public static session = 'pigallery2-session'; public static configPriority = 'config-priority'; + public static configStyle = 'config-style'; } diff --git a/src/common/config/private/PrivateConfig.ts b/src/common/config/private/PrivateConfig.ts index 330cf703..16e1f08a 100644 --- a/src/common/config/private/PrivateConfig.ts +++ b/src/common/config/private/PrivateConfig.ts @@ -319,7 +319,7 @@ export class ServerThumbnailConfig extends ClientThumbnailConfig { type: 'boolean', tags: { - name: $localize`Use chroma subsampling.`, + name: $localize`Use chroma subsampling`, priority: ConfigPriority.underTheHood }, description: $localize`Use high quality chroma subsampling in webp. See: https://sharp.pixelplumbing.com/api-output#webp.` diff --git a/src/common/config/public/ClientConfig.ts b/src/common/config/public/ClientConfig.ts index 06d4ff00..729b8d95 100644 --- a/src/common/config/public/ClientConfig.ts +++ b/src/common/config/public/ClientConfig.ts @@ -21,7 +21,7 @@ export enum MapProviders { } export enum ConfigPriority { - basic = 0, advanced, underTheHood + basic = 1, advanced, underTheHood } diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index 10575fbd..04effe01 100644 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -105,7 +105,7 @@ import {SettingsEntryComponent} from './ui/settings/template/settings-entry/sett import {UsersComponent} from './ui/settings/users/users.component'; import {SharingsListComponent} from './ui/settings/sharings-list/sharings-list.component'; import {ThemeService} from './model/theme.service'; -import {StringifyConfigPriority} from './pipes/StringifyConfigPriority'; +import {StringifyEnum} from './pipes/StringifyEnum'; import {StringifySearchType} from './pipes/StringifySearchType'; import {MarkerFactory} from './ui/gallery/map/MarkerFactory'; @@ -224,7 +224,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon; GPXFilesFilterPipe, MDFilesFilterPipe, StringifySearchQuery, - StringifyConfigPriority, + StringifyEnum, StringifySearchType, FileDTOToPathPipe, PhotoFilterPipe, diff --git a/src/frontend/app/pipes/StringifyConfigPriority.ts b/src/frontend/app/pipes/StringifyConfigPriority.ts deleted file mode 100644 index 44f7d92c..00000000 --- a/src/frontend/app/pipes/StringifyConfigPriority.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import { ConfigPriority } from '../../../common/config/public/ClientConfig'; -import { SortingMethods } from '../../../common/entities/SortingMethods'; -import {EnumTranslations} from '../ui/EnumTranslations'; - -@Pipe({ name: 'stringifyConfigPriority' }) -export class StringifyConfigPriority implements PipeTransform { - - transform(method: ConfigPriority): string { - return EnumTranslations[ConfigPriority[method]]; - } -} - diff --git a/src/frontend/app/pipes/StringifyEnum.ts b/src/frontend/app/pipes/StringifyEnum.ts new file mode 100644 index 00000000..d4b4bdb8 --- /dev/null +++ b/src/frontend/app/pipes/StringifyEnum.ts @@ -0,0 +1,12 @@ +import {Pipe, PipeTransform} from '@angular/core'; +import {ConfigPriority} from '../../../common/config/public/ClientConfig'; +import {EnumTranslations} from '../ui/EnumTranslations'; + +@Pipe({name: 'stringifyEnum'}) +export class StringifyEnum implements PipeTransform { + + transform(name: string): string { + return EnumTranslations[name]; + } +} + diff --git a/src/frontend/app/ui/EnumTranslations.ts b/src/frontend/app/ui/EnumTranslations.ts index 17c6c89d..4b14360b 100644 --- a/src/frontend/app/ui/EnumTranslations.ts +++ b/src/frontend/app/ui/EnumTranslations.ts @@ -3,6 +3,7 @@ import {ConfigPriority, MapProviders, NavigationLinkTypes} from '../../../common import {ReIndexingSensitivity} from '../../../common/config/private/PrivateConfig'; import {SortingMethods} from '../../../common/entities/SortingMethods'; import {SearchQueryTypes} from '../../../common/entities/SearchQueryDTO'; +import {ConfigStyle} from './settings/settings.service'; export const EnumTranslations: Record = {}; export const enumToTranslatedArray = (EnumType: any): { key: number; value: string }[] => { @@ -26,6 +27,10 @@ EnumTranslations[ConfigPriority[ConfigPriority.basic]] = $localize`Basic`; EnumTranslations[ConfigPriority[ConfigPriority.advanced]] = $localize`Advanced`; EnumTranslations[ConfigPriority[ConfigPriority.underTheHood]] = $localize`Under the hood`; + +EnumTranslations[ConfigStyle[ConfigStyle.full]] = $localize`Full`; +EnumTranslations[ConfigStyle[ConfigStyle.compact]] = $localize`Compact`; + EnumTranslations[MapProviders[MapProviders.Custom]] = $localize`Custom`; EnumTranslations[MapProviders[MapProviders.OpenStreetMap]] = $localize`OpenStreetMap`; EnumTranslations[MapProviders[MapProviders.Mapbox]] = $localize`Mapbox`; diff --git a/src/frontend/app/ui/admin/admin.component.html b/src/frontend/app/ui/admin/admin.component.html index 5dced471..73089d4d 100644 --- a/src/frontend/app/ui/admin/admin.component.html +++ b/src/frontend/app/ui/admin/admin.component.html @@ -36,7 +36,7 @@
- +
+
+
+ +
diff --git a/src/frontend/app/ui/admin/admin.component.ts b/src/frontend/app/ui/admin/admin.component.ts index 627c2b98..c1a85b27 100644 --- a/src/frontend/app/ui/admin/admin.component.ts +++ b/src/frontend/app/ui/admin/admin.component.ts @@ -5,7 +5,7 @@ import {NotificationService} from '../../model/notification.service'; import {NotificationType} from '../../../../common/entities/NotificationDTO'; import {NavigationService} from '../../model/navigation.service'; import {ViewportScroller} from '@angular/common'; -import {SettingsService} from '../settings/settings.service'; +import {ConfigStyle, SettingsService} from '../settings/settings.service'; import {ConfigPriority} from '../../../../common/config/public/ClientConfig'; import {WebConfig} from '../../../../common/config/private/WebConfig'; import {ISettingsComponent} from '../settings/template/ISettingsComponent'; @@ -24,7 +24,9 @@ export class AdminComponent implements OnInit, AfterViewInit { settingsComponentsElemRef: QueryList; contents: ISettingsComponent[] = []; configPriorities: { key: number; value: string; }[]; + configStyles: { key: number; value: string; }[]; public readonly ConfigPriority = ConfigPriority; + public readonly ConfigStyle = ConfigStyle; public readonly configPaths: string[] = []; constructor( @@ -36,6 +38,7 @@ export class AdminComponent implements OnInit, AfterViewInit { private piTitleService: PiTitleService ) { this.configPriorities = enumToTranslatedArray(ConfigPriority); + this.configStyles = enumToTranslatedArray(ConfigStyle); const wc = WebConfigClassBuilder.attachPrivateInterface(new WebConfig()); this.configPaths = Object.keys(wc.State) .filter(s => !wc.__state[s].volatile); diff --git a/src/frontend/app/ui/settings/settings.service.ts b/src/frontend/app/ui/settings/settings.service.ts index bd06c4e6..965a1ad4 100644 --- a/src/frontend/app/ui/settings/settings.service.ts +++ b/src/frontend/app/ui/settings/settings.service.ts @@ -12,9 +12,16 @@ import {StatisticDTO} from '../../../../common/entities/settings/StatisticDTO'; import {ScheduledJobsService} from './scheduled-jobs.service'; import {IWebConfigClassPrivate} from '../../../../../node_modules/typeconfig/src/decorators/class/IWebConfigClass'; + +export enum ConfigStyle { + full = 1, compact +} + + @Injectable() export class SettingsService { public configPriority = ConfigPriority.basic; + public configStyle = ConfigStyle.full; public settings: BehaviorSubject & WebConfig>; private fetchingSettings = false; public statistic: BehaviorSubject; @@ -30,6 +37,10 @@ export class SettingsService { this.configPriority = parseInt(this.cookieService.get(CookieNames.configPriority)); } + if (this.cookieService.check(CookieNames.configStyle)) { + this.configStyle = + parseInt(this.cookieService.get(CookieNames.configStyle)); + } this.settings.pipe(first()).subscribe(() => { @@ -68,13 +79,19 @@ export class SettingsService { return this.networkService.putJson('/settings', {settings, settingsPath}); } - configPriorityChanged(): void { + configSetupChanged(): void { // save it for some years this.cookieService.set( CookieNames.configPriority, this.configPriority.toString(), 365 * 50 ); + // save it for some years + this.cookieService.set( + CookieNames.configStyle, + this.configStyle.toString(), + 365 * 50 + ); } async loadStatistic(): Promise { diff --git a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.html b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.html index b8da1796..b676d1ed 100644 --- a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.html +++ b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.html @@ -5,7 +5,8 @@ -
@@ -546,7 +547,7 @@
- + [Experimental] diff --git a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts index 1b084480..c52aa885 100644 --- a/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts +++ b/src/frontend/app/ui/settings/template/settings-entry/settings-entry.component.ts @@ -12,7 +12,7 @@ import { TAGS, ThemeConfig } from '../../../../../../common/config/public/ClientConfig'; -import {SettingsService} from '../../settings.service'; +import {ConfigStyle, SettingsService} from '../../settings.service'; import {WebConfig} from '../../../../../../common/config/private/WebConfig'; import {JobScheduleConfig, UserConfig} from '../../../../../../common/config/private/PrivateConfig'; import {enumToTranslatedArray} from '../../../EnumTranslations'; @@ -79,6 +79,7 @@ export class SettingsEntryComponent newThemeModalRef: any; iconModal: { ref?: any, error?: string }; @Input() noChangeDetection = false; + public readonly ConfigStyle = ConfigStyle; constructor(private searchQueryParserService: SearchQueryParserService, diff --git a/src/frontend/app/ui/settings/template/template.component.html b/src/frontend/app/ui/settings/template/template.component.html index 08e88fa5..77b4f260 100644 --- a/src/frontend/app/ui/settings/template/template.component.html +++ b/src/frontend/app/ui/settings/template/template.component.html @@ -69,7 +69,7 @@ -