mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00: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:
		
							
								
								
									
										6
									
								
								cli/src/api/open-api/api.ts
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								cli/src/api/open-api/api.ts
									
									
									
										generated
									
									
									
								
							| @@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto { | |||||||
|      * @memberof SystemConfigTemplateStorageOptionDto |      * @memberof SystemConfigTemplateStorageOptionDto | ||||||
|      */ |      */ | ||||||
|     'secondOptions': Array<string>; |     'secondOptions': Array<string>; | ||||||
|  |     /** | ||||||
|  |      *  | ||||||
|  |      * @type {Array<string>} | ||||||
|  |      * @memberof SystemConfigTemplateStorageOptionDto | ||||||
|  |      */ | ||||||
|  |     'weekOptions': Array<string>; | ||||||
|     /** |     /** | ||||||
|      *  |      *  | ||||||
|      * @type {Array<string>} |      * @type {Array<string>} | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ Name | Type | Description | Notes | |||||||
| **monthOptions** | **List<String>** |  | [default to const []] | **monthOptions** | **List<String>** |  | [default to const []] | ||||||
| **presetOptions** | **List<String>** |  | [default to const []] | **presetOptions** | **List<String>** |  | [default to const []] | ||||||
| **secondOptions** | **List<String>** |  | [default to const []] | **secondOptions** | **List<String>** |  | [default to const []] | ||||||
|  | **weekOptions** | **List<String>** |  | [default to const []] | ||||||
| **yearOptions** | **List<String>** |  | [default to const []] | **yearOptions** | **List<String>** |  | [default to const []] | ||||||
| 
 | 
 | ||||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|     this.monthOptions = const [], |     this.monthOptions = const [], | ||||||
|     this.presetOptions = const [], |     this.presetOptions = const [], | ||||||
|     this.secondOptions = const [], |     this.secondOptions = const [], | ||||||
|  |     this.weekOptions = const [], | ||||||
|     this.yearOptions = const [], |     this.yearOptions = const [], | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
| @@ -34,6 +35,8 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
| 
 | 
 | ||||||
|   List<String> secondOptions; |   List<String> secondOptions; | ||||||
| 
 | 
 | ||||||
|  |   List<String> weekOptions; | ||||||
|  | 
 | ||||||
|   List<String> yearOptions; |   List<String> yearOptions; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
| @@ -44,6 +47,7 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|      other.monthOptions == monthOptions && |      other.monthOptions == monthOptions && | ||||||
|      other.presetOptions == presetOptions && |      other.presetOptions == presetOptions && | ||||||
|      other.secondOptions == secondOptions && |      other.secondOptions == secondOptions && | ||||||
|  |      other.weekOptions == weekOptions && | ||||||
|      other.yearOptions == yearOptions; |      other.yearOptions == yearOptions; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
| @@ -55,10 +59,11 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|     (monthOptions.hashCode) + |     (monthOptions.hashCode) + | ||||||
|     (presetOptions.hashCode) + |     (presetOptions.hashCode) + | ||||||
|     (secondOptions.hashCode) + |     (secondOptions.hashCode) + | ||||||
|  |     (weekOptions.hashCode) + | ||||||
|     (yearOptions.hashCode); |     (yearOptions.hashCode); | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   String toString() => 'SystemConfigTemplateStorageOptionDto[dayOptions=$dayOptions, hourOptions=$hourOptions, minuteOptions=$minuteOptions, monthOptions=$monthOptions, presetOptions=$presetOptions, secondOptions=$secondOptions, yearOptions=$yearOptions]'; |   String toString() => 'SystemConfigTemplateStorageOptionDto[dayOptions=$dayOptions, hourOptions=$hourOptions, minuteOptions=$minuteOptions, monthOptions=$monthOptions, presetOptions=$presetOptions, secondOptions=$secondOptions, weekOptions=$weekOptions, yearOptions=$yearOptions]'; | ||||||
| 
 | 
 | ||||||
|   Map<String, dynamic> toJson() { |   Map<String, dynamic> toJson() { | ||||||
|     final json = <String, dynamic>{}; |     final json = <String, dynamic>{}; | ||||||
| @@ -68,6 +73,7 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|       json[r'monthOptions'] = this.monthOptions; |       json[r'monthOptions'] = this.monthOptions; | ||||||
|       json[r'presetOptions'] = this.presetOptions; |       json[r'presetOptions'] = this.presetOptions; | ||||||
|       json[r'secondOptions'] = this.secondOptions; |       json[r'secondOptions'] = this.secondOptions; | ||||||
|  |       json[r'weekOptions'] = this.weekOptions; | ||||||
|       json[r'yearOptions'] = this.yearOptions; |       json[r'yearOptions'] = this.yearOptions; | ||||||
|     return json; |     return json; | ||||||
|   } |   } | ||||||
| @@ -98,6 +104,9 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|         secondOptions: json[r'secondOptions'] is List |         secondOptions: json[r'secondOptions'] is List | ||||||
|             ? (json[r'secondOptions'] as List).cast<String>() |             ? (json[r'secondOptions'] as List).cast<String>() | ||||||
|             : const [], |             : const [], | ||||||
|  |         weekOptions: json[r'weekOptions'] is List | ||||||
|  |             ? (json[r'weekOptions'] as List).cast<String>() | ||||||
|  |             : const [], | ||||||
|         yearOptions: json[r'yearOptions'] is List |         yearOptions: json[r'yearOptions'] is List | ||||||
|             ? (json[r'yearOptions'] as List).cast<String>() |             ? (json[r'yearOptions'] as List).cast<String>() | ||||||
|             : const [], |             : const [], | ||||||
| @@ -154,6 +163,7 @@ class SystemConfigTemplateStorageOptionDto { | |||||||
|     'monthOptions', |     'monthOptions', | ||||||
|     'presetOptions', |     'presetOptions', | ||||||
|     'secondOptions', |     'secondOptions', | ||||||
|  |     'weekOptions', | ||||||
|     'yearOptions', |     'yearOptions', | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -46,6 +46,11 @@ void main() { | |||||||
|       // TODO |       // TODO | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |     // List<String> weekOptions (default value: const []) | ||||||
|  |     test('to test the property `weekOptions`', () async { | ||||||
|  |       // TODO | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     // List<String> yearOptions (default value: const []) |     // List<String> yearOptions (default value: const []) | ||||||
|     test('to test the property `yearOptions`', () async { |     test('to test the property `yearOptions`', () async { | ||||||
|       // TODO |       // TODO | ||||||
|   | |||||||
| @@ -7924,6 +7924,12 @@ | |||||||
|             }, |             }, | ||||||
|             "type": "array" |             "type": "array" | ||||||
|           }, |           }, | ||||||
|  |           "weekOptions": { | ||||||
|  |             "items": { | ||||||
|  |               "type": "string" | ||||||
|  |             }, | ||||||
|  |             "type": "array" | ||||||
|  |           }, | ||||||
|           "yearOptions": { |           "yearOptions": { | ||||||
|             "items": { |             "items": { | ||||||
|               "type": "string" |               "type": "string" | ||||||
| @@ -7934,6 +7940,7 @@ | |||||||
|         "required": [ |         "required": [ | ||||||
|           "yearOptions", |           "yearOptions", | ||||||
|           "monthOptions", |           "monthOptions", | ||||||
|  |           "weekOptions", | ||||||
|           "dayOptions", |           "dayOptions", | ||||||
|           "hourOptions", |           "hourOptions", | ||||||
|           "minuteOptions", |           "minuteOptions", | ||||||
|   | |||||||
| @@ -16,6 +16,7 @@ import { | |||||||
|   supportedMinuteTokens, |   supportedMinuteTokens, | ||||||
|   supportedMonthTokens, |   supportedMonthTokens, | ||||||
|   supportedSecondTokens, |   supportedSecondTokens, | ||||||
|  |   supportedWeekTokens, | ||||||
|   supportedYearTokens, |   supportedYearTokens, | ||||||
| } from '../system-config'; | } from '../system-config'; | ||||||
| import { SystemConfigCore } from '../system-config/system-config.core'; | import { SystemConfigCore } from '../system-config/system-config.core'; | ||||||
| @@ -239,6 +240,7 @@ export class StorageTemplateService { | |||||||
|     const dateTokens = [ |     const dateTokens = [ | ||||||
|       ...supportedYearTokens, |       ...supportedYearTokens, | ||||||
|       ...supportedMonthTokens, |       ...supportedMonthTokens, | ||||||
|  |       ...supportedWeekTokens, | ||||||
|       ...supportedDayTokens, |       ...supportedDayTokens, | ||||||
|       ...supportedHourTokens, |       ...supportedHourTokens, | ||||||
|       ...supportedMinuteTokens, |       ...supportedMinuteTokens, | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| export class SystemConfigTemplateStorageOptionDto { | export class SystemConfigTemplateStorageOptionDto { | ||||||
|   yearOptions!: string[]; |   yearOptions!: string[]; | ||||||
|   monthOptions!: string[]; |   monthOptions!: string[]; | ||||||
|  |   weekOptions!: string[]; | ||||||
|   dayOptions!: string[]; |   dayOptions!: string[]; | ||||||
|   hourOptions!: string[]; |   hourOptions!: string[]; | ||||||
|   minuteOptions!: string[]; |   minuteOptions!: string[]; | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| export const supportedYearTokens = ['y', 'yy']; | export const supportedYearTokens = ['y', 'yy']; | ||||||
| export const supportedMonthTokens = ['M', 'MM', 'MMM', 'MMMM']; | export const supportedMonthTokens = ['M', 'MM', 'MMM', 'MMMM']; | ||||||
|  | export const supportedWeekTokens = ['W', 'WW']; | ||||||
| export const supportedDayTokens = ['d', 'dd']; | export const supportedDayTokens = ['d', 'dd']; | ||||||
| export const supportedHourTokens = ['h', 'hh', 'H', 'HH']; | export const supportedHourTokens = ['h', 'hh', 'H', 'HH']; | ||||||
| export const supportedMinuteTokens = ['m', 'mm']; | export const supportedMinuteTokens = ['m', 'mm']; | ||||||
| @@ -18,6 +19,7 @@ export const supportedPresetTokens = [ | |||||||
|   '{{y}}-{{MMM}}-{{dd}}/{{filename}}', |   '{{y}}-{{MMM}}-{{dd}}/{{filename}}', | ||||||
|   '{{y}}-{{MMMM}}-{{dd}}/{{filename}}', |   '{{y}}-{{MMMM}}-{{dd}}/{{filename}}', | ||||||
|   '{{y}}/{{y}}-{{MM}}/{{filename}}', |   '{{y}}/{{y}}-{{MM}}/{{filename}}', | ||||||
|  |   '{{y}}/{{y}}-{{WW}}/{{filename}}', | ||||||
| ]; | ]; | ||||||
|  |  | ||||||
| export const INITIAL_SYSTEM_CONFIG = 'INITIAL_SYSTEM_CONFIG'; | export const INITIAL_SYSTEM_CONFIG = 'INITIAL_SYSTEM_CONFIG'; | ||||||
|   | |||||||
| @@ -221,8 +221,10 @@ describe(SystemConfigService.name, () => { | |||||||
|           '{{y}}-{{MMM}}-{{dd}}/{{filename}}', |           '{{y}}-{{MMM}}-{{dd}}/{{filename}}', | ||||||
|           '{{y}}-{{MMMM}}-{{dd}}/{{filename}}', |           '{{y}}-{{MMMM}}-{{dd}}/{{filename}}', | ||||||
|           '{{y}}/{{y}}-{{MM}}/{{filename}}', |           '{{y}}/{{y}}-{{MM}}/{{filename}}', | ||||||
|  |           '{{y}}/{{y}}-{{WW}}/{{filename}}', | ||||||
|         ], |         ], | ||||||
|         secondOptions: ['s', 'ss'], |         secondOptions: ['s', 'ss'], | ||||||
|  |         weekOptions: ['W', 'WW'], | ||||||
|         yearOptions: ['y', 'yy'], |         yearOptions: ['y', 'yy'], | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ import { | |||||||
|   supportedMonthTokens, |   supportedMonthTokens, | ||||||
|   supportedPresetTokens, |   supportedPresetTokens, | ||||||
|   supportedSecondTokens, |   supportedSecondTokens, | ||||||
|  |   supportedWeekTokens, | ||||||
|   supportedYearTokens, |   supportedYearTokens, | ||||||
| } from './system-config.constants'; | } from './system-config.constants'; | ||||||
| import { SystemConfigCore, SystemConfigValidator } from './system-config.core'; | import { SystemConfigCore, SystemConfigValidator } from './system-config.core'; | ||||||
| @@ -57,6 +58,7 @@ export class SystemConfigService { | |||||||
|     const options = new SystemConfigTemplateStorageOptionDto(); |     const options = new SystemConfigTemplateStorageOptionDto(); | ||||||
|  |  | ||||||
|     options.dayOptions = supportedDayTokens; |     options.dayOptions = supportedDayTokens; | ||||||
|  |     options.weekOptions = supportedWeekTokens; | ||||||
|     options.monthOptions = supportedMonthTokens; |     options.monthOptions = supportedMonthTokens; | ||||||
|     options.yearOptions = supportedYearTokens; |     options.yearOptions = supportedYearTokens; | ||||||
|     options.hourOptions = supportedHourTokens; |     options.hourOptions = supportedHourTokens; | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								web/src/api/open-api/api.ts
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								web/src/api/open-api/api.ts
									
									
									
										generated
									
									
									
								
							| @@ -3542,6 +3542,12 @@ export interface SystemConfigTemplateStorageOptionDto { | |||||||
|      * @memberof SystemConfigTemplateStorageOptionDto |      * @memberof SystemConfigTemplateStorageOptionDto | ||||||
|      */ |      */ | ||||||
|     'secondOptions': Array<string>; |     'secondOptions': Array<string>; | ||||||
|  |     /** | ||||||
|  |      *  | ||||||
|  |      * @type {Array<string>} | ||||||
|  |      * @memberof SystemConfigTemplateStorageOptionDto | ||||||
|  |      */ | ||||||
|  |     'weekOptions': Array<string>; | ||||||
|     /** |     /** | ||||||
|      *  |      *  | ||||||
|      * @type {Array<string>} |      * @type {Array<string>} | ||||||
|   | |||||||
| @@ -58,11 +58,12 @@ | |||||||
|       filetypefull: 'IMAGE', |       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 = [ |     const dateTokens = [ | ||||||
|       ...templateOptions.yearOptions, |       ...templateOptions.yearOptions, | ||||||
|       ...templateOptions.monthOptions, |       ...templateOptions.monthOptions, | ||||||
|  |       ...templateOptions.weekOptions, | ||||||
|       ...templateOptions.dayOptions, |       ...templateOptions.dayOptions, | ||||||
|       ...templateOptions.hourOptions, |       ...templateOptions.hourOptions, | ||||||
|       ...templateOptions.minuteOptions, |       ...templateOptions.minuteOptions, | ||||||
|   | |||||||
| @@ -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="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"> |   <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>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> | ||||||
|   <div class="flex gap-[50px]"> |   <div class="flex gap-[40px]"> | ||||||
|     <div> |     <div> | ||||||
|       <p class="font-medium text-immich-primary dark:text-immich-dark-primary">YEAR</p> |       <p class="font-medium text-immich-primary dark:text-immich-dark-primary">YEAR</p> | ||||||
|       <ul> |       <ul> | ||||||
| @@ -37,6 +37,15 @@ | |||||||
|       </ul> |       </ul> | ||||||
|     </div> |     </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> |     <div> | ||||||
|       <p class="font-medium text-immich-primary dark:text-immich-dark-primary">DAY</p> |       <p class="font-medium text-immich-primary dark:text-immich-dark-primary">DAY</p> | ||||||
|       <ul> |       <ul> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user