Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package clientbrowsers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreatePopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Name string
|
||||
Codes []string
|
||||
DataId string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo(codes.ClientBrowser_LogCreateBrowser, params.Name)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入浏览器名称").
|
||||
Field("dataId", params.DataId).
|
||||
Require("请输入数据ID")
|
||||
|
||||
if len(params.Codes) == 0 {
|
||||
params.Codes = []string{params.Name}
|
||||
}
|
||||
|
||||
// 检查dataId
|
||||
browserResp, err := this.RPC().FormalClientBrowserRPC().FindFormalClientBrowserWithDataId(this.AdminContext(), &pb.FindFormalClientBrowserWithDataIdRequest{DataId: params.DataId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if browserResp.FormalClientBrowser != nil {
|
||||
this.Fail("该数据ID已经被 '" + browserResp.FormalClientBrowser.Name + "'所使用,请换一个")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = this.RPC().FormalClientBrowserRPC().CreateFormalClientBrowser(this.AdminContext(), &pb.CreateFormalClientBrowserRequest{
|
||||
Name: params.Name,
|
||||
Codes: params.Codes,
|
||||
DataId: params.DataId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user