50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package apps
|
|
|
|
import (
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/policies"
|
|
"github.com/iwind/TeaGo/actions"
|
|
"github.com/iwind/TeaGo/maps"
|
|
)
|
|
|
|
type CreatePopupAction struct {
|
|
actionutils.ParentAction
|
|
}
|
|
|
|
func (this *CreatePopupAction) Init() {
|
|
this.Nav("", "", "")
|
|
}
|
|
|
|
func (this *CreatePopupAction) RunGet(params struct{}) {
|
|
clusters := policies.LoadAvailableDeployClusters()
|
|
this.Data["clusters"] = clusters
|
|
|
|
defaultClusterID := policies.LoadDefaultClusterID()
|
|
if defaultClusterID <= 0 && len(clusters) > 0 {
|
|
defaultClusterID = clusters[0].GetInt64("id")
|
|
}
|
|
this.Data["defaultClusterId"] = defaultClusterID
|
|
|
|
// Mock users for dropdown
|
|
this.Data["users"] = []maps.Map{
|
|
{"id": int64(1), "name": "张三", "username": "zhangsan"},
|
|
{"id": int64(2), "name": "李四", "username": "lisi"},
|
|
{"id": int64(3), "name": "王五", "username": "wangwu"},
|
|
}
|
|
|
|
this.Show()
|
|
}
|
|
|
|
func (this *CreatePopupAction) RunPost(params struct {
|
|
Name string
|
|
ClusterId int64
|
|
UserId int64
|
|
|
|
Must *actions.Must
|
|
CSRF *actionutils.CSRF
|
|
}) {
|
|
params.Must.Field("name", params.Name).Require("请输入应用名称")
|
|
params.Must.Field("clusterId", params.ClusterId).Gt(0, "请选择所属集群")
|
|
this.Success()
|
|
}
|