clean from dirty code in network transport subsystem
This commit is contained in:
parent
b89a78c0a4
commit
68d085bb67
|
|
@ -1,13 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<q-card-actions>
|
<q-card-actions>
|
||||||
<q-btn color="green" v-on:click="SendAndRequest(senddata, 1, 0, 'mykey', true)">Apply</q-btn>
|
<q-btn color="green"
|
||||||
<q-btn color="orange" v-on:click="SendAndRequest(senddata, 1, 1, 'mykey', true)">Save</q-btn>
|
v-on:click="PostData(senddata, 1, 0, ShowDelayDialog('Data applying...', 1000, null))">Apply</q-btn>
|
||||||
<q-btn color="red" v-on:click="SendAndRequest(senddata, 1, 2, 'mykey', true)">Save & Reboot</q-btn>
|
<q-btn color="orange"
|
||||||
|
v-on:click="PostData(senddata, 1, 1, ShowDelayDialog('Data saving...', 1000, null))">Save</q-btn>
|
||||||
|
<q-btn color="red"
|
||||||
|
v-on:click="PostData(senddata, 1, 2, ShowDelayDialog('Data saving and reboot...', 10000, null))">Save &
|
||||||
|
Reboot</q-btn>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
//import { defineProps } from "vue";
|
import { ShowDelayDialog } from "./helpers";
|
||||||
const props = defineProps(['senddata']);
|
const props = defineProps(['senddata']);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
@ -37,5 +37,5 @@ const init = {
|
||||||
eth_gw: "", eth_dns1: "", eth_dns2: "", eth_dns3: "", eth_mac: ""
|
eth_gw: "", eth_dns1: "", eth_dns2: "", eth_dns3: "", eth_mac: ""
|
||||||
}
|
}
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
@ -33,6 +33,6 @@ const init = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onUnmounted, reactive, onMounted } from "vue";
|
import { computed, onUnmounted, reactive, onMounted } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp//network";
|
import { PostData } from "components/webguicomp//network";
|
||||||
import { secondsToHms } from "components/webguicomp/helpers"
|
import { secondsToHms } from "components/webguicomp/helpers"
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
@ -29,12 +29,12 @@ const init = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
|
|
||||||
let intervalId
|
let intervalId
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
onUnmounted(() => clearInterval(intervalId))
|
onUnmounted(() => clearInterval(intervalId))
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp//network";
|
import { PostData } from "components/webguicomp//network";
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -39,5 +39,5 @@ const init = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp//network";
|
import { PostData } from "components/webguicomp//network";
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
const init = {
|
const init = {
|
||||||
|
|
@ -38,5 +38,5 @@ const init = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -31,5 +31,5 @@ const init = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, onUnmounted, reactive, onMounted } from "vue";
|
import { computed, onUnmounted, reactive, onMounted } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
import { secondsToHms } from "components/webguicomp/helpers"
|
import { secondsToHms } from "components/webguicomp/helpers"
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
@ -50,12 +50,12 @@ const init = {
|
||||||
free_ram_min: 0
|
free_ram_min: 0
|
||||||
}
|
}
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
|
|
||||||
let intervalId
|
let intervalId
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
onUnmounted(() => clearInterval(intervalId))
|
onUnmounted(() => clearInterval(intervalId))
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network"
|
import { PostData } from "components/webguicomp/network"
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
@ -35,5 +35,5 @@ const init = {
|
||||||
model_name: "", hw_rev: 0, fw_rev: "", idf_rev: "", build_date: "", ser_num: ""
|
model_name: "", hw_rev: 0, fw_rev: "", idf_rev: "", build_date: "", ser_num: ""
|
||||||
}
|
}
|
||||||
const data = reactive(init);
|
const data = reactive(init);
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive } from "vue";
|
import { computed, reactive } from "vue";
|
||||||
import { SendAndRequest } from "components/webguicomp/network";
|
import { PostData } from "components/webguicomp/network";
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import SelectWiFiDialog from 'components/webguicomp/SelectWiFiDialog.vue'
|
import SelectWiFiDialog from 'components/webguicomp/SelectWiFiDialog.vue'
|
||||||
import CardActions from "components/webguicomp/CardActions.vue"
|
import CardActions from "components/webguicomp/CardActions.vue"
|
||||||
|
|
@ -74,7 +74,7 @@ function OpenScanDialog() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SendAndRequest(data, 2, 0, 'mykey', false);
|
PostData(data, 2, 0, null);
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
26
network.js
26
network.js
|
|
@ -1,27 +1,10 @@
|
||||||
import { api } from "boot/axios";
|
import { api } from "boot/axios";
|
||||||
import { sha256 } from "js-sha256";
|
import { sha256 } from "js-sha256";
|
||||||
import { Notify, Dialog } from "quasar";
|
import { Notify } from "quasar";
|
||||||
|
|
||||||
const API_URL = "/api";
|
const API_URL = "/api";
|
||||||
const SHA256_HMAC_KEY = "mykey";
|
const SHA256_HMAC_KEY = "mykey";
|
||||||
|
|
||||||
function ShowSaveDialog(apltype) {
|
|
||||||
const opername = ['Data applying...', 'Data saving...', 'Data saving and reboot...'];
|
|
||||||
let step = (apltype == 2) ? 1 : 10;
|
|
||||||
let percentage = 0;
|
|
||||||
const dialog = Dialog.create({ message: opername[apltype], progress: true, persistent: true, ok: false })
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
percentage = Math.min(100, percentage + step);
|
|
||||||
dialog.update({
|
|
||||||
message: `${opername[apltype]} ${percentage}%`
|
|
||||||
})
|
|
||||||
if (percentage === 100) {
|
|
||||||
clearInterval(interval);
|
|
||||||
setTimeout(() => { dialog.hide() }, 350)
|
|
||||||
}
|
|
||||||
}, 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
function PostData(varlist, messtype, applytype, onfinished) {
|
function PostData(varlist, messtype, applytype, onfinished) {
|
||||||
var pld = {};
|
var pld = {};
|
||||||
var data = {};
|
var data = {};
|
||||||
|
|
@ -50,12 +33,7 @@ function PostData(varlist, messtype, applytype, onfinished) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SendAndRequest(varlist, mstp, apltp, shakey, okreport) {
|
export { PostData };
|
||||||
var onfinish = (okreport) ? () => { ShowSaveDialog(apltp) } : null;
|
|
||||||
PostData(varlist, mstp, apltp, onfinish);
|
|
||||||
}
|
|
||||||
|
|
||||||
export { SendAndRequest, PostData };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user