diff --git a/internal/web/actions/default/clusters/index.go b/internal/web/actions/default/clusters/index.go index 80786d3e..4fe3c115 100644 --- a/internal/web/actions/default/clusters/index.go +++ b/internal/web/actions/default/clusters/index.go @@ -145,6 +145,7 @@ func (this *IndexAction) RunGet(params struct { "dnsDomainName": dnsDomainName, "countServers": countServersResp.Count, "timeZone": cluster.TimeZone, + "isPinned": cluster.IsPinned, }) } } diff --git a/internal/web/actions/default/clusters/init.go b/internal/web/actions/default/clusters/init.go index 041a638b..09166295 100644 --- a/internal/web/actions/default/clusters/init.go +++ b/internal/web/actions/default/clusters/init.go @@ -16,6 +16,7 @@ func init() { Prefix("/clusters"). Get("", new(IndexAction)). GetPost("/create", new(CreateAction)). + Post("/pin", new(PinAction)). // 只要登录即可访问的Action EndHelpers(). diff --git a/internal/web/actions/default/clusters/pin.go b/internal/web/actions/default/clusters/pin.go new file mode 100644 index 00000000..244f3918 --- /dev/null +++ b/internal/web/actions/default/clusters/pin.go @@ -0,0 +1,34 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package clusters + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" +) + +type PinAction struct { + actionutils.ParentAction +} + +func (this *PinAction) RunPost(params struct { + ClusterId int64 + IsPinned bool +}) { + if params.IsPinned { + defer this.CreateLogInfo("置顶集群 %d", params.ClusterId) + } else { + defer this.CreateLogInfo("取消置顶集群 %d", params.ClusterId) + } + + _, err := this.RPC().NodeClusterRPC().UpdateNodeClusterPinned(this.AdminContext(), &pb.UpdateNodeClusterPinnedRequest{ + NodeClusterId: params.ClusterId, + IsPinned: params.IsPinned, + }) + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/web/views/@default/clusters/index.css b/web/views/@default/clusters/index.css index e69de29b..0866b91f 100644 --- a/web/views/@default/clusters/index.css +++ b/web/views/@default/clusters/index.css @@ -0,0 +1,21 @@ +.cluster-name-td { + position: relative; +} +.cluster-name-td .icon.pin { + display: none; + position: absolute; + right: 1em; + top: 50%; + margin-top: -0.7em; + opacity: 0.6; +} +.cluster-name-td .icon.visible { + display: inline; +} +.cluster-name-td .icon.opacity { + opacity: 0.3; +} +.cluster-name-td:hover .icon.pin { + display: inline; +} +/*# sourceMappingURL=index.css.map */ \ No newline at end of file diff --git a/web/views/@default/clusters/index.css.map b/web/views/@default/clusters/index.css.map index 66dc9051..0fd65c33 100644 --- a/web/views/@default/clusters/index.css.map +++ b/web/views/@default/clusters/index.css.map @@ -1 +1 @@ -undefined \ No newline at end of file +{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA;EACC,kBAAA;;AADD,gBAGC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,kBAAA;EACA,YAAA;;AATF,gBAYC,MAAK;EACJ,eAAA;;AAbF,gBAgBC,MAAK;EACJ,YAAA;;AAIF,gBAAgB,MACf,MAAK;EACJ,eAAA","file":"index.css"} \ No newline at end of file diff --git a/web/views/@default/clusters/index.html b/web/views/@default/clusters/index.html index 39285c70..64e4cc9f 100644 --- a/web/views/@default/clusters/index.html +++ b/web/views/@default/clusters/index.html @@ -41,11 +41,14 @@ - + {{cluster.name}}
时区:{{cluster.timeZone}}
+ + + {{cluster.countAllNodes}} diff --git a/web/views/@default/clusters/index.js b/web/views/@default/clusters/index.js index 90d6f77a..0954478e 100644 --- a/web/views/@default/clusters/index.js +++ b/web/views/@default/clusters/index.js @@ -4,4 +4,15 @@ Tea.context(function () { this.showLatest = function () { this.latestVisible = !this.latestVisible } + + this.pin = function (clusterId, isPinned) { + this.$post(".pin") + .params({ + clusterId: clusterId, + isPinned: isPinned + }) + .success(function () { + teaweb.reload() + }) + } }) \ No newline at end of file diff --git a/web/views/@default/clusters/index.less b/web/views/@default/clusters/index.less index 39c455f7..7c01d0fe 100644 --- a/web/views/@default/clusters/index.less +++ b/web/views/@default/clusters/index.less @@ -1,2 +1,26 @@ -table a span { +.cluster-name-td { + position: relative; + + .icon.pin { + display: none; + position: absolute; + right: 1em; + top: 50%; + margin-top: -0.7em; + opacity: 0.6; + } + + .icon.visible { + display: inline; + } + + .icon.opacity { + opacity: 0.3; + } +} + +.cluster-name-td:hover { + .icon.pin { + display: inline; + } } \ No newline at end of file