显示SSH认证相关集群、节点

This commit is contained in:
GoEdgeLab
2020-10-25 21:27:28 +08:00
parent cccc64a629
commit f15e64960c
40 changed files with 297 additions and 163 deletions

View File

@@ -3,7 +3,7 @@ package node
import (
"encoding/json"
"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"
)

View File

@@ -3,7 +3,7 @@ package node
import (
"encoding/json"
"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/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"

View File

@@ -1,9 +1,9 @@
package settings
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/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/maps"
)

View File

@@ -1,4 +1,4 @@
package clusters
package clusterutils
import (
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"

View File

@@ -1,23 +1,29 @@
package clusters
package clusterutils
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
"net/http"
)
type Helper struct {
type ClustersHelper struct {
}
func NewHelper() *Helper {
return &Helper{}
func NewClustersHelper() *ClustersHelper {
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"
selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar()
tabbar.Add("集群", "", "/clusters", "", selectedTabbar == "cluster")
tabbar.Add("SSH认证", "", "/clusters/grants", "", selectedTabbar == "grant")
actionutils.SetTabbar(action, tabbar)
}

View File

@@ -1,9 +1,9 @@
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/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
)

View File

@@ -1,9 +1,9 @@
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/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/maps"
)

View 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()
}

View 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()
}

View File

@@ -1,9 +1,9 @@
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/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
@@ -34,6 +34,22 @@ func (this *IndexAction) RunGet(params struct{}) {
}
grantMaps := []maps.Map{}
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{
"id": grant.Id,
"name": grant.Name,
@@ -41,6 +57,8 @@ func (this *IndexAction) RunGet(params struct{}) {
"type": grant.Method,
"name": grantutils.FindGrantMethodName(grant.Method),
},
"countClusters": countClusters,
"countNodes": countNodes,
})
}
this.Data["grants"] = grantMaps

View 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()
})
}

View File

@@ -1,9 +1,9 @@
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/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/maps"
)

View File

@@ -1,9 +1,9 @@
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/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/maps"
)
@@ -13,7 +13,7 @@ type UpdateAction struct {
}
func (this *UpdateAction) Init() {
this.Nav("", "", "")
this.Nav("", "grant", "update")
}
func (this *UpdateAction) RunGet(params struct {

View File

@@ -1,9 +1,9 @@
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/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/maps"
)

View File

@@ -1,6 +1,7 @@
package clusters
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
@@ -9,7 +10,7 @@ func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(helpers.NewUserMustAuth()).
Helper(NewHelper()).
Helper(clusterutils.NewClustersHelper()).
Prefix("/clusters").
Get("", new(IndexAction)).
GetPost("/create", new(CreateAction)).

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -1,7 +1,6 @@
package nodes
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/helpers"
"github.com/iwind/TeaGo"
@@ -19,15 +18,6 @@ func init() {
GetPost("/ipAddresses/createPopup", new(ipAddresses.CreatePopupAction)).
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()
})
}

View File

@@ -7,6 +7,7 @@ import (
_ "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/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/dashboard"
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/db"

View File

@@ -10,7 +10,7 @@ Vue.component("grant-selector", {
// 选择授权
select: function () {
let that = this;
teaweb.popup("/nodes/grants/selectPopup", {
teaweb.popup("/clusters/grants/selectPopup", {
callback: (resp) => {
that.grantId = resp.data.grant.id;
if (that.grantId > 0) {
@@ -22,7 +22,7 @@ Vue.component("grant-selector", {
// 创建授权
create: function () {
teaweb.popup("/nodes/grants/createPopup", {
teaweb.popup("/clusters/grants/createPopup", {
height: "31em",
callback: (resp) => {
this.grantId = resp.data.grant.id;
@@ -39,7 +39,7 @@ Vue.component("grant-selector", {
window.location.reload();
return;
}
teaweb.popup("/nodes/grants/updatePopup?grantId=" + this.grant.id, {
teaweb.popup("/clusters/grants/updatePopup?grantId=" + this.grant.id, {
height: "31em",
callback: (resp) => {
this.grant = resp.data.grant;

View 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>

View 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>

View File

@@ -47,12 +47,17 @@
</tr>
</tbody>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>描述</td>
<td>
<textarea name="description" rows="3"></textarea>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,5 @@
Tea.context(function () {
this.method = "user";
this.success = NotifySuccess("保存成功", "/clusters/grants");
});

View File

@@ -1,10 +1,5 @@
{$layout}
{$template "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>
{$template "grant_menu"}
<table class="ui table selectable definition">
<tr>
@@ -56,3 +51,17 @@
</td>
</tr>
</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>

View 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> &nbsp; <a href="" @click.prevent="deleteGrant(grant.id)">删除</a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -9,7 +9,8 @@
<td class="title">选择认证</td>
<td>
<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>
</tr>
</table>

View File

@@ -1,10 +1,5 @@
{$layout}
{$template "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>
{$template "grant_menu"}
<div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success">

View File

@@ -0,0 +1,5 @@
Tea.context(function () {
this.method = this.grant.method;
this.success = NotifySuccess("保存成功", "/clusters/grants/grant?grantId=" + this.grant.id);
});

View File

@@ -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>

View File

@@ -1,5 +0,0 @@
Tea.context(function () {
this.method = "user";
this.success = NotifySuccess("保存成功", "/nodes/grants");
});

View File

@@ -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> &nbsp; <a href="" @click.prevent="deleteGrant(grant.id)">删除</a>
</td>
</tr>
</table>
<div class="page" v-html="page"></div>

View File

@@ -1,5 +0,0 @@
Tea.context(function () {
this.method = this.grant.method;
this.success = NotifySuccess("保存成功", "/nodes/grants/grant?grantId=" + this.grant.id);
});