1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

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
This commit is contained in:
Daniel Dietzler 2023-09-28 19:47:31 +02:00 committed by GitHub
parent c145963b02
commit 521436dd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 41 additions and 3 deletions

View File

@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto {
* @memberof SystemConfigTemplateStorageOptionDto
*/
'secondOptions': Array<string>;
/**
*
* @type {Array<string>}
* @memberof SystemConfigTemplateStorageOptionDto
*/
'weekOptions': Array<string>;
/**
*
* @type {Array<string>}

View File

@ -7924,6 +7924,12 @@
},
"type": "array"
},
"weekOptions": {
"items": {
"type": "string"
},
"type": "array"
},
"yearOptions": {
"items": {
"type": "string"
@ -7934,6 +7940,7 @@
"required": [
"yearOptions",
"monthOptions",
"weekOptions",
"dayOptions",
"hourOptions",
"minuteOptions",

View File

@ -16,6 +16,7 @@ import {
supportedMinuteTokens,
supportedMonthTokens,
supportedSecondTokens,
supportedWeekTokens,
supportedYearTokens,
} from '../system-config';
import { SystemConfigCore } from '../system-config/system-config.core';
@ -239,6 +240,7 @@ export class StorageTemplateService {
const dateTokens = [
...supportedYearTokens,
...supportedMonthTokens,
...supportedWeekTokens,
...supportedDayTokens,
...supportedHourTokens,
...supportedMinuteTokens,

View File

@ -1,6 +1,7 @@
export class SystemConfigTemplateStorageOptionDto {
yearOptions!: string[];
monthOptions!: string[];
weekOptions!: string[];
dayOptions!: string[];
hourOptions!: string[];
minuteOptions!: string[];

View File

@ -1,5 +1,6 @@
export const supportedYearTokens = ['y', 'yy'];
export const supportedMonthTokens = ['M', 'MM', 'MMM', 'MMMM'];
export const supportedWeekTokens = ['W', 'WW'];
export const supportedDayTokens = ['d', 'dd'];
export const supportedHourTokens = ['h', 'hh', 'H', 'HH'];
export const supportedMinuteTokens = ['m', 'mm'];
@ -18,6 +19,7 @@ export const supportedPresetTokens = [
'{{y}}-{{MMM}}-{{dd}}/{{filename}}',
'{{y}}-{{MMMM}}-{{dd}}/{{filename}}',
'{{y}}/{{y}}-{{MM}}/{{filename}}',
'{{y}}/{{y}}-{{WW}}/{{filename}}',
];
export const INITIAL_SYSTEM_CONFIG = 'INITIAL_SYSTEM_CONFIG';

View File

@ -221,8 +221,10 @@ describe(SystemConfigService.name, () => {
'{{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'],
});
});

View File

@ -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;

View File

@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto {
* @memberof SystemConfigTemplateStorageOptionDto
*/
'secondOptions': Array<string>;
/**
*
* @type {Array<string>}
* @memberof SystemConfigTemplateStorageOptionDto
*/
'weekOptions': Array<string>;
/**
*
* @type {Array<string>}

View File

@ -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,

View File

@ -16,9 +16,9 @@
<div class="mt-2 rounded-lg bg-gray-200 p-4 text-xs dark:bg-gray-700 dark:text-immich-dark-fg">
<div class="mb-2 text-gray-600 dark:text-immich-dark-fg">
<p>Asset's creation timestamp is used for the datetime information</p>
<p>Sample time 2022-09-04T20:03:05.250</p>
<p>Sample time 2022-02-03T04:56:05.250</p>
</div>
<div class="flex gap-[50px]">
<div class="flex gap-[40px]">
<div>
<p class="font-medium text-immich-primary dark:text-immich-dark-primary">YEAR</p>
<ul>
@ -37,6 +37,15 @@
</ul>
</div>
<div>
<p class="font-medium text-immich-primary dark:text-immich-dark-primary">WEEK</p>
<ul>
{#each options.weekOptions as weekFormat}
<li>{'{{'}{weekFormat}{'}}'} - {getLuxonExample(weekFormat)}</li>
{/each}
</ul>
</div>
<div>
<p class="font-medium text-immich-primary dark:text-immich-dark-primary">DAY</p>
<ul>