浏览代码

refactor(server, web): standardize theme api response (#4664)

* web: standardize theme api response

* revert makefile change that i didn't mean to commit
Wingy 1 年之前
父节点
当前提交
a08a687951

+ 2 - 2
cli/src/api/open-api/api.ts

@@ -2966,10 +2966,10 @@ export interface ServerStatsResponseDto {
 export interface ServerThemeDto {
 export interface ServerThemeDto {
     /**
     /**
      * 
      * 
-     * @type {SystemConfigThemeDto}
+     * @type {string}
      * @memberof ServerThemeDto
      * @memberof ServerThemeDto
      */
      */
-    'theme': SystemConfigThemeDto;
+    'customCss': string;
 }
 }
 /**
 /**
  * 
  * 

+ 1 - 1
mobile/openapi/doc/ServerThemeDto.md

@@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
 ## Properties
 ## Properties
 Name | Type | Description | Notes
 Name | Type | Description | Notes
 ------------ | ------------- | ------------- | -------------
 ------------ | ------------- | ------------- | -------------
-**theme** | [**SystemConfigThemeDto**](SystemConfigThemeDto.md) |  | 
+**customCss** | **String** |  | 
 
 
 [[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)
 
 

+ 8 - 8
mobile/openapi/lib/model/server_theme_dto.dart

@@ -13,26 +13,26 @@ part of openapi.api;
 class ServerThemeDto {
 class ServerThemeDto {
   /// Returns a new [ServerThemeDto] instance.
   /// Returns a new [ServerThemeDto] instance.
   ServerThemeDto({
   ServerThemeDto({
-    required this.theme,
+    required this.customCss,
   });
   });
 
 
-  SystemConfigThemeDto theme;
+  String customCss;
 
 
   @override
   @override
   bool operator ==(Object other) => identical(this, other) || other is ServerThemeDto &&
   bool operator ==(Object other) => identical(this, other) || other is ServerThemeDto &&
-     other.theme == theme;
+     other.customCss == customCss;
 
 
   @override
   @override
   int get hashCode =>
   int get hashCode =>
     // ignore: unnecessary_parenthesis
     // ignore: unnecessary_parenthesis
-    (theme.hashCode);
+    (customCss.hashCode);
 
 
   @override
   @override
-  String toString() => 'ServerThemeDto[theme=$theme]';
+  String toString() => 'ServerThemeDto[customCss=$customCss]';
 
 
   Map<String, dynamic> toJson() {
   Map<String, dynamic> toJson() {
     final json = <String, dynamic>{};
     final json = <String, dynamic>{};
-      json[r'theme'] = this.theme;
+      json[r'customCss'] = this.customCss;
     return json;
     return json;
   }
   }
 
 
@@ -44,7 +44,7 @@ class ServerThemeDto {
       final json = value.cast<String, dynamic>();
       final json = value.cast<String, dynamic>();
 
 
       return ServerThemeDto(
       return ServerThemeDto(
-        theme: SystemConfigThemeDto.fromJson(json[r'theme'])!,
+        customCss: mapValueOfType<String>(json, r'customCss')!,
       );
       );
     }
     }
     return null;
     return null;
@@ -92,7 +92,7 @@ class ServerThemeDto {
 
 
   /// The list of required keys that must be present in a JSON.
   /// The list of required keys that must be present in a JSON.
   static const requiredKeys = <String>{
   static const requiredKeys = <String>{
-    'theme',
+    'customCss',
   };
   };
 }
 }
 
 

+ 2 - 2
mobile/openapi/test/server_theme_dto_test.dart

@@ -16,8 +16,8 @@ void main() {
   // final instance = ServerThemeDto();
   // final instance = ServerThemeDto();
 
 
   group('test ServerThemeDto', () {
   group('test ServerThemeDto', () {
-    // SystemConfigThemeDto theme
-    test('to test the property `theme`', () async {
+    // String customCss
+    test('to test the property `customCss`', () async {
       // TODO
       // TODO
     });
     });
 
 

+ 3 - 3
server/immich-openapi-specs.json

@@ -7836,12 +7836,12 @@
       },
       },
       "ServerThemeDto": {
       "ServerThemeDto": {
         "properties": {
         "properties": {
-          "theme": {
-            "$ref": "#/components/schemas/SystemConfigThemeDto"
+          "customCss": {
+            "type": "string"
           }
           }
         },
         },
         "required": [
         "required": [
-          "theme"
+          "customCss"
         ],
         ],
         "type": "object"
         "type": "object"
       },
       },

+ 1 - 3
server/src/domain/server-info/server-info.dto.ts

@@ -80,9 +80,7 @@ export class ServerMediaTypesResponseDto {
   sidecar!: string[];
   sidecar!: string[];
 }
 }
 
 
-export class ServerThemeDto {
-  theme!: SystemConfigThemeDto;
-}
+export class ServerThemeDto extends SystemConfigThemeDto {}
 
 
 export class ServerConfigDto {
 export class ServerConfigDto {
   oauthButtonText!: string;
   oauthButtonText!: string;

+ 1 - 1
server/src/domain/server-info/server-info.service.ts

@@ -72,7 +72,7 @@ export class ServerInfoService {
 
 
   async getTheme() {
   async getTheme() {
     const { theme } = await this.configCore.getConfig();
     const { theme } = await this.configCore.getConfig();
-    return { theme };
+    return theme;
   }
   }
 
 
   async getConfig(): Promise<ServerConfigDto> {
   async getConfig(): Promise<ServerConfigDto> {

+ 1 - 3
server/test/e2e/server-info.e2e-spec.ts

@@ -161,9 +161,7 @@ describe(`${ServerInfoController.name} (e2e)`, () => {
       const { status, body } = await request(server).get('/server-info/theme');
       const { status, body } = await request(server).get('/server-info/theme');
       expect(status).toBe(200);
       expect(status).toBe(200);
       expect(body).toEqual({
       expect(body).toEqual({
-        theme: {
-          customCss: '',
-        },
+        customCss: '',
       });
       });
     });
     });
   });
   });

+ 2 - 2
web/src/api/open-api/api.ts

@@ -2966,10 +2966,10 @@ export interface ServerStatsResponseDto {
 export interface ServerThemeDto {
 export interface ServerThemeDto {
     /**
     /**
      * 
      * 
-     * @type {SystemConfigThemeDto}
+     * @type {string}
      * @memberof ServerThemeDto
      * @memberof ServerThemeDto
      */
      */
-    'theme': SystemConfigThemeDto;
+    'customCss': string;
 }
 }
 /**
 /**
  * 
  * 

+ 1 - 3
web/src/routes/custom.css/+server.ts

@@ -1,9 +1,7 @@
 import { RequestHandler, text } from '@sveltejs/kit';
 import { RequestHandler, text } from '@sveltejs/kit';
 export const GET = (async ({ locals: { api } }) => {
 export const GET = (async ({ locals: { api } }) => {
   const {
   const {
-    data: {
-      theme: { customCss },
-    },
+    data: { customCss },
   } = await api.serverInfoApi.getTheme();
   } = await api.serverInfoApi.getTheme();
   return text(customCss, {
   return text(customCss, {
     headers: {
     headers: {