mirror of
https://github.com/immich-app/immich.git
synced 2025-11-13 16:22:36 +09:00
feat(server,web): system config for admin (#959)
* feat: add admin config module for user configured config, uses it for ffmpeg * feat: add api endpoint to retrieve admin config settings and values * feat: add settings panel to admin page on web (wip) * feat: add api endpoint to update the admin config * chore: re-generate openapi spec after rebase * refactor: move from admin config to system config naming * chore: move away from UseGuards to new @Authenticated decorator * style: dark mode styling for lists and fix conflicting colors * wip: 2 column design, no edit button * refactor: system config * chore: generate open api * chore: rm broken test * chore: cleanup types * refactor: config module names Co-authored-by: Zack Pollard <zackpollard@ymail.com> Co-authored-by: Zack Pollard <zack.pollard@moonpig.com>
This commit is contained in:
@@ -1407,6 +1407,67 @@ export interface SmartInfoResponseDto {
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
export const SystemConfigKey = {
|
||||
Crf: 'ffmpeg_crf',
|
||||
Preset: 'ffmpeg_preset',
|
||||
TargetVideoCodec: 'ffmpeg_target_video_codec',
|
||||
TargetAudioCodec: 'ffmpeg_target_audio_codec',
|
||||
TargetScaling: 'ffmpeg_target_scaling'
|
||||
} as const;
|
||||
|
||||
export type SystemConfigKey = typeof SystemConfigKey[keyof typeof SystemConfigKey];
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface SystemConfigResponseDto
|
||||
*/
|
||||
export interface SystemConfigResponseDto {
|
||||
/**
|
||||
*
|
||||
* @type {Array<SystemConfigResponseItem>}
|
||||
* @memberof SystemConfigResponseDto
|
||||
*/
|
||||
'config': Array<SystemConfigResponseItem>;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface SystemConfigResponseItem
|
||||
*/
|
||||
export interface SystemConfigResponseItem {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SystemConfigResponseItem
|
||||
*/
|
||||
'name': string;
|
||||
/**
|
||||
*
|
||||
* @type {SystemConfigKey}
|
||||
* @memberof SystemConfigResponseItem
|
||||
*/
|
||||
'key': SystemConfigKey;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SystemConfigResponseItem
|
||||
*/
|
||||
'value': string;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof SystemConfigResponseItem
|
||||
*/
|
||||
'defaultValue': string;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
export const ThumbnailFormat = {
|
||||
Jpeg: 'JPEG',
|
||||
Webp: 'WEBP'
|
||||
@@ -4946,6 +5007,173 @@ export class ServerInfoApi extends BaseAPI {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SystemConfigApi - axios parameter creator
|
||||
* @export
|
||||
*/
|
||||
export const SystemConfigApiAxiosParamCreator = function (configuration?: Configuration) {
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getConfig: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/system-config`;
|
||||
// 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;
|
||||
|
||||
// authentication bearer required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateConfig: async (body: object, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'body' is not null or undefined
|
||||
assertParamExists('updateConfig', 'body', body)
|
||||
const localVarPath = `/system-config`;
|
||||
// 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: 'PUT', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication bearer required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* SystemConfigApi - functional programming interface
|
||||
* @export
|
||||
*/
|
||||
export const SystemConfigApiFp = function(configuration?: Configuration) {
|
||||
const localVarAxiosParamCreator = SystemConfigApiAxiosParamCreator(configuration)
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async getConfig(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SystemConfigResponseDto>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getConfig(options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async updateConfig(body: object, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SystemConfigResponseDto>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.updateConfig(body, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* SystemConfigApi - factory interface
|
||||
* @export
|
||||
*/
|
||||
export const SystemConfigApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
||||
const localVarFp = SystemConfigApiFp(configuration)
|
||||
return {
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getConfig(options?: any): AxiosPromise<SystemConfigResponseDto> {
|
||||
return localVarFp.getConfig(options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
updateConfig(body: object, options?: any): AxiosPromise<SystemConfigResponseDto> {
|
||||
return localVarFp.updateConfig(body, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* SystemConfigApi - object-oriented interface
|
||||
* @export
|
||||
* @class SystemConfigApi
|
||||
* @extends {BaseAPI}
|
||||
*/
|
||||
export class SystemConfigApi extends BaseAPI {
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof SystemConfigApi
|
||||
*/
|
||||
public getConfig(options?: AxiosRequestConfig) {
|
||||
return SystemConfigApiFp(this.configuration).getConfig(options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {object} body
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof SystemConfigApi
|
||||
*/
|
||||
public updateConfig(body: object, options?: AxiosRequestConfig) {
|
||||
return SystemConfigApiFp(this.configuration).updateConfig(body, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UserApi - axios parameter creator
|
||||
* @export
|
||||
|
||||
Reference in New Issue
Block a user