From 8e30f483953e1cf803d670b7efddb4817570c704 Mon Sep 17 00:00:00 2001 From: naiba Date: Wed, 9 Dec 2020 10:27:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20#9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/dashboard/controller/controller.go | 6 ------ model/server.go | 5 +++++ resource/static/main.js | 3 +++ resource/template/common/footer.html | 2 +- resource/template/common/header.html | 2 +- resource/template/page/server.html | 4 +++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/dashboard/controller/controller.go b/cmd/dashboard/controller/controller.go index bff034e..95485b9 100644 --- a/cmd/dashboard/controller/controller.go +++ b/cmd/dashboard/controller/controller.go @@ -27,12 +27,6 @@ func ServeWeb(port uint) { "stf": func(s uint64) string { return time.Unix(int64(s), 0).Format("2006年1月2号 15:04") }, - "fs": func() string { - if !dao.Conf.Debug { - return "" - } - return fmt.Sprintf("%d", time.Now().UnixNano()) - }, "sf": func(duration uint64) string { return time.Duration(time.Duration(duration) * time.Second).String() }, diff --git a/model/server.go b/model/server.go index c5790d3..643d1ea 100644 --- a/model/server.go +++ b/model/server.go @@ -1,6 +1,7 @@ package model import ( + "fmt" "time" pb "github.com/naiba/nezha/proto" @@ -19,3 +20,7 @@ type Server struct { Stream pb.NezhaService_HeartbeatServer `gorm:"-" json:"-"` StreamClose chan<- error `gorm:"-" json:"-"` } + +func (s Server) Marshal() string { + return fmt.Sprintf(`{"ID":%d,"Name":"%s","Secret":"%s"}`, s.ID, s.Name, s.Secret) +} diff --git a/resource/static/main.js b/resource/static/main.js index 8435d92..1353053 100644 --- a/resource/static/main.js +++ b/resource/static/main.js @@ -72,6 +72,9 @@ function showFormModal(modelSelector, formID, URL, getData) { function addOrEditServer(server) { const modal = $('.server.modal') + if (server) { + server = JSON.parse(server) + } modal.children('.header').text((server ? '修改' : '添加') + '服务器') modal.find('.positive.button').html(server ? '修改' : '添加') modal.find('input[name=id]').val(server ? server.ID : null) diff --git a/resource/template/common/footer.html b/resource/template/common/footer.html index 45b394a..7aade5d 100644 --- a/resource/template/common/footer.html +++ b/resource/template/common/footer.html @@ -8,7 +8,7 @@ - + diff --git a/resource/template/common/header.html b/resource/template/common/header.html index 2674067..2091551 100644 --- a/resource/template/common/header.html +++ b/resource/template/common/header.html @@ -9,7 +9,7 @@ {{.Title}} - + diff --git a/resource/template/page/server.html b/resource/template/page/server.html index 5971d38..b85d76a 100644 --- a/resource/template/page/server.html +++ b/resource/template/page/server.html @@ -16,6 +16,7 @@ ID 备注 密钥 + 最后活跃 管理 @@ -25,9 +26,10 @@ {{$server.ID}} {{$server.Name}} {{$server.Secret}} + {{$server.LastActive}}
-