前端页面
This commit is contained in:
@@ -19,31 +19,45 @@ 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")
|
||||
defaultPrimaryClusterId := policies.LoadDefaultClusterID()
|
||||
if defaultPrimaryClusterId <= 0 && len(clusters) > 0 {
|
||||
defaultPrimaryClusterId = clusters[0].GetInt64("id")
|
||||
}
|
||||
this.Data["defaultClusterId"] = defaultClusterID
|
||||
this.Data["defaultPrimaryClusterId"] = defaultPrimaryClusterId
|
||||
|
||||
defaultBackupClusterId := int64(0)
|
||||
for _, cluster := range clusters {
|
||||
clusterId := cluster.GetInt64("id")
|
||||
if clusterId > 0 && clusterId != defaultPrimaryClusterId {
|
||||
defaultBackupClusterId = clusterId
|
||||
break
|
||||
}
|
||||
}
|
||||
this.Data["defaultBackupClusterId"] = defaultBackupClusterId
|
||||
|
||||
// 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"},
|
||||
{"id": int64(1), "name": "User A", "username": "zhangsan"},
|
||||
{"id": int64(2), "name": "User B", "username": "lisi"},
|
||||
{"id": int64(3), "name": "User C", "username": "wangwu"},
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Name string
|
||||
ClusterId int64
|
||||
UserId int64
|
||||
Name string
|
||||
PrimaryClusterId int64
|
||||
BackupClusterId int64
|
||||
UserId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.Field("name", params.Name).Require("请输入应用名称")
|
||||
params.Must.Field("clusterId", params.ClusterId).Gt(0, "请选择所属集群")
|
||||
params.Must.Field("name", params.Name).Require("please input app name")
|
||||
params.Must.Field("primaryClusterId", params.PrimaryClusterId).Gt(0, "please select primary cluster")
|
||||
if params.BackupClusterId > 0 && params.BackupClusterId == params.PrimaryClusterId {
|
||||
this.FailField("backupClusterId", "backup cluster must be different from primary cluster")
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user