Skip to content

Commit

Permalink
Deploying to gh-pages from @ 360c8f1 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
o0shojo0o committed Nov 4, 2023
1 parent c6a84f2 commit 61df6ff
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 35 deletions.
34 changes: 32 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ export default {
watch: {
'$store.state.gitVersion': function (newVal) {
if (this.$store.state.version) {
this.$store.state.newVersionAvailable = newVal != this.$store.state.version;
//this.$store.state.newVersionAvailable = newVal != this.$store.state.version;
this.$store.state.newVersionAvailable = isNewVersionAvailable(this.$store.state.version, newVal);
}
},
'$store.state.version': function (newVal) {
if (this.$store.state.gitVersion) {
this.$store.state.newVersionAvailable = newVal != this.$store.state.gitVersion;
//this.$store.state.newVersionAvailable = newVal != this.$store.state.gitVersion;
this.$store.state.newVersionAvailable = isNewVersionAvailable(newVal, this.$store.state.gitVersion);
}
},
},
Expand Down Expand Up @@ -144,6 +146,34 @@ async function getStatistics(vue) {
}
}
function isNewVersionAvailable(local, git){
return compareVersions(local, git) == -1
}
// 0 if a = b
// 1 if a > b
// -1 if a < b
const compareVersions = ((prep, l, i, r) => (a, b) =>{
a = prep(a);
b = prep(b);
l = Math.max(a.length, b.length);
i = 0;
r = i;
while (!r && i < l)
//convert into integer, uncluding undefined values
r = ~~a[i] - ~~b[i++];
return r < 0 ? -1 : (r ? 1 : 0);
})(t => ("" + t)
// treat non-numerical characters as lower version
// replacing them with a negative number based on charcode of first character
.replace(/[^\d.]+/g, c => "." + (c.replace(/[\W_]+/, "").toUpperCase().charCodeAt(0) - 65536) + ".")
// remove trailing "." and "0" if followed by non-numerical characters (1.0.0b);
.replace(/(?:\.0+)*(\.-\d+(?:\.\d+)?)\.*$/g, "$1")
// return array
.split("."));
</script>

<style>
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default new Vuex.Store({
page: '/statistics',
},
{
title: 'Update',
title: 'Update & Backup',
icon: 'mdi-tray-arrow-up',
page: '/update',
},
Expand Down
137 changes: 106 additions & 31 deletions src/views/Update.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,71 @@
<template>
<v-container class="home">
<v-container class="Update">
<v-row>
<v-col cols="12" lg="4">
<v-card class="pa-2" elevation="4">
<v-card-title>
<h2>Firmware</h2>
</v-card-title>
<hr />
<br />
<div class="text-center">
<v-file-input v-model="firmwareFile" prepend-icon="mdi-file-powerpoint-outline" show-size filled accept=".bin" label="Select firmware upload" dense></v-file-input>

<ButtonCondition color="success" :condition="sockedIsConnected && inputFWCheck" text="Update Firmware" icon="mdi-file-upload" :onclick="uploadFirmware" />
</div>
</v-card>
</v-col>
<v-col cols="12" lg="4">
<v-card class="pa-2" elevation="4">
<v-card-title>
<h2>Filesystem</h2>
</v-card-title>
<hr />
<br />
<div class="text-center">
<v-file-input v-model="filesystemFile" prepend-icon="mdi-file-powerpoint-outline" show-size filled accept=".bin" label="Select filesystem upload" dense></v-file-input>
<ButtonCondition color="success" :condition="sockedIsConnected && inputFSCheck" text="Update Filesystem" icon="mdi-file-upload" :onclick="uploadFilesystem" />
</div>
</v-card>
</v-col>
<v-col cols="12" lg="8">
<v-row>
<v-col cols="12" lg="12">
<v-card class="pa-0" elevation="4">
<v-card-text class="text-md-center">
<h2>Firmware / Filesystem Update</h2>
</v-card-text>
</v-card>
</v-col>
</v-row>
<v-row>
<v-col cols="12" lg="6">
<v-card class="pa-2" elevation="4">
<v-card-title>
<h2>Firmware</h2>
</v-card-title>
<hr />
<br />
<div class="text-center">
<v-file-input v-model="firmwareFile" prepend-icon="mdi-file-powerpoint-outline" show-size filled accept=".bin" label="Select firmware upload" dense></v-file-input>
<ButtonCondition color="success" :condition="sockedIsConnected && inputFWCheck" text="Update Firmware" icon="mdi-file-upload" :onclick="uploadFirmware" />
</div>
</v-card>
</v-col>
<v-col cols="12" lg="6">
<v-card class="pa-2" elevation="4">
<v-card-title>
<h2>Filesystem</h2>
</v-card-title>
<hr />
<br />
<div class="text-center">
<v-file-input v-model="filesystemFile" prepend-icon="mdi-file-powerpoint-outline" show-size filled accept=".bin" label="Select filesystem upload" dense></v-file-input>
<ButtonCondition color="success" :condition="sockedIsConnected && inputFSCheck" text="Update Filesystem" icon="mdi-file-upload" :onclick="uploadFilesystem" />
</div>
</v-card>
</v-col>
</v-row>
<v-row>
<v-col cols="12" lg="12">
<v-card class="pa-0" elevation="4">
<v-card-text class="text-md-center">
<h2>Configuration backup and restore</h2>
</v-card-text>
</v-card>
</v-col>
</v-row>
<v-row>
<v-col cols="12" lg="12">
<v-card class="pa-2" elevation="4">
<v-card-title>
<h2>Configuration</h2>
</v-card-title>
<hr />
<br />
<div class="text-center">
<v-file-input v-model="configFile" prepend-icon="mdi-file-table-outline" show-size filled accept=".json" label="Select configuration file" dense></v-file-input>
<ButtonCondition color="warning" :condition="sockedIsConnected && inputConfigCheck" text="Restore" icon="mdi-file-upload" :onclick="uploadConfig" />
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<ButtonCondition color="success" :condition="sockedIsConnected" text="Backup" icon="mdi-file-download" :onclick="downloadConfig" />
</div>
</v-card>
</v-col>
</v-row>
</v-col>
<v-col cols="12" lg="4">
<v-card class="pa-2" elevation="4">
<v-card-title>
Expand All @@ -38,7 +76,7 @@
<DownloadStats :items="gitReleases" />
</v-card>
</v-col>
</v-row>
</v-row>
</v-container>
</template>

Expand All @@ -52,6 +90,7 @@ export default {
return {
firmwareFile: null,
filesystemFile: null,
configFile: null,
};
},
computed: {
Expand All @@ -73,6 +112,9 @@ export default {
inputFSCheck() {
return this.filesystemFile != null && this.filesystemFile != undefined && this.filesystemFile != '';
},
inputConfigCheck() {
return this.configFile != null && this.configFile != undefined && this.configFile != '';
},
},
methods: {
async uploadFirmware() {
Expand All @@ -87,7 +129,7 @@ export default {
if (this.$pixelitHost == undefined || this.$pixelitHost == null || this.$pixelitHost == '') {
alert('No Pixelit Host defined!');
} else {
await fetch('http://' + this.$pixelitHost + '/update', { method: 'POST', body: formData });
await fetch(`http://${this.$pixelitHost}/update`, { method: 'POST', body: formData });
}
} catch (e) {
e;
Expand All @@ -105,12 +147,45 @@ export default {
if (this.$pixelitHost == undefined || this.$pixelitHost == null || this.$pixelitHost == '') {
alert('No Pixelit Host defined!');
} else {
await fetch('http://' + this.$pixelitHost + '/update', { method: 'POST', body: formData });
await fetch(`http://${this.$pixelitHost}/update`, { method: 'POST', body: formData });
}
} catch (e) {
e;
}
},
uploadConfig() {
let reader = new FileReader();
reader.onload = e => {
const config = JSON.parse(e.target.result);
// Clean Config
delete config.version;
delete config.isESP8266;
this.$socket.sendObj({ setConfig: config });
setTimeout(() => {
this.$socket.close();
}, 3000);
};
reader.readAsText(this.configFile);
},
async downloadConfig(){
try {
//const jsonData = JSON.stringify(await (await fetch(`http://${this.$pixelitHost}/api/config`)).json());
const jsonData = JSON.stringify(this.$store.state.configData);
const blob = new Blob([jsonData], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `pixlitConfig_${this.$store.state.version}.json`;
link.click();
URL.revokeObjectURL(url);
} catch (error) {
console.log(`downloadConfig: error (${error})`);
}
}
},
};
</script>
1 change: 1 addition & 0 deletions webui/css/app.200a0b77.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webui/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="mobile-web-app-capable" content="yes"><link rel="icon" href="https://pixelit-project.github.io/PixelIt/webui/favicon.ico"><title>PixelIt WebUI</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"><link href="https://pixelit-project.github.io/PixelIt/webui/css/app.77365047.css" rel="preload" as="style"><link href="https://pixelit-project.github.io/PixelIt/webui/css/chunk-vendors.d0ec1288.css" rel="preload" as="style"><link href="https://pixelit-project.github.io/PixelIt/webui/js/app.65984d2b.js" rel="preload" as="script"><link href="https://pixelit-project.github.io/PixelIt/webui/js/chunk-vendors.8c2e95df.js" rel="preload" as="script"><link href="https://pixelit-project.github.io/PixelIt/webui/css/chunk-vendors.d0ec1288.css" rel="stylesheet"><link href="https://pixelit-project.github.io/PixelIt/webui/css/app.77365047.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Pixel It the Matrix Display doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="https://pixelit-project.github.io/PixelIt/webui/js/chunk-vendors.8c2e95df.js"></script><script src="https://pixelit-project.github.io/PixelIt/webui/js/app.65984d2b.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="mobile-web-app-capable" content="yes"><link rel="icon" href="https://pixelit-project.github.io/PixelIt/webui/favicon.ico"><title>PixelIt WebUI</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"><link href="https://pixelit-project.github.io/PixelIt/webui/css/app.200a0b77.css" rel="preload" as="style"><link href="https://pixelit-project.github.io/PixelIt/webui/css/chunk-vendors.d0ec1288.css" rel="preload" as="style"><link href="https://pixelit-project.github.io/PixelIt/webui/js/app.b9a126bd.js" rel="preload" as="script"><link href="https://pixelit-project.github.io/PixelIt/webui/js/chunk-vendors.e308edae.js" rel="preload" as="script"><link href="https://pixelit-project.github.io/PixelIt/webui/css/chunk-vendors.d0ec1288.css" rel="stylesheet"><link href="https://pixelit-project.github.io/PixelIt/webui/css/app.200a0b77.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Pixel It the Matrix Display doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="https://pixelit-project.github.io/PixelIt/webui/js/chunk-vendors.e308edae.js"></script><script src="https://pixelit-project.github.io/PixelIt/webui/js/app.b9a126bd.js"></script></body></html>
2 changes: 2 additions & 0 deletions webui/js/app.b9a126bd.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions webui/js/app.b9a126bd.js.map

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions webui/js/chunk-vendors.e308edae.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions webui/js/chunk-vendors.e308edae.js.map

Large diffs are not rendered by default.

0 comments on commit 61df6ff

Please sign in to comment.