2020-09-15 14:44:52 +08:00
|
|
|
package reverseProxy
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/schedulingconfigs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type SchedulingAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *SchedulingAction) Init() {
|
|
|
|
|
this.FirstMenu("scheduling")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *SchedulingAction) RunGet(params struct {
|
|
|
|
|
ServerId int64
|
|
|
|
|
}) {
|
2020-09-21 11:37:24 +08:00
|
|
|
reverseProxyResp, err := this.RPC().ServerRPC().FindAndInitServerReverseProxyConfig(this.AdminContext(), &pb.FindAndInitServerReverseProxyConfigRequest{ServerId: params.ServerId})
|
2020-09-15 14:44:52 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-08-20 15:49:09 +08:00
|
|
|
var reverseProxy = serverconfigs.NewReverseProxyConfig()
|
2020-09-21 19:51:50 +08:00
|
|
|
err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
|
2020-09-15 14:44:52 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
2020-09-21 11:37:24 +08:00
|
|
|
this.Data["reverseProxyId"] = reverseProxy.Id
|
2020-09-15 14:44:52 +08:00
|
|
|
|
|
|
|
|
schedulingCode := reverseProxy.FindSchedulingConfig().Code
|
|
|
|
|
schedulingMap := schedulingconfigs.FindSchedulingType(schedulingCode)
|
|
|
|
|
if schedulingMap == nil {
|
|
|
|
|
this.ErrorPage(errors.New("invalid scheduling code '" + schedulingCode + "'"))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.Data["scheduling"] = schedulingMap
|
|
|
|
|
|
|
|
|
|
this.Show()
|
|
|
|
|
}
|