mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 00:15:48 +01:00
✨ Add new types for integration configuration
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { ConfigType } from '../../types/config';
|
||||
import { BackendConfigType, ConfigType } from '../../types/config';
|
||||
import { configExists } from './configExists';
|
||||
import { getFallbackConfig } from './getFallbackConfig';
|
||||
import { readConfig } from './readConfig';
|
||||
|
||||
export const getConfig = (name: string): ConfigType => {
|
||||
export const getConfig = (name: string): BackendConfigType => {
|
||||
if (!configExists(name)) return getFallbackConfig();
|
||||
return readConfig(name);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ConfigType } from '../../types/config';
|
||||
import { BackendConfigType } from '../../types/config';
|
||||
|
||||
export const getFallbackConfig = (name?: string): ConfigType => ({
|
||||
export const getFallbackConfig = (name?: string): BackendConfigType => ({
|
||||
schemaVersion: '1.0.0',
|
||||
configProperties: {
|
||||
name: name ?? 'default',
|
||||
@@ -12,7 +12,12 @@ export const getFallbackConfig = (name?: string): ConfigType => ({
|
||||
common: {
|
||||
searchEngine: {
|
||||
type: 'google',
|
||||
properties: {
|
||||
enabled: true,
|
||||
openInNewTab: true,
|
||||
},
|
||||
},
|
||||
defaultConfig: 'default',
|
||||
},
|
||||
customization: {
|
||||
colors: {},
|
||||
|
||||
23
src/tools/config/getFrontendConfig.ts
Normal file
23
src/tools/config/getFrontendConfig.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ConfigType } from '../../types/config';
|
||||
import { getConfig } from './getConfig';
|
||||
|
||||
export const getFrontendConfig = (name: string): ConfigType => {
|
||||
const config = getConfig(name);
|
||||
|
||||
return {
|
||||
...config,
|
||||
services: config.services.map((s) => ({
|
||||
...s,
|
||||
integration: s.integration
|
||||
? {
|
||||
...s.integration,
|
||||
properties: s.integration?.properties.map((p) => ({
|
||||
...p,
|
||||
value: p.type === 'private' ? null : p.value,
|
||||
isDefined: p.value != null,
|
||||
})),
|
||||
}
|
||||
: null,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user