Converted schema from JavaScript into JSON

This commit is contained in:
Alicia Sykes 2021-06-07 16:01:11 +01:00
parent 9bdc960799
commit 0e86d0dbfb
6 changed files with 232 additions and 378 deletions

View File

@ -29,7 +29,7 @@
import VJsoneditor from 'v-jsoneditor';
import { localStorageKeys } from '@/utils/defaults';
import configSchema from '@/utils/ConfigSchema';
import configSchema from '@/utils/ConfigSchema.json';
import Ajv from 'ajv7';
export default {

View File

@ -1,158 +0,0 @@
---
pageInfo:
title: Hello World
description: 'This is a demo'
sections:
- name: Firewall
items:
- title: OPNsense
description: Firewall Central Management
icon: networking/opnsense.png
target: iframe
url: https://192.168.1.1
- title: NetData
description: System resource usage on firewall
icon: networking/netdata.png
url: http://192.168.1.1:19999/
- title: MalTrail
description: Malicious traffic detection system
icon: networking/maltrail.png
url: http://192.168.1.1:8338
- title: Ntopng
description: Network traffic probe and network use monitor
icon: networking/ntop.png
url: http://192.168.1.1:3001
- title: Sensei
description: Additional data features
icon: networking/sensei.png
url: https://192.168.1.1/ui/sensei/
- title: Monit
description: Status of firewall system alerts
icon: networking/monit.png
url: https://192.168.1.1/ui/monit/status
- title: Firewall Logs
description: Real-time view of firewall data and logs
icon: networking/logs.png
url: https://192.168.1.1/ui/diagnostics/firewall/log
- title: WireGuard
description: Manage WireGuard client and server on firewall
icon: networking/wireguard.png
url: https://192.168.1.1/ui/wireguard/general
- name: DNS Device
displayData:
collapsed: false
rows: 2
items:
- title: Pi-Hole
description: DNS settings for ad & tracker blocking
icon: networking/pihole.png
url: http://192.168.130.2/admin
- title: PiAlert
description: Presence monitoring and ARP scanning
icon: networking/pialert.png
url: http://192.168.130.2/pialert/
- title: SmokePing
description: Network latency monitoring
icon: networking/smokeping.png
url: http://192.168.130.2:8086/
- title: StatPing
description: Up-time monitoring for local service
icon: networking/statping.png
url: http://192.168.130.2:8083/
- title: LibreSpeed
description: Local network speed and latency test
icon: networking/librespeed.png
url: http://192.168.130.2:49154/
- title: NetData
description: Real-time system resource usage
icon: networking/netdata.png
url: http://192.168.130.2:19999
- title: Portainer
description: Docker container management
icon: networking/portainer.png
url: http://192.168.130.2:9000/
- title: cAdvisor
description: Container monitoring
icon: networking/cadvisor.png
url: http://192.168.130.2:8084/
- title: Glances
description: Simple resource usage
icon: networking/glances.png
url: http://192.168.130.2:61208
- title: Dozzle
description: Docker container web log viewer
icon: networking/dozzle.png
url: http://192.168.130.2:8093
- title: Prometheus
description: System Statistics Aggregation with PromQL
icon: networking/prometheus.png
url: http://192.168.130.2:8090/
- title: Grafana
description: Data visualised on dashboards
icon: networking/grafana.png
url: http://192.168.130.2:8091/
- name: External Services
items:
- title: DuckDNS
description: Dynamic DNS for fixed public IP
icon: networking/duckdns.png
url: https://www.duckdns.org/
- title: BorgBase
description: Off-site system Borg backups
icon: networking/borgbase.png
url: https://www.borgbase.com/repositories
- title: Mullvad
description: Hosted VPN provider
icon: networking/mullvad.png
url: https://mullvad.net/en/account/
- title: ZeroTier
description: Secure networks between devices
icon: networking/zeroteir.png
url: https://my.zerotier.com/
- title: HealthChecks
description: Cron Job Monitoring
icon: networking/healthchecks.png
url: https://healthchecks.io/checks/
- title: ISP - Vodafone
description: Broadband internet provider
icon: networking/vodafone.png
url: https://myaccount.vodafone.co.uk/
- name: Other Devices
items:
- title: Modem
description: ISP Router Modem Combo
icon: ''
url: http://192.168.1.5
- title: Wireless Access Point
description: View clients connected to WiFi
icon: ''
url: http://192.168.1.109/info.php
- title: Fing
description: Monitor connectivity issues, ISP quality, health checks and troubleshooting
provider: Fing
icon: ''
url: https://app.fing.com/
- title: Switch
description: Manage VLANs on Ubiquity Ethernet switch
icon: ''
url: "#"
- name: External Utilities
displayData:
collapsed: true
items:
- title: Public IP
description: Check public IP and associated data
icon: ''
url: https://www.whatismyip.com/
- title: Who Is Lookup
description: Check ICAN info for a given IP address or domain
icon: ''
url: https://whois.domaintools.com/
- title: Speed Test
description: Upload + download speeds and latency
icon: ''
url: https://speed.cloudflare.com/
- title: Mullvad Check
description: Confirms a secure connection to Mullvad's WireGuard servers
icon: ''
url: https://mullvad.net/check

View File

@ -12,7 +12,6 @@
--warning: #f6f000;
--danger: #f80363;
--neutral: #272f4d;
--white: #fff;
--black: #000;

View File

@ -1,217 +0,0 @@
/**
* This is the schema for the main app configuration (usually ./public/conf.yml)
* It enables the users data to be validated when making changes,
* and detailed warnings shown, to avoid any unexpected errors or issues
*/
module.exports = {
type: 'object',
required: ['sections'],
additionalProperties: false,
properties: {
/* Page Info */
pageInfo: {
type: 'object',
properties: {
title: {
type: 'string',
description: 'Title and heading for the app',
},
description: {
type: 'string',
description: 'Sub-title, displayed in header',
},
navLinks: {
type: 'array',
maxItems: 6,
description: 'Quick access links, displayed in header',
items: {
type: 'object',
additionalProperties: false,
required: ['title', 'path'],
properties: {
title: {
type: 'string',
},
path: {
type: 'string',
},
},
},
},
footerText: { type: 'string' },
},
required: ['title'],
additionalProperties: false,
},
/* App Config */
appConfig: {
type: 'object',
description: 'Application configuration',
properties: {
backgroundImg: {
type: 'string',
description: 'A URL to an image asset to be displayed as background',
},
theme: {
type: 'string',
default: 'Callisto',
description: 'A theme to be applied by default on first load',
},
enableFontAwesome: {
type: 'boolean',
default: true,
description: 'Should load font-awesome assets',
},
fontAwesomeKey: {
type: 'string',
pattern: '^[a-z0-9]{10}$',
description: 'API key for font-awesome',
},
cssThemes: {
type: 'array',
description: 'Theme names to be added to the dropdown',
items: {
type: 'string',
},
},
externalStyleSheet: {
description: 'URL or URLs of external stylesheets to add to dropdown/ load',
type: [
'string', 'array',
],
items: {
type: 'string',
},
},
customCss: {
type: 'string',
description: 'Any custom CSS overides, must be minified',
},
},
additionalProperties: false,
},
/* Sections */
sections: {
type: 'array',
description: 'Array of sections, containing items',
items: {
type: 'object',
required: ['name', 'items'],
additionalProperties: false,
properties: {
name: {
type: 'string',
description: 'Title/ heading for a section',
},
icon: {
type: 'string',
description: 'Icon will be displayed next to title',
},
/* Section Display Data */
displayData: {
type: 'object',
additionalProperties: false,
description: 'Optional meta data for customizing a section',
properties: {
collapsed: {
type: 'boolean',
default: false,
description: 'If true, section needs to be clicked to open',
},
color: {
type: 'string',
description: 'Hex code, or HTML color for section fill',
},
customStyles: {
type: 'string',
description: 'CSS overides for section container',
},
itemSize: {
enum: ['small', 'medium', 'large'],
default: 'medium',
description: 'Size of items within the section',
},
rows: {
type: 'number',
minimum: 1,
maximum: 5,
default: 1,
description: 'The amount of space that the section spans vertically',
},
cols: {
type: 'number',
minimum: 1,
maximum: 5,
default: 1,
description: 'The amount of space that the section spans horizontally',
},
layout: {
enum: ['grid', 'auto'],
default: 'auto',
description: 'If set to grid, items have uniform width, and itemCount can be set',
},
itemCountX: {
type: 'number',
minimum: 1,
maximum: 12,
description: 'Number of items per column',
},
itemCountY: {
type: 'number',
minimum: 1,
maximum: 12,
description: 'Number of items per row',
},
},
},
/* Items within a section */
items: {
type: 'array',
description: 'Array of items to display with a section',
items: {
type: 'object',
additionalProperties: false,
required: ['title'],
properties: {
title: {
type: 'string',
description: 'Text shown on the item',
},
description: {
type: 'string',
nullable: true,
description: 'Short description, shown on hover or in a tooltip',
},
icon: {
type: 'string',
nullable: true,
description: 'An icon, either as a font-awesome identifier, local or remote URL, or auto-fetched favicon',
},
url: {
type: 'string',
description: 'The destination to navigate to when item is clicked',
},
target: {
enum: ['newtab', 'sametab', 'iframe'],
default: 'newtab',
description: 'Opening method, when item is clicked',
},
color: {
type: 'string',
description: 'A custom fill color of the item',
},
provider: {
type: 'string',
description: 'Provider name, e.g. Microsoft',
},
},
},
},
},
},
},
},
};

230
src/utils/ConfigSchema.json Normal file
View File

@ -0,0 +1,230 @@
{
"type": "object",
"required": [
"sections"
],
"additionalProperties": false,
"properties": {
"pageInfo": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Title and heading for the app"
},
"description": {
"type": "string",
"description": "Sub-title, displayed in header"
},
"navLinks": {
"type": "array",
"maxItems": 6,
"description": "Quick access links, displayed in header",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"title",
"path"
],
"properties": {
"title": {
"type": "string"
},
"path": {
"type": "string"
}
}
}
},
"footerText": {
"type": "string"
}
},
"required": [
"title"
],
"additionalProperties": false
},
"appConfig": {
"type": "object",
"description": "Application configuration",
"properties": {
"backgroundImg": {
"type": "string",
"description": "A URL to an image asset to be displayed as background"
},
"theme": {
"type": "string",
"default": "Callisto",
"description": "A theme to be applied by default on first load"
},
"enableFontAwesome": {
"type": "boolean",
"default": true,
"description": "Should load font-awesome assets"
},
"fontAwesomeKey": {
"type": "string",
"pattern": "^[a-z0-9]{10}$",
"description": "API key for font-awesome"
},
"cssThemes": {
"type": "array",
"description": "Theme names to be added to the dropdown",
"items": {
"type": "string"
}
},
"externalStyleSheet": {
"description": "URL or URLs of external stylesheets to add to dropdown/ load",
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"customCss": {
"type": "string",
"description": "Any custom CSS overides, must be minified"
}
},
"additionalProperties": false
},
"sections": {
"type": "array",
"description": "Array of sections, containing items",
"items": {
"type": "object",
"required": [
"name",
"items"
],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "Title/ heading for a section"
},
"icon": {
"type": "string",
"description": "Icon will be displayed next to title"
},
"displayData": {
"type": "object",
"additionalProperties": false,
"description": "Optional meta data for customizing a section",
"properties": {
"collapsed": {
"type": "boolean",
"default": false,
"description": "If true, section needs to be clicked to open"
},
"color": {
"type": "string",
"description": "Hex code, or HTML color for section fill"
},
"customStyles": {
"type": "string",
"description": "CSS overides for section container"
},
"itemSize": {
"enum": [
"small",
"medium",
"large"
],
"default": "medium",
"description": "Size of items within the section"
},
"rows": {
"type": "number",
"minimum": 1,
"maximum": 5,
"default": 1,
"description": "The amount of space that the section spans vertically"
},
"cols": {
"type": "number",
"minimum": 1,
"maximum": 5,
"default": 1,
"description": "The amount of space that the section spans horizontally"
},
"layout": {
"enum": [
"grid",
"auto"
],
"default": "auto",
"description": "If set to grid, items have uniform width, and itemCount can be set"
},
"itemCountX": {
"type": "number",
"minimum": 1,
"maximum": 12,
"description": "Number of items per column"
},
"itemCountY": {
"type": "number",
"minimum": 1,
"maximum": 12,
"description": "Number of items per row"
}
}
},
"items": {
"type": "array",
"description": "Array of items to display with a section",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"description": "Text shown on the item"
},
"description": {
"type": "string",
"nullable": true,
"description": "Short description, shown on hover or in a tooltip"
},
"icon": {
"type": "string",
"nullable": true,
"description": "An icon, either as a font-awesome identifier, local or remote URL, or auto-fetched favicon"
},
"url": {
"type": "string",
"description": "The destination to navigate to when item is clicked"
},
"target": {
"enum": [
"newtab",
"sametab",
"iframe"
],
"default": "newtab",
"description": "Opening method, when item is clicked"
},
"color": {
"type": "string",
"description": "A custom fill color of the item"
},
"provider": {
"type": "string",
"description": "Provider name, e.g. Microsoft"
}
}
}
}
}
}
}
}
}

View File

@ -2,7 +2,7 @@ const Ajv = require('ajv');
const yaml = require('js-yaml');
const fs = require('fs');
const schema = require('./ConfigSchema');
const schema = require('./ConfigSchema.json');
const validatorOptions = {
strict: true,