UI update
This commit is contained in:
200
frontend/package-lock.json
generated
200
frontend/package-lock.json
generated
@@ -9,7 +9,9 @@
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.0.0-beta.176",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.185"
|
||||
"@tiptap/extension-code-block-lowlight": "^2.0.0-beta.68",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.185",
|
||||
"lowlight": "^2.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@material/textfield": "^14.0.0",
|
||||
@@ -1028,6 +1030,59 @@
|
||||
"@tiptap/core": "^2.0.0-beta.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block-lowlight": {
|
||||
"version": "2.0.0-beta.68",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code-block-lowlight/-/extension-code-block-lowlight-2.0.0-beta.68.tgz",
|
||||
"integrity": "sha512-927vw4DJ5pq3lYOdJbBrCjJZ/YsbsEzWkb7SwRsaztDXcgsF2z8gt6dy7onXMaqm5rDx6eNofLPdhUyLCswW8Q==",
|
||||
"dependencies": {
|
||||
"@tiptap/extension-code-block": "^2.0.0-beta.37",
|
||||
"@types/lowlight": "^0.0.3",
|
||||
"lowlight": "^1.20.0",
|
||||
"prosemirror-model": "^1.16.1",
|
||||
"prosemirror-state": "^1.3.4",
|
||||
"prosemirror-view": "^1.23.6"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^2.0.0-beta.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block-lowlight/node_modules/fault": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz",
|
||||
"integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==",
|
||||
"dependencies": {
|
||||
"format": "^0.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block-lowlight/node_modules/highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz",
|
||||
"integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block-lowlight/node_modules/lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"dependencies": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-document": {
|
||||
"version": "2.0.0-beta.15",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-2.0.0-beta.15.tgz",
|
||||
@@ -1235,12 +1290,25 @@
|
||||
"integrity": "sha512-pYrtLtOwku/7r1i9AMONsJMVYAtk3hzOfiGNekhtq5tYBGA7unMve8RvUclKLMT3PrihvJqUmzsRGh0RP84hKg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/hast": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
|
||||
"integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
|
||||
"dependencies": {
|
||||
"@types/unist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
|
||||
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/lowlight": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/lowlight/-/lowlight-0.0.3.tgz",
|
||||
"integrity": "sha512-R83q/yPX2nIlo9D3WtSjyUDd57t8s+GVLaL8YIv3k7zMMWpYpOXqjJgrWp80qXUJB/a1t76nTyBpxrv0JNYaEg=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "17.0.36",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.36.tgz",
|
||||
@@ -1360,6 +1428,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/unist": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||
"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz",
|
||||
@@ -2970,6 +3043,18 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fault": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz",
|
||||
"integrity": "sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==",
|
||||
"dependencies": {
|
||||
"format": "^0.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
@@ -3042,6 +3127,14 @@
|
||||
"node": ">= 0.12"
|
||||
}
|
||||
},
|
||||
"node_modules/format": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
|
||||
"integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/fs-minipass": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
|
||||
@@ -3259,6 +3352,14 @@
|
||||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/highlight.js": {
|
||||
"version": "11.5.1",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.5.1.tgz",
|
||||
"integrity": "sha512-LKzHqnxr4CrD2YsNoIf/o5nJ09j4yi/GcH5BnYz9UnVpZdS4ucMgvP61TDty5xJcFGRjnH4DpujkS9bHT3hq0Q==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-encoding-sniffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz",
|
||||
@@ -3668,6 +3769,20 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/lowlight": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-2.6.1.tgz",
|
||||
"integrity": "sha512-t0ueDL6SIn9FKHipm78CNjWcJQv0xi6WCjYAICyO6GyPzoT7E58yom1mNwvI7AMwVe3pLwwFT0Bt2gml7uaUeQ==",
|
||||
"dependencies": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"fault": "^2.0.0",
|
||||
"highlight.js": "~11.5.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
@@ -6728,6 +6843,43 @@
|
||||
"prosemirror-state": "^1.3.4"
|
||||
}
|
||||
},
|
||||
"@tiptap/extension-code-block-lowlight": {
|
||||
"version": "2.0.0-beta.68",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code-block-lowlight/-/extension-code-block-lowlight-2.0.0-beta.68.tgz",
|
||||
"integrity": "sha512-927vw4DJ5pq3lYOdJbBrCjJZ/YsbsEzWkb7SwRsaztDXcgsF2z8gt6dy7onXMaqm5rDx6eNofLPdhUyLCswW8Q==",
|
||||
"requires": {
|
||||
"@tiptap/extension-code-block": "^2.0.0-beta.37",
|
||||
"@types/lowlight": "^0.0.3",
|
||||
"lowlight": "^1.20.0",
|
||||
"prosemirror-model": "^1.16.1",
|
||||
"prosemirror-state": "^1.3.4",
|
||||
"prosemirror-view": "^1.23.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"fault": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz",
|
||||
"integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==",
|
||||
"requires": {
|
||||
"format": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz",
|
||||
"integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A=="
|
||||
},
|
||||
"lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"requires": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@tiptap/extension-document": {
|
||||
"version": "2.0.0-beta.15",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-2.0.0-beta.15.tgz",
|
||||
@@ -6849,12 +7001,25 @@
|
||||
"integrity": "sha512-pYrtLtOwku/7r1i9AMONsJMVYAtk3hzOfiGNekhtq5tYBGA7unMve8RvUclKLMT3PrihvJqUmzsRGh0RP84hKg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/hast": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz",
|
||||
"integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==",
|
||||
"requires": {
|
||||
"@types/unist": "*"
|
||||
}
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
|
||||
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/lowlight": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/lowlight/-/lowlight-0.0.3.tgz",
|
||||
"integrity": "sha512-R83q/yPX2nIlo9D3WtSjyUDd57t8s+GVLaL8YIv3k7zMMWpYpOXqjJgrWp80qXUJB/a1t76nTyBpxrv0JNYaEg=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "17.0.36",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.36.tgz",
|
||||
@@ -6974,6 +7139,11 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/unist": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz",
|
||||
"integrity": "sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ=="
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz",
|
||||
@@ -8086,6 +8256,14 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"fault": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz",
|
||||
"integrity": "sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==",
|
||||
"requires": {
|
||||
"format": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
@@ -8143,6 +8321,11 @@
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"format": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
|
||||
"integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww=="
|
||||
},
|
||||
"fs-minipass": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz",
|
||||
@@ -8310,6 +8493,11 @@
|
||||
"integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==",
|
||||
"dev": true
|
||||
},
|
||||
"highlight.js": {
|
||||
"version": "11.5.1",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.5.1.tgz",
|
||||
"integrity": "sha512-LKzHqnxr4CrD2YsNoIf/o5nJ09j4yi/GcH5BnYz9UnVpZdS4ucMgvP61TDty5xJcFGRjnH4DpujkS9bHT3hq0Q=="
|
||||
},
|
||||
"html-encoding-sniffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz",
|
||||
@@ -8656,6 +8844,16 @@
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"lowlight": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-2.6.1.tgz",
|
||||
"integrity": "sha512-t0ueDL6SIn9FKHipm78CNjWcJQv0xi6WCjYAICyO6GyPzoT7E58yom1mNwvI7AMwVe3pLwwFT0Bt2gml7uaUeQ==",
|
||||
"requires": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"fault": "^2.0.0",
|
||||
"highlight.js": "~11.5.0"
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
|
||||
@@ -40,11 +40,17 @@
|
||||
"svelte-preprocess": "^4.10.1",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "~4.6.2",
|
||||
"window": "^4.2.7"
|
||||
"window": "^4.2.7",
|
||||
"@tiptap/core": "^2.0.0-beta.176",
|
||||
"@tiptap/extension-code-block-lowlight": "^2.0.0-beta.68",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.185",
|
||||
"lowlight": "^2.6.1"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^2.0.0-beta.176",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.185"
|
||||
"@tiptap/extension-code-block-lowlight": "^2.0.0-beta.68",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.185",
|
||||
"lowlight": "^2.6.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<script context="module">
|
||||
import { CodeJar } from 'codejar';
|
||||
import { withLineNumbers } from 'codejar/linenumbers';
|
||||
import Prism from 'prismjs';
|
||||
|
||||
export function codedit(node, { code, autofocus = false, loc = false, ...options }) {
|
||||
const highlight = loc ? withLineNumbers(Prism.highlightElement) : Prism.highlightElement;
|
||||
|
||||
const editor = CodeJar(node, highlight, options);
|
||||
|
||||
editor.onUpdate((code) => fire(node, 'change', code));
|
||||
|
||||
function update({ code, autofocus = false, loc = false, ...options }) {
|
||||
editor.updateOptions(options);
|
||||
editor.updateCode(code);
|
||||
}
|
||||
|
||||
update({ code, ...options });
|
||||
|
||||
autofocus && node.focus();
|
||||
|
||||
return {
|
||||
update,
|
||||
destroy() {
|
||||
editor.destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fire(el, name, detail) {
|
||||
const e = new CustomEvent(name, { detail });
|
||||
el.dispatchEvent(e);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export let code = '';
|
||||
</script>
|
||||
|
||||
<div use:codedit={{ code, $$restProps }} />
|
||||
@@ -2,19 +2,19 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { Editor } from '@tiptap/core';
|
||||
import StarterKit from '@tiptap/starter-kit';
|
||||
import * as fs from 'fs';
|
||||
// const config_file = fs.readFileSync('../.storage/config.yaml', 'utf8');
|
||||
|
||||
let element;
|
||||
let editor;
|
||||
|
||||
onMount(() => {
|
||||
onMount(async () => {
|
||||
const res = await fetch('api/edit_config');
|
||||
const file_data = await res.text();
|
||||
|
||||
editor = new Editor({
|
||||
element: element,
|
||||
extensions: [StarterKit],
|
||||
content: 'config_file',
|
||||
content: file_data,
|
||||
onTransaction: () => {
|
||||
// force re-render so `editor.isActive` works as expected
|
||||
editor = editor;
|
||||
}
|
||||
});
|
||||
@@ -27,7 +27,11 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<div bind:this={element} />
|
||||
{#if editor}
|
||||
<button onclick="editor.chain().focus().toggleBold().run()"> Save </button>
|
||||
{/if}
|
||||
|
||||
<div class="wrapper" bind:this={element} />
|
||||
|
||||
<style>
|
||||
button.active {
|
||||
|
||||
@@ -1,14 +1,38 @@
|
||||
import { readFile } from 'fs'
|
||||
import { readFile, readFileSync, writeFile } from 'fs'
|
||||
|
||||
export function get() {
|
||||
|
||||
readFile('../.storage/config.yaml', 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
console.log(data);
|
||||
});
|
||||
export function get(request) {
|
||||
const data = readFileSync('.storage/config.yaml', 'utf-8')
|
||||
return {
|
||||
body: data
|
||||
}
|
||||
// readFile('.storage/config.yaml', 'utf8', (err, data) => {
|
||||
// if (err) {
|
||||
// console.error('oh no :(')
|
||||
// console.error(err);
|
||||
// return;
|
||||
// }
|
||||
// console.log(data);
|
||||
// return { data }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
// export function post(request) {
|
||||
// writeFile('../.storage/config.yaml', request, (err) => {
|
||||
// if (err) {
|
||||
// console.error(err);
|
||||
// return;
|
||||
// }
|
||||
// console.log(request);
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// export function get(request) {
|
||||
// return {
|
||||
// body: { hello: "world" }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<!-- <script context="module">
|
||||
// export const load = async ({ fetch }) => {
|
||||
// const res = await fetch('/api/edit_config');
|
||||
// const data = await res;
|
||||
// console.log({ data });
|
||||
// return {
|
||||
// props: { data }
|
||||
// };
|
||||
// };
|
||||
</script> -->
|
||||
<script>
|
||||
import Button from '@smui/button';
|
||||
import Tabbar from '@smui/tab-bar';
|
||||
import Tab, { Label } from '@smui/tab';
|
||||
import Textfield from '@smui/textfield';
|
||||
import HelperText from '@smui/textfield/helper-text';
|
||||
import Header from '$lib/Header.svelte';
|
||||
|
||||
let active = 'Config';
|
||||
let yaml = '';
|
||||
let actuators_id = '';
|
||||
let sensors_id = '';
|
||||
let db_password = '';
|
||||
let db_username = '';
|
||||
let db_host = '';
|
||||
let db_port = '';
|
||||
let db_database = '';
|
||||
let ha_url = '';
|
||||
let ha_token = '';
|
||||
// export let data = '';
|
||||
export const ssr = false;
|
||||
import * as fs from 'fs';
|
||||
const config_file = fs.readFileSync('../.storage/config.yaml', 'utf8');
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/env';
|
||||
let CodeEditor;
|
||||
onMount(async () => {
|
||||
const module = await import('$lib/CodeEditor.svelte');
|
||||
CodeEditor = module.default;
|
||||
});
|
||||
</script>
|
||||
|
||||
<Header />
|
||||
<!-- <pre>{config_file}</pre> -->
|
||||
<!-- <svelte:component this={CodeEditor}>{config_file}</svelte:component> -->
|
||||
<div use:CodeEditor.codedit={{ config_file, $$restProps }} />
|
||||
|
||||
<Tabbar tabs={['Config', 'Dashboard', 'About Us']} let:tab bind:active>
|
||||
<Tab {tab}>
|
||||
<Label>{tab}</Label>
|
||||
</Tab>
|
||||
</Tabbar>
|
||||
{#if active === 'Config'}
|
||||
<pre>Yaml</pre>
|
||||
|
||||
<pre>ML settings</pre>
|
||||
<div>
|
||||
<Textfield bind:value={actuators_id} label="actuators_id">
|
||||
<HelperText slot="helper">List of actuators_id (comma delimited)</HelperText>
|
||||
</Textfield>
|
||||
<Textfield bind:value={sensors_id} label="sensors_id">
|
||||
<HelperText slot="helper">List of sensors_id (comma delimited)</HelperText>
|
||||
</Textfield>
|
||||
</div>
|
||||
|
||||
<pre>DB settings</pre>
|
||||
<div>
|
||||
<Textfield bind:value={db_password} label="db_password" /><br />
|
||||
<Textfield bind:value={db_username} label="db_username" /><br />
|
||||
<Textfield bind:value={db_host} label="db_host" /><br />
|
||||
<Textfield bind:value={db_port} label="db_port" /><br />
|
||||
<Textfield bind:value={db_database} label="db_database" />
|
||||
</div>
|
||||
|
||||
<pre>Homeassistant settings</pre>
|
||||
<div>
|
||||
<Textfield bind:value={ha_url} label="ha_url">
|
||||
<HelperText slot="helper">Http url ie 192.168.1.100:8123</HelperText>
|
||||
</Textfield>
|
||||
<Textfield bind:value={ha_token} label="ha_token">
|
||||
<HelperText slot="helper">Homeassistant token created from profile</HelperText>
|
||||
</Textfield>
|
||||
</div>
|
||||
<div><Button action="/contact" method="POST">Save</Button></div>
|
||||
{:else}
|
||||
<div />
|
||||
{/if}
|
||||
@@ -1,13 +1,3 @@
|
||||
<!-- <script context="module">
|
||||
// export const load = async ({ fetch }) => {
|
||||
// const res = await fetch('/api/edit_config');
|
||||
// const data = await res;
|
||||
// console.log({ data });
|
||||
// return {
|
||||
// props: { data }
|
||||
// };
|
||||
// };
|
||||
</script> -->
|
||||
<script>
|
||||
import Button from '@smui/button';
|
||||
import Tabbar from '@smui/tab-bar';
|
||||
@@ -25,8 +15,6 @@
|
||||
let db_database = '';
|
||||
let ha_url = '';
|
||||
let ha_token = '';
|
||||
// export let data = '';
|
||||
|
||||
import TipTap from '$lib/TipTap.svelte';
|
||||
</script>
|
||||
|
||||
@@ -38,7 +26,8 @@
|
||||
{#if active === 'Config'}
|
||||
<pre>Yaml</pre>
|
||||
<TipTap />
|
||||
<pre>ML settings</pre>
|
||||
|
||||
<!-- <pre>ML settings</pre>
|
||||
<div>
|
||||
<Textfield bind:value={actuators_id} label="actuators_id">
|
||||
<HelperText slot="helper">List of actuators_id (comma delimited)</HelperText>
|
||||
@@ -66,7 +55,7 @@
|
||||
<HelperText slot="helper">Homeassistant token created from profile</HelperText>
|
||||
</Textfield>
|
||||
</div>
|
||||
<div><Button action="/contact" method="POST">Save</Button></div>
|
||||
<div><Button action="/contact" method="POST">Save</Button></div> -->
|
||||
{:else}
|
||||
<div />
|
||||
{/if}
|
||||
|
||||
29
frontend/static/config.yaml
Normal file
29
frontend/static/config.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
actuactors_id:
|
||||
- light.bathroom_lights
|
||||
- light.corridor_lights
|
||||
- light.hallway_lights
|
||||
- switch.livingroom_entrance_switch_right
|
||||
- switch.livingroom_entrance_switch_center
|
||||
- switch.livingroom_entrance_switch_left
|
||||
- light.bedroom_sidetable_lamp
|
||||
- light.bedroom_ceiling_light
|
||||
sensors_id:
|
||||
- sensor.corridor_end_sensor_illuminance_lux
|
||||
- binary_sensor.corridor_end_sensor_occupancy
|
||||
- sensor.corridor_entrance_sensor_illuminance_lux
|
||||
- binary_sensor.corridor_entrance_sensor_occupancy
|
||||
- sensor.livingroom_desk_sensor_illuminance_lux
|
||||
- binary_sensor.livingroom_desk_sensor_occupancy
|
||||
- sensor.bedroom_entrance_sensor_illuminance_lux
|
||||
- binary_sensor.bedroom_entrance_sensor_occupancy
|
||||
- sensor.bathroom_entrance_sensor_illuminance_lux
|
||||
- binary_sensor.bathroom_entrance_sensor_occupancy
|
||||
- binary_sensor.chris_phone_is_charging
|
||||
- device_tracker.chris_phone
|
||||
- weather.home
|
||||
db_options:
|
||||
- db_password: Wp95kLJex8fqNjez
|
||||
db_username: homeassistant
|
||||
db_host: 192.168.1.100
|
||||
db_port: '3306'
|
||||
db_database: homeassistant
|
||||
Reference in New Issue
Block a user