mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
集群设置左侧菜单显示TOA设置状态
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
@@ -148,11 +149,15 @@ func (this *ClusterHelper) createSettingMenu(cluster *pb.NodeCluster, selectedIt
|
|||||||
"url": "/clusters/cluster/settings/services?clusterId=" + clusterId,
|
"url": "/clusters/cluster/settings/services?clusterId=" + clusterId,
|
||||||
"isActive": selectedItem == "service",
|
"isActive": selectedItem == "service",
|
||||||
})
|
})
|
||||||
|
{
|
||||||
|
isChecked, _ := this.checkTOA(cluster.Id)
|
||||||
items = append(items, maps.Map{
|
items = append(items, maps.Map{
|
||||||
"name": "TOA设置",
|
"name": "TOA设置",
|
||||||
"url": "/clusters/cluster/settings/toa?clusterId=" + clusterId,
|
"url": "/clusters/cluster/settings/toa?clusterId=" + clusterId,
|
||||||
"isActive": selectedItem == "toa",
|
"isActive": selectedItem == "toa",
|
||||||
|
"isOn": isChecked,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,3 +225,24 @@ func (this *ClusterHelper) checkMessages(clusterId int64) (bool, error) {
|
|||||||
}
|
}
|
||||||
return resp.Count > 0, nil
|
return resp.Count > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查TOA是否设置
|
||||||
|
func (this *ClusterHelper) checkTOA(clusterId int64) (bool, error) {
|
||||||
|
rpcClient, err := rpc.SharedRPC()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
resp, err := rpcClient.NodeClusterRPC().FindEnabledNodeClusterTOA(rpcClient.Context(0), &pb.FindEnabledNodeClusterTOARequest{NodeClusterId: clusterId})
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if len(resp.ToaJSON) == 0 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
var toaConfig = &nodeconfigs.TOAConfig{}
|
||||||
|
err = json.Unmarshal(resp.ToaJSON, toaConfig)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return toaConfig.IsOn, nil
|
||||||
|
}
|
||||||
|
|||||||
17
internal/web/actions/default/servers/metrics/update.go
Normal file
17
internal/web/actions/default/servers/metrics/update.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package metrics
|
||||||
|
|
||||||
|
import "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
|
||||||
|
type UpdateAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *UpdateAction) Init() {
|
||||||
|
this.Nav("", "", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *UpdateAction) RunGet(params struct{}) {
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
36
web/public/js/components/server/metric-keys-config-box.js
Normal file
36
web/public/js/components/server/metric-keys-config-box.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// 指标对象
|
||||||
|
Vue.component("metric-keys-config-box", {
|
||||||
|
props: ["v-keys"],
|
||||||
|
data: function () {
|
||||||
|
let keys = this.vKeys
|
||||||
|
if (keys == null) {
|
||||||
|
keys = []
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
keys: keys,
|
||||||
|
isAdding: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
template: `<div>
|
||||||
|
<div>
|
||||||
|
<div v-for="key in keys">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" placeholder=""/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<button type="button" class="ui button tiny">确定</button>
|
||||||
|
<a href="" @click.prevent="cancel"><i class="icon remove small"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" class="ui button tiny">+</button>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
47
web/public/js/components/server/metric-period-config-box.js
Normal file
47
web/public/js/components/server/metric-period-config-box.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// 指标周期设置
|
||||||
|
Vue.component("metric-period-config-box", {
|
||||||
|
props: ["v-period", "v-period-unit"],
|
||||||
|
data: function () {
|
||||||
|
let period = this.vPeriod
|
||||||
|
let periodUnit = this.vPeriodUnit
|
||||||
|
if (period == null || period.toString().length == 0) {
|
||||||
|
period = 1
|
||||||
|
}
|
||||||
|
if (periodUnit == null || periodUnit.length == 0) {
|
||||||
|
periodUnit = "day"
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
periodConfig: {
|
||||||
|
period: period,
|
||||||
|
unit: periodUnit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
"periodConfig.period": function (v) {
|
||||||
|
v = parseInt(v)
|
||||||
|
if (isNaN(v) || v <= 0) {
|
||||||
|
v = 1
|
||||||
|
}
|
||||||
|
this.periodConfig.period = v
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: `<div>
|
||||||
|
<input type="hidden" name="periodJSON" :value="JSON.stringify(periodConfig)"/>
|
||||||
|
<div class="ui fields inline">
|
||||||
|
<div class="ui field">
|
||||||
|
<input type="text" v-model="periodConfig.period" maxlength="4" size="4"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<select class="ui dropdown" v-model="periodConfig.unit">
|
||||||
|
<option value="minute">分钟</option>
|
||||||
|
<option value="hour">小时</option>
|
||||||
|
<option value="day">天</option>
|
||||||
|
<option value="week">周</option>
|
||||||
|
<option value="month">月</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="comment">在此周期内同一对象累积为同一数据。</p>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user