From 6df7dcd8fed706006ad3262d8adf0891c474fc05 Mon Sep 17 00:00:00 2001
From: mzz2017
Date: Thu, 1 Oct 2020 21:36:00 +0800
Subject: [PATCH] fix: wrong sorted result by Latency field
---
gui/src/node.vue | 52 +++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/gui/src/node.vue b/gui/src/node.vue
index 27da2907..e14c8723 100644
--- a/gui/src/node.vue
+++ b/gui/src/node.vue
@@ -94,7 +94,7 @@
{{ $t("welcome.title") }}
@@ -157,7 +157,9 @@
{{ props.row.servers.length }}
@@ -194,8 +196,8 @@
-
+
+
{{ props.row.pingLatency }}
@@ -349,6 +352,7 @@
:label="$t('server.latency')"
class="ping-latency"
sortable
+ :custom-sort="sortping"
>
{{ props.row.pingLatency }}
@@ -444,6 +448,7 @@ import ModalServer from "@/components/modalServer";
import ModalSubscription from "@/components/modalSuscription";
import { waitingConnected } from "@/assets/js/networkInspect";
import axios from "@/plugins/axios";
+
export default {
name: "Node",
components: { ModalSubscription, ModalServer },
@@ -533,6 +538,26 @@ export default {
});
},
methods: {
+ sortNumberServers(a, b, isAsc) {
+ console.log(a.servers.length, b.servers.length, isAsc);
+ if (!isAsc) {
+ return a.servers.length < b.servers.length ? 1 : -1;
+ }
+ return a.servers.length > b.servers.length ? 1 : -1;
+ },
+ sortping(a, b, isAsc) {
+ if (isNaN(parseInt(a.pingLatency))) {
+ return 1;
+ }
+ if (isNaN(parseInt(b.pingLatency))) {
+ return -1;
+ }
+ if (!isAsc) {
+ return parseInt(a.pingLatency) < parseInt(b.pingLatency) ? 1 : -1;
+ } else {
+ return parseInt(a.pingLatency) > parseInt(b.pingLatency) ? 1 : -1;
+ }
+ },
updateConnectView(runningState) {
if (!runningState) {
runningState = this.runningState;
@@ -1053,21 +1078,26 @@ export default {
td {
font-size: 0.9em;
}
+
.node-section {
margin-top: 1rem;
+
.iconfont {
margin-right: 0.1em;
}
+
.operate-box {
> * {
margin-right: 0.5rem;
}
}
}
+
.card {
max-width: 500px;
margin: auto;
}
+
.ping-latency {
font-size: 0.8em;
}
@@ -1075,6 +1105,7 @@ td {