前端页面
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package policies
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/httpdnsutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("httpdns", "policy", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
httpdnsutils.AddLeftMenu(this.Parent())
|
||||
this.Data["policies"] = loadGlobalPolicies()
|
||||
this.Data["availableClusters"] = loadAvailableDeployClusters()
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
DefaultClusterId int64
|
||||
EnableUserDomainVerify bool
|
||||
DefaultTTL int
|
||||
DefaultFallbackMs int
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
if params.DefaultClusterId <= 0 || !isValidClusterID(params.DefaultClusterId) {
|
||||
this.Fail("please select a valid default cluster")
|
||||
return
|
||||
}
|
||||
|
||||
params.Must.Field("defaultTTL", params.DefaultTTL).Gt(0, "default ttl should be > 0")
|
||||
params.Must.Field("defaultFallbackMs", params.DefaultFallbackMs).Gt(0, "default fallback should be > 0")
|
||||
|
||||
if params.DefaultTTL > 86400 {
|
||||
this.Fail("default TTL should be <= 86400")
|
||||
return
|
||||
}
|
||||
if params.DefaultFallbackMs > 10000 {
|
||||
this.Fail("default fallback should be <= 10000 ms")
|
||||
return
|
||||
}
|
||||
|
||||
saveGlobalPolicies(maps.Map{
|
||||
"defaultClusterId": params.DefaultClusterId,
|
||||
"enableUserDomainVerify": params.EnableUserDomainVerify,
|
||||
"defaultTTL": params.DefaultTTL,
|
||||
"defaultFallbackMs": params.DefaultFallbackMs,
|
||||
})
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
func isValidClusterID(clusterID int64) bool {
|
||||
for _, cluster := range loadAvailableDeployClusters() {
|
||||
if cluster.GetInt64("id") == clusterID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user