Adds a more realistic config for development.
This commit is contained in:
@@ -22,11 +22,11 @@ a {
|
||||
}
|
||||
|
||||
.title {
|
||||
color: var(--text-title);
|
||||
color: var(--text-title) !important;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--text-subtitle);
|
||||
color: var(--text-subtitle) !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
||||
@@ -13,43 +13,47 @@ links:
|
||||
url: 'https://example.com'
|
||||
|
||||
services:
|
||||
- title: '/Media'
|
||||
icon: 'fas fa-photo-film'
|
||||
items:
|
||||
- title: 'Jellyfin'
|
||||
subtitle: 'Media server for movies and shows'
|
||||
target: '_blank'
|
||||
url: 'https://eagle.tuleu.me'
|
||||
type: jellyfin
|
||||
keywords: 'cloud storage files'
|
||||
|
||||
- title: 'Sonarr'
|
||||
subtitle: 'Shows tracker'
|
||||
target: '_blank'
|
||||
url: 'http://sonarr.lan'
|
||||
type: sonarr
|
||||
keywords: 'shows tracker torrent usenet'
|
||||
|
||||
- title: 'Radarr'
|
||||
subtitle: 'Movie tracker'
|
||||
target: '_blank'
|
||||
url: 'http://radarr.lan'
|
||||
type: sonarr
|
||||
keywords: 'movies tracker torrent usenet'
|
||||
|
||||
|
||||
- title: '/Cloud'
|
||||
subtitle: 'Private Cloud Utilities'
|
||||
icon: 'fas fa-cloud'
|
||||
items:
|
||||
- title: 'NAS'
|
||||
subtitle: 'Network Attached Storage'
|
||||
icon: 'fas fa-hard-drive'
|
||||
target: '_blank'
|
||||
url: '/NAS'
|
||||
type: prowlarr
|
||||
url: 'https://owl.tuleu.me'
|
||||
keywords: 'cloud nas files storage'
|
||||
|
||||
keywords: 'cloud storage files'
|
||||
|
||||
- title: 'PiHole'
|
||||
subtitle: 'A DNS Hole'
|
||||
logo: 'https://cdn.rawgit.com/pi-hole/graphics/master/Vortex/Vortex.svg'
|
||||
target: '_blank'
|
||||
url: '/pihole'
|
||||
type: 'pihole'
|
||||
keywords: 'cloud storage files'
|
||||
|
||||
- title: '/Cloud'
|
||||
subtitle: 'Private Cloud Utilities'
|
||||
icon: 'fas fa-cloud'
|
||||
- title: '/Infra'
|
||||
icon: 'fas fa-network-wired'
|
||||
items:
|
||||
- title: 'NAS'
|
||||
subtitle: 'Network Attached Storage'
|
||||
icon: 'fas fa-hard-drive'
|
||||
target: '_blank'
|
||||
url: '/NAS'
|
||||
|
||||
keywords: 'cloud storage files'
|
||||
|
||||
- title: 'PiHole'
|
||||
subtitle: 'A DNS Hole'
|
||||
icon: 'fas fa-hard-drive'
|
||||
subtitle: 'A DNS to send telemetry and ads to the void'
|
||||
target: '_blank'
|
||||
url: '/pihole'
|
||||
url: 'https://pihole.lan/admin'
|
||||
type: 'pihole'
|
||||
keywords: 'cloud storage files'
|
||||
keywords: 'dns ads blocker internet'
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
export let brand: BrandConfig = {};
|
||||
export let color = 'var(--text)';
|
||||
console.log(brand);
|
||||
|
||||
function masked() {
|
||||
return brand.logo != undefined && brand.asmask == true;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
export let data: any;
|
||||
|
||||
const component = getServiceComponent(service.type || '');
|
||||
|
||||
console.log(service);
|
||||
</script>
|
||||
|
||||
<div class="card">
|
||||
|
||||
@@ -17,6 +17,8 @@ export interface ServiceConfig extends SectionConfig {
|
||||
url: string;
|
||||
target?: string;
|
||||
type?: string;
|
||||
tag: string;
|
||||
keywords: string;
|
||||
|
||||
[x: string]: unknown;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { defaultConfig, stripPrivateFields, serverConfig, clientConfig, merge } from './config';
|
||||
import {
|
||||
defaultConfig,
|
||||
stripPrivateFields,
|
||||
serverConfig,
|
||||
clientConfig,
|
||||
mergeConfig
|
||||
} from './config';
|
||||
import type { Config } from '$lib/config';
|
||||
|
||||
describe('Config', () => {
|
||||
@@ -9,7 +15,7 @@ describe('Config', () => {
|
||||
});
|
||||
|
||||
it('should be able to merge with POJO', () => {
|
||||
const merged: Config = merge<Config>(defaultConfig, {
|
||||
const merged: Config = mergeConfig(defaultConfig, {
|
||||
subtitle: "Homer's favorite neighboor",
|
||||
colors: {
|
||||
light: { notInDefault: 'foo' }
|
||||
@@ -20,7 +26,8 @@ describe('Config', () => {
|
||||
items: [
|
||||
{
|
||||
title: 'anoy homer',
|
||||
customKey: 'all the time'
|
||||
customKey: 'all the time',
|
||||
keywords: 'a b cc'
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -39,6 +46,7 @@ describe('Config', () => {
|
||||
expect(merged.services[0].items).toHaveLength(1);
|
||||
expect(merged.services[0].items[0].title).toEqual('anoy homer');
|
||||
expect(merged.services[0].items[0].customKey).toEqual('all the time');
|
||||
expect(merged.services[0].items[0].keywords).toEqual('a b cc');
|
||||
});
|
||||
|
||||
it('should be able to strip custom keys', () => {
|
||||
|
||||
@@ -17,7 +17,9 @@ const requiredService: Required<ServiceConfig> = {
|
||||
asmask: false,
|
||||
url: '',
|
||||
target: '',
|
||||
type: ''
|
||||
type: '',
|
||||
tag: '',
|
||||
keywords: [],
|
||||
};
|
||||
|
||||
const requiredServiceGroup: Required<ServiceGroupConfig> = {
|
||||
@@ -55,7 +57,7 @@ export const requiredConfig: Required<Config> = {
|
||||
|
||||
type SPOJO = Record<string, unknown>;
|
||||
|
||||
export function merge<Type extends SPOJO>(a: Type, b: SPOJO): Type {
|
||||
function merge<Type extends SPOJO>(a: Type, b: SPOJO): Type {
|
||||
const res: Type = { ...a };
|
||||
for (const [key, value] of Object.entries(b)) {
|
||||
if (
|
||||
@@ -80,6 +82,11 @@ export function merge<Type extends SPOJO>(a: Type, b: SPOJO): Type {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
export function mergeConfig(a: Config, b: SPOJO): Config {
|
||||
return merge<Config>(a,b);
|
||||
}
|
||||
|
||||
const defaultLightConfig: ColorConfig = {};
|
||||
defaultLightConfig['highlight-primary'] = '#3367d6';
|
||||
defaultLightConfig['highlight-secondary'] = '#4285f4';
|
||||
@@ -118,11 +125,16 @@ export const defaultConfig: Config = {
|
||||
dark: defaultDarkConfig
|
||||
},
|
||||
|
||||
links: [],
|
||||
|
||||
services: []
|
||||
};
|
||||
|
||||
function strip<Type extends SPOJO>(toStrip: Type, reference: Type): Type {
|
||||
const res: Type = { ...toStrip };
|
||||
if ( reference == undefined ) {
|
||||
return res;
|
||||
}
|
||||
const referenceNames = Object.entries(reference).map(([key, value]) => key);
|
||||
|
||||
for (const [key, value] of Object.entries(res)) {
|
||||
@@ -145,6 +157,7 @@ function strip<Type extends SPOJO>(toStrip: Type, reference: Type): Type {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// it is a child object, we strip it further
|
||||
const childReference: SPOJO = reference[key] as SPOJO;
|
||||
(res as SPOJO)[key] = strip(value as SPOJO, childReference);
|
||||
@@ -171,7 +184,7 @@ export function clientConfig(): Config {
|
||||
return _clientConfig;
|
||||
}
|
||||
|
||||
let _serverConfig = merge<Config>(defaultConfig, configData);
|
||||
let _serverConfig = mergeConfig(defaultConfig, configData);
|
||||
|
||||
let _clientConfig = stripPrivateFields(_serverConfig);
|
||||
|
||||
@@ -181,7 +194,7 @@ export function watchDymamicConfig() {
|
||||
const reloadConfig = async () => {
|
||||
try {
|
||||
const dynamicConfig = yml.load(await readFile(__filepath, 'utf8'));
|
||||
_serverConfig = merge<Config>(defaultConfig, dynamicConfig);
|
||||
_serverConfig = mergeConfig(defaultConfig, dynamicConfig);
|
||||
_clientConfig = stripPrivateFields(_serverConfig);
|
||||
} catch (err) {
|
||||
console.error('could not read or parse config: ' + err);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
export const data = undefined;
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<p>pihole status</p>
|
||||
pihole status
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
export const data = undefined;
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<p>Prowlarr content</p>
|
||||
Prowlarr content
|
||||
|
||||
Reference in New Issue
Block a user