diff --git a/cli/src/api/open-api/api.ts b/cli/src/api/open-api/api.ts index 0d63ba318..caab7f4b8 100644 --- a/cli/src/api/open-api/api.ts +++ b/cli/src/api/open-api/api.ts @@ -2958,6 +2958,19 @@ export interface ServerStatsResponseDto { */ 'videos': number; } +/** + * + * @export + * @interface ServerThemeDto + */ +export interface ServerThemeDto { + /** + * + * @type {SystemConfigThemeDto} + * @memberof ServerThemeDto + */ + 'theme': SystemConfigThemeDto; +} /** * * @export @@ -13193,6 +13206,35 @@ export const ServerInfoApiAxiosParamCreator = function (configuration?: Configur + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getTheme: async (options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/server-info/theme`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -13295,6 +13337,15 @@ export const ServerInfoApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.getSupportedMediaTypes(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getTheme(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getTheme(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {*} [options] Override http request option. @@ -13362,6 +13413,14 @@ export const ServerInfoApiFactory = function (configuration?: Configuration, bas getSupportedMediaTypes(options?: AxiosRequestConfig): AxiosPromise { return localVarFp.getSupportedMediaTypes(options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getTheme(options?: AxiosRequestConfig): AxiosPromise { + return localVarFp.getTheme(options).then((request) => request(axios, basePath)); + }, /** * * @param {*} [options] Override http request option. @@ -13440,6 +13499,16 @@ export class ServerInfoApi extends BaseAPI { return ServerInfoApiFp(this.configuration).getSupportedMediaTypes(options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ServerInfoApi + */ + public getTheme(options?: AxiosRequestConfig) { + return ServerInfoApiFp(this.configuration).getTheme(options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {*} [options] Override http request option. diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILES index cb9b0ad50..cbad0876c 100644 --- a/mobile/openapi/.openapi-generator/FILES +++ b/mobile/openapi/.openapi-generator/FILES @@ -115,6 +115,7 @@ doc/ServerInfoResponseDto.md doc/ServerMediaTypesResponseDto.md doc/ServerPingResponse.md doc/ServerStatsResponseDto.md +doc/ServerThemeDto.md doc/ServerVersionResponseDto.md doc/SharedLinkApi.md doc/SharedLinkCreateDto.md @@ -285,6 +286,7 @@ lib/model/server_info_response_dto.dart lib/model/server_media_types_response_dto.dart lib/model/server_ping_response.dart lib/model/server_stats_response_dto.dart +lib/model/server_theme_dto.dart lib/model/server_version_response_dto.dart lib/model/shared_link_create_dto.dart lib/model/shared_link_edit_dto.dart @@ -438,6 +440,7 @@ test/server_info_response_dto_test.dart test/server_media_types_response_dto_test.dart test/server_ping_response_test.dart test/server_stats_response_dto_test.dart +test/server_theme_dto_test.dart test/server_version_response_dto_test.dart test/shared_link_api_test.dart test/shared_link_create_dto_test.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index b4760ae80..e676dbd88 100644 Binary files a/mobile/openapi/README.md and b/mobile/openapi/README.md differ diff --git a/mobile/openapi/doc/ServerInfoApi.md b/mobile/openapi/doc/ServerInfoApi.md index c196bf108..64a373cc0 100644 Binary files a/mobile/openapi/doc/ServerInfoApi.md and b/mobile/openapi/doc/ServerInfoApi.md differ diff --git a/mobile/openapi/doc/ServerThemeDto.md b/mobile/openapi/doc/ServerThemeDto.md new file mode 100644 index 000000000..d79f55cf3 Binary files /dev/null and b/mobile/openapi/doc/ServerThemeDto.md differ diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index de69b2894..22c4a23e6 100644 Binary files a/mobile/openapi/lib/api.dart and b/mobile/openapi/lib/api.dart differ diff --git a/mobile/openapi/lib/api/server_info_api.dart b/mobile/openapi/lib/api/server_info_api.dart index 51bcbfa4b..b8ea50ba8 100644 Binary files a/mobile/openapi/lib/api/server_info_api.dart and b/mobile/openapi/lib/api/server_info_api.dart differ diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index 51be9d011..2bd9411af 100644 Binary files a/mobile/openapi/lib/api_client.dart and b/mobile/openapi/lib/api_client.dart differ diff --git a/mobile/openapi/lib/model/server_theme_dto.dart b/mobile/openapi/lib/model/server_theme_dto.dart new file mode 100644 index 000000000..e803c5880 Binary files /dev/null and b/mobile/openapi/lib/model/server_theme_dto.dart differ diff --git a/mobile/openapi/test/server_info_api_test.dart b/mobile/openapi/test/server_info_api_test.dart index 17e5e2c5e..f431f521b 100644 Binary files a/mobile/openapi/test/server_info_api_test.dart and b/mobile/openapi/test/server_info_api_test.dart differ diff --git a/mobile/openapi/test/server_theme_dto_test.dart b/mobile/openapi/test/server_theme_dto_test.dart new file mode 100644 index 000000000..c1f63ea49 Binary files /dev/null and b/mobile/openapi/test/server_theme_dto_test.dart differ diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index 7ae327558..f9164a265 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -4126,6 +4126,27 @@ ] } }, + "/server-info/theme": { + "get": { + "operationId": "getTheme", + "parameters": [], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ServerThemeDto" + } + } + }, + "description": "" + } + }, + "tags": [ + "Server Info" + ] + } + }, "/server-info/version": { "get": { "operationId": "getServerVersion", @@ -7812,6 +7833,17 @@ ], "type": "object" }, + "ServerThemeDto": { + "properties": { + "theme": { + "$ref": "#/components/schemas/SystemConfigThemeDto" + } + }, + "required": [ + "theme" + ], + "type": "object" + }, "ServerVersionResponseDto": { "properties": { "major": { diff --git a/server/src/domain/server-info/server-info.dto.ts b/server/src/domain/server-info/server-info.dto.ts index 2b9ac95cc..40a5f3a47 100644 --- a/server/src/domain/server-info/server-info.dto.ts +++ b/server/src/domain/server-info/server-info.dto.ts @@ -1,5 +1,6 @@ import { FeatureFlags, IServerVersion } from '@app/domain'; import { ApiProperty, ApiResponseProperty } from '@nestjs/swagger'; +import { SystemConfigThemeDto } from '../system-config/dto/system-config-theme.dto'; export class ServerPingResponse { @ApiResponseProperty({ type: String, example: 'pong' }) @@ -79,6 +80,10 @@ export class ServerMediaTypesResponseDto { sidecar!: string[]; } +export class ServerThemeDto { + theme!: SystemConfigThemeDto; +} + export class ServerConfigDto { oauthButtonText!: string; loginPageMessage!: string; diff --git a/server/src/domain/server-info/server-info.service.ts b/server/src/domain/server-info/server-info.service.ts index e386fa17c..bb1b22729 100644 --- a/server/src/domain/server-info/server-info.service.ts +++ b/server/src/domain/server-info/server-info.service.ts @@ -70,6 +70,11 @@ export class ServerInfoService { return this.configCore.getFeatures(); } + async getTheme() { + const { theme } = await this.configCore.getConfig(); + return { theme }; + } + async getConfig(): Promise { const config = await this.configCore.getConfig(); diff --git a/server/src/domain/system-config/system-config.service.spec.ts b/server/src/domain/system-config/system-config.service.spec.ts index 1dcbd013d..f687e4506 100644 --- a/server/src/domain/system-config/system-config.service.spec.ts +++ b/server/src/domain/system-config/system-config.service.spec.ts @@ -298,4 +298,10 @@ describe(SystemConfigService.name, () => { subscription.unsubscribe(); }); }); + + describe('getTheme', () => { + it('should return the default theme', async () => { + await expect(sut.getTheme()).resolves.toEqual(defaults.theme); + }); + }); }); diff --git a/server/src/domain/system-config/system-config.service.ts b/server/src/domain/system-config/system-config.service.ts index 610a1dc29..a44f10c09 100644 --- a/server/src/domain/system-config/system-config.service.ts +++ b/server/src/domain/system-config/system-config.service.ts @@ -1,6 +1,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { JobName } from '../job'; import { CommunicationEvent, ICommunicationRepository, IJobRepository, ISystemConfigRepository } from '../repositories'; +import { SystemConfigThemeDto } from './dto/system-config-theme.dto'; import { SystemConfigDto, mapConfig } from './dto/system-config.dto'; import { SystemConfigTemplateStorageOptionDto } from './response-dto/system-config-template-storage-option.dto'; import { @@ -30,6 +31,11 @@ export class SystemConfigService { return this.core.config$; } + async getTheme(): Promise { + const { theme } = await this.core.getConfig(); + return theme; + } + async getConfig(): Promise { const config = await this.core.getConfig(); return mapConfig(config); diff --git a/server/src/immich/controllers/server-info.controller.ts b/server/src/immich/controllers/server-info.controller.ts index b286329ab..7355583ac 100644 --- a/server/src/immich/controllers/server-info.controller.ts +++ b/server/src/immich/controllers/server-info.controller.ts @@ -6,6 +6,7 @@ import { ServerMediaTypesResponseDto, ServerPingResponse, ServerStatsResponseDto, + ServerThemeDto, ServerVersionResponseDto, } from '@app/domain'; import { Controller, Get } from '@nestjs/common'; @@ -43,6 +44,12 @@ export class ServerInfoController { return this.service.getFeatures(); } + @PublicRoute() + @Get('theme') + getTheme(): Promise { + return this.service.getTheme(); + } + @PublicRoute() @Get('config') getServerConfig(): Promise { diff --git a/server/test/e2e/server-info.e2e-spec.ts b/server/test/e2e/server-info.e2e-spec.ts index cd6afbc07..8f776187f 100644 --- a/server/test/e2e/server-info.e2e-spec.ts +++ b/server/test/e2e/server-info.e2e-spec.ts @@ -155,4 +155,16 @@ describe(`${ServerInfoController.name} (e2e)`, () => { }); }); }); + + describe('GET /server-info/theme', () => { + it('should respond with the server theme', async () => { + const { status, body } = await request(server).get('/server-info/theme'); + expect(status).toBe(200); + expect(body).toEqual({ + theme: { + customCss: '', + }, + }); + }); + }); }); diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 0d63ba318..caab7f4b8 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -2958,6 +2958,19 @@ export interface ServerStatsResponseDto { */ 'videos': number; } +/** + * + * @export + * @interface ServerThemeDto + */ +export interface ServerThemeDto { + /** + * + * @type {SystemConfigThemeDto} + * @memberof ServerThemeDto + */ + 'theme': SystemConfigThemeDto; +} /** * * @export @@ -13193,6 +13206,35 @@ export const ServerInfoApiAxiosParamCreator = function (configuration?: Configur + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getTheme: async (options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/server-info/theme`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -13295,6 +13337,15 @@ export const ServerInfoApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.getSupportedMediaTypes(options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getTheme(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getTheme(options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @param {*} [options] Override http request option. @@ -13362,6 +13413,14 @@ export const ServerInfoApiFactory = function (configuration?: Configuration, bas getSupportedMediaTypes(options?: AxiosRequestConfig): AxiosPromise { return localVarFp.getSupportedMediaTypes(options).then((request) => request(axios, basePath)); }, + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getTheme(options?: AxiosRequestConfig): AxiosPromise { + return localVarFp.getTheme(options).then((request) => request(axios, basePath)); + }, /** * * @param {*} [options] Override http request option. @@ -13440,6 +13499,16 @@ export class ServerInfoApi extends BaseAPI { return ServerInfoApiFp(this.configuration).getSupportedMediaTypes(options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ServerInfoApi + */ + public getTheme(options?: AxiosRequestConfig) { + return ServerInfoApiFp(this.configuration).getTheme(options).then((request) => request(this.axios, this.basePath)); + } + /** * * @param {*} [options] Override http request option. diff --git a/web/src/routes/custom.css/+server.ts b/web/src/routes/custom.css/+server.ts index acf8e6d10..d5ea304cd 100644 --- a/web/src/routes/custom.css/+server.ts +++ b/web/src/routes/custom.css/+server.ts @@ -1,6 +1,10 @@ import { RequestHandler, text } from '@sveltejs/kit'; export const GET = (async ({ locals: { api } }) => { - const { customCss } = await api.systemConfigApi.getConfig().then((res) => res.data.theme); + const { + data: { + theme: { customCss }, + }, + } = await api.serverInfoApi.getTheme(); return text(customCss, { headers: { 'Content-Type': 'text/css',