From 9fd37d5acd35c641da9a9f1f8f56e4aca5dbcee2 Mon Sep 17 00:00:00 2001
From: LucHeart
Date: Sat, 20 Jan 2024 00:31:21 +0100
Subject: [PATCH] Ota finish up
---
package-lock.json | 41 ++-
package.json | 1 +
src/globals/config/config.development.js | 4 +-
src/js/UserHub.js | 28 ++
src/views/dashboard/Navigation/NavRoot.vue | 4 +-
src/views/dashboard/devices/DevicesRoot.vue | 2 +-
src/views/dashboard/devices/Ota/OtaUpdate.vue | 251 ++++++++++++++++--
src/views/dashboard/shockers/LiveSlider.vue | 11 +-
src/views/dashboard/shockers/own/Device.vue | 4 +-
.../shockers/shared/SharedDevice.vue | 5 +-
.../shockers/shared/SharedShocker.vue | 2 +-
src/views/public/nav/PublicNavRoot.vue | 4 +-
12 files changed, 324 insertions(+), 33 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index f269baa..f4d591a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "openshock_web_ui",
- "version": "3.3.0",
+ "version": "3.5.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "openshock_web_ui",
- "version": "3.3.0",
+ "version": "3.5.0",
"license": "AGPL",
"dependencies": {
"@fontsource/poppins": "^5.0.8",
@@ -25,6 +25,7 @@
"material-design-icons-iconfont": "^6.7.0",
"mitt": "^3.0.1",
"normalize.css": "^8.0.1",
+ "relative-time-vue-component": "^5.0.2",
"toastr": "^2.1.4",
"vue": "^3.3.7",
"vue-cropperjs": "^5.0.0",
@@ -7053,6 +7054,24 @@
"node": ">= 0.10"
}
},
+ "node_modules/relative-time-component": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/relative-time-component/-/relative-time-component-5.0.0.tgz",
+ "integrity": "sha512-Cu5MYEwAsIZaQJ0UW69FgiKqI2RBSWnsDnW0jVs5rC+AF6DgnhqDCIRihf/SRf9hYd1/u48h0JmbmQKueeP6bA==",
+ "dependencies": {
+ "@types/node": "*",
+ "tslib": "2"
+ }
+ },
+ "node_modules/relative-time-vue-component": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/relative-time-vue-component/-/relative-time-vue-component-5.0.2.tgz",
+ "integrity": "sha512-UYqg+l8T5CKBeFqn0W1SdDhb/fk5YzykA4qJi+fOBi6/zlu3VV3kY2nWvVLX9osY+qRmPqhRczPdEW8jVKeLAQ==",
+ "dependencies": {
+ "relative-time-component": "^5.0.0",
+ "vue": "3"
+ }
+ },
"node_modules/renderkid": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz",
@@ -14001,6 +14020,24 @@
"integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==",
"dev": true
},
+ "relative-time-component": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/relative-time-component/-/relative-time-component-5.0.0.tgz",
+ "integrity": "sha512-Cu5MYEwAsIZaQJ0UW69FgiKqI2RBSWnsDnW0jVs5rC+AF6DgnhqDCIRihf/SRf9hYd1/u48h0JmbmQKueeP6bA==",
+ "requires": {
+ "@types/node": "*",
+ "tslib": "2"
+ }
+ },
+ "relative-time-vue-component": {
+ "version": "5.0.2",
+ "resolved": "https://registry.npmjs.org/relative-time-vue-component/-/relative-time-vue-component-5.0.2.tgz",
+ "integrity": "sha512-UYqg+l8T5CKBeFqn0W1SdDhb/fk5YzykA4qJi+fOBi6/zlu3VV3kY2nWvVLX9osY+qRmPqhRczPdEW8jVKeLAQ==",
+ "requires": {
+ "relative-time-component": "^5.0.0",
+ "vue": "3"
+ }
+ },
"renderkid": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz",
diff --git a/package.json b/package.json
index 4e1b88d..879d047 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"material-design-icons-iconfont": "^6.7.0",
"mitt": "^3.0.1",
"normalize.css": "^8.0.1",
+ "relative-time-vue-component": "^5.0.2",
"toastr": "^2.1.4",
"vue": "^3.3.7",
"vue-cropperjs": "^5.0.0",
diff --git a/src/globals/config/config.development.js b/src/globals/config/config.development.js
index 5ac498a..35bef3c 100644
--- a/src/globals/config/config.development.js
+++ b/src/globals/config/config.development.js
@@ -1,7 +1,7 @@
const config = {
name: "ShockLink Dev",
- webUiUrl: "https://dev.shocklink.net/#/",
- apiUrl: "https://dev-api.shocklink.net/",
+ webUiUrl: "https://staging.shocklink.net/#/",
+ apiUrl: "https://staging-api.shocklink.net/",
shortUrl: "https://shockl.ink/",
}
diff --git a/src/js/UserHub.js b/src/js/UserHub.js
index da669d5..4b961ac 100644
--- a/src/js/UserHub.js
+++ b/src/js/UserHub.js
@@ -46,6 +46,34 @@ export default class ws {
});
});
+ this.connection.on("DeviceUpdate", (deviceId, type) => {
+ emitter.emit('deviceUpdate', { deviceId, type });
+ });
+
+
+ // OTA
+
+ this.connection.on("OtaInstallStarted", (deviceId, updateId, version) => {
+ emitter.emit('otaInstallStarted', { deviceId, updateId, version });
+ });
+
+ this.connection.on("OtaInstallProgress", (deviceId, updateId, task, progress) => {
+ emitter.emit('otaInstallProgress', { deviceId, updateId, task, progress });
+ });
+
+ this.connection.on("OtaInstallFailed", (deviceId, updateId, fatal, message) => {
+ emitter.emit('otaInstallFailed', { deviceId, updateId, fatal, message });
+ });
+
+ this.connection.on("OtaRollback", (deviceId, updateId) => {
+ emitter.emit('otaRollback', { deviceId, updateId });
+ });
+
+ this.connection.on("OtaInstallSucceeded", (deviceId, updateId) => {
+ emitter.emit('otaInstallSucceeded', { deviceId, updateId });
+ });
+
+
this.interval = setInterval(() => {
if(storeF.state.userHubState != this.connection._connectionState) {
storeF.commit('setUserHubState', this.connection._connectionState);
diff --git a/src/views/dashboard/Navigation/NavRoot.vue b/src/views/dashboard/Navigation/NavRoot.vue
index 34af34b..63540a8 100644
--- a/src/views/dashboard/Navigation/NavRoot.vue
+++ b/src/views/dashboard/Navigation/NavRoot.vue
@@ -278,7 +278,7 @@ export default {
}
}
-@media (min-width: 992px) {
+@media (min-width: 1283px) {
.first-level {
flex-flow: row nowrap;
justify-content: flex-start;
@@ -299,7 +299,7 @@ export default {
}
-@media (max-width: 991px) {
+@media (max-width: 1282px) {
.first-level {
.navbar-logo img {
diff --git a/src/views/dashboard/devices/DevicesRoot.vue b/src/views/dashboard/devices/DevicesRoot.vue
index 50dedb9..b75f5c2 100644
--- a/src/views/dashboard/devices/DevicesRoot.vue
+++ b/src/views/dashboard/devices/DevicesRoot.vue
@@ -264,7 +264,7 @@ export default {
ws.captive(deviceId, enabled);
},
getFirmwareVersionString(version) {
- if(version === null) return "Older than 7.1.0.0, please upgrade.";
+ if(version === null) return "Older than 0.8.0, please upgrade.";
return version;
},
ellipsis(e, item) {
diff --git a/src/views/dashboard/devices/Ota/OtaUpdate.vue b/src/views/dashboard/devices/Ota/OtaUpdate.vue
index ed53f46..4b377b5 100644
--- a/src/views/dashboard/devices/Ota/OtaUpdate.vue
+++ b/src/views/dashboard/devices/Ota/OtaUpdate.vue
@@ -8,20 +8,58 @@
-
-
-
-
-
+
+
+
+ Device Status
+
+
+
+
+
+
+ {{ deviceOnline ? 'Online' : 'Offline' }}
+
+
+
+
+
+ Firmware Version
+
+
+ {{ deviceState.firmwareVersion }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ data.value }}
+
+
+ {{ data.value }}
+
+
+
+
+
+
+
-
+
Start update?
You are about to start a OTA Update
-
- Branch {{ this.branch }} with Version {{ this.version }}
+
+ Branch {{ this.branch }} with Version {{ this.version }}
+
@@ -33,34 +71,145 @@
-
-
+
+
+
+ Update in progress
+
+ {{ progressTaskName }}
+
+
+
+
+
+
+
+
+
+
+
+ Update finished
+
+ Update finished successfully
+
+
+
+
+
+ Back
+
+
+
+
+
+
+
+
+ Device rolled back to previous version
+
+
+
+
+
+
+
+ Update failed
+
+ {{ deviceInfo.failed }}
+
+
-+
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/src/views/dashboard/shockers/LiveSlider.vue b/src/views/dashboard/shockers/LiveSlider.vue
index b3f9daa..86853bf 100644
--- a/src/views/dashboard/shockers/LiveSlider.vue
+++ b/src/views/dashboard/shockers/LiveSlider.vue
@@ -3,7 +3,7 @@
- {{ parseInt(percentageY * 100) }}%
+ {{ actualLimitedNumber }}%
@@ -41,10 +41,15 @@ export default {
const rect = this.$refs.slcon.getBoundingClientRect();
return 1 - (this.y / rect.height);
},
+
+ actualLimitedNumber() {
+ if(this.shocker.limits === undefined) return parseInt(this.percentageY * 100);
+ return parseInt(this.percentageY * (this.shocker.limits.intensity === null ? 100 : this.shocker.limits.intensity));
+ }
},
watch: {
- percentageY(newValue) {
- this.shocker.$live.intensity = newValue * 100;
+ actualLimitedNumber(newValue) {
+ this.shocker.$live.intensity = newValue;
}
},
methods: {
diff --git a/src/views/dashboard/shockers/own/Device.vue b/src/views/dashboard/shockers/own/Device.vue
index 1116293..61bea37 100644
--- a/src/views/dashboard/shockers/own/Device.vue
+++ b/src/views/dashboard/shockers/own/Device.vue
@@ -95,8 +95,8 @@ export default {
this.live.gateway = res.data.data.gateway;
this.live.gatewayCountry = res.data.data.country;
- this.live.websocket = new WebSocket('wss://' + this.live.gateway + '/1/ws/live/' + this.device.id);
- //this.live.websocket = new WebSocket('wss://localhost:5443/1/ws/live/' + this.device.id);
+ //this.live.websocket = new WebSocket('wss://' + this.live.gateway + '/1/ws/live/' + this.device.id);
+ this.live.websocket = new WebSocket('wss://localhost:5443/1/ws/live/' + this.device.id);
this.live.websocket.onclose = (event) => {
console.log(event, "Live Control Gateway Connection Closed");
diff --git a/src/views/dashboard/shockers/shared/SharedDevice.vue b/src/views/dashboard/shockers/shared/SharedDevice.vue
index a0f893e..ea7c845 100644
--- a/src/views/dashboard/shockers/shared/SharedDevice.vue
+++ b/src/views/dashboard/shockers/shared/SharedDevice.vue
@@ -96,7 +96,8 @@ export default {
this.live.gateway = res.data.data.gateway;
this.live.gatewayCountry = res.data.data.country;
- this.live.websocket = new WebSocket('wss://' + this.live.gateway + '/1/ws/live/' + this.device.id);
+ this.live.websocket = new WebSocket('wss://localhost:5443/1/ws/live/' + this.device.id);
+ //this.live.websocket = new WebSocket('wss://' + this.live.gateway + '/1/ws/live/' + this.device.id);
this.live.websocket.onclose = (event) => {
console.log(event, "Live Control Gateway Connection Closed");
@@ -175,7 +176,7 @@ export default {
},
computed: {
getFirmwareVersionString() {
- if (this.firmwareVersion === null) return "Older than 7.1.0.0, please upgrade.";
+ if (this.firmwareVersion === null) return "Older than 0.8.0, please upgrade.";
return this.firmwareVersion;
},
lcgState() {
diff --git a/src/views/dashboard/shockers/shared/SharedShocker.vue b/src/views/dashboard/shockers/shared/SharedShocker.vue
index 5321bf0..4470534 100644
--- a/src/views/dashboard/shockers/shared/SharedShocker.vue
+++ b/src/views/dashboard/shockers/shared/SharedShocker.vue
@@ -23,7 +23,7 @@
-
+