feat: 展示排序 close #29

This commit is contained in:
naiba
2021-01-08 21:04:50 +08:00
parent 35766e590d
commit 347bb7faa0
14 changed files with 63 additions and 42 deletions

View File

@@ -9,7 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
<script src="/static/main.js?v202012211616"></script>
<script src="/static/main.js?v202101082103"></script>
</body>
</html>

View File

@@ -8,6 +8,10 @@
<label>备注</label>
<input type="text" name="name" placeholder="爱因斯坦-光速1号">
</div>
<div class="field">
<label>展示权重</label>
<input type="number" name="DisplayIndex" placeholder="越大越靠前">
</div>
<div class="secret field">
<label>密钥</label>
<input type="text" name="secret">

View File

@@ -13,20 +13,20 @@
<table class="ui very basic table">
<thead>
<tr>
<th>ID</th>
<th>权重</th>
<th>备注</th>
<th>IP</th>
<th>密钥</th>
<th>最后活跃</th>
<th>管理</th>
</tr>
</thead>
<tbody>
{{range $server := .Servers}}
<tr>
<td>{{$server.ID}}</td>
<td>{{$server.DisplayIndex}}</td>
<td>{{$server.Name}}</td>
<td>{{$server.Host.IP}}</td>
<td>{{$server.Secret}}</td>
<td>{{$server.LastActive}}</td>
<td>
<div class="ui mini icon buttons">
<button class="ui button" onclick="addOrEditServer({{$server.Marshal}})">

View File

@@ -172,9 +172,8 @@
ws.onmessage = function (evt) {
const oldServers = statusCards.servers
statusCards.servers = JSON.parse(evt.data)
const keys = Object.keys(statusCards.servers)
for (let i = 0; i < keys.length; i++) {
const ns = statusCards.servers[keys[i]];
for (let i = 0; i < statusCards.servers.length; i++) {
const ns = statusCards.servers[i];
if (!ns.Host) ns.live = false
else {
const lastActive = new Date(ns.LastActive).getTime()

View File

@@ -238,9 +238,8 @@
}
ws.onmessage = function (evt) {
statusCards.servers = JSON.parse(evt.data)
const keys = Object.keys(statusCards.servers)
for (let i = 0; i < keys.length; i++) {
const ns = statusCards.servers[keys[i]];
for (let i = 0; i < statusCards.servers.length; i++) {
const ns = statusCards.servers[i];
if (!ns.Host) ns.live = false
else {
const lastActive = new Date(ns.LastActive).getTime()