mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
节点可以单独设置所使用的API节点地址
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
@@ -50,6 +51,22 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["dnsResolverConfig"] = dnsResolverConfig
|
||||
|
||||
// API相关
|
||||
apiConfigResp, err := this.RPC().NodeRPC().FindNodeAPIConfig(this.AdminContext(), &pb.FindNodeAPIConfigRequest{NodeId: params.NodeId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var apiNodeAddrs = []*serverconfigs.NetworkAddressConfig{}
|
||||
if len(apiConfigResp.ApiNodeAddrsJSON) > 0 {
|
||||
err = json.Unmarshal(apiConfigResp.ApiNodeAddrsJSON, &apiNodeAddrs)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.Data["apiNodeAddrs"] = apiNodeAddrs
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -59,6 +76,8 @@ func (this *IndexAction) RunPost(params struct {
|
||||
|
||||
DnsResolverJSON []byte
|
||||
|
||||
ApiNodeAddrsJSON []byte
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
@@ -68,6 +87,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
this.Fail("CPU线程数不能小于0")
|
||||
}
|
||||
|
||||
// 系统设置
|
||||
_, err := this.RPC().NodeRPC().UpdateNodeSystem(this.AdminContext(), &pb.UpdateNodeSystemRequest{
|
||||
NodeId: params.NodeId,
|
||||
MaxCPU: params.MaxCPU,
|
||||
@@ -77,6 +97,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
// DNS解析设置
|
||||
var dnsResolverConfig = nodeconfigs.DefaultDNSResolverConfig()
|
||||
err = json.Unmarshal(params.DnsResolverJSON, dnsResolverConfig)
|
||||
if err != nil {
|
||||
@@ -98,5 +119,22 @@ func (this *IndexAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
// API节点设置
|
||||
var apiNodeAddrs = []*serverconfigs.NetworkAddressConfig{}
|
||||
if len(params.ApiNodeAddrsJSON) > 0 {
|
||||
err = json.Unmarshal(params.ApiNodeAddrsJSON, &apiNodeAddrs)
|
||||
if err != nil {
|
||||
this.Fail("API节点地址校验错误:" + err.Error())
|
||||
}
|
||||
}
|
||||
_, err = this.RPC().NodeRPC().UpdateNodeAPIConfig(this.AdminContext(), &pb.UpdateNodeAPIConfigRequest{
|
||||
NodeId: params.NodeId,
|
||||
ApiNodeAddrsJSON: params.ApiNodeAddrsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
|
||||
var tabbar = actionutils.NewTabbar()
|
||||
tabbar.Add("集群列表", "", "/clusters", "", false)
|
||||
if teaconst.IsPlus {
|
||||
tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "board", selectedTabbar == "board")
|
||||
tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board")
|
||||
}
|
||||
tabbar.Add("集群节点", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node")
|
||||
tabbar.Add("集群设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<td class="title">SSH主机地址</td>
|
||||
<td>
|
||||
<input type="text" name="sshHost" maxlength="64" v-model="sshHost"/>
|
||||
<p class="comment"><span v-if="hostIsAutoFilled"><strong>已自动填充,需要保存</strong>。</span>比如192.168.1.100。</p>
|
||||
<p class="comment"><span v-if="hostIsAutoFilled" class="red"><strong>已自动填充</strong>,需要点击"保存"按钮后生效。</span>比如192.168.1.100。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -19,6 +19,19 @@
|
||||
<h4>DNS解析</h4>
|
||||
<dns-resolver-config-box :v-dns-resolver-config="dnsResolverConfig"></dns-resolver-config-box>
|
||||
|
||||
<h4>API相关</h4>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">API节点地址</td>
|
||||
<td>
|
||||
<div style="margin-bottom: 0.5em">
|
||||
<api-node-addresses-box :v-name="'apiNodeAddrsJSON'" :v-addrs="apiNodeAddrs"></api-node-addresses-box>
|
||||
</div>
|
||||
<p class="comment">当前节点单独使用的API节点设置。<pro-warning-label></pro-warning-label></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
</div>
|
||||
@@ -19,4 +19,17 @@ a.small {
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
}
|
||||
.node-name-td {
|
||||
position: relative;
|
||||
}
|
||||
.node-name-td .icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 50%;
|
||||
margin-top: -1em;
|
||||
}
|
||||
.node-name-td:hover .icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
/*# sourceMappingURL=nodes.css.map */
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["nodes.less"],"names":[],"mappings":"AAAA,MAAO;EACN,oBAAA;;AAGD,CACC;EACC,iCAAA;;AAIF,WACC;EACC,kBAAA;EACA,aAAA;;AAIF,WAAW,UACV;EACC,eAAA;EACA,cAAA;;AAIF,WAAW,MACV;EACC,eAAA;;AAIF,CAAC;EACA,gBAAA;EACA,kBAAA","file":"nodes.css"}
|
||||
{"version":3,"sources":["nodes.less"],"names":[],"mappings":"AAAA,MAAO;EACN,oBAAA;;AAGD,CACC;EACC,iCAAA;;AAIF,WACC;EACC,kBAAA;EACA,aAAA;;AAIF,WAAW,UACV;EACC,eAAA;EACA,cAAA;;AAIF,WAAW,MACV;EACC,eAAA;;AAIF,CAAC;EACA,gBAAA;EACA,kBAAA;;AAGD;EACC,kBAAA;;AADD,aAGC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,gBAAA;;AAIF,aAAa,MACZ,MAAK;EACJ,eAAA","file":"nodes.css"}
|
||||
@@ -73,7 +73,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="node in nodes">
|
||||
<td><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}<sup v-if="node.level > 1"><span class="blue"> L{{node.level}}</span></sup></a>
|
||||
<td class="node-name-td"><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}<sup v-if="node.level > 1"><span class="blue"> L{{node.level}}</span></sup></a>
|
||||
|
||||
<a :href="'/clusters/cluster/node/update?clusterId=' + clusterId + '&nodeId=' + node.id" title="设置"><i class="icon setting grey"></i></a>
|
||||
|
||||
<div v-if="node.region != null">
|
||||
<grey-label>区域:{{node.region.name}}</grey-label>
|
||||
</div>
|
||||
|
||||
@@ -31,4 +31,22 @@ a {
|
||||
a.small {
|
||||
font-size: 0.8em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.node-name-td {
|
||||
position: relative;
|
||||
|
||||
.icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 50%;
|
||||
margin-top: -1em;
|
||||
}
|
||||
}
|
||||
|
||||
.node-name-td:hover {
|
||||
.icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,17 @@
|
||||
.cluster-name-td .icon.opacity {
|
||||
opacity: 0.3;
|
||||
}
|
||||
.cluster-name-td .icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 3em;
|
||||
top: 50%;
|
||||
margin-top: -0.7em;
|
||||
}
|
||||
.cluster-name-td:hover .icon.pin {
|
||||
display: inline;
|
||||
}
|
||||
.cluster-name-td:hover .icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
/*# sourceMappingURL=index.css.map */
|
||||
@@ -1 +1 @@
|
||||
{"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"}
|
||||
{"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;;AAjBF,gBAoBC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,kBAAA;;AAIF,gBAAgB,MACf,MAAK;EACJ,eAAA;;AAFF,gBAAgB,MAIf,MAAK;EACJ,eAAA","file":"index.css"}
|
||||
@@ -43,6 +43,9 @@
|
||||
<tr v-for="cluster in clusters">
|
||||
<td class="cluster-name-td">
|
||||
<a :href="'/clusters/cluster?clusterId=' + cluster.id"><keyword :v-word="keyword">{{cluster.name}}</keyword></a>
|
||||
|
||||
<a :href="'/clusters/cluster/settings?clusterId=' + cluster.id" title="设置"><i class="icon setting grey"></i></a>
|
||||
|
||||
<div v-if="cluster.timeZone != null && cluster.timeZone.length > 0">
|
||||
<grey-label>时区:{{cluster.timeZone}}</grey-label>
|
||||
</div>
|
||||
|
||||
@@ -17,10 +17,21 @@
|
||||
.icon.opacity {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 3em;
|
||||
top: 50%;
|
||||
margin-top: -0.7em;
|
||||
}
|
||||
}
|
||||
|
||||
.cluster-name-td:hover {
|
||||
.icon.pin {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
.icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
14
web/views/@default/clusters/nodes.css
Normal file
14
web/views/@default/clusters/nodes.css
Normal file
@@ -0,0 +1,14 @@
|
||||
.node-name-td {
|
||||
position: relative;
|
||||
}
|
||||
.node-name-td .icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 50%;
|
||||
margin-top: -1em;
|
||||
}
|
||||
.node-name-td:hover .icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
/*# sourceMappingURL=nodes.css.map */
|
||||
1
web/views/@default/clusters/nodes.css.map
Normal file
1
web/views/@default/clusters/nodes.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["nodes.less"],"names":[],"mappings":"AAAA;EACC,kBAAA;;AADD,aAGC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,gBAAA;;AAIF,aAAa,MACZ,MAAK;EACJ,eAAA","file":"nodes.css"}
|
||||
@@ -67,7 +67,10 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="node in nodes">
|
||||
<td><a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}<sup v-if="node.level > 1"><span class="blue"> L{{node.level}}</span></sup></a>
|
||||
<td class="node-name-td"><a :href="'/clusters/cluster/node?clusterId=' + node.cluster.id + '&nodeId=' + node.id">{{node.name}}<sup v-if="node.level > 1"><span class="blue"> L{{node.level}}</span></sup></a>
|
||||
|
||||
<a :href="'/clusters/cluster/node/update?clusterId=' + node.cluster.id + '&nodeId=' + node.id" title="设置"><i class="icon setting grey"></i></a>
|
||||
|
||||
<div v-if="node.region != null">
|
||||
<grey-label>区域:{{node.region.name}}</grey-label>
|
||||
</div>
|
||||
|
||||
17
web/views/@default/clusters/nodes.less
Normal file
17
web/views/@default/clusters/nodes.less
Normal file
@@ -0,0 +1,17 @@
|
||||
.node-name-td {
|
||||
position: relative;
|
||||
|
||||
.icon.setting {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 50%;
|
||||
margin-top: -1em;
|
||||
}
|
||||
}
|
||||
|
||||
.node-name-td:hover {
|
||||
.icon.setting {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user