Skip to content

Commit

Permalink
fixed network display error.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykuku committed Mar 21, 2024
1 parent 205f83d commit 13b2b95
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 38 deletions.
12 changes: 1 addition & 11 deletions main/.env.dev
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
# .env.dev
NODE_ENV=dev
# VUE_APP_DEV_IP=demo.casaos.io
# VUE_APP_DEV_IP=192.168.2.197
# VUE_APP_DEV_IP=192.168.2.209
# VUE_APP_DEV_IP=192.168.2.15
# VUE_APP_DEV_IP=192.168.2.219
# VUE_APP_DEV_IP=192.168.2.157
# VUE_APP_DEV_IP=192.168.2.132
# VUE_APP_DEV_IP=192.168.2.219
#VUE_APP_DEV_IP=192.168.2.243
VUE_APP_DEV_IP=192.168.2.226
VUE_APP_DEV_IP=10.0.163.68
VUE_APP_DEV_PORT=80
#VUE_APP_DEV_PORT=81
2 changes: 1 addition & 1 deletion main/src/components/settings/UpdateCompleteModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- Modal-Card Header Start -->
<header class="modal-card-head">
<div class="is-flex-grow-1">
<h3 class="title is-header">{{ panelTitle }}</h3>
<h3 class="title is-header">{{$t('Update completed')}}</h3>
</div>
<b-icon class="close-button" icon="close-outline" pack="casa" @click.native="$emit('close');" />
</header>
Expand Down
1 change: 1 addition & 0 deletions main/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ router.beforeEach(async (to, from, next) => {
localStorage.removeItem("access_token");
localStorage.removeItem("refresh_token");
localStorage.removeItem("wallpaper");
localStorage.removeItem("user");
next('/login');
break;

Expand Down
1 change: 1 addition & 0 deletions main/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export default {
},
async showUpdateCompleteModal() {
await this.$api.users.getLinkAppDetail();
const versionRes = await this.$api.sys.getVersion();
if (versionRes.data.success == 200) {
this.$buefy.modal.open({
Expand Down
55 changes: 29 additions & 26 deletions main/src/widgets/Network.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ export default {
methods: {
buildDatas(data) {
if (data.length === 0) {
return;
if (data.length == 0) {
return
}
data.forEach((el, index) => {
if (this.networks[index] === undefined) {
this.networks[index] = [
Expand All @@ -190,33 +189,37 @@ export default {
cacheData: 0,
cacheTime: 0
}
];
]
}
// Send Data
if (this.networks[index][0].data.length >= 60) {
this.networks[index][0].data.shift()
}
if (this.networks[index][0].cacheData > 0) {
const timeGap = this.networks[index][0].cacheTime == 0 ? 2 : el.time - this.networks[index][0].cacheTime
this.networks[index][0].data.push(this.covertToKB((el.bytesSent - this.networks[index][0].cacheData) / timeGap))
}
this.networks[index][0].cacheData = el.bytesSent;
this.networks[index][0].cacheTime = el.time;
const updateData = (networkIndex, dataIndex, bytes, cacheData, cacheTime) => {
if (this.networks[networkIndex][dataIndex].data.length >= 60) {
this.networks[networkIndex][dataIndex].data.shift();
}
if (this.networks[networkIndex][dataIndex].cacheData > 0) {
const timeGap = this.networks[networkIndex][dataIndex].cacheTime === 0 ? 2 : el.time - this.networks[networkIndex][dataIndex].cacheTime;
this.networks[networkIndex][dataIndex].data.push(this.covertToKB((bytes - cacheData) / timeGap));
}
this.networks[networkIndex][dataIndex].cacheData = bytes;
this.networks[networkIndex][dataIndex].cacheTime = cacheTime;
};
updateData(index, 0, el.bytesSent, this.networks[index][0].cacheData, this.networks[index][0].cacheTime);
updateData(index, 1, el.bytesRecv, this.networks[index][1].cacheData, this.networks[index][1].cacheTime);
// RecvData
if (this.networks[index][1].data.length >= 60) {
this.networks[index][1].data.shift()
}
if (this.networks[index][1].cacheData > 0) {
const timeGap = this.networks[index][1].cacheTime == 0 ? 2 : el.time - this.networks[index][1].cacheTime
this.networks[index][1].data.push(this.covertToKB((el.bytesRecv - this.networks[index][1].cacheData) / timeGap))
}
this.networks[index][1].cacheData = el.bytesRecv;
this.networks[index][1].cacheTime = el.time;
});
this.networkId = this.networkId > this.networks.length - 1 ? 0 : this.networkId;
this.$refs.chart?.updateSeries(this.networks[this.networkId]);
this.networkId = this.networkId > this.networks.length - 1 ? 0 : this.networkId
this.$refs.chart?.updateSeries(this.networks[this.networkId])
if (this.networks) {
const upSpeed = this.networks[this.networkId][0].data[this.networks[this.networkId][0].data.length - 1];
const downSpeed = this.networks[this.networkId][1].data[this.networks[this.networkId][1].data.length - 1];
this.currentUpSpeed = isNaN(upSpeed) ? 0 : upSpeed;
this.currentDownSpeed = isNaN(downSpeed) ? 0 : downSpeed;
const upSpeed = this.networks[this.networkId][0].data[this.networks[this.networkId][0].data.length - 1]
const downSpeed = this.networks[this.networkId][1].data[this.networks[this.networkId][1].data.length - 1]
this.currentUpSpeed = isNaN(upSpeed) ? 0 : upSpeed
this.currentDownSpeed = isNaN(downSpeed) ? 0 : downSpeed
}
},
covertToKB(bytes) {
Expand Down

0 comments on commit 13b2b95

Please sign in to comment.