Updates, updates, updates
This commit is contained in:
parent
d32246b973
commit
7e8e352989
@ -4,8 +4,10 @@ require('dotenv/config');
|
||||
|
||||
// or replace multiple strings
|
||||
function replaceTemplate() {
|
||||
return src(['./dist/**.html'])
|
||||
return src(['./dist/**'])
|
||||
.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/'));
|
||||
};
|
||||
|
||||
|
2236
package-lock.json
generated
2236
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,12 +4,14 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "npm run build && npm run deploy",
|
||||
"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",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"dotenv": "^16.1.4",
|
||||
"lit": "^2.7.5",
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./css/app.css">
|
||||
<script type="module" src="./js/edit.js"></script>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./css/app.css">
|
||||
<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';
|
||||
|
||||
@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 = [
|
||||
css`
|
||||
.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) {
|
||||
if (event?.target?.files?.length > 0) {
|
||||
const file = event?.target?.files[0];
|
||||
@ -122,17 +121,16 @@ export class LavenderConfigure extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem(LAVENDER_WIDGETS, JSON.stringify(lavenderWidgets));
|
||||
window.location.replace('./index.html');
|
||||
fetch(`CONFIG_STORE_URL?json=${JSON.stringify(lavenderWidgets)}`).then(() => window.location.replace('./index.html'));
|
||||
}
|
||||
|
||||
override render() {
|
||||
const widgetJSON = localStorage.getItem(LAVENDER_WIDGETS) ?? '[]';
|
||||
const widgetJSON = this.text ?? '[]';
|
||||
const widgets = JSON.parse(widgetJSON);
|
||||
|
||||
return html`
|
||||
<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">
|
||||
${widgets.map((widget: any) => {
|
||||
return html`
|
||||
@ -149,7 +147,7 @@ export class LavenderConfigure extends LitElement {
|
||||
<div><div>Height</div><input type="text" name="urlHeight"></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>
|
||||
<input type="file" @change="${(e: any) => this.handleFiles(e)}" id="importer" style="display:none" />
|
||||
`;
|
||||
|
21
src/index.ts
21
src/index.ts
@ -7,12 +7,23 @@ export class LavenderWidgets extends LitElement {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
const widgetJSON = localStorage.getItem('lavender-widgets') ?? '[]';
|
||||
this.widgets = JSON.parse(widgetJSON);
|
||||
if (this.widgets.length == 0) {
|
||||
window.location.href = './edit.html';
|
||||
}
|
||||
|
||||
let that = this;
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
that.requestUpdate();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
css`
|
||||
.centerit {
|
||||
|
Loading…
Reference in New Issue
Block a user