From 521436dd218781d560384a330b93d6cca82eb8f1 Mon Sep 17 00:00:00 2001 From: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:47:31 +0200 Subject: [PATCH] feat(server): Add week numbers for templating (#4263) * add week numbers as template option * generate api * fix tests * change example date to show week padding * change example date to immich birthday --- cli/src/api/open-api/api.ts | 6 ++++++ .../SystemConfigTemplateStorageOptionDto.md | Bin 842 -> 904 bytes ...em_config_template_storage_option_dto.dart | Bin 5510 -> 5868 bytes ...nfig_template_storage_option_dto_test.dart | Bin 1516 -> 1655 bytes server/immich-openapi-specs.json | 7 +++++++ .../storage-template.service.ts | 2 ++ ...stem-config-template-storage-option.dto.ts | 1 + .../system-config/system-config.constants.ts | 2 ++ .../system-config.service.spec.ts | 2 ++ .../system-config/system-config.service.ts | 2 ++ web/src/api/open-api/api.ts | 6 ++++++ .../storage-template-settings.svelte | 3 ++- .../supported-datetime-panel.svelte | 13 +++++++++++-- 13 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index f9c983833f..67334711ee 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto { * @memberof SystemConfigTemplateStorageOptionDto */ 'secondOptions': Array; + /** + * + * @type {Array} + * @memberof SystemConfigTemplateStorageOptionDto + */ + 'weekOptions': Array; /** * * @type {Array} diff --git a/mobile/openapi/doc/SystemConfigTemplateStorageOptionDto.md b/mobile/openapi/doc/SystemConfigTemplateStorageOptionDto.md index 18adaa6fadc4937a955fb6459f45357c33c6c90e..6465fcbef866a4c5531e55c559810db78d6ce2f1 100644 GIT binary patch delta 20 bcmX@b*1^6ZlZmA~H8p#(0i)IAOs0nbNazO$ delta 11 ScmeBRKgG5olWFpDriTC-=>(Vn diff --git a/mobile/openapi/lib/model/system_config_template_storage_option_dto.dart b/mobile/openapi/lib/model/system_config_template_storage_option_dto.dart index 23d17e16aa8e403e3f9407d90cf93b4849624af3..da9138745f5223a8d99ef7fec5b82d57383b7bfc 100644 GIT binary patch delta 187 zcmZqEexti#A`?q_YHIf6KqlGA6PX@CIQN+(Hy1NcV-yBS`4^OA=I0eF*xD+9RXVbW zZRTW^XM`xd$SS#6gN>6>5J{=63W&2=gMA^RB$BXttb(mVNk(R|9@v})4zbNAIT%?b kkd#;{WEJP}JO9S^1llhzg% DprR0m diff --git a/mobile/openapi/test/system_config_template_storage_option_dto_test.dart b/mobile/openapi/test/system_config_template_storage_option_dto_test.dart index 57e059d9b821f71b5fa08c0652b29d018b2f9fd2..6082748336d93b3842c32f096c3dfe2125aa31b1 100644 GIT binary patch delta 29 gcmaFE{hen+HY-bcYHIdm1tup5;{%i9 { '{{y}}-{{MMM}}-{{dd}}/{{filename}}', '{{y}}-{{MMMM}}-{{dd}}/{{filename}}', '{{y}}/{{y}}-{{MM}}/{{filename}}', + '{{y}}/{{y}}-{{WW}}/{{filename}}', ], secondOptions: ['s', 'ss'], + weekOptions: ['W', 'WW'], yearOptions: ['y', 'yy'], }); }); diff --git a/server/src/domain/system-config/system-config.service.ts b/server/src/domain/system-config/system-config.service.ts index cf289b7f97..3359175010 100644 --- a/server/src/domain/system-config/system-config.service.ts +++ b/server/src/domain/system-config/system-config.service.ts @@ -10,6 +10,7 @@ import { supportedMonthTokens, supportedPresetTokens, supportedSecondTokens, + supportedWeekTokens, supportedYearTokens, } from './system-config.constants'; import { SystemConfigCore, SystemConfigValidator } from './system-config.core'; @@ -57,6 +58,7 @@ export class SystemConfigService { const options = new SystemConfigTemplateStorageOptionDto(); options.dayOptions = supportedDayTokens; + options.weekOptions = supportedWeekTokens; options.monthOptions = supportedMonthTokens; options.yearOptions = supportedYearTokens; options.hourOptions = supportedHourTokens; diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index f9c983833f..67334711ee 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto { * @memberof SystemConfigTemplateStorageOptionDto */ 'secondOptions': Array; + /** + * + * @type {Array} + * @memberof SystemConfigTemplateStorageOptionDto + */ + 'weekOptions': Array; /** * * @type {Array} diff --git a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte index 5cee5edb46..c0018edcb7 100644 --- a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte +++ b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte @@ -58,11 +58,12 @@ filetypefull: 'IMAGE', }; - const dt = luxon.DateTime.fromISO(new Date('2022-09-04T20:03:05.250').toISOString()); + const dt = luxon.DateTime.fromISO(new Date('2022-02-03T04:56:05.250').toISOString()); const dateTokens = [ ...templateOptions.yearOptions, ...templateOptions.monthOptions, + ...templateOptions.weekOptions, ...templateOptions.dayOptions, ...templateOptions.hourOptions, ...templateOptions.minuteOptions, diff --git a/web/src/lib/components/admin-page/settings/storage-template/supported-datetime-panel.svelte b/web/src/lib/components/admin-page/settings/storage-template/supported-datetime-panel.svelte index d95c58fda5..8a72268240 100644 --- a/web/src/lib/components/admin-page/settings/storage-template/supported-datetime-panel.svelte +++ b/web/src/lib/components/admin-page/settings/storage-template/supported-datetime-panel.svelte @@ -16,9 +16,9 @@

Asset's creation timestamp is used for the datetime information

-

Sample time 2022-09-04T20:03:05.250

+

Sample time 2022-02-03T04:56:05.250

-
+

YEAR

    @@ -37,6 +37,15 @@
+
+

WEEK

+
    + {#each options.weekOptions as weekFormat} +
  • {'{{'}{weekFormat}{'}}'} - {getLuxonExample(weekFormat)}
  • + {/each} +
+
+

DAY