mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
增加删除API节点功能
This commit is contained in:
22
internal/web/actions/default/api/delete.go
Normal file
22
internal/web/actions/default/api/delete.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
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 {
|
||||||
|
NodeId int64
|
||||||
|
}) {
|
||||||
|
_, err := this.RPC().APINodeRPC().DeleteAPINode(this.AdminContext(), &pb.DeleteAPINodeRequest{NodeId: params.NodeId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ func init() {
|
|||||||
Prefix("/api").
|
Prefix("/api").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
GetPost("/node/createPopup", new(node.CreatePopupAction)).
|
GetPost("/node/createPopup", new(node.CreatePopupAction)).
|
||||||
|
Post("/delete", new(DeleteAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ func (this *CreateAddrPopupAction) RunPost(params struct {
|
|||||||
params.Must.
|
params.Must.
|
||||||
Field("addr", params.Addr).
|
Field("addr", params.Addr).
|
||||||
Require("请输入访问地址")
|
Require("请输入访问地址")
|
||||||
|
|
||||||
host, port, err := net.SplitHostPort(params.Addr)
|
host, port, err := net.SplitHostPort(params.Addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.FailField("addr", "错误的访问地址")
|
this.FailField("addr", "错误的访问地址")
|
||||||
|
|||||||
@@ -26,7 +26,8 @@
|
|||||||
<label-on :v-is-on="node.isOn"></label-on>
|
<label-on :v-is-on="node.isOn"></label-on>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a :href="'/api/node/settings?nodeId=' + node.id">设置</a>
|
<a :href="'/api/node/settings?nodeId=' + node.id">设置</a>
|
||||||
|
<a href="" @click.prevent="deleteNode(node.id)">删除</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
|
// 创建节点
|
||||||
this.createNode = function () {
|
this.createNode = function () {
|
||||||
teaweb.popup("/api/node/createPopup", {
|
teaweb.popup("/api/node/createPopup", {
|
||||||
width: "50em",
|
width: "50em",
|
||||||
@@ -10,4 +11,16 @@ Tea.context(function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除节点
|
||||||
|
this.deleteNode = function (nodeId) {
|
||||||
|
let that = this
|
||||||
|
teaweb.confirm("确定要删除此节点吗?", function () {
|
||||||
|
that.$post("/api/delete")
|
||||||
|
.params({
|
||||||
|
nodeId: nodeId
|
||||||
|
})
|
||||||
|
.refresh()
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user