Updates, updates, updates
This commit is contained in:
parent
d32246b973
commit
7e8e352989
@ -4,8 +4,10 @@ require('dotenv/config');
|
|||||||
|
|
||||||
// or replace multiple strings
|
// or replace multiple strings
|
||||||
function replaceTemplate() {
|
function replaceTemplate() {
|
||||||
return src(['./dist/**.html'])
|
return src(['./dist/**'])
|
||||||
.pipe(replace(/FONTAWESOME_SCRIPT_URL/g, process.env.FONTAWESOME_SCRIPT_URL))
|
.pipe(replace(/FONTAWESOME_SCRIPT_URL/g, process.env.FONTAWESOME_SCRIPT_URL))
|
||||||
|
.pipe(replace(/CONFIG_STORE_URL/g, process.env.CONFIG_STORE_URL))
|
||||||
|
.pipe(replace(/CONFIG_FETCH_URL/g, process.env.CONFIG_FETCH_URL))
|
||||||
.pipe(dest('./dist/'));
|
.pipe(dest('./dist/'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2234
package-lock.json
generated
2234
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,12 +4,14 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"start": "npm run build && npm run deploy",
|
||||||
"build": "npx tsc && cp -R public dist && npx gulp && npx rollup -c",
|
"build": "npx tsc && cp -R public dist && npx gulp && npx rollup -c",
|
||||||
|
"deploy": "rm -rf ~/www/html/lavender && cp -R build ~/www/html/lavender",
|
||||||
"clean": "rm -rf build && rm -rf dist",
|
"clean": "rm -rf build && rm -rf dist",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.1.4",
|
"dotenv": "^16.1.4",
|
||||||
"lit": "^2.7.5",
|
"lit": "^2.7.5",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="./css/app.css">
|
<link rel="stylesheet" href="./css/app.css">
|
||||||
<script type="module" src="./js/edit.js"></script>
|
<script type="module" src="./js/edit.js"></script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="./css/app.css">
|
<link rel="stylesheet" href="./css/app.css">
|
||||||
<link rel="manifest" href="./manifest.json" />
|
<link rel="manifest" href="./manifest.json" />
|
||||||
|
38
src/edit.ts
38
src/edit.ts
@ -4,7 +4,20 @@ import { customElement } from 'lit/decorators.js';
|
|||||||
const LAVENDER_WIDGETS = 'lavender-widgets';
|
const LAVENDER_WIDGETS = 'lavender-widgets';
|
||||||
|
|
||||||
@customElement('lavender-configure')
|
@customElement('lavender-configure')
|
||||||
export class LavenderConfigure extends LitElement {
|
export default class LavenderConfigure extends LitElement {
|
||||||
|
text = '[]'
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
let that = this;
|
||||||
|
|
||||||
|
setTimeout( async () => {
|
||||||
|
const response = await fetch('CONFIG_FETCH_URL');
|
||||||
|
that.text = await response.text();
|
||||||
|
that.requestUpdate();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
static override styles = [
|
static override styles = [
|
||||||
css`
|
css`
|
||||||
.centerit {
|
.centerit {
|
||||||
@ -73,20 +86,6 @@ export class LavenderConfigure extends LitElement {
|
|||||||
`
|
`
|
||||||
];
|
];
|
||||||
|
|
||||||
export() {
|
|
||||||
const downloader = this.shadowRoot?.getElementById('downloader');
|
|
||||||
const widgets = JSON.parse(localStorage.getItem(LAVENDER_WIDGETS) ?? '[]');
|
|
||||||
const dataStr = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(widgets))}`;
|
|
||||||
downloader?.setAttribute('href', dataStr);
|
|
||||||
downloader?.setAttribute('download', 'lavender.json');
|
|
||||||
downloader?.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
import() {
|
|
||||||
const importer = this.shadowRoot?.getElementById('importer') as HTMLInputElement;
|
|
||||||
importer?.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFiles(event: any) {
|
handleFiles(event: any) {
|
||||||
if (event?.target?.files?.length > 0) {
|
if (event?.target?.files?.length > 0) {
|
||||||
const file = event?.target?.files[0];
|
const file = event?.target?.files[0];
|
||||||
@ -122,17 +121,16 @@ export class LavenderConfigure extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem(LAVENDER_WIDGETS, JSON.stringify(lavenderWidgets));
|
fetch(`CONFIG_STORE_URL?json=${JSON.stringify(lavenderWidgets)}`).then(() => window.location.replace('./index.html'));
|
||||||
window.location.replace('./index.html');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
const widgetJSON = localStorage.getItem(LAVENDER_WIDGETS) ?? '[]';
|
const widgetJSON = this.text ?? '[]';
|
||||||
const widgets = JSON.parse(widgetJSON);
|
const widgets = JSON.parse(widgetJSON);
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<h1 class="centerit">Lavender Widget Editor</h1>
|
<h1 class="centerit">Lavender Widget Editor</h1>
|
||||||
<div class="buttonbar"><button class="button" @click="${() => this.save()}">Save</button><button class="button" @click="${() => this.export()}">Export</button><button class="button" @click="${() => this.import()}">Import</button></div>
|
<div class="buttonbar"><button class="button" @click="${async () => await this.save()}">Save</button></div>
|
||||||
<div class="widgets">
|
<div class="widgets">
|
||||||
${widgets.map((widget: any) => {
|
${widgets.map((widget: any) => {
|
||||||
return html`
|
return html`
|
||||||
@ -149,7 +147,7 @@ export class LavenderConfigure extends LitElement {
|
|||||||
<div><div>Height</div><input type="text" name="urlHeight"></div>
|
<div><div>Height</div><input type="text" name="urlHeight"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttonbar"><button class="button" @click="${() => this.save()}">Save</button><button class="button" @click="${() => this.export()}">Export</button><button class="button" @click="${() => this.import()}">Import</button></div>
|
<div class="buttonbar"><button class="button" @click="${() => this.save()}">Save</button></div>
|
||||||
<a id="downloader" style="display: none"></a>
|
<a id="downloader" style="display: none"></a>
|
||||||
<input type="file" @change="${(e: any) => this.handleFiles(e)}" id="importer" style="display:none" />
|
<input type="file" @change="${(e: any) => this.handleFiles(e)}" id="importer" style="display:none" />
|
||||||
`;
|
`;
|
||||||
|
17
src/index.ts
17
src/index.ts
@ -7,12 +7,23 @@ export class LavenderWidgets extends LitElement {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
const widgetJSON = localStorage.getItem('lavender-widgets') ?? '[]';
|
|
||||||
this.widgets = JSON.parse(widgetJSON);
|
let that = this;
|
||||||
if (this.widgets.length == 0) {
|
|
||||||
|
setTimeout(async () => {
|
||||||
|
const response = await fetch('CONFIG_FETCH_URL');
|
||||||
|
const text = await response.text();
|
||||||
|
|
||||||
|
const widgetJSON = text ?? '[]';
|
||||||
|
that.widgets = JSON.parse(widgetJSON);
|
||||||
|
if (that.widgets.length == 0) {
|
||||||
window.location.href = './edit.html';
|
window.location.href = './edit.html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.requestUpdate();
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
static override styles = [
|
static override styles = [
|
||||||
css`
|
css`
|
||||||
.centerit {
|
.centerit {
|
||||||
|
Loading…
Reference in New Issue
Block a user