增加手动安装节点列表

This commit is contained in:
GoEdgeLab
2020-10-28 12:47:24 +08:00
parent 97b5405fcf
commit 4c8ea8953b
8 changed files with 131 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ func init() {
GetPost("/createNode", new(CreateNodeAction)). GetPost("/createNode", new(CreateNodeAction)).
GetPost("/createBatch", new(CreateBatchAction)). GetPost("/createBatch", new(CreateBatchAction)).
GetPost("/updateNodeSSH", new(UpdateNodeSSHAction)). GetPost("/updateNodeSSH", new(UpdateNodeSSHAction)).
GetPost("/installManual", new(InstallManualAction)).
// 节点相关 // 节点相关
Get("/node", new(node.NodeAction)). Get("/node", new(node.NodeAction)).

View File

@@ -0,0 +1,67 @@
package cluster
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type InstallManualAction struct {
actionutils.ParentAction
}
func (this *InstallManualAction) Init() {
this.Nav("", "node", "install")
this.SecondMenu("nodes")
}
func (this *InstallManualAction) RunGet(params struct {
ClusterId int64
}) {
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "manual")
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{ClusterId: params.ClusterId})
if err != nil {
this.ErrorPage(err)
return
}
nodeMaps := []maps.Map{}
for _, node := range nodesResp.Nodes {
loginParams := maps.Map{}
if node.Login != nil && len(node.Login.Params) > 0 {
err := json.Unmarshal(node.Login.Params, &loginParams)
if err != nil {
this.ErrorPage(err)
return
}
}
installStatus := maps.Map{
"isRunning": false,
"isFinished": false,
}
if node.InstallStatus != nil {
installStatus = maps.Map{
"isRunning": node.InstallStatus.IsRunning,
"isFinished": node.InstallStatus.IsFinished,
"isOk": node.InstallStatus.IsOk,
"error": node.InstallStatus.Error,
}
}
nodeMaps = append(nodeMaps, maps.Map{
"id": node.Id,
"isOn": node.IsOn,
"name": node.Name,
"addresses": node.IpAddresses,
"login": node.Login,
"loginParams": loginParams,
"installStatus": installStatus,
})
}
this.Data["nodes"] = nodeMaps
this.Show()
}

View File

@@ -8,6 +8,11 @@ import (
// 安装升级相关的左侧菜单 // 安装升级相关的左侧菜单
func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map { func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
return []maps.Map{ return []maps.Map{
{
"name": "手动安装",
"url": "/clusters/cluster/installManual?clusterId=" + numberutils.FormatInt64(clusterId),
"isActive": selectedItem == "manual",
},
{ {
"name": "自动注册", "name": "自动注册",
"url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(clusterId), "url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(clusterId),

View File

@@ -1,5 +1,5 @@
<second-menu> <second-menu>
<menu-item :href="'/clusters/cluster?clusterId=' + clusterId" code="index">节点列表</menu-item> <menu-item :href="'/clusters/cluster?clusterId=' + clusterId" code="index">节点列表</menu-item>
<menu-item :href="'/clusters/cluster/createNode?clusterId=' + clusterId" code="create">创建节点</menu-item> <menu-item :href="'/clusters/cluster/createNode?clusterId=' + clusterId" code="create">创建节点</menu-item>
<menu-item :href="'/clusters/cluster/installNodes?clusterId=' + clusterId" code="install">安装升级</menu-item> <menu-item :href="'/clusters/cluster/installManual?clusterId=' + clusterId" code="install">安装升级</menu-item>
</second-menu> </second-menu>

View File

@@ -0,0 +1,7 @@
.left-box {
top: 10em;
}
.right-box {
top: 10em;
}
/*# sourceMappingURL=installManual.css.map */

View File

@@ -0,0 +1 @@
{"version":3,"sources":["installManual.less"],"names":[],"mappings":"AAAA;EACC,SAAA;;AAGD;EACC,SAAA","file":"installManual.css"}

View File

@@ -0,0 +1,42 @@
{$layout}
{$template "menu"}
{$template "/left_menu"}
<div class="right-box">
<p class="comment" v-if="nodes.length == 0">暂时没有需要远程安装的节点。</p>
<div v-if="nodes.length > 0">
<h3>所有未安装节点</h3>
<table class="ui table selectable">
<thead>
<tr>
<th>节点名</th>
<th>访问IP</th>
<th>SSH地址</th>
<th class="four wide">节点状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="node in nodes">
<td>
<a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">{{node.name}}</a>
</td>
<td>
<span v-for="addr in node.addresses" v-if="addr.canAccess" class="ui label tiny">{{addr.ip}}</span>
</td>
<td>
<span v-if="node.login != null && node.login.type == 'ssh' && node.loginParams != null && node.loginParams.host != null && node.loginParams.host.length > 0">
{{node.loginParams.host}}:{{node.loginParams.port}}
</span>
<span v-else class="disabled">没有设置</span>
</td>
<td>
<span class="disabled">等待安装</span>
</td>
<td>
<a :href="'/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id">手动安装</a>
</td>
</tr>
</table>
</div>
</div>

View File

@@ -0,0 +1,7 @@
.left-box {
top: 10em;
}
.right-box {
top: 10em;
}