0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-04-15 03:11:28 -05:00

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

* web: standardize theme api response

* revert makefile change that i didn't mean to commit
This commit is contained in:
Wingy 2023-10-26 19:32:33 -07:00 committed by GitHub
parent 7ff68223ab
commit a08a687951
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 22 additions and 28 deletions

View file

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

View file

@ -8,7 +8,7 @@ import 'package:openapi/api.dart';
## Properties
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)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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