mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
显示SSH认证相关集群、节点
This commit is contained in:
@@ -3,7 +3,7 @@ package node
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package node
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package clusters
|
package clusterutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
|
|||||||
@@ -1,23 +1,29 @@
|
|||||||
package clusters
|
package clusterutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Helper struct {
|
type ClustersHelper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHelper() *Helper {
|
func NewClustersHelper() *ClustersHelper {
|
||||||
return &Helper{}
|
return &ClustersHelper{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
func (this *ClustersHelper) BeforeAction(action *actions.ActionObject) {
|
||||||
|
if action.Request.Method != http.MethodGet {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
action.Data["teaMenu"] = "clusters"
|
action.Data["teaMenu"] = "clusters"
|
||||||
|
|
||||||
selectedTabbar, _ := action.Data["mainTab"]
|
selectedTabbar, _ := action.Data["mainTab"]
|
||||||
|
|
||||||
tabbar := actionutils.NewTabbar()
|
tabbar := actionutils.NewTabbar()
|
||||||
tabbar.Add("集群", "", "/clusters", "", selectedTabbar == "cluster")
|
tabbar.Add("集群", "", "/clusters", "", selectedTabbar == "cluster")
|
||||||
|
tabbar.Add("SSH认证", "", "/clusters/grants", "", selectedTabbar == "grant")
|
||||||
actionutils.SetTabbar(action, tabbar)
|
actionutils.SetTabbar(action, tabbar)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
44
internal/web/actions/default/clusters/grants/delete.go
Normal file
44
internal/web/actions/default/clusters/grants/delete.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package grants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *DeleteAction) RunPost(params struct {
|
||||||
|
GrantId int64
|
||||||
|
}) {
|
||||||
|
// 检查是否有别的集群或节点正在使用
|
||||||
|
countResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClustersWithGrantId(this.AdminContext(), &pb.CountAllEnabledNodeClustersWithGrantIdRequest{
|
||||||
|
GrantId: params.GrantId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if countResp.Count > 0 {
|
||||||
|
this.Fail("有集群正在使用此服务,请修改后再删除")
|
||||||
|
}
|
||||||
|
|
||||||
|
countResp2, err := this.RPC().NodeRPC().CountAllEnabledNodesWithGrantId(this.AdminContext(), &pb.CountAllEnabledNodesWithGrantIdRequest{GrantId: params.GrantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if countResp2.Count > 0 {
|
||||||
|
this.Fail("有节点正在使用此服务,请修改后再删除")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
_, err = this.RPC().NodeGrantRPC().DisableNodeGrant(this.AdminContext(), &pb.DisableNodeGrantRequest{GrantId: params.GrantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
88
internal/web/actions/default/clusters/grants/grant.go
Normal file
88
internal/web/actions/default/clusters/grants/grant.go
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
package grants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GrantAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GrantAction) Init() {
|
||||||
|
this.Nav("", "grant", "index")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *GrantAction) RunGet(params struct {
|
||||||
|
GrantId int64
|
||||||
|
}) {
|
||||||
|
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledGrant(this.AdminContext(), &pb.FindEnabledGrantRequest{GrantId: params.GrantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if grantResp.Grant == nil {
|
||||||
|
this.WriteString("can not find the grant")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO 处理节点专用的认证
|
||||||
|
|
||||||
|
grant := grantResp.Grant
|
||||||
|
this.Data["grant"] = maps.Map{
|
||||||
|
"id": grant.Id,
|
||||||
|
"name": grant.Name,
|
||||||
|
"method": grant.Method,
|
||||||
|
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
||||||
|
"username": grant.Username,
|
||||||
|
"password": grant.Password,
|
||||||
|
"privateKey": grant.PrivateKey,
|
||||||
|
"description": grant.Description,
|
||||||
|
"su": grant.Su,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用此认证的集群
|
||||||
|
clusterMaps := []maps.Map{}
|
||||||
|
clustersResp, err := this.RPC().NodeClusterRPC().FindAllEnabledNodeClustersWithGrantId(this.AdminContext(), &pb.FindAllEnabledNodeClustersWithGrantIdRequest{GrantId: params.GrantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, cluster := range clustersResp.Clusters {
|
||||||
|
clusterMaps = append(clusterMaps, maps.Map{
|
||||||
|
"id": cluster.Id,
|
||||||
|
"name": cluster.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["clusters"] = clusterMaps
|
||||||
|
|
||||||
|
// 使用此认证的节点
|
||||||
|
nodeMaps := []maps.Map{}
|
||||||
|
nodesResp, err := this.RPC().NodeRPC().FindAllEnabledNodesWithGrantId(this.AdminContext(), &pb.FindAllEnabledNodesWithGrantIdRequest{GrantId: params.GrantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, node := range nodesResp.Nodes {
|
||||||
|
if node.Cluster == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
clusterMap := maps.Map{
|
||||||
|
"id": node.Cluster.Id,
|
||||||
|
"name": node.Cluster.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeMaps = append(nodeMaps, maps.Map{
|
||||||
|
"id": node.Id,
|
||||||
|
"name": node.Name,
|
||||||
|
"cluster": clusterMap,
|
||||||
|
"isOn": node.IsOn,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["nodes"] = nodeMaps
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -34,6 +34,22 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
grantMaps := []maps.Map{}
|
grantMaps := []maps.Map{}
|
||||||
for _, grant := range grantsResp.Grants {
|
for _, grant := range grantsResp.Grants {
|
||||||
|
// 集群数
|
||||||
|
countClustersResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClustersWithGrantId(this.AdminContext(), &pb.CountAllEnabledNodeClustersWithGrantIdRequest{GrantId: grant.Id})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
countClusters := countClustersResp.Count
|
||||||
|
|
||||||
|
// 节点数
|
||||||
|
countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesWithGrantId(this.AdminContext(), &pb.CountAllEnabledNodesWithGrantIdRequest{GrantId: grant.Id})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
countNodes := countNodesResp.Count
|
||||||
|
|
||||||
grantMaps = append(grantMaps, maps.Map{
|
grantMaps = append(grantMaps, maps.Map{
|
||||||
"id": grant.Id,
|
"id": grant.Id,
|
||||||
"name": grant.Name,
|
"name": grant.Name,
|
||||||
@@ -41,6 +57,8 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
"type": grant.Method,
|
"type": grant.Method,
|
||||||
"name": grantutils.FindGrantMethodName(grant.Method),
|
"name": grantutils.FindGrantMethodName(grant.Method),
|
||||||
},
|
},
|
||||||
|
"countClusters": countClusters,
|
||||||
|
"countNodes": countNodes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.Data["grants"] = grantMaps
|
this.Data["grants"] = grantMaps
|
||||||
27
internal/web/actions/default/clusters/grants/init.go
Normal file
27
internal/web/actions/default/clusters/grants/init.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package grants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
|
"github.com/iwind/TeaGo"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||||
|
server.
|
||||||
|
Helper(helpers.NewUserMustAuth()).
|
||||||
|
Helper(clusterutils.NewClustersHelper()).
|
||||||
|
Prefix("/clusters/grants").
|
||||||
|
|
||||||
|
// 授权管理
|
||||||
|
Get("", new(IndexAction)).
|
||||||
|
GetPost("/create", new(CreateAction)).
|
||||||
|
GetPost("/update", new(UpdateAction)).
|
||||||
|
Post("/delete", new(DeleteAction)).
|
||||||
|
Get("/grant", new(GrantAction)).
|
||||||
|
GetPost("/selectPopup", new(SelectPopupAction)).
|
||||||
|
GetPost("/createPopup", new(CreatePopupAction)).
|
||||||
|
GetPost("/updatePopup", new(UpdatePopupAction)).
|
||||||
|
EndAll()
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
@@ -13,7 +13,7 @@ type UpdateAction struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *UpdateAction) Init() {
|
func (this *UpdateAction) Init() {
|
||||||
this.Nav("", "", "")
|
this.Nav("", "grant", "update")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *UpdateAction) RunGet(params struct {
|
func (this *UpdateAction) RunGet(params struct {
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package grants
|
package grants
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package clusters
|
package clusters
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
"github.com/iwind/TeaGo"
|
"github.com/iwind/TeaGo"
|
||||||
)
|
)
|
||||||
@@ -9,7 +10,7 @@ func init() {
|
|||||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||||
server.
|
server.
|
||||||
Helper(helpers.NewUserMustAuth()).
|
Helper(helpers.NewUserMustAuth()).
|
||||||
Helper(NewHelper()).
|
Helper(clusterutils.NewClustersHelper()).
|
||||||
Prefix("/clusters").
|
Prefix("/clusters").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
GetPost("/create", new(CreateAction)).
|
GetPost("/create", new(CreateAction)).
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package grants
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DeleteAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *DeleteAction) RunPost(params struct {
|
|
||||||
GrantId int64
|
|
||||||
}) {
|
|
||||||
_, err := this.RPC().NodeGrantRPC().DisableNodeGrant(this.AdminContext(), &pb.DisableNodeGrantRequest{GrantId: params.GrantId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Success()
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package grants
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *GrantAction) Init() {
|
|
||||||
this.Nav("", "grant", "index")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *GrantAction) RunGet(params struct {
|
|
||||||
GrantId int64
|
|
||||||
}) {
|
|
||||||
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledGrant(this.AdminContext(), &pb.FindEnabledGrantRequest{GrantId: params.GrantId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if grantResp.Grant == nil {
|
|
||||||
this.WriteString("can not find the grant")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO 处理节点专用的认证
|
|
||||||
|
|
||||||
grant := grantResp.Grant
|
|
||||||
this.Data["grant"] = maps.Map{
|
|
||||||
"id": grant.Id,
|
|
||||||
"name": grant.Name,
|
|
||||||
"method": grant.Method,
|
|
||||||
"methodName": grantutils.FindGrantMethodName(grant.Method),
|
|
||||||
"username": grant.Username,
|
|
||||||
"password": grant.Password,
|
|
||||||
"privateKey": grant.PrivateKey,
|
|
||||||
"description": grant.Description,
|
|
||||||
"su": grant.Su,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package nodes
|
package nodes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||||
"github.com/iwind/TeaGo"
|
"github.com/iwind/TeaGo"
|
||||||
@@ -19,15 +18,6 @@ func init() {
|
|||||||
GetPost("/ipAddresses/createPopup", new(ipAddresses.CreatePopupAction)).
|
GetPost("/ipAddresses/createPopup", new(ipAddresses.CreatePopupAction)).
|
||||||
GetPost("/ipAddresses/updatePopup", new(ipAddresses.UpdatePopupAction)).
|
GetPost("/ipAddresses/updatePopup", new(ipAddresses.UpdatePopupAction)).
|
||||||
|
|
||||||
// 授权管理
|
|
||||||
Get("/grants", new(grants.IndexAction)).
|
|
||||||
GetPost("/grants/create", new(grants.CreateAction)).
|
|
||||||
GetPost("/grants/update", new(grants.UpdateAction)).
|
|
||||||
Post("/grants/delete", new(grants.DeleteAction)).
|
|
||||||
Get("/grants/grant", new(grants.GrantAction)).
|
|
||||||
GetPost("/grants/selectPopup", new(grants.SelectPopupAction)).
|
|
||||||
GetPost("/grants/createPopup", new(grants.CreatePopupAction)).
|
|
||||||
GetPost("/grants/updatePopup", new(grants.UpdatePopupAction)).
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings"
|
||||||
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/csrf"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/csrf"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dashboard"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Vue.component("grant-selector", {
|
|||||||
// 选择授权
|
// 选择授权
|
||||||
select: function () {
|
select: function () {
|
||||||
let that = this;
|
let that = this;
|
||||||
teaweb.popup("/nodes/grants/selectPopup", {
|
teaweb.popup("/clusters/grants/selectPopup", {
|
||||||
callback: (resp) => {
|
callback: (resp) => {
|
||||||
that.grantId = resp.data.grant.id;
|
that.grantId = resp.data.grant.id;
|
||||||
if (that.grantId > 0) {
|
if (that.grantId > 0) {
|
||||||
@@ -22,7 +22,7 @@ Vue.component("grant-selector", {
|
|||||||
|
|
||||||
// 创建授权
|
// 创建授权
|
||||||
create: function () {
|
create: function () {
|
||||||
teaweb.popup("/nodes/grants/createPopup", {
|
teaweb.popup("/clusters/grants/createPopup", {
|
||||||
height: "31em",
|
height: "31em",
|
||||||
callback: (resp) => {
|
callback: (resp) => {
|
||||||
this.grantId = resp.data.grant.id;
|
this.grantId = resp.data.grant.id;
|
||||||
@@ -39,7 +39,7 @@ Vue.component("grant-selector", {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
teaweb.popup("/nodes/grants/updatePopup?grantId=" + this.grant.id, {
|
teaweb.popup("/clusters/grants/updatePopup?grantId=" + this.grant.id, {
|
||||||
height: "31em",
|
height: "31em",
|
||||||
callback: (resp) => {
|
callback: (resp) => {
|
||||||
this.grant = resp.data.grant;
|
this.grant = resp.data.grant;
|
||||||
|
|||||||
6
web/views/@default/clusters/grants/@grant_menu.html
Normal file
6
web/views/@default/clusters/grants/@grant_menu.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<first-menu>
|
||||||
|
<menu-item href="/clusters/grants">认证列表</menu-item>
|
||||||
|
<span class="item">|</span>
|
||||||
|
<menu-item :href="'/clusters/grants/grant?grantId=' + grant.id" code="index">{{grant.name}}详情</menu-item>
|
||||||
|
<menu-item :href="'/clusters/grants/update?grantId=' + grant.id" code="update">修改</menu-item>
|
||||||
|
</first-menu>
|
||||||
4
web/views/@default/clusters/grants/@menu.html
Normal file
4
web/views/@default/clusters/grants/@menu.html
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<first-menu>
|
||||||
|
<menu-item href="/clusters/grants" code="index">认证列表</menu-item>
|
||||||
|
<menu-item href="/clusters/grants/create" code="create">创建认证</menu-item>
|
||||||
|
</first-menu>
|
||||||
@@ -47,12 +47,17 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
|
</tr>
|
||||||
|
<tbody v-show="moreOptionsVisible">
|
||||||
<tr>
|
<tr>
|
||||||
<td>描述</td>
|
<td>描述</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea name="description" rows="3"></textarea>
|
<textarea name="description" rows="3"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
5
web/views/@default/clusters/grants/create.js
Normal file
5
web/views/@default/clusters/grants/create.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.method = "user";
|
||||||
|
|
||||||
|
this.success = NotifySuccess("保存成功", "/clusters/grants");
|
||||||
|
});
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "grant_menu"}
|
||||||
|
|
||||||
<second-menu>
|
|
||||||
<menu-item :href="'/nodes/grants/grant?grantId=' + grant.id" active="true">详情</menu-item>
|
|
||||||
<menu-item :href="'/nodes/grants/update?grantId=' + grant.id">修改</menu-item>
|
|
||||||
</second-menu>
|
|
||||||
|
|
||||||
<table class="ui table selectable definition">
|
<table class="ui table selectable definition">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -56,3 +51,17 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<h3>使用此认证的集群</h3>
|
||||||
|
<div>
|
||||||
|
<p v-if="clusters.length == 0" class="comment">暂时还没有集群使用此认证。</p>
|
||||||
|
<a :href="'/clusters/cluster?clusterId=' + cluster.id" class="ui label small" v-for="cluster in clusters">{{cluster.name}}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<h3>使用此认证的节点</h3>
|
||||||
|
<div>
|
||||||
|
<p v-if="nodes.length == 0" class="comment">暂时还没有节点使用此认证。</p>
|
||||||
|
<a :href="'/clusters/cluster/node?clusterId=' + node.cluster.id + '&nodeId=' + node.id" class="ui label small" :class="{red:!node.isOn}" v-for="node in nodes">{{node.name}}<span class="small">({{node.cluster.name}})</span></a>
|
||||||
|
</div>
|
||||||
37
web/views/@default/clusters/grants/index.html
Normal file
37
web/views/@default/clusters/grants/index.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<div class="ui message" v-if="grants.length == 0">暂时还没有认证信息。</div>
|
||||||
|
|
||||||
|
<table class="ui table selectable" v-if="grants.length > 0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>类型</th>
|
||||||
|
<th>集群数</th>
|
||||||
|
<th>节点数</th>
|
||||||
|
<th class="two op">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr v-for="grant in grants">
|
||||||
|
<td>{{grant.id}}</td>
|
||||||
|
<td>{{grant.name}}</td>
|
||||||
|
<td>
|
||||||
|
<span class="ui label tiny">{{grant.method.name}}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span v-if="grant.countClusters > 0">{{grant.countClusters}}</span>
|
||||||
|
<span v-else class="disabled">0</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span v-if="grant.countNodes > 0">{{grant.countNodes}}</span>
|
||||||
|
<span v-else class="disabled">0</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a :href="'/clusters/grants/grant?grantId=' + grant.id">详情</a> <a href="" @click.prevent="deleteGrant(grant.id)">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="page" v-html="page"></div>
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
<td class="title">选择认证</td>
|
<td class="title">选择认证</td>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="grants.length == 0">暂时还没有可用的认证。</span>
|
<span v-if="grants.length == 0">暂时还没有可用的认证。</span>
|
||||||
<a class="ui label small" v-for="grant in grants" :class="{blue:grantId == grant.id}" @click.prevent="selectGrant(grant)">{{grant.name}} <span class="small">({{grant.methodName}})</span></a>
|
<a class="ui label small" v-for="grant in grants" :class="{blue:grantId == grant.id}" @click.prevent="selectGrant(grant)" style="margin-bottom:0.5em">{{grant.name}} <span class="small">({{grant.methodName}})</span></a>
|
||||||
|
<p class="comment">请点击选中某个认证。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
{$layout}
|
{$layout}
|
||||||
{$template "menu"}
|
{$template "grant_menu"}
|
||||||
|
|
||||||
<second-menu>
|
|
||||||
<menu-item :href="'/nodes/grants/grant?grantId=' + grant.id">详情</menu-item>
|
|
||||||
<menu-item :href="'/nodes/grants/update?grantId=' + grant.id" active="true">修改</menu-item>
|
|
||||||
</second-menu>
|
|
||||||
|
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
5
web/views/@default/clusters/grants/update.js
Normal file
5
web/views/@default/clusters/grants/update.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.method = this.grant.method;
|
||||||
|
|
||||||
|
this.success = NotifySuccess("保存成功", "/clusters/grants/grant?grantId=" + this.grant.id);
|
||||||
|
});
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<first-menu>
|
|
||||||
<menu-item href="/nodes/grants" code="index">认证列表</menu-item>
|
|
||||||
<menu-item href="/nodes/grants/create" code="create">创建认证</menu-item>
|
|
||||||
</first-menu>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
Tea.context(function () {
|
|
||||||
this.method = "user";
|
|
||||||
|
|
||||||
this.success = NotifySuccess("保存成功", "/nodes/grants");
|
|
||||||
});
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
{$template "menu"}
|
|
||||||
|
|
||||||
<div class="ui message" v-if="grants.length == 0">暂时还没有认证信息。</div>
|
|
||||||
|
|
||||||
<table class="ui table selectable" v-if="grants.length > 0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th>
|
|
||||||
<th>名称</th>
|
|
||||||
<th>类型</th>
|
|
||||||
<th class="two op">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tr v-for="grant in grants">
|
|
||||||
<td>{{grant.id}}</td>
|
|
||||||
<td>{{grant.name}}</td>
|
|
||||||
<td>{{grant.method.name}}</td>
|
|
||||||
<td>
|
|
||||||
<a :href="'/nodes/grants/grant?grantId=' + grant.id">详情</a> <a href="" @click.prevent="deleteGrant(grant.id)">删除</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="page" v-html="page"></div>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
Tea.context(function () {
|
|
||||||
this.method = this.grant.method;
|
|
||||||
|
|
||||||
this.success = NotifySuccess("保存成功", "/nodes/grants/grant?grantId=" + this.grant.id);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user