From 9bc6c22bd2217dfee677cfbdce9270a5f3bcfc2c Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 12 Oct 2021 11:43:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E4=B8=AD=E6=8C=87=E5=AE=9A=E8=8A=82=E7=82=B9=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clusters/cluster/settings/index.go | 14 ++++++++++++ .../clusters/cluster/settings/index.html | 18 ++++++++++++++- .../clusters/cluster/settings/index.js | 22 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/internal/web/actions/default/clusters/cluster/settings/index.go b/internal/web/actions/default/clusters/cluster/settings/index.go index f5278b84..8c441fb2 100644 --- a/internal/web/actions/default/clusters/cluster/settings/index.go +++ b/internal/web/actions/default/clusters/cluster/settings/index.go @@ -4,6 +4,7 @@ import ( "github.com/TeaOSLab/EdgeAdmin/internal/oplogs" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" @@ -21,6 +22,7 @@ func (this *IndexAction) Init() { func (this *IndexAction) RunGet(params struct { ClusterId int64 }) { + // 基本信息 clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: params.ClusterId}) if err != nil { this.ErrorPage(err) @@ -53,10 +55,20 @@ func (this *IndexAction) RunGet(params struct { } this.Data["grant"] = grantMap + // 时区 + this.Data["timeZoneGroups"] = nodeconfigs.FindAllTimeZoneGroups() + this.Data["timeZoneLocations"] = nodeconfigs.FindAllTimeZoneLocations() + + if len(cluster.TimeZone) == 0 { + cluster.TimeZone = nodeconfigs.DefaultTimeZoneLocation + } + this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(cluster.TimeZone) + this.Data["cluster"] = maps.Map{ "id": cluster.Id, "name": cluster.Name, "installDir": cluster.InstallDir, + "timeZone": cluster.TimeZone, } this.Show() @@ -68,6 +80,7 @@ func (this *IndexAction) RunPost(params struct { Name string GrantId int64 InstallDir string + TimeZone string Must *actions.Must }) { @@ -83,6 +96,7 @@ func (this *IndexAction) RunPost(params struct { Name: params.Name, NodeGrantId: params.GrantId, InstallDir: params.InstallDir, + TimeZone: params.TimeZone, }) if err != nil { this.ErrorPage(err) diff --git a/web/views/@default/clusters/cluster/settings/index.html b/web/views/@default/clusters/cluster/settings/index.html index 4680e1cb..0495e216 100644 --- a/web/views/@default/clusters/cluster/settings/index.html +++ b/web/views/@default/clusters/cluster/settings/index.html @@ -2,7 +2,6 @@ {$template "/left_menu"}
-

基础设置

@@ -24,6 +23,23 @@

当节点没有单独设置安装目录时,默认使用此设置。如果集群和节点都没有设置安装目录,则使用/$登录用户/edge-node 目录。

+ + + +
时区 +
+
+ +
+
+ +
+
+
diff --git a/web/views/@default/clusters/cluster/settings/index.js b/web/views/@default/clusters/cluster/settings/index.js index 295a9aaf..f8491562 100644 --- a/web/views/@default/clusters/cluster/settings/index.js +++ b/web/views/@default/clusters/cluster/settings/index.js @@ -1,3 +1,25 @@ Tea.context(function () { this.success = NotifyReloadSuccess("保存成功") + + this.timeZoneGroupCode = "asia" + if (this.timeZoneLocation != null) { + this.timeZoneGroupCode = this.timeZoneLocation.group + } + + this.$delay(function () { + this.$watch("timeZoneGroupCode", function (groupCode) { + let firstLocation = null + this.timeZoneLocations.forEach(function (v) { + if (firstLocation != null) { + return + } + if (v.group == groupCode) { + firstLocation = v + } + }) + if (firstLocation != null) { + this.cluster.timeZone = firstLocation.name + } + }) + }) }) \ No newline at end of file