mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 01:10:29 +08:00
增加手动安装节点列表
This commit is contained in:
@@ -23,6 +23,7 @@ func init() {
|
||||
GetPost("/createNode", new(CreateNodeAction)).
|
||||
GetPost("/createBatch", new(CreateBatchAction)).
|
||||
GetPost("/updateNodeSSH", new(UpdateNodeSSHAction)).
|
||||
GetPost("/installManual", new(InstallManualAction)).
|
||||
|
||||
// 节点相关
|
||||
Get("/node", new(node.NodeAction)).
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -8,6 +8,11 @@ import (
|
||||
// 安装升级相关的左侧菜单
|
||||
func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
|
||||
return []maps.Map{
|
||||
{
|
||||
"name": "手动安装",
|
||||
"url": "/clusters/cluster/installManual?clusterId=" + numberutils.FormatInt64(clusterId),
|
||||
"isActive": selectedItem == "manual",
|
||||
},
|
||||
{
|
||||
"name": "自动注册",
|
||||
"url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(clusterId),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<second-menu>
|
||||
<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/installNodes?clusterId=' + clusterId" code="install">安装升级</menu-item>
|
||||
<menu-item :href="'/clusters/cluster/installManual?clusterId=' + clusterId" code="install">安装升级</menu-item>
|
||||
</second-menu>
|
||||
7
web/views/@default/clusters/cluster/installManual.css
Normal file
7
web/views/@default/clusters/cluster/installManual.css
Normal file
@@ -0,0 +1,7 @@
|
||||
.left-box {
|
||||
top: 10em;
|
||||
}
|
||||
.right-box {
|
||||
top: 10em;
|
||||
}
|
||||
/*# sourceMappingURL=installManual.css.map */
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["installManual.less"],"names":[],"mappings":"AAAA;EACC,SAAA;;AAGD;EACC,SAAA","file":"installManual.css"}
|
||||
42
web/views/@default/clusters/cluster/installManual.html
Normal file
42
web/views/@default/clusters/cluster/installManual.html
Normal 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>
|
||||
7
web/views/@default/clusters/cluster/installManual.less
Normal file
7
web/views/@default/clusters/cluster/installManual.less
Normal file
@@ -0,0 +1,7 @@
|
||||
.left-box {
|
||||
top: 10em;
|
||||
}
|
||||
|
||||
.right-box {
|
||||
top: 10em;
|
||||
}
|
||||
Reference in New Issue
Block a user