Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
567ffc80b6 | ||
|
|
5d15a08ac8 | ||
|
|
2b84037346 | ||
|
|
536f11e617 | ||
|
|
5d367a384e | ||
|
|
04933e6bf0 | ||
|
|
12abe9aa69 | ||
|
|
cba642a4bc | ||
|
|
9fce0ac0aa | ||
|
|
681812b619 | ||
|
|
6d0be57698 | ||
|
|
1d521602e1 | ||
|
|
2f67e7937a | ||
|
|
e0078a42dc | ||
|
|
3ec875d49d | ||
|
|
35028d1310 | ||
|
|
7ba3d7c4bb | ||
|
|
c05e64098c | ||
|
|
e82ee56a2c | ||
|
|
5681b61aea | ||
|
|
d6ce7eab25 | ||
|
|
bf597fe41c | ||
|
|
6a920f964f | ||
|
|
977b66ba4e | ||
|
|
4659c29358 | ||
|
|
e3bc95b275 | ||
|
|
bf51255e13 | ||
|
|
915fe6837b | ||
|
|
d1237215c0 | ||
|
|
8ba5cfdfa6 | ||
|
|
0d1097425d | ||
|
|
0789a9ecc8 | ||
|
|
400f764b74 | ||
|
|
46e036e3a4 | ||
|
|
17e6264af8 | ||
|
|
468b6ae125 | ||
|
|
e5f5ee4f6a | ||
|
|
3695082ec2 | ||
|
|
f384d86014 | ||
|
|
34bf5028c3 | ||
|
|
8b727aa939 | ||
|
|
9432600de6 | ||
|
|
bb790ec687 | ||
|
|
8bad658d7c |
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/apps"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
|
||||
@@ -9,10 +10,13 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/nodes"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
_ "github.com/iwind/TeaGo/bootstrap"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/iwind/gosock/pkg/gosock"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -53,6 +57,20 @@ func main() {
|
||||
fmt.Println("[ERROR]reset failed: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// reset local api
|
||||
var apiNodeExe = Tea.Root + "/edge-api/bin/edge-api"
|
||||
_, err = os.Stat(apiNodeExe)
|
||||
if err == nil {
|
||||
var cmd = exec.Command(apiNodeExe, "reset")
|
||||
var stderr = &bytes.Buffer{}
|
||||
cmd.Stderr = stderr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
fmt.Println("reset api node failed: " + stderr.String())
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("done")
|
||||
})
|
||||
app.On("recover", func() {
|
||||
|
||||
@@ -61,10 +61,11 @@ func LoadAPIConfig() (*APIConfig, error) {
|
||||
|
||||
// ResetAPIConfig 重置配置
|
||||
func ResetAPIConfig() error {
|
||||
filename := "api.yaml"
|
||||
var filename = "api.yaml"
|
||||
|
||||
// 重置 configs/api.yaml
|
||||
{
|
||||
configFile := Tea.ConfigFile(filename)
|
||||
var configFile = Tea.ConfigFile(filename)
|
||||
stat, err := os.Stat(configFile)
|
||||
if err == nil && !stat.IsDir() {
|
||||
err = os.Remove(configFile)
|
||||
@@ -77,7 +78,7 @@ func ResetAPIConfig() error {
|
||||
// 重置 ~/.edge-admin/api.yaml
|
||||
homeDir, homeErr := os.UserHomeDir()
|
||||
if homeErr == nil {
|
||||
configFile := homeDir + "/." + teaconst.ProcessName + "/" + filename
|
||||
var configFile = homeDir + "/." + teaconst.ProcessName + "/" + filename
|
||||
stat, err := os.Stat(configFile)
|
||||
if err == nil && !stat.IsDir() {
|
||||
err = os.Remove(configFile)
|
||||
@@ -89,7 +90,7 @@ func ResetAPIConfig() error {
|
||||
|
||||
// 重置 /etc/edge-admin/api.yaml
|
||||
{
|
||||
configFile := "/etc/" + teaconst.ProcessName + "/" + filename
|
||||
var configFile = "/etc/" + teaconst.ProcessName + "/" + filename
|
||||
stat, err := os.Stat(configFile)
|
||||
if err == nil && !stat.IsDir() {
|
||||
err = os.Remove(configFile)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package teaconst
|
||||
|
||||
const (
|
||||
Version = "0.5.4"
|
||||
Version = "0.5.7"
|
||||
|
||||
APINodeVersion = "0.5.4"
|
||||
APINodeVersion = "0.5.7"
|
||||
|
||||
ProductName = "Edge Admin"
|
||||
ProcessName = "edge-admin"
|
||||
|
||||
@@ -98,10 +98,6 @@ func (this *RPCClient) NodeRegionRPC() pb.NodeRegionServiceClient {
|
||||
return pb.NewNodeRegionServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) NodePriceItemRPC() pb.NodePriceItemServiceClient {
|
||||
return pb.NewNodePriceItemServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) NodeIPAddressRPC() pb.NodeIPAddressServiceClient {
|
||||
return pb.NewNodeIPAddressServiceClient(this.pickConn())
|
||||
}
|
||||
@@ -399,26 +395,6 @@ func (this *RPCClient) UserRPC() pb.UserServiceClient {
|
||||
return pb.NewUserServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserBillRPC() pb.UserBillServiceClient {
|
||||
return pb.NewUserBillServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) ServerBillRPC() pb.ServerBillServiceClient {
|
||||
return pb.NewServerBillServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserAccountRPC() pb.UserAccountServiceClient {
|
||||
return pb.NewUserAccountServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserAccountLogRPC() pb.UserAccountLogServiceClient {
|
||||
return pb.NewUserAccountLogServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserAccountDailyStatRPC() pb.UserAccountDailyStatServiceClient {
|
||||
return pb.NewUserAccountDailyStatServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserAccessKeyRPC() pb.UserAccessKeyServiceClient {
|
||||
return pb.NewUserAccessKeyServiceClient(this.pickConn())
|
||||
}
|
||||
@@ -475,14 +451,6 @@ func (this *RPCClient) ServerStatBoardChartRPC() pb.ServerStatBoardChartServiceC
|
||||
return pb.NewServerStatBoardChartServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) PlanRPC() pb.PlanServiceClient {
|
||||
return pb.NewPlanServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) UserPlanRPC() pb.UserPlanServiceClient {
|
||||
return pb.NewUserPlanServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
func (this *RPCClient) TrafficDailyStatRPC() pb.TrafficDailyStatServiceClient {
|
||||
return pb.NewTrafficDailyStatServiceClient(this.pickConn())
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package numberutils
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func FormatInt64(value int64) string {
|
||||
@@ -28,17 +30,35 @@ func FormatBytes(bytes int64) string {
|
||||
if bytes < Pow1024(1) {
|
||||
return FormatInt64(bytes) + "B"
|
||||
} else if bytes < Pow1024(2) {
|
||||
return fmt.Sprintf("%.2fKB", float64(bytes)/float64(Pow1024(1)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fKB", float64(bytes)/float64(Pow1024(1))))
|
||||
} else if bytes < Pow1024(3) {
|
||||
return fmt.Sprintf("%.2fMB", float64(bytes)/float64(Pow1024(2)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fMB", float64(bytes)/float64(Pow1024(2))))
|
||||
} else if bytes < Pow1024(4) {
|
||||
return fmt.Sprintf("%.2fGB", float64(bytes)/float64(Pow1024(3)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fGB", float64(bytes)/float64(Pow1024(3))))
|
||||
} else if bytes < Pow1024(5) {
|
||||
return fmt.Sprintf("%.2fTB", float64(bytes)/float64(Pow1024(4)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fTB", float64(bytes)/float64(Pow1024(4))))
|
||||
} else if bytes < Pow1024(6) {
|
||||
return fmt.Sprintf("%.2fPB", float64(bytes)/float64(Pow1024(5)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fPB", float64(bytes)/float64(Pow1024(5))))
|
||||
} else {
|
||||
return fmt.Sprintf("%.2fEB", float64(bytes)/float64(Pow1024(6)))
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.2fEB", float64(bytes)/float64(Pow1024(6))))
|
||||
}
|
||||
}
|
||||
|
||||
func FormatBits(bits int64) string {
|
||||
if bits < Pow1024(1) {
|
||||
return FormatInt64(bits) + "bps"
|
||||
} else if bits < Pow1024(2) {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fKbps", float64(bits)/float64(Pow1024(1))))
|
||||
} else if bits < Pow1024(3) {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fMbps", float64(bits)/float64(Pow1024(2))))
|
||||
} else if bits < Pow1024(4) {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fGbps", float64(bits)/float64(Pow1024(3))))
|
||||
} else if bits < Pow1024(5) {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fTbps", float64(bits)/float64(Pow1024(4))))
|
||||
} else if bits < Pow1024(6) {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fPbps", float64(bits)/float64(Pow1024(5))))
|
||||
} else {
|
||||
return TrimZeroSuffix(fmt.Sprintf("%.4fEbps", float64(bits)/float64(Pow1024(6))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +82,19 @@ func FormatFloat(f interface{}, decimal int) string {
|
||||
switch x := f.(type) {
|
||||
case float32, float64:
|
||||
var s = fmt.Sprintf("%."+types.String(decimal)+"f", x)
|
||||
|
||||
// 分隔
|
||||
var dotIndex = strings.Index(s, ".")
|
||||
if dotIndex > 0 {
|
||||
var d = s[:dotIndex]
|
||||
var f2 = s[dotIndex:]
|
||||
f2 = strings.TrimRight(strings.TrimRight(f2, "0"), ".")
|
||||
return formatDigit(d) + f2
|
||||
}
|
||||
|
||||
return s
|
||||
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
|
||||
return types.String(x)
|
||||
return formatDigit(types.String(x))
|
||||
case string:
|
||||
return x
|
||||
}
|
||||
@@ -74,3 +104,44 @@ func FormatFloat(f interface{}, decimal int) string {
|
||||
func FormatFloat2(f interface{}) string {
|
||||
return FormatFloat(f, 2)
|
||||
}
|
||||
|
||||
var decimalReg = regexp.MustCompile(`^(\d+\.\d+)([a-zA-Z]+)?$`)
|
||||
|
||||
// TrimZeroSuffix 去除小数数字尾部多余的0
|
||||
func TrimZeroSuffix(s string) string {
|
||||
var matches = decimalReg.FindStringSubmatch(s)
|
||||
if len(matches) < 3 {
|
||||
return s
|
||||
}
|
||||
return strings.TrimRight(strings.TrimRight(matches[1], "0"), ".") + matches[2]
|
||||
}
|
||||
|
||||
func formatDigit(d string) string {
|
||||
if len(d) == 0 {
|
||||
return d
|
||||
}
|
||||
|
||||
var prefix = ""
|
||||
if d[0] < '0' || d[0] > '9' {
|
||||
prefix = d[:1]
|
||||
d = d[1:]
|
||||
}
|
||||
|
||||
var l = len(d)
|
||||
if l > 3 {
|
||||
var pieces = l / 3
|
||||
var commIndex = l - pieces*3
|
||||
var d2 = ""
|
||||
if commIndex > 0 {
|
||||
d2 = d[:commIndex] + ", "
|
||||
}
|
||||
for i := 0; i < pieces; i++ {
|
||||
d2 += d[commIndex+i*3 : commIndex+i*3+3]
|
||||
if i != pieces-1 {
|
||||
d2 += ", "
|
||||
}
|
||||
}
|
||||
return prefix + d2
|
||||
}
|
||||
return prefix + d
|
||||
}
|
||||
|
||||
@@ -33,4 +33,35 @@ func TestFormatFloat(t *testing.T) {
|
||||
t.Log(numberutils.FormatFloat(100.23456, 2))
|
||||
t.Log(numberutils.FormatFloat(100.000023, 2))
|
||||
t.Log(numberutils.FormatFloat(100.012, 2))
|
||||
t.Log(numberutils.FormatFloat(123.012, 2))
|
||||
t.Log(numberutils.FormatFloat(1234.012, 2))
|
||||
t.Log(numberutils.FormatFloat(12345.012, 2))
|
||||
t.Log(numberutils.FormatFloat(123456.012, 2))
|
||||
t.Log(numberutils.FormatFloat(1234567.012, 2))
|
||||
t.Log(numberutils.FormatFloat(12345678.012, 2))
|
||||
t.Log(numberutils.FormatFloat(123456789.012, 2))
|
||||
t.Log(numberutils.FormatFloat(1234567890.012, 2))
|
||||
t.Log(numberutils.FormatFloat(123, 2))
|
||||
t.Log(numberutils.FormatFloat(1234, 2))
|
||||
t.Log(numberutils.FormatFloat(1234.00001, 4))
|
||||
t.Log(numberutils.FormatFloat(1234.56700, 4))
|
||||
t.Log(numberutils.FormatFloat(-1234.56700, 2))
|
||||
t.Log(numberutils.FormatFloat(-221745.12, 2))
|
||||
}
|
||||
|
||||
func TestTrimZeroSuffix(t *testing.T) {
|
||||
for _, s := range []string{
|
||||
"1",
|
||||
"1.0000",
|
||||
"1.10",
|
||||
"100",
|
||||
"100.0000",
|
||||
"100.0",
|
||||
"100.0123",
|
||||
"100.0010",
|
||||
"100.000KB",
|
||||
"100.010MB",
|
||||
} {
|
||||
t.Log(s, "=>", numberutils.TrimZeroSuffix(s))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,6 +318,7 @@ func (this *DetailAction) RunGet(params struct {
|
||||
"level": node.Level,
|
||||
"levelInfo": nodeconfigs.FindNodeLevel(int(node.Level)),
|
||||
"lnAddrs": lnAddrs,
|
||||
"enableIPLists": node.EnableIPLists,
|
||||
|
||||
"status": maps.Map{
|
||||
"isActive": status.IsActive,
|
||||
|
||||
@@ -100,14 +100,15 @@ func (this *UpdateAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
var nodeMap = maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddresses": ipAddressMaps,
|
||||
"cluster": clusterMap,
|
||||
"isOn": node.IsOn,
|
||||
"group": groupMap,
|
||||
"region": regionMap,
|
||||
"level": node.Level,
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddresses": ipAddressMaps,
|
||||
"cluster": clusterMap,
|
||||
"isOn": node.IsOn,
|
||||
"group": groupMap,
|
||||
"region": regionMap,
|
||||
"level": node.Level,
|
||||
"enableIPLists": node.EnableIPLists,
|
||||
}
|
||||
|
||||
if node.LnAddrs == nil {
|
||||
@@ -157,6 +158,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
IsOn bool
|
||||
Level int32
|
||||
LnAddrs []string
|
||||
EnableIPLists bool
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -234,6 +236,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
IsOn: params.IsOn,
|
||||
Level: params.Level,
|
||||
LnAddrs: lnAddrs,
|
||||
EnableIPLists: params.EnableIPLists,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -78,6 +78,11 @@ func (this *IndexAction) RunPost(params struct {
|
||||
HttpAllAllowNodeIP bool
|
||||
HttpAllDefaultDomain string
|
||||
|
||||
HttpAccessLogEnableRequestHeaders bool
|
||||
HttpAccessLogEnableResponseHeaders bool
|
||||
HttpAccessLogCommonRequestHeadersOnly bool
|
||||
HttpAccessLogEnableCookies bool
|
||||
|
||||
LogRecordServerError bool
|
||||
|
||||
Must *actions.Must
|
||||
@@ -123,6 +128,11 @@ func (this *IndexAction) RunPost(params struct {
|
||||
config.HTTPAll.AllowNodeIP = params.HttpAllAllowNodeIP
|
||||
config.HTTPAll.DefaultDomain = params.HttpAllDefaultDomain
|
||||
|
||||
config.HTTPAccessLog.EnableRequestHeaders = params.HttpAccessLogEnableRequestHeaders
|
||||
config.HTTPAccessLog.EnableResponseHeaders = params.HttpAccessLogEnableResponseHeaders
|
||||
config.HTTPAccessLog.CommonRequestHeadersOnly = params.HttpAccessLogCommonRequestHeadersOnly
|
||||
config.HTTPAccessLog.EnableCookies = params.HttpAccessLogEnableCookies
|
||||
|
||||
config.Log.RecordServerError = params.LogRecordServerError
|
||||
|
||||
err = config.Init()
|
||||
|
||||
@@ -45,7 +45,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
grant := grantResp.NodeGrant
|
||||
var grant = grantResp.NodeGrant
|
||||
if grant != nil {
|
||||
grantMap = maps.Map{
|
||||
"id": grant.Id,
|
||||
@@ -79,6 +79,16 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
// SSH参数
|
||||
var sshParams = nodeconfigs.DefaultSSHParams()
|
||||
if len(cluster.SshParamsJSON) > 0 {
|
||||
err = json.Unmarshal(cluster.SshParamsJSON, sshParams)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.Data["cluster"] = maps.Map{
|
||||
"id": cluster.Id,
|
||||
"name": cluster.Name,
|
||||
@@ -89,6 +99,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"clock": clockConfig,
|
||||
"autoRemoteStart": cluster.AutoRemoteStart,
|
||||
"autoInstallNftables": cluster.AutoInstallNftables,
|
||||
"sshParams": sshParams,
|
||||
}
|
||||
|
||||
// 默认值
|
||||
@@ -104,6 +115,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
Name string
|
||||
GrantId int64
|
||||
SshParamsPort int
|
||||
InstallDir string
|
||||
TimeZone string
|
||||
NodeMaxThreads int32
|
||||
@@ -129,6 +141,16 @@ func (this *IndexAction) RunPost(params struct {
|
||||
Lte(int64(nodeconfigs.DefaultMaxThreadsMax), "单节点最大线程数最大值不能大于"+types.String(nodeconfigs.DefaultMaxThreadsMax))
|
||||
}
|
||||
|
||||
// ssh
|
||||
var sshParams = nodeconfigs.DefaultSSHParams()
|
||||
sshParams.Port = params.SshParamsPort
|
||||
sshParamsJSON, err := json.Marshal(sshParams)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
// clock
|
||||
var clockConfig = nodeconfigs.DefaultClockConfig()
|
||||
clockConfig.AutoSync = params.ClockAutoSync
|
||||
clockConfig.Server = params.ClockServer
|
||||
@@ -155,6 +177,7 @@ func (this *IndexAction) RunPost(params struct {
|
||||
ClockJSON: clockConfigJSON,
|
||||
AutoRemoteStart: params.AutoRemoteStart,
|
||||
AutoInstallNftables: params.AutoInstallNftables,
|
||||
SshParamsJSON: sshParamsJSON,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -11,7 +11,7 @@ type IndexAction struct {
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "region")
|
||||
this.Nav("", "", "index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
@@ -20,7 +20,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
regionMaps := []maps.Map{}
|
||||
var regionMaps = []maps.Map{}
|
||||
for _, region := range regionsResp.NodeRegions {
|
||||
countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesWithNodeRegionId(this.AdminContext(), &pb.CountAllEnabledNodesWithNodeRegionIdRequest{NodeRegionId: region.Id})
|
||||
if err != nil {
|
||||
|
||||
@@ -18,9 +18,13 @@ func init() {
|
||||
GetPost("/updatePopup", new(UpdatePopupAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
Post("/sort", new(SortAction)).
|
||||
Get("/nodes", new(NodesAction)).
|
||||
GetPost("/updateNodeRegionPopup", new(UpdateNodeRegionPopupAction)).
|
||||
|
||||
//
|
||||
GetPost("/selectPopup", new(SelectPopupAction)).
|
||||
GetPost("/prices", new(PricesAction)).
|
||||
GetPost("/updatePricePopup", new(UpdatePricePopupAction)).
|
||||
|
||||
//
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions/regionutils"
|
||||
"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
|
||||
BitsFrom int64
|
||||
BitsTo int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称").
|
||||
Field("bitsFrom", params.BitsFrom).
|
||||
Gte(0, "请输入不小于0的整数").
|
||||
Field("bitsTo", params.BitsTo).
|
||||
Gte(0, "请输入不小于0的整数")
|
||||
|
||||
createResp, err := this.RPC().NodePriceItemRPC().CreateNodePriceItem(this.AdminContext(), &pb.CreateNodePriceItemRequest{
|
||||
Name: params.Name,
|
||||
Type: regionutils.PriceTypeTraffic,
|
||||
BitsFrom: params.BitsFrom * 1000 * 1000,
|
||||
BitsTo: params.BitsTo * 1000 * 1000,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
defer this.CreateLogInfo("创建流量价格项目", createResp.NodePriceItemId)
|
||||
this.Success()
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
ItemId int64
|
||||
}) {
|
||||
defer this.CreateLogInfo("删除流量价格项目 %d", params.ItemId)
|
||||
|
||||
_, err := this.RPC().NodePriceItemRPC().DeleteNodePriceItem(this.AdminContext(), &pb.DeleteNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNode)).
|
||||
Data("teaMenu", "clusters").
|
||||
Data("teaSubMenu", "region").
|
||||
Prefix("/clusters/regions/items").
|
||||
GetPost("/createPopup", new(CreatePopupAction)).
|
||||
GetPost("/updatePopup", new(UpdatePopupAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package items
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdatePopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdatePopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdatePopupAction) RunGet(params struct {
|
||||
ItemId int64
|
||||
}) {
|
||||
itemResp, err := this.RPC().NodePriceItemRPC().FindEnabledNodePriceItem(this.AdminContext(), &pb.FindEnabledNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
item := itemResp.NodePriceItem
|
||||
if item == nil {
|
||||
this.NotFound("nodePriceItem", params.ItemId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["item"] = maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"bitsFrom": item.BitsFrom,
|
||||
"bitsTo": item.BitsTo,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdatePopupAction) RunPost(params struct {
|
||||
ItemId int64
|
||||
Name string
|
||||
BitsFrom int64
|
||||
BitsTo int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo("修改流量价格项目 %d", params.ItemId)
|
||||
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称").
|
||||
Field("bitsFrom", params.BitsFrom).
|
||||
Gte(0, "请输入不小于0的整数").
|
||||
Field("bitsTo", params.BitsTo).
|
||||
Gte(0, "请输入不小于0的整数")
|
||||
|
||||
_, err := this.RPC().NodePriceItemRPC().UpdateNodePriceItem(this.AdminContext(), &pb.UpdateNodePriceItemRequest{
|
||||
NodePriceItemId: params.ItemId,
|
||||
Name: params.Name,
|
||||
BitsFrom: params.BitsFrom * 1000 * 1000,
|
||||
BitsTo: params.BitsTo * 1000 * 1000,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
92
internal/web/actions/default/clusters/regions/nodes.go
Normal file
92
internal/web/actions/default/clusters/regions/nodes.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package regions
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type NodesAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *NodesAction) Init() {
|
||||
this.Nav("", "", "node")
|
||||
}
|
||||
|
||||
func (this *NodesAction) RunGet(params struct {
|
||||
RegionId int64
|
||||
}) {
|
||||
this.Data["regionId"] = params.RegionId
|
||||
|
||||
// 所有区域
|
||||
regionsResp, err := this.RPC().NodeRegionRPC().FindAllAvailableNodeRegions(this.AdminContext(), &pb.FindAllAvailableNodeRegionsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var regionMaps = []maps.Map{}
|
||||
for _, region := range regionsResp.NodeRegions {
|
||||
regionMaps = append(regionMaps, maps.Map{
|
||||
"id": region.Id,
|
||||
"name": region.Name,
|
||||
})
|
||||
}
|
||||
this.Data["regions"] = regionMaps
|
||||
|
||||
// 节点数量
|
||||
countResp, err := this.RPC().NodeRPC().CountAllNodeRegionInfo(this.AdminContext(), &pb.CountAllNodeRegionInfoRequest{NodeRegionId: params.RegionId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var page = this.NewPage(countResp.Count)
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
// 节点列表
|
||||
var hasNodesWithoutRegion = false
|
||||
nodesResp, err := this.RPC().NodeRPC().ListNodeRegionInfo(this.AdminContext(), &pb.ListNodeRegionInfoRequest{
|
||||
NodeRegionId: params.RegionId,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var nodeMaps = []maps.Map{}
|
||||
for _, node := range nodesResp.InfoList {
|
||||
// region
|
||||
var regionMap maps.Map
|
||||
if node.NodeRegion != nil {
|
||||
regionMap = maps.Map{
|
||||
"id": node.NodeRegion.Id,
|
||||
"name": node.NodeRegion.Name,
|
||||
}
|
||||
} else {
|
||||
hasNodesWithoutRegion = true
|
||||
}
|
||||
|
||||
// cluster
|
||||
var clusterMap maps.Map
|
||||
if node.NodeCluster != nil {
|
||||
clusterMap = maps.Map{
|
||||
"id": node.NodeCluster.Id,
|
||||
"name": node.NodeCluster.Name,
|
||||
}
|
||||
}
|
||||
|
||||
nodeMaps = append(nodeMaps, maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"region": regionMap,
|
||||
"cluster": clusterMap,
|
||||
})
|
||||
}
|
||||
this.Data["nodes"] = nodeMaps
|
||||
this.Data["hasNodesWithoutRegion"] = hasNodesWithoutRegion
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package regions
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions/regionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type PricesAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *PricesAction) Init() {
|
||||
this.Nav("", "", "price")
|
||||
}
|
||||
|
||||
func (this *PricesAction) RunGet(params struct{}) {
|
||||
// 所有价格项目
|
||||
itemsResp, err := this.RPC().NodePriceItemRPC().FindAllAvailableNodePriceItems(this.AdminContext(), &pb.FindAllAvailableNodePriceItemsRequest{Type: regionutils.PriceTypeTraffic})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
itemMaps := []maps.Map{}
|
||||
for _, item := range itemsResp.NodePriceItems {
|
||||
|
||||
itemMaps = append(itemMaps, maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"bitsFromString": this.formatBits(item.BitsFrom),
|
||||
"bitsToString": this.formatBits(item.BitsTo),
|
||||
})
|
||||
}
|
||||
this.Data["items"] = itemMaps
|
||||
|
||||
// 所有区域
|
||||
regionsResp, err := this.RPC().NodeRegionRPC().FindAllEnabledNodeRegions(this.AdminContext(), &pb.FindAllEnabledNodeRegionsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
regionMaps := []maps.Map{}
|
||||
for _, region := range regionsResp.NodeRegions {
|
||||
pricesMap := map[string]float32{}
|
||||
if len(region.PricesJSON) > 0 {
|
||||
err = json.Unmarshal(region.PricesJSON, &pricesMap)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
regionMaps = append(regionMaps, maps.Map{
|
||||
"id": region.Id,
|
||||
"isOn": region.IsOn,
|
||||
"name": region.Name,
|
||||
"prices": pricesMap,
|
||||
})
|
||||
}
|
||||
this.Data["regions"] = regionMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *PricesAction) formatBits(bits int64) string {
|
||||
sizeHuman := ""
|
||||
if bits < 1000 {
|
||||
sizeHuman = numberutils.FormatInt64(bits) + "BPS"
|
||||
} else if bits < 1_000_000 {
|
||||
sizeHuman = fmt.Sprintf("%.2fKBPS", float64(bits)/1000)
|
||||
} else if bits < 1_000_000_000 {
|
||||
sizeHuman = fmt.Sprintf("%.2fMBPS", float64(bits)/1000/1000)
|
||||
} else if bits < 1_000_000_000_000 {
|
||||
sizeHuman = fmt.Sprintf("%.2fGBPS", float64(bits)/1000/1000/1000)
|
||||
} else if bits < 1_000_000_000_000_000 {
|
||||
sizeHuman = fmt.Sprintf("%.2fTBPS", float64(bits)/1000/1000/1000/1000)
|
||||
} else if bits < 1_000_000_000_000_000_000 {
|
||||
sizeHuman = fmt.Sprintf("%.2fPBPS", float64(bits)/1000/1000/1000/1000/1000)
|
||||
} else {
|
||||
sizeHuman = fmt.Sprintf("%.2fEBPS", float64(bits)/1000/1000/1000/1000/1000/1000)
|
||||
}
|
||||
return sizeHuman
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package regionutils
|
||||
|
||||
const (
|
||||
PriceTypeTraffic = "traffic"
|
||||
)
|
||||
@@ -40,12 +40,18 @@ func (this *SelectPopupAction) RunPost(params struct {
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
if params.RegionId <= 0 {
|
||||
this.Data["region"] = nil
|
||||
this.Success()
|
||||
return
|
||||
}
|
||||
|
||||
regionResp, err := this.RPC().NodeRegionRPC().FindEnabledNodeRegion(this.AdminContext(), &pb.FindEnabledNodeRegionRequest{NodeRegionId: params.RegionId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
region := regionResp.NodeRegion
|
||||
var region = regionResp.NodeRegion
|
||||
if region == nil {
|
||||
this.NotFound("nodeRegion", params.RegionId)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package regions
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdateNodeRegionPopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdateNodeRegionPopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdateNodeRegionPopupAction) RunGet(params struct {
|
||||
NodeId int64
|
||||
RegionId int64
|
||||
}) {
|
||||
// node
|
||||
nodeResp, err := this.RPC().NodeRPC().FindEnabledNode(this.AdminContext(), &pb.FindEnabledNodeRequest{NodeId: params.NodeId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var node = nodeResp.Node
|
||||
if node == nil {
|
||||
this.NotFound("node", params.NodeId)
|
||||
return
|
||||
}
|
||||
this.Data["node"] = maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
}
|
||||
|
||||
// region
|
||||
this.Data["region"] = maps.Map{
|
||||
"id": 0,
|
||||
"name": "",
|
||||
}
|
||||
if params.RegionId > 0 {
|
||||
regionResp, err := this.RPC().NodeRegionRPC().FindEnabledNodeRegion(this.AdminContext(), &pb.FindEnabledNodeRegionRequest{NodeRegionId: params.RegionId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var region = regionResp.NodeRegion
|
||||
if region != nil {
|
||||
this.Data["region"] = maps.Map{
|
||||
"id": region.Id,
|
||||
"name": region.Name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// all regions
|
||||
regionsResp, err := this.RPC().NodeRegionRPC().FindAllAvailableNodeRegions(this.AdminContext(), &pb.FindAllAvailableNodeRegionsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var regionMaps = []maps.Map{}
|
||||
for _, region := range regionsResp.NodeRegions {
|
||||
regionMaps = append(regionMaps, maps.Map{
|
||||
"id": region.Id,
|
||||
"name": region.Name,
|
||||
})
|
||||
}
|
||||
this.Data["regions"] = regionMaps
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdateNodeRegionPopupAction) RunPost(params struct {
|
||||
NodeId int64
|
||||
RegionId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo("修改节点 %d 区域到 %d", params.RegionId)
|
||||
|
||||
_, err := this.RPC().NodeRPC().UpdateNodeRegionInfo(this.AdminContext(), &pb.UpdateNodeRegionInfoRequest{
|
||||
NodeId: params.NodeId,
|
||||
NodeRegionId: params.RegionId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package regions
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpdatePricePopupAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpdatePricePopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpdatePricePopupAction) RunGet(params struct {
|
||||
RegionId int64
|
||||
ItemId int64
|
||||
}) {
|
||||
// 区域
|
||||
regionResp, err := this.RPC().NodeRegionRPC().FindEnabledNodeRegion(this.AdminContext(), &pb.FindEnabledNodeRegionRequest{NodeRegionId: params.RegionId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
region := regionResp.NodeRegion
|
||||
if region == nil {
|
||||
this.NotFound("nodeRegion", params.RegionId)
|
||||
return
|
||||
}
|
||||
this.Data["region"] = maps.Map{
|
||||
"id": region.Id,
|
||||
"isOn": region.IsOn,
|
||||
"name": region.Name,
|
||||
}
|
||||
|
||||
// 当前价格
|
||||
pricesMap := map[string]float32{}
|
||||
if len(region.PricesJSON) > 0 {
|
||||
err = json.Unmarshal(region.PricesJSON, &pricesMap)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.Data["price"] = pricesMap[numberutils.FormatInt64(params.ItemId)]
|
||||
|
||||
// 价格项
|
||||
itemResp, err := this.RPC().NodePriceItemRPC().FindEnabledNodePriceItem(this.AdminContext(), &pb.FindEnabledNodePriceItemRequest{NodePriceItemId: params.ItemId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
item := itemResp.NodePriceItem
|
||||
if item == nil {
|
||||
this.NotFound("nodePriceItem", params.ItemId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["item"] = maps.Map{
|
||||
"id": item.Id,
|
||||
"name": item.Name,
|
||||
"bitsFrom": item.BitsFrom,
|
||||
"bitsTo": item.BitsTo,
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpdatePricePopupAction) RunPost(params struct {
|
||||
RegionId int64
|
||||
ItemId int64
|
||||
Price float32
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo("修改区域 %d-价格项 %d 的价格", params.RegionId, params.ItemId)
|
||||
|
||||
_, err := this.RPC().NodeRegionRPC().UpdateNodeRegionPrice(this.AdminContext(), &pb.UpdateNodeRegionPriceRequest{
|
||||
NodeRegionId: params.RegionId,
|
||||
NodeItemId: params.ItemId,
|
||||
Price: params.Price,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
@@ -76,16 +76,14 @@ func (this *IndexAction) RunPost(params struct{}) {
|
||||
this.Data["dashboard"] = maps.Map{
|
||||
"defaultClusterId": resp.DefaultNodeClusterId,
|
||||
|
||||
"countServers": resp.CountServers,
|
||||
"countNodeClusters": resp.CountNodeClusters,
|
||||
"countNodes": resp.CountNodes,
|
||||
"countOfflineNodes": resp.CountOfflineNodes,
|
||||
"countUsers": resp.CountUsers,
|
||||
"countAPINodes": resp.CountAPINodes,
|
||||
"countOfflineAPINodes": resp.CountOfflineAPINodes,
|
||||
"countDBNodes": resp.CountDBNodes,
|
||||
"countUserNodes": resp.CountUserNodes,
|
||||
"countOfflineUserNodes": resp.CountOfflineUserNodes,
|
||||
"countServers": resp.CountServers,
|
||||
"countNodeClusters": resp.CountNodeClusters,
|
||||
"countNodes": resp.CountNodes,
|
||||
"countOfflineNodes": resp.CountOfflineNodes,
|
||||
"countUsers": resp.CountUsers,
|
||||
"countAPINodes": resp.CountAPINodes,
|
||||
"countOfflineAPINodes": resp.CountOfflineAPINodes,
|
||||
"countDBNodes": resp.CountDBNodes,
|
||||
|
||||
"canGoServers": configloaders.AllowModule(this.AdminId(), configloaders.AdminModuleCodeServer),
|
||||
"canGoNodes": configloaders.AllowModule(this.AdminId(), configloaders.AdminModuleCodeNode),
|
||||
|
||||
@@ -43,7 +43,7 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
}
|
||||
var defaultRoute = dnsResp.DefaultRoute
|
||||
domainName := ""
|
||||
dnsMap := maps.Map{
|
||||
var dnsMap = maps.Map{
|
||||
"dnsName": dnsResp.Name,
|
||||
"domainId": 0,
|
||||
"domainName": "",
|
||||
@@ -76,14 +76,14 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
nodeMaps := []maps.Map{}
|
||||
var nodeMaps = []maps.Map{}
|
||||
for _, node := range nodesResp.Nodes {
|
||||
if len(node.Routes) > 0 {
|
||||
for _, route := range node.Routes {
|
||||
// 检查是否已解析
|
||||
isResolved := false
|
||||
var isResolved = false
|
||||
if cluster.DnsDomainId > 0 && len(cluster.DnsName) > 0 && len(node.IpAddr) > 0 {
|
||||
recordType := "A"
|
||||
var recordType = "A"
|
||||
if utils.IsIPv6(node.IpAddr) {
|
||||
recordType = "AAAA"
|
||||
}
|
||||
@@ -102,9 +102,10 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
nodeMaps = append(nodeMaps, maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddr": node.IpAddr,
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddr": node.IpAddr,
|
||||
"ipAddrId": node.NodeIPAddressId,
|
||||
"route": maps.Map{
|
||||
"name": route.Name,
|
||||
"code": route.Code,
|
||||
@@ -117,7 +118,7 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
// 默认线路
|
||||
var isResolved = false
|
||||
if len(defaultRoute) > 0 {
|
||||
recordType := "A"
|
||||
var recordType = "A"
|
||||
if utils.IsIPv6(node.IpAddr) {
|
||||
recordType = "AAAA"
|
||||
}
|
||||
@@ -135,9 +136,10 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
isResolved = checkResp.IsOk
|
||||
}
|
||||
nodeMaps = append(nodeMaps, maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddr": node.IpAddr,
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"ipAddr": node.IpAddr,
|
||||
"ipAddrId": node.NodeIPAddressId,
|
||||
"route": maps.Map{
|
||||
"name": "",
|
||||
"code": "",
|
||||
@@ -155,7 +157,7 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
serverMaps := []maps.Map{}
|
||||
var serverMaps = []maps.Map{}
|
||||
for _, server := range serversResp.Servers {
|
||||
// 检查是否已解析
|
||||
isResolved := false
|
||||
@@ -198,7 +200,7 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
issueMaps := []maps.Map{}
|
||||
var issueMaps = []maps.Map{}
|
||||
for _, issue := range issuesResp.Issues {
|
||||
issueMaps = append(issueMaps, maps.Map{
|
||||
"target": issue.Target,
|
||||
@@ -218,7 +220,7 @@ func (this *ClusterAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
taskMaps := []maps.Map{}
|
||||
var taskMaps = []maps.Map{}
|
||||
for _, task := range resp.DnsTasks {
|
||||
var clusterMap maps.Map = nil
|
||||
var nodeMap maps.Map = nil
|
||||
|
||||
@@ -22,12 +22,14 @@ func (this *UpdateNodePopupAction) Init() {
|
||||
func (this *UpdateNodePopupAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
NodeId int64
|
||||
IpAddrId int64
|
||||
}) {
|
||||
this.Data["nodeId"] = params.NodeId
|
||||
|
||||
dnsInfoResp, err := this.RPC().NodeRPC().FindEnabledNodeDNS(this.AdminContext(), &pb.FindEnabledNodeDNSRequest{
|
||||
NodeId: params.NodeId,
|
||||
NodeClusterId: params.ClusterId,
|
||||
NodeIPAddrId: params.IpAddrId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -39,12 +41,13 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
||||
return
|
||||
}
|
||||
this.Data["ipAddr"] = dnsInfo.IpAddr
|
||||
this.Data["ipAddrId"] = dnsInfo.NodeIPAddressId
|
||||
this.Data["routes"] = domainutils.ConvertRoutesToMaps(dnsInfo)
|
||||
this.Data["domainId"] = dnsInfo.DnsDomainId
|
||||
this.Data["domainName"] = dnsInfo.DnsDomainName
|
||||
|
||||
// 读取所有线路
|
||||
allRouteMaps := []maps.Map{}
|
||||
var allRouteMaps = []maps.Map{}
|
||||
if dnsInfo.DnsDomainId > 0 {
|
||||
routesResp, err := this.RPC().DNSDomainRPC().FindAllDNSDomainRoutes(this.AdminContext(), &pb.FindAllDNSDomainRoutesRequest{DnsDomainId: dnsInfo.DnsDomainId})
|
||||
if err != nil {
|
||||
@@ -75,6 +78,7 @@ func (this *UpdateNodePopupAction) RunGet(params struct {
|
||||
func (this *UpdateNodePopupAction) RunPost(params struct {
|
||||
NodeId int64
|
||||
IpAddr string
|
||||
IpAddrId int64
|
||||
DomainId int64
|
||||
DnsRoutesJSON []byte
|
||||
|
||||
@@ -84,7 +88,7 @@ func (this *UpdateNodePopupAction) RunPost(params struct {
|
||||
// 操作日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "修改节点 %d 的DNS设置", params.NodeId)
|
||||
|
||||
routes := []string{}
|
||||
var routes = []string{}
|
||||
if len(params.DnsRoutesJSON) > 0 {
|
||||
err := json.Unmarshal(params.DnsRoutesJSON, &routes)
|
||||
if err != nil {
|
||||
@@ -103,10 +107,11 @@ func (this *UpdateNodePopupAction) RunPost(params struct {
|
||||
|
||||
// 执行修改
|
||||
_, err := this.RPC().NodeRPC().UpdateNodeDNS(this.AdminContext(), &pb.UpdateNodeDNSRequest{
|
||||
NodeId: params.NodeId,
|
||||
IpAddr: params.IpAddr,
|
||||
DnsDomainId: params.DomainId,
|
||||
Routes: routes,
|
||||
NodeId: params.NodeId,
|
||||
IpAddr: params.IpAddr,
|
||||
NodeIPAddressId: params.IpAddrId,
|
||||
DnsDomainId: params.DomainId,
|
||||
Routes: routes,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -59,7 +59,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
var providerMaps = []maps.Map{}
|
||||
for _, provider := range providersResp.DnsProviders {
|
||||
dataUpdatedTime := ""
|
||||
var dataUpdatedTime = ""
|
||||
if provider.DataUpdatedAt > 0 {
|
||||
dataUpdatedTime = timeutil.FormatTime("Y-m-d H:i:s", provider.DataUpdatedAt)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
countDomains := countDomainsResp.Count
|
||||
var countDomains = countDomainsResp.Count
|
||||
|
||||
providerMaps = append(providerMaps, maps.Map{
|
||||
"id": provider.Id,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package acme
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
@@ -25,7 +26,7 @@ func (this *UpdateTaskPopupAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
task := taskResp.AcmeTask
|
||||
var task = taskResp.AcmeTask
|
||||
if task == nil {
|
||||
this.NotFound("acmeTask", params.TaskId)
|
||||
return
|
||||
@@ -74,7 +75,7 @@ func (this *UpdateTaskPopupAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
providerMaps := []maps.Map{}
|
||||
var providerMaps = []maps.Map{}
|
||||
for _, provider := range providersResp.DnsProviders {
|
||||
providerMaps = append(providerMaps, maps.Map{
|
||||
"id": provider.Id,
|
||||
@@ -93,7 +94,7 @@ func (this *UpdateTaskPopupAction) RunPost(params struct {
|
||||
AcmeUserId int64
|
||||
DnsProviderId int64
|
||||
DnsDomain string
|
||||
Domains []string
|
||||
DomainsJSON []byte
|
||||
AutoRenew bool
|
||||
AuthURL string
|
||||
|
||||
@@ -123,11 +124,20 @@ func (this *UpdateTaskPopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
if len(params.Domains) == 0 {
|
||||
var domains = []string{}
|
||||
if len(params.DomainsJSON) > 0 {
|
||||
err := json.Unmarshal(params.DomainsJSON, &domains)
|
||||
if err != nil {
|
||||
this.Fail("解析域名数据失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(domains) == 0 {
|
||||
this.Fail("请输入证书域名列表")
|
||||
}
|
||||
realDomains := []string{}
|
||||
for _, domain := range params.Domains {
|
||||
var realDomains = []string{}
|
||||
for _, domain := range domains {
|
||||
domain = strings.ToLower(domain)
|
||||
if params.AuthType == "dns" {
|
||||
if !strings.HasSuffix(domain, "."+dnsDomain) && domain != dnsDomain {
|
||||
|
||||
@@ -15,7 +15,11 @@ func (this *CreatePopupAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||
func (this *CreatePopupAction) RunGet(params struct {
|
||||
ProviderCode string
|
||||
}) {
|
||||
this.Data["providerCode"] = params.ProviderCode
|
||||
|
||||
// 服务商
|
||||
providersResp, err := this.RPC().ACMEProviderRPC().FindAllACMEProviders(this.AdminContext(), &pb.FindAllACMEProvidersRequest{})
|
||||
if err != nil {
|
||||
|
||||
@@ -30,9 +30,10 @@ func (this *SelectPopupAction) RunGet(params struct {
|
||||
// TODO 列出常用和最新的证书供用户选择
|
||||
|
||||
this.Data["keyword"] = params.Keyword
|
||||
this.Data["selectedCertIds"] = params.SelectedCertIds
|
||||
|
||||
// 已经选择的证书
|
||||
selectedCertIds := []string{}
|
||||
var selectedCertIds = []string{}
|
||||
if len(params.SelectedCertIds) > 0 {
|
||||
selectedCertIds = strings.Split(params.SelectedCertIds, ",")
|
||||
}
|
||||
|
||||
26
internal/web/actions/default/servers/headers/options.go
Normal file
26
internal/web/actions/default/servers/headers/options.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package headers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
type OptionsAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *OptionsAction) RunPost(params struct {
|
||||
Type string
|
||||
}) {
|
||||
if params.Type == "request" {
|
||||
this.Data["headers"] = serverconfigs.AllHTTPCommonRequestHeaders
|
||||
} else if params.Type == "response" {
|
||||
this.Data["headers"] = serverconfigs.AllHTTPCommonResponseHeaders
|
||||
} else {
|
||||
this.Data["headers"] = []string{}
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package servers
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
@@ -90,15 +89,16 @@ func (this *IndexAction) RunGet(params struct {
|
||||
|
||||
// 服务列表
|
||||
serversResp, err := this.RPC().ServerRPC().ListEnabledServersMatch(this.AdminContext(), &pb.ListEnabledServersMatchRequest{
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
NodeClusterId: params.ClusterId,
|
||||
ServerGroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
AuditingFlag: params.AuditingFlag,
|
||||
TrafficOutDesc: params.TrafficOutOrder == "desc",
|
||||
TrafficOutAsc: params.TrafficOutOrder == "asc",
|
||||
UserId: params.UserId,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
NodeClusterId: params.ClusterId,
|
||||
ServerGroupId: params.GroupId,
|
||||
Keyword: params.Keyword,
|
||||
AuditingFlag: params.AuditingFlag,
|
||||
TrafficOutDesc: params.TrafficOutOrder == "desc",
|
||||
TrafficOutAsc: params.TrafficOutOrder == "asc",
|
||||
UserId: params.UserId,
|
||||
IgnoreServerNames: true,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -176,27 +176,35 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
// 域名列表
|
||||
var serverNames = []*serverconfigs.ServerNameConfig{}
|
||||
if server.IsAuditing || (server.AuditingResult != nil && !server.AuditingResult.IsOk) {
|
||||
server.ServerNamesJSON = server.AuditingServerNamesJSON
|
||||
|
||||
if len(config.ServerNames) == 0 {
|
||||
// 审核中的域名
|
||||
if len(server.ServerNamesJSON) > 0 {
|
||||
var serverNames = []*serverconfigs.ServerNameConfig{}
|
||||
err = json.Unmarshal(server.ServerNamesJSON, &serverNames)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
config.ServerNames = serverNames
|
||||
}
|
||||
}
|
||||
}
|
||||
var auditingIsOk = true
|
||||
if !server.IsAuditing && server.AuditingResult != nil && !server.AuditingResult.IsOk {
|
||||
auditingIsOk = false
|
||||
}
|
||||
if len(server.ServerNamesJSON) > 0 {
|
||||
err = json.Unmarshal(server.ServerNamesJSON, &serverNames)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
var firstServerName = ""
|
||||
for _, serverNameConfig := range config.ServerNames {
|
||||
if len(serverNameConfig.Name) > 0 {
|
||||
firstServerName = serverNameConfig.Name
|
||||
break
|
||||
}
|
||||
}
|
||||
var countServerNames = 0
|
||||
for _, serverName := range serverNames {
|
||||
if len(serverName.SubNames) == 0 {
|
||||
countServerNames++
|
||||
} else {
|
||||
countServerNames += len(serverName.SubNames)
|
||||
if len(serverNameConfig.SubNames) > 0 {
|
||||
firstServerName = serverNameConfig.SubNames[0]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,9 +224,9 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
// 统计数据
|
||||
var bandwidth = ""
|
||||
var bandwidthBits int64 = 0
|
||||
if server.BandwidthBytes > 0 {
|
||||
bandwidth = numberutils.FormatBytes(server.BandwidthBytes)
|
||||
bandwidthBits = server.BandwidthBytes * 8
|
||||
}
|
||||
|
||||
serverMaps = append(serverMaps, maps.Map{
|
||||
@@ -232,13 +240,13 @@ func (this *IndexAction) RunGet(params struct {
|
||||
"ports": portMaps,
|
||||
"serverTypeName": serverconfigs.FindServerType(server.Type).GetString("name"),
|
||||
"groups": groupMaps,
|
||||
"serverNames": serverNames,
|
||||
"countServerNames": countServerNames,
|
||||
"firstServerName": firstServerName,
|
||||
"countServerNames": server.CountServerNames,
|
||||
"isAuditing": server.IsAuditing,
|
||||
"auditingIsOk": auditingIsOk,
|
||||
"user": userMap,
|
||||
"auditingTime": auditingTime,
|
||||
"bandwidth": bandwidth,
|
||||
"bandwidthBits": bandwidthBits,
|
||||
})
|
||||
}
|
||||
this.Data["servers"] = serverMaps
|
||||
|
||||
@@ -2,6 +2,7 @@ package servers
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/headers"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/users"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
@@ -26,10 +27,13 @@ func init() {
|
||||
Get("/serverNamesPopup", new(ServerNamesPopupAction)).
|
||||
Post("/status", new(StatusAction)).
|
||||
|
||||
//
|
||||
// user
|
||||
Post("/users/options", new(users.OptionsAction)).
|
||||
Post("/users/plans", new(users.PlansAction)).
|
||||
|
||||
// header
|
||||
Post("/headers/options", new(headers.OptionsAction)).
|
||||
|
||||
//
|
||||
EndAll()
|
||||
})
|
||||
|
||||
@@ -21,21 +21,21 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
Ip string
|
||||
Keyword string
|
||||
GlobalOnly bool
|
||||
Unread bool
|
||||
EventLevel string
|
||||
ListType string
|
||||
}) {
|
||||
this.Data["type"] = ""
|
||||
this.Data["ip"] = params.Ip
|
||||
this.Data["keyword"] = params.Keyword
|
||||
this.Data["globalOnly"] = params.GlobalOnly
|
||||
this.Data["unread"] = params.Unread
|
||||
this.Data["eventLevel"] = params.EventLevel
|
||||
this.Data["listType"] = params.ListType
|
||||
|
||||
countUnreadResp, err := this.RPC().IPItemRPC().CountAllEnabledIPItems(this.AdminContext(), &pb.CountAllEnabledIPItemsRequest{
|
||||
Ip: params.Ip,
|
||||
Keyword: params.Keyword,
|
||||
GlobalOnly: params.GlobalOnly,
|
||||
Unread: true,
|
||||
EventLevel: params.EventLevel,
|
||||
@@ -48,7 +48,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["countUnread"] = countUnreadResp.Count
|
||||
|
||||
countResp, err := this.RPC().IPItemRPC().CountAllEnabledIPItems(this.AdminContext(), &pb.CountAllEnabledIPItemsRequest{
|
||||
Ip: params.Ip,
|
||||
Keyword: params.Keyword,
|
||||
GlobalOnly: params.GlobalOnly,
|
||||
Unread: params.Unread,
|
||||
EventLevel: params.EventLevel,
|
||||
@@ -63,7 +63,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
itemsResp, err := this.RPC().IPItemRPC().ListAllEnabledIPItems(this.AdminContext(), &pb.ListAllEnabledIPItemsRequest{
|
||||
Ip: params.Ip,
|
||||
Keyword: params.Keyword,
|
||||
GlobalOnly: params.GlobalOnly,
|
||||
Unread: params.Unread,
|
||||
EventLevel: params.EventLevel,
|
||||
|
||||
@@ -19,8 +19,10 @@ func (this *CreateDeletePopupAction) Init() {
|
||||
|
||||
func (this *CreateDeletePopupAction) RunGet(params struct {
|
||||
HeaderPolicyId int64
|
||||
Type string
|
||||
}) {
|
||||
this.Data["headerPolicyId"] = params.HeaderPolicyId
|
||||
this.Data["type"] = params.Type
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
)
|
||||
|
||||
// 删除Header
|
||||
// DeleteAction 删除Header
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
@@ -65,34 +65,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
// 套餐
|
||||
var userPlanMap = maps.Map{"id": server.UserPlanId, "dayTo": "", "plan": maps.Map{}}
|
||||
if server.UserPlanId > 0 {
|
||||
userPlanResp, err := this.RPC().UserPlanRPC().FindEnabledUserPlan(this.AdminContext(), &pb.FindEnabledUserPlanRequest{UserPlanId: server.UserPlanId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var userPlan = userPlanResp.UserPlan
|
||||
if userPlan != nil {
|
||||
planResp, err := this.RPC().PlanRPC().FindEnabledPlan(this.AdminContext(), &pb.FindEnabledPlanRequest{PlanId: userPlan.PlanId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var plan = planResp.Plan
|
||||
if plan != nil {
|
||||
userPlanMap = maps.Map{
|
||||
"id": userPlan.Id,
|
||||
"dayTo": userPlan.DayTo,
|
||||
"plan": maps.Map{
|
||||
"id": plan.Id,
|
||||
"name": plan.Name,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Data["userPlan"] = userPlanMap
|
||||
this.initUserPlan(server)
|
||||
|
||||
// 集群
|
||||
clusterId := int64(0)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package settings
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
func (this *IndexAction) initUserPlan(server *pb.Server) {
|
||||
var userPlanMap = maps.Map{"id": server.UserPlanId, "dayTo": "", "plan": maps.Map{}}
|
||||
this.Data["userPlan"] = userPlanMap
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type CreatePopupAction struct {
|
||||
@@ -27,6 +27,9 @@ func (this *CreatePopupAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Type string
|
||||
|
||||
// URL
|
||||
Mode string
|
||||
BeforeURL string
|
||||
AfterURL string
|
||||
@@ -34,51 +37,129 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
MatchRegexp bool
|
||||
KeepRequestURI bool
|
||||
KeepArgs bool
|
||||
Status int
|
||||
CondsJSON []byte
|
||||
IsOn bool
|
||||
|
||||
// 域名
|
||||
DomainsAll bool
|
||||
DomainsBeforeJSON []byte
|
||||
DomainAfter string
|
||||
DomainAfterScheme string
|
||||
|
||||
// 端口
|
||||
PortsAll bool
|
||||
PortsBefore []string
|
||||
PortAfter int
|
||||
PortAfterScheme string
|
||||
|
||||
Status int
|
||||
CondsJSON []byte
|
||||
IsOn bool
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.
|
||||
Field("beforeURL", params.BeforeURL).
|
||||
Require("请填写跳转前的URL")
|
||||
var config = &serverconfigs.HTTPHostRedirectConfig{}
|
||||
config.Type = params.Type
|
||||
config.Status = params.Status
|
||||
config.IsOn = params.IsOn
|
||||
|
||||
switch params.Type {
|
||||
case serverconfigs.HTTPHostRedirectTypeURL:
|
||||
params.Must.
|
||||
Field("beforeURL", params.BeforeURL).
|
||||
Require("请填写跳转前的URL")
|
||||
|
||||
// 校验格式
|
||||
if params.MatchRegexp {
|
||||
_, err := regexp.Compile(params.BeforeURL)
|
||||
if err != nil {
|
||||
this.Fail("跳转前URL正则表达式错误:" + err.Error())
|
||||
}
|
||||
} else {
|
||||
u, err := url.Parse(params.BeforeURL)
|
||||
if err != nil {
|
||||
this.FailField("beforeURL", "请输入正确的跳转前URL")
|
||||
}
|
||||
if (u.Scheme != "http" && u.Scheme != "https") ||
|
||||
len(u.Host) == 0 {
|
||||
this.FailField("beforeURL", "请输入正确的跳转前URL")
|
||||
}
|
||||
|
||||
// 校验格式
|
||||
if params.MatchRegexp {
|
||||
_, err := regexp.Compile(params.BeforeURL)
|
||||
if err != nil {
|
||||
this.Fail("跳转前URL正则表达式错误:" + err.Error())
|
||||
}
|
||||
} else {
|
||||
u, err := url.Parse(params.BeforeURL)
|
||||
if err != nil {
|
||||
this.FailField("beforeURL", "请输入正确的跳转前URL")
|
||||
}
|
||||
if (u.Scheme != "http" && u.Scheme != "https") ||
|
||||
len(u.Host) == 0 {
|
||||
this.FailField("beforeURL", "请输入正确的跳转前URL")
|
||||
}
|
||||
|
||||
}
|
||||
params.Must.
|
||||
Field("afterURL", params.AfterURL).
|
||||
Require("请填写跳转后URL")
|
||||
|
||||
params.Must.
|
||||
Field("afterURL", params.AfterURL).
|
||||
Require("请填写跳转后URL")
|
||||
// 校验格式
|
||||
if params.MatchRegexp {
|
||||
// 正则表达式情况下不做校验
|
||||
} else {
|
||||
u, err := url.Parse(params.AfterURL)
|
||||
if err != nil {
|
||||
this.FailField("afterURL", "请输入正确的跳转后URL")
|
||||
}
|
||||
if (u.Scheme != "http" && u.Scheme != "https") ||
|
||||
len(u.Host) == 0 {
|
||||
this.FailField("afterURL", "请输入正确的跳转后URL")
|
||||
}
|
||||
}
|
||||
|
||||
// 校验格式
|
||||
if params.MatchRegexp {
|
||||
// 正则表达式情况下不做校验
|
||||
} else {
|
||||
u, err := url.Parse(params.AfterURL)
|
||||
if err != nil {
|
||||
this.FailField("afterURL", "请输入正确的跳转后URL")
|
||||
config.Mode = params.Mode
|
||||
config.BeforeURL = params.BeforeURL
|
||||
config.AfterURL = params.AfterURL
|
||||
config.MatchPrefix = params.MatchPrefix
|
||||
config.MatchRegexp = params.MatchRegexp
|
||||
config.KeepRequestURI = params.KeepRequestURI
|
||||
config.KeepArgs = params.KeepArgs
|
||||
case serverconfigs.HTTPHostRedirectTypeDomain:
|
||||
config.DomainsAll = params.DomainsAll
|
||||
var domainsBefore = []string{}
|
||||
if len(params.DomainsBeforeJSON) > 0 {
|
||||
err := json.Unmarshal(params.DomainsBeforeJSON, &domainsBefore)
|
||||
if err != nil {
|
||||
this.Fail("错误的域名格式:" + err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
if (u.Scheme != "http" && u.Scheme != "https") ||
|
||||
len(u.Host) == 0 {
|
||||
this.FailField("afterURL", "请输入正确的跳转后URL")
|
||||
config.DomainsBefore = domainsBefore
|
||||
if !params.DomainsAll {
|
||||
if len(domainsBefore) == 0 {
|
||||
this.Fail("请输入跳转前域名")
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(params.DomainAfter) == 0 {
|
||||
this.FailField("domainAfter", "请输入跳转后域名")
|
||||
return
|
||||
}
|
||||
config.DomainAfter = params.DomainAfter
|
||||
config.DomainAfterScheme = params.DomainAfterScheme
|
||||
case serverconfigs.HTTPHostRedirectTypePort:
|
||||
config.PortsAll = params.PortsAll
|
||||
|
||||
config.PortsBefore = params.PortsBefore
|
||||
var portReg = regexp.MustCompile(`^\d+$`)
|
||||
var portRangeReg = regexp.MustCompile(`^\d+-\d+$`)
|
||||
if !config.PortsAll {
|
||||
for _, port := range params.PortsBefore {
|
||||
port = strings.ReplaceAll(port, " ", "")
|
||||
if !portReg.MatchString(port) && !portRangeReg.MatchString(port) {
|
||||
this.Fail("端口号" + port + "填写错误(请输入单个端口号或一个端口范围)")
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(params.PortsBefore) == 0 {
|
||||
this.Fail("请输入跳转前端口")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if params.PortAfter <= 0 {
|
||||
this.FailField("portAfter", "请输入跳转后端口")
|
||||
return
|
||||
}
|
||||
config.PortAfter = params.PortAfter
|
||||
config.PortAfterScheme = params.PortAfterScheme
|
||||
}
|
||||
|
||||
params.Must.
|
||||
@@ -99,19 +180,16 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
this.Fail("匹配条件校验失败:" + err.Error())
|
||||
}
|
||||
}
|
||||
config.Conds = conds
|
||||
|
||||
this.Data["redirect"] = maps.Map{
|
||||
"mode": params.Mode,
|
||||
"status": params.Status,
|
||||
"beforeURL": params.BeforeURL,
|
||||
"afterURL": params.AfterURL,
|
||||
"matchPrefix": params.MatchPrefix,
|
||||
"matchRegexp": params.MatchRegexp,
|
||||
"keepRequestURI": params.KeepRequestURI,
|
||||
"keepArgs": params.KeepArgs,
|
||||
"conds": conds,
|
||||
"isOn": params.IsOn,
|
||||
// 校验配置
|
||||
err := config.Init()
|
||||
if err != nil {
|
||||
this.Fail("配置校验失败:" + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["redirect"] = config
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
//go:build !plus
|
||||
|
||||
package users
|
||||
|
||||
import (
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
@@ -17,33 +16,6 @@ func (this *PlansAction) RunPost(params struct {
|
||||
UserId int64
|
||||
ServerId int64
|
||||
}) {
|
||||
if !teaconst.IsPlus || params.UserId <= 0 {
|
||||
this.Data["plans"] = []maps.Map{}
|
||||
this.Success()
|
||||
}
|
||||
|
||||
// TODO 优化用户套餐查询
|
||||
userPlansResp, err := this.RPC().UserPlanRPC().FindAllEnabledUserPlansForServer(this.AdminContext(), &pb.FindAllEnabledUserPlansForServerRequest{
|
||||
UserId: params.UserId,
|
||||
ServerId: params.ServerId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var userPlanMaps = []maps.Map{}
|
||||
for _, userPlan := range userPlansResp.UserPlans {
|
||||
if userPlan.Plan == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
userPlanMaps = append(userPlanMaps, maps.Map{
|
||||
"id": userPlan.Id,
|
||||
"name": userPlan.Plan.Name,
|
||||
"dayTo": userPlan.DayTo,
|
||||
})
|
||||
}
|
||||
this.Data["plans"] = userPlanMaps
|
||||
|
||||
this.Data["plans"] = []maps.Map{}
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
@@ -145,7 +146,7 @@ func checkRequestSecurity(securityConfig *systemconfigs.SecurityConfig, req *htt
|
||||
if err == nil && len(realDomain) > 0 {
|
||||
domain = realDomain
|
||||
}
|
||||
if !lists.ContainsString(securityConfig.AllowDomains, domain) {
|
||||
if !configutils.MatchDomains(securityConfig.AllowDomains, domain) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/logs"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/regions/items"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/tasks"
|
||||
|
||||
// 通用
|
||||
|
||||
@@ -853,67 +853,6 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-bandwidth-ranges",{props:["v-ranges"],data:function(){let e=this.vRanges;return{ranges:e=null==e?[]:e,isAdding:!1,minMB:"",maxMB:"",pricePerMB:"",totalPrice:"",addingRange:{minMB:0,maxMB:0,pricePerMB:0,totalPrice:0}}},methods:{add:function(){this.isAdding=!this.isAdding;let e=this;setTimeout(function(){e.$refs.minMB.focus()})},cancelAdding:function(){this.isAdding=!1},confirm:function(){this.isAdding=!1,this.minMB="",this.maxMB="",this.pricePerMB="",this.totalPrice="",this.ranges.push(this.addingRange),this.ranges.$sort(function(e,t){return e.minMB<t.minMB?-1:e.minMB==t.minMB?0==t.maxMB||e.maxMB<t.maxMB?-1:0:1}),this.change(),this.addingRange={minMB:0,maxMB:0,pricePerMB:0,totalPrice:0}},remove:function(e){this.ranges.$remove(e),this.change()},change:function(){this.$emit("change",this.ranges)}},watch:{minMB:function(e){let t=parseInt(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.minMB=t},maxMB:function(e){let t=parseInt(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.maxMB=t},pricePerMB:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.pricePerMB=t},totalPrice:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.totalPrice=t}},template:`<div>
|
||||
<!-- 已有价格 -->
|
||||
<div v-if="ranges.length > 0">
|
||||
<div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em">
|
||||
{{range.minMB}}MB - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>∞</span> 价格:<span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerMB}}元/MB</span>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
|
||||
<!-- 添加 -->
|
||||
<div v-if="isAdding">
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">带宽下限 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="最小带宽" style="width: 7em" maxlength="10" ref="minMB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minMB"/>
|
||||
<span class="ui label">MB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">带宽上限 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="最大带宽" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxMB"/>
|
||||
<span class="ui label">MB</span>
|
||||
</div>
|
||||
<p class="comment">如果填0,表示上不封顶。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>总价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="总价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="totalPrice"/>
|
||||
<span class="ui label">元/MB</span>
|
||||
</div>
|
||||
<p class="comment">和单位价格二选一。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">单位价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerMB"/>
|
||||
<span class="ui label">元/MB</span>
|
||||
</div>
|
||||
<p class="comment">和总价格二选一。如果设置了单位价格,那么"总价格 = 单位价格 x 带宽"。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="ui button small" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<div v-if="!isAdding">
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-price-config-box",{props:["v-price-type","v-monthly-price","v-seasonally-price","v-yearly-price","v-traffic-price","v-bandwidth-price","v-disable-period"],data:function(){let e=this.vPriceType,t=(null==e&&(e="bandwidth"),0),i=this.vMonthlyPrice,s=(null==i||i<=0?i="":(i=i.toString(),t=parseFloat(i),isNaN(t)&&(t=0)),0),n=this.vSeasonallyPrice,o=(null==n||n<=0?n="":(n=n.toString(),s=parseFloat(n),isNaN(s)&&(s=0)),0),a=this.vYearlyPrice,l=(null==a||a<=0?a="":(a=a.toString(),o=parseFloat(a),isNaN(o)&&(o=0)),this.vTrafficPrice),c=0,r=(null!=l?c=l.base:l={base:0},""),d=(0<c&&(r=c.toString()),this.vBandwidthPrice);return null==d?d={percentile:95,ranges:[]}:null==d.ranges&&(d.ranges=[]),{priceType:e,monthlyPrice:i,seasonallyPrice:n,yearlyPrice:a,monthlyPriceNumber:t,seasonallyPriceNumber:s,yearlyPriceNumber:o,trafficPriceBase:r,trafficPrice:l,bandwidthPrice:d,bandwidthPercentile:d.percentile}},methods:{changeBandwidthPriceRanges:function(e){this.bandwidthPrice.ranges=e}},watch:{monthlyPrice:function(e){let t=parseFloat(e);isNaN(t)&&(t=0),this.monthlyPriceNumber=t},seasonallyPrice:function(e){let t=parseFloat(e);isNaN(t)&&(t=0),this.seasonallyPriceNumber=t},yearlyPrice:function(e){let t=parseFloat(e);isNaN(t)&&(t=0),this.yearlyPriceNumber=t},trafficPriceBase:function(e){let t=parseFloat(e);isNaN(t)&&(t=0),this.trafficPrice.base=t},bandwidthPercentile:function(e){let t=parseInt(e);isNaN(t)||t<=0?t=95:100<t&&(t=100),this.bandwidthPrice.percentile=t}},template:`<div>
|
||||
<input type="hidden" name="priceType" :value="priceType"/>
|
||||
<input type="hidden" name="monthlyPrice" :value="monthlyPriceNumber"/>
|
||||
@@ -994,11 +933,250 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<tr>
|
||||
<td>带宽价格</td>
|
||||
<td>
|
||||
<plan-bandwidth-ranges :v-ranges="bandwidthPrice.ranges" @change="changeBandwidthPriceRanges"></plan-bandwidth-ranges>
|
||||
<plan-bandwidth-ranges v-model="bandwidthPrice.ranges" @change="changeBandwidthPriceRanges"></plan-bandwidth-ranges>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-price-traffic-config-box",{props:["v-plan-price-traffic-config"],data:function(){let e=this.vPlanPriceTrafficConfig;return null==(e=null==e?{base:0,ranges:[],supportRegions:!1}:e).ranges&&(e.ranges=[]),{config:e,priceBase:e.base,isEditing:!1}},watch:{priceBase:function(e){e=parseFloat(e);isNaN(e)||e<0?this.config.base=0:this.config.base=e}},methods:{edit:function(){this.isEditing=!this.isEditing}},template:`<div>
|
||||
<input type="hidden" name="trafficPriceJSON" :value="JSON.stringify(config)"/>
|
||||
<div>
|
||||
基础流量价格:<span v-if="config.base > 0">{{config.base}}元/GB</span><span v-else class="disabled">没有设置</span> |
|
||||
阶梯价格:<span v-if="config.ranges.length > 0">{{config.ranges.length}}段</span><span v-else class="disabled">没有设置</span> <span v-if="config.supportRegions">| 支持区域流量计费</span>
|
||||
<div style="margin-top: 0.5em">
|
||||
<a href="" @click.prevent="edit">修改 <i class="icon angle" :class="{up: isEditing, down: !isEditing}"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="isEditing" style="margin-top: 0.5em">
|
||||
<table class="ui table definition selectable" style="margin-top: 0">
|
||||
<tr>
|
||||
<td class="title">基础流量费用</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" v-model="priceBase" maxlength="10" style="width: 7em"/>
|
||||
<span class="ui label">元/GB</span>
|
||||
</div>
|
||||
<p class="comment">没有定义流量阶梯价格时,使用此价格。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>流量阶梯价格</td>
|
||||
<td>
|
||||
<plan-traffic-ranges v-model="config.ranges"></plan-traffic-ranges>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>支持按区域流量计费</td>
|
||||
<td>
|
||||
<checkbox v-model="config.supportRegions"></checkbox>
|
||||
<p class="comment">选中后,表示可以根据节点所在区域设置不同的流量价格。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-bandwidth-ranges",{props:["value"],data:function(){let e=this.value;return{ranges:e=null==e?[]:e,isAdding:!1,minMB:"",minMBUnit:"mb",maxMB:"",maxMBUnit:"mb",pricePerMB:"",totalPrice:"",addingRange:{minMB:0,maxMB:0,pricePerMB:0,totalPrice:0}}},methods:{add:function(){this.isAdding=!this.isAdding;let e=this;setTimeout(function(){e.$refs.minMB.focus()})},cancelAdding:function(){this.isAdding=!1},confirm:function(){this.addingRange.minMB<0?teaweb.warn("带宽下限需要大于0"):this.addingRange.maxMB<0?teaweb.warn("带宽上限需要大于0"):this.addingRange.pricePerMB<=0?teaweb.warn("请设置单位价格或者总价格"):(this.isAdding=!1,this.minMB="",this.maxMB="",this.pricePerMB="",this.totalPrice="",this.ranges.push(this.addingRange),this.ranges.$sort(function(e,t){return e.minMB<t.minMB?-1:e.minMB==t.minMB?0==t.maxMB||e.maxMB<t.maxMB?-1:0:1}),this.change(),this.addingRange={minMB:0,maxMB:0,pricePerMB:0,totalPrice:0})},remove:function(e){this.ranges.$remove(e),this.change()},change:function(){this.$emit("change",this.ranges)},formatMB:function(e){return teaweb.formatBits(1024*e*1024)},changeMinMB:function(e){let t=parseFloat(e.toString());switch((isNaN(t)||t<0)&&(t=0),this.minMBUnit){case"gb":t*=1024;break;case"tb":t*=1048576}this.addingRange.minMB=t},changeMaxMB:function(e){let t=parseFloat(e.toString());switch((isNaN(t)||t<0)&&(t=0),this.maxMBUnit){case"gb":t*=1024;break;case"tb":t*=1048576}this.addingRange.maxMB=t}},watch:{minMB:function(e){this.changeMinMB(e)},minMBUnit:function(){this.changeMinMB(this.minMB)},maxMB:function(e){this.changeMaxMB(e)},maxMBUnit:function(){this.changeMaxMB(this.maxMB)},pricePerMB:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.pricePerMB=t},totalPrice:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.totalPrice=t}},template:`<div>
|
||||
<!-- 已有价格 -->
|
||||
<div v-if="ranges.length > 0">
|
||||
<div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em">
|
||||
{{formatMB(range.minMB)}} - <span v-if="range.maxMB > 0">{{formatMB(range.maxMB)}}</span><span v-else>∞</span> 价格:<span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerMB}}元/Mbps</span>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
|
||||
<!-- 添加 -->
|
||||
<div v-if="isAdding">
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">带宽下限 *</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" placeholder="最小带宽" style="width: 7em" maxlength="10" ref="minMB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minMB"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" v-model="minMBUnit">
|
||||
<option value="mb">Mbps</option>
|
||||
<option value="gb">Gbps</option>
|
||||
<option value="tb">Tbps</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">带宽上限 *</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" placeholder="最大带宽" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxMB"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" v-model="maxMBUnit">
|
||||
<option value="mb">Mbps</option>
|
||||
<option value="gb">Gbps</option>
|
||||
<option value="tb">Tbps</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">如果填0,表示上不封顶。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">单位价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerMB"/>
|
||||
<span class="ui label">元/Mbps</span>
|
||||
</div>
|
||||
<p class="comment">和总价格二选一。如果设置了单位价格,那么"总价格 = 单位价格 x 带宽/Mbps"。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>总价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="总价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="totalPrice"/>
|
||||
<span class="ui label">元</span>
|
||||
</div>
|
||||
<p class="comment">固定的总价格,和单位价格二选一。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="ui button small" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<div v-if="!isAdding">
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-price-bandwidth-config-box",{props:["v-plan-price-bandwidth-config"],data:function(){let e=this.vPlanPriceBandwidthConfig;return null==(e=null==e?{percentile:95,base:0,ranges:[],supportRegions:!1}:e).ranges&&(e.ranges=[]),{config:e,bandwidthPercentile:e.percentile,priceBase:e.base,isEditing:!1}},watch:{priceBase:function(e){e=parseFloat(e);isNaN(e)||e<0?this.config.base=0:this.config.base=e},bandwidthPercentile:function(e){e=parseInt(e);isNaN(e)||e<0?this.config.percentile=0:this.config.percentile=e}},methods:{edit:function(){this.isEditing=!this.isEditing}},template:`<div>
|
||||
<input type="hidden" name="bandwidthPriceJSON" :value="JSON.stringify(config)"/>
|
||||
<div>
|
||||
带宽百分位:<span v-if="config.percentile > 0">{{config.percentile}}th</span><span v-else class="disabled">没有设置</span> |
|
||||
基础带宽价格:<span v-if="config.base > 0">{{config.base}}元/Mbps</span><span v-else class="disabled">没有设置</span> |
|
||||
阶梯价格:<span v-if="config.ranges.length > 0">{{config.ranges.length}}段</span><span v-else class="disabled">没有设置</span> <span v-if="config.supportRegions">| 支持区域带宽计费</span>
|
||||
<div style="margin-top: 0.5em">
|
||||
<a href="" @click.prevent="edit">修改 <i class="icon angle" :class="{up: isEditing, down: !isEditing}"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div v-show="isEditing" style="margin-top: 0.5em">
|
||||
<table class="ui table definition selectable" style="margin-top: 0">
|
||||
<tr>
|
||||
<td class="title">带宽百分位 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 4em" maxlength="3" v-model="bandwidthPercentile"/>
|
||||
<span class="ui label">th</span>
|
||||
</div>
|
||||
<p class="comment">带宽计费位置,在1-100之间。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">基础带宽费用</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" v-model="priceBase" maxlength="10" style="width: 7em"/>
|
||||
<span class="ui label">元/Mbps</span>
|
||||
</div>
|
||||
<p class="comment">没有定义带宽阶梯价格时,使用此价格。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>带宽阶梯价格</td>
|
||||
<td>
|
||||
<plan-bandwidth-ranges v-model="config.ranges"></plan-bandwidth-ranges>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>支持按区域带宽计费</td>
|
||||
<td>
|
||||
<checkbox v-model="config.supportRegions"></checkbox>
|
||||
<p class="comment">选中后,表示可以根据节点所在区域设置不同的带宽价格。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>`}),Vue.component("plan-traffic-ranges",{props:["value"],data:function(){let e=this.value;return{ranges:e=null==e?[]:e,isAdding:!1,minGB:"",minGBUnit:"gb",maxGB:"",maxGBUnit:"gb",pricePerGB:"",totalPrice:"",addingRange:{minGB:0,maxGB:0,pricePerGB:0,totalPrice:0}}},methods:{add:function(){this.isAdding=!this.isAdding;let e=this;setTimeout(function(){e.$refs.minGB.focus()})},cancelAdding:function(){this.isAdding=!1},confirm:function(){this.addingRange.minGB<0?teaweb.warn("流量下限需要大于0"):this.addingRange.maxGB<0?teaweb.warn("流量上限需要大于0"):this.addingRange.pricePerGB<=0&&this.addingRange.totalPrice<=0?teaweb.warn("请设置单位价格或者总价格"):(this.isAdding=!1,this.minGB="",this.maxGB="",this.pricePerGB="",this.totalPrice="",this.ranges.push(this.addingRange),this.ranges.$sort(function(e,t){return e.minGB<t.minGB?-1:e.minGB==t.minGB?0==t.maxGB||e.maxGB<t.maxGB?-1:0:1}),this.change(),this.addingRange={minGB:0,maxGB:0,pricePerGB:0,totalPrice:0})},remove:function(e){this.ranges.$remove(e),this.change()},change:function(){this.$emit("change",this.ranges)},formatGB:function(e){return teaweb.formatBytes(1024*e*1024*1024)},changeMinGB:function(e){let t=parseFloat(e.toString());switch((isNaN(t)||t<0)&&(t=0),this.minGBUnit){case"tb":t*=1024;break;case"pb":t*=1048576;break;case"eb":t*=1073741824}this.addingRange.minGB=t},changeMaxGB:function(e){let t=parseFloat(e.toString());switch((isNaN(t)||t<0)&&(t=0),this.maxGBUnit){case"tb":t*=1024;break;case"pb":t*=1048576;break;case"eb":t*=1073741824}this.addingRange.maxGB=t}},watch:{minGB:function(e){this.changeMinGB(e)},minGBUnit:function(e){this.changeMinGB(this.minGB)},maxGB:function(e){this.changeMaxGB(e)},maxGBUnit:function(e){this.changeMaxGB(this.maxGB)},pricePerGB:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.pricePerGB=t},totalPrice:function(e){let t=parseFloat(e.toString());(isNaN(t)||t<0)&&(t=0),this.addingRange.totalPrice=t}},template:`<div>
|
||||
<!-- 已有价格 -->
|
||||
<div v-if="ranges.length > 0">
|
||||
<div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em">
|
||||
{{formatGB(range.minGB)}} - <span v-if="range.maxGB > 0">{{formatGB(range.maxGB)}}</span><span v-else>∞</span> 价格:<span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerGB}}元/GB</span>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
|
||||
<!-- 添加 -->
|
||||
<div v-if="isAdding">
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">流量下限 *</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" placeholder="最小流量" style="width: 7em" maxlength="10" ref="minGB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minGB"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" v-model="minGBUnit">
|
||||
<option value="gb">GB</option>
|
||||
<option value="tb">TB</option>
|
||||
<option value="pb">PB</option>
|
||||
<option value="eb">EB</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">流量上限 *</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" placeholder="最大流量" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxGB"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" v-model="maxGBUnit">
|
||||
<option value="gb">GB</option>
|
||||
<option value="tb">TB</option>
|
||||
<option value="pb">PB</option>
|
||||
<option value="eb">EB</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">如果填0,表示上不封顶。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">单位价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerGB"/>
|
||||
<span class="ui label">元/GB</span>
|
||||
</div>
|
||||
<p class="comment">和总价格二选一。如果设置了单位价格,那么"总价格 = 单位价格 x 流量/GB"。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>总价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="总价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="totalPrice"/>
|
||||
<span class="ui label">元</span>
|
||||
</div>
|
||||
<p class="comment">固定的总价格,和单位价格二选一。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="ui button small" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<div v-if="!isAdding">
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`}),Vue.component("http-stat-config-box",{props:["v-stat-config","v-is-location","v-is-group"],data:function(){let e=this.vStatConfig;return{stat:e=null==e?{isPrior:!1,isOn:!1}:e}},template:`<div>
|
||||
<input type="hidden" name="statJSON" :value="JSON.stringify(stat)"/>
|
||||
<table class="ui table definition selectable">
|
||||
@@ -1143,7 +1321,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
|
||||
<!-- HSTS -->
|
||||
<tr v-show="vProtocol == 'https'">
|
||||
<td :class="{'color-border':hsts.isOn}">是否开启HSTS</td>
|
||||
<td :class="{'color-border':hsts.isOn}">开启HSTS</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="hstsOn" v-model="hsts.isOn" value="1"/>
|
||||
@@ -1289,7 +1467,8 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
|
||||
<!-- refererBlock -->
|
||||
<span v-if="rule.param == '\${refererBlock}'">
|
||||
{{rule.checkpointOptions.allowDomains}}
|
||||
<span v-if="rule.checkpointOptions.allowDomains != null && rule.checkpointOptions.allowDomains.length > 0">允许{{rule.checkpointOptions.allowDomains}}</span>
|
||||
<span v-if="rule.checkpointOptions.denyDomains != null && rule.checkpointOptions.denyDomains.length > 0">禁止{{rule.checkpointOptions.denyDomains}}</span>
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
@@ -1381,10 +1560,9 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 1em"></th>
|
||||
<th>跳转前URL</th>
|
||||
<th>跳转前</th>
|
||||
<th style="width: 1em"></th>
|
||||
<th>跳转后URL</th>
|
||||
<th>匹配模式</th>
|
||||
<th>跳转后</th>
|
||||
<th>HTTP状态码</th>
|
||||
<th class="two wide">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
@@ -1394,17 +1572,47 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<tr>
|
||||
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
|
||||
<td>
|
||||
{{redirect.beforeURL}}
|
||||
<div v-if="redirect.type == '' || redirect.type == 'url'">
|
||||
{{redirect.beforeURL}}
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>URL跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.matchPrefix">匹配前缀</grey-label>
|
||||
<grey-label v-if="redirect.matchRegexp">正则匹配</grey-label>
|
||||
<grey-label v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="redirect.type == 'domain'">
|
||||
<span v-if="redirect.domainsAll">所有域名</span>
|
||||
<span v-if="!redirect.domainsAll && redirect.domainsBefore != null">
|
||||
<span v-if="redirect.domainsBefore.length == 1">{{redirect.domainsBefore[0]}}</span>
|
||||
<span v-if="redirect.domainsBefore.length > 1">{{redirect.domainsBefore[0]}}等{{redirect.domainsBefore.length}}个域名</span>
|
||||
</span>
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>域名跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.domainAfterScheme != null && redirect.domainAfterScheme.length > 0">{{redirect.domainAfterScheme}}</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="redirect.type == 'port'">
|
||||
<span v-if="redirect.portsAll">所有端口</span>
|
||||
<span v-if="!redirect.portsAll && redirect.portsBefore != null">
|
||||
<span v-if="redirect.portsBefore.length <= 5">{{redirect.portsBefore.join(", ")}}</span>
|
||||
<span v-if="redirect.portsBefore.length > 5">{{redirect.portsBefore.slice(0, 5).join(", ")}}等{{redirect.portsBefore.length}}个端口</span>
|
||||
</span>
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>端口跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.portAfterScheme != null && redirect.portAfterScheme.length > 0">{{redirect.portAfterScheme}}</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 0.5em" v-if="redirect.conds != null && redirect.conds.groups != null && redirect.conds.groups.length > 0">
|
||||
<span class="ui label text basic tiny">匹配条件</span>
|
||||
<grey-label>匹配条件</grey-label>
|
||||
</div>
|
||||
</td>
|
||||
<td nowrap="">-></td>
|
||||
<td>{{redirect.afterURL}}</td>
|
||||
<td>
|
||||
<span v-if="redirect.matchPrefix">匹配前缀</span>
|
||||
<span v-if="redirect.matchRegexp">正则匹配</span>
|
||||
<span v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</span>
|
||||
<span v-if="redirect.type == '' || redirect.type == 'url'">{{redirect.afterURL}}</span>
|
||||
<span v-if="redirect.type == 'domain'">{{redirect.domainAfter}}</span>
|
||||
<span v-if="redirect.type == 'port'">{{redirect.portAfter}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="redirect.status > 0">{{redirect.status}}</span>
|
||||
@@ -1598,7 +1806,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<td>单IP最大并发连接数</td>
|
||||
<td>
|
||||
<input type="text" maxlength="6" v-model="maxConnsPerIP"/>
|
||||
<p class="comment">单IP最大连接数,统计单个IP总连接数时不区分服务,超出此限制则响应用户<code-label>429</code-label>代码。为0表示不限制。<span v-if="maxConnsPerIP <= 3" class="red">当前设置的并发连接数过低,可能会影响正常用户访问,建议不小于3。</span></p>
|
||||
<p class="comment">单IP最大连接数,统计单个IP总连接数时不区分服务,超出此限制则响应用户<code-label>429</code-label>代码。为0表示不限制。<span v-if="maxConnsPerIP > 0 && maxConnsPerIP <= 3" class="red">当前设置的并发连接数过低,可能会影响正常用户访问,建议不小于3。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -1851,7 +2059,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>`}),Vue.component("http-firewall-checkpoint-referer-block",{props:["v-checkpoint"],data:function(){let e=!0,t=!0,i=[],s={},n=("boolean"==typeof(s=null==(s=null!=window.parent.UPDATING_RULE?window.parent.UPDATING_RULE.checkpointOptions:s)?{}:s).allowEmpty&&(e=s.allowEmpty),"boolean"==typeof s.allowSameDomain&&(t=s.allowSameDomain),null!=s.allowDomains&&"object"==typeof s.allowDomains&&(i=s.allowDomains),this);return setTimeout(function(){n.change()},100),{allowEmpty:e,allowSameDomain:t,allowDomains:i,options:{},value:0}},watch:{allowEmpty:function(){this.change()},allowSameDomain:function(){this.change()}},methods:{changeAllowDomains:function(e){this.allowDomains=e,this.change()},change:function(){this.vCheckpoint.options=[{code:"allowEmpty",value:this.allowEmpty},{code:"allowSameDomain",value:this.allowSameDomain},{code:"allowDomains",value:this.allowDomains}]}},template:`<div>
|
||||
</div>`}),Vue.component("http-firewall-checkpoint-referer-block",{props:["v-checkpoint"],data:function(){let e=!0,t=!0,i=[],s=[],n={},o=("boolean"==typeof(n=null==(n=null!=window.parent.UPDATING_RULE?window.parent.UPDATING_RULE.checkpointOptions:n)?{}:n).allowEmpty&&(e=n.allowEmpty),"boolean"==typeof n.allowSameDomain&&(t=n.allowSameDomain),null!=n.allowDomains&&"object"==typeof n.allowDomains&&(i=n.allowDomains),null!=n.denyDomains&&"object"==typeof n.denyDomains&&(s=n.denyDomains),this);return setTimeout(function(){o.change()},100),{allowEmpty:e,allowSameDomain:t,allowDomains:i,denyDomains:s,options:{},value:0}},watch:{allowEmpty:function(){this.change()},allowSameDomain:function(){this.change()}},methods:{changeAllowDomains:function(e){this.allowDomains=e,this.change()},changeDenyDomains:function(e){this.denyDomains=e,this.change()},change:function(){this.vCheckpoint.options=[{code:"allowEmpty",value:this.allowEmpty},{code:"allowSameDomain",value:this.allowSameDomain},{code:"allowDomains",value:this.allowDomains},{code:"denyDomains",value:this.denyDomains}]}},template:`<div>
|
||||
<input type="hidden" name="operator" value="eq"/>
|
||||
<input type="hidden" name="value" :value="value"/>
|
||||
<table class="ui table">
|
||||
@@ -1876,6 +2084,13 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<p class="comment">允许的来源域名列表,比如<code-label>example.com</code-label>、<code-label>*.example.com</code-label>。单个星号<code-label>*</code-label>表示允许所有域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>禁止的来源域名</td>
|
||||
<td>
|
||||
<values-box :values="denyDomains" @change="changeDenyDomains"></values-box>
|
||||
<p class="comment">禁止的来源域名列表,比如<code-label>example.org</code-label>、<code-label>*.example.org</code-label>;除了这些禁止的来源域名外,其他域名都会被允许,除非限定了允许的来源域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>`}),Vue.component("http-access-log-partitions-box",{props:["v-partition","v-day","v-query"],mounted:function(){let t=this;Tea.action("/servers/logs/partitionData").params({day:this.vDay}).success(function(e){t.partitions=[],e.data.partitions.reverse().forEach(function(e){t.partitions.push({code:e,isDisabled:!1,hasLogs:!1})}),0<t.partitions.length&&((null==t.vPartition||t.vPartition<0)&&(t.selectedPartition=t.partitions[0].code),1<t.partitions.length&&t.checkLogs())}).post()},data:function(){return{partitions:[],selectedPartition:this.vPartition,checkingPartition:0}},methods:{url:function(e){let t=window.location.toString();return 0<(t=(t=(t=(t=t.replace(/\?partition=-?\d+/,"?")).replace(/\?requestId=-?\d+/,"?")).replace(/&partition=-?\d+/,"")).replace(/&requestId=-?\d+/,"")).indexOf("?")?t+="&partition="+e:t+="?partition="+e,t},disable:function(t){this.partitions.forEach(function(e){e.code==t&&(e.isDisabled=!0)})},checkLogs:function(){let t=this,i=this.checkingPartition,s={partition:i},e=this.vQuery;null!=e&&0!=e.length&&(e.split("&").forEach(function(e){e=e.split("=");s[e[0]]=decodeURIComponent(e[1])}),Tea.action("/servers/logs/hasLogs").params(s).post().success(function(e){e.data.hasLogs&&(t.partitions[t.partitions.length-1-i].hasLogs=!0),++i>=t.partitions.length||(t.checkingPartition=i,t.checkLogs())}))}},template:`<div v-if="partitions.length > 1">
|
||||
<div class="ui divider" style="margin-bottom: 0"></div>
|
||||
@@ -1943,7 +2158,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<button class="ui button tiny" @click.prevent="addRef(false)" type="button">+添加缓存条件</button> <a href="" @click.prevent="addRef(true)">+添加不缓存条件</a>
|
||||
</div>
|
||||
<div class="margin"></div>
|
||||
</div>`}),Vue.component("origin-list-box",{props:["v-primary-origins","v-backup-origins","v-server-type","v-params"],data:function(){return{primaryOrigins:this.vPrimaryOrigins,backupOrigins:this.vBackupOrigins}},methods:{createPrimaryOrigin:function(){teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&"+this.vParams,{height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},createBackupOrigin:function(){teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&"+this.vParams,{height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},updateOrigin:function(e,t){teaweb.popup("/servers/server/settings/origins/updatePopup?originType="+t+"&"+this.vParams+"&originId="+e,{height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},deleteOrigin:function(e,t){let i=this;teaweb.confirm("确定要删除此源站吗?",function(){Tea.action("/servers/server/settings/origins/delete?"+i.vParams+"&originId="+e+"&originType="+t).post().success(function(){teaweb.success("删除成功",function(){window.location.reload()})})})}},template:`<div>
|
||||
</div>`}),Vue.component("origin-list-box",{props:["v-primary-origins","v-backup-origins","v-server-type","v-params"],data:function(){return{primaryOrigins:this.vPrimaryOrigins,backupOrigins:this.vBackupOrigins}},methods:{createPrimaryOrigin:function(){teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&"+this.vParams,{width:"45em",height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},createBackupOrigin:function(){teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&"+this.vParams,{width:"45em",height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},updateOrigin:function(e,t){teaweb.popup("/servers/server/settings/origins/updatePopup?originType="+t+"&"+this.vParams+"&originId="+e,{width:"45em",height:"27em",callback:function(e){teaweb.success("保存成功",function(){window.location.reload()})}})},deleteOrigin:function(e,t){let i=this;teaweb.confirm("确定要删除此源站吗?",function(){Tea.action("/servers/server/settings/origins/delete?"+i.vParams+"&originId="+e+"&originType="+t).post().success(function(){teaweb.success("删除成功",function(){window.location.reload()})})})}},template:`<div>
|
||||
<h3>主要源站 <a href="" @click.prevent="createPrimaryOrigin()">[添加主要源站]</a> </h3>
|
||||
<p class="comment" v-if="primaryOrigins.length == 0">暂时还没有主要源站。</p>
|
||||
<origin-list-table v-if="primaryOrigins.length > 0" :v-origins="vPrimaryOrigins" :v-origin-type="'primary'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin"></origin-list-table>
|
||||
@@ -2170,35 +2385,56 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
已启用 / <span>空连接次数:{{config.minAttempts}}次/分钟</span> / 封禁时间:{{config.timeoutSeconds}}秒 <span v-if="config.ignoreLocal">/ 忽略局域网访问</span>
|
||||
</span>
|
||||
<span v-else>未启用</span>
|
||||
</div>`}),Vue.component("domains-box",{props:["v-domains","name"],data:function(){let e=this.vDomains,t=(null==e&&(e=[]),"domainsJSON");return null!=this.name&&"string"==typeof this.name&&(t=this.name),{domains:e,isAdding:!1,addingDomain:"",realName:t}},methods:{add:function(){this.isAdding=!0;let e=this;setTimeout(function(){e.$refs.addingDomain.focus()},100)},confirm:function(){let t=this;if(this.addingDomain=this.addingDomain.replace(/\s/g,""),0==this.addingDomain.length)teaweb.warn("请输入要添加的域名",function(){t.$refs.addingDomain.focus()});else{if("~"==this.addingDomain[0]){var e=this.addingDomain.substring(1);try{new RegExp(e)}catch(e){return void teaweb.warn("正则表达式错误:"+e.message,function(){t.$refs.addingDomain.focus()})}}this.domains.push(this.addingDomain),this.cancel()}},remove:function(e){this.domains.$remove(e)},cancel:function(){this.isAdding=!1,this.addingDomain=""}},template:`<div>
|
||||
</div>`}),Vue.component("domains-box",{props:["v-domains","name","v-support-wildcard"],data:function(){let e=this.vDomains,t=(null==e&&(e=[]),"domainsJSON"),i=(null!=this.name&&"string"==typeof this.name&&(t=this.name),!0);return"boolean"==typeof this.vSupportWildcard&&(i=this.vSupportWildcard),{domains:e,mode:"single",batchDomains:"",isAdding:!1,addingDomain:"",isEditing:!1,editingIndex:-1,realName:t,supportWildcard:i}},watch:{vSupportWildcard:function(e){"boolean"==typeof e&&(this.supportWildcard=e)},mode:function(e){let t=this;setTimeout(function(){"single"==e?null!=t.$refs.addingDomain&&t.$refs.addingDomain.focus():"batch"==e&&null!=t.$refs.batchDomains&&t.$refs.batchDomains.focus()},100)}},methods:{add:function(){this.isAdding=!0;let e=this;setTimeout(function(){e.$refs.addingDomain.focus()},100)},confirm:function(){if("batch"==this.mode)this.confirmBatch();else{let t=this;if(this.addingDomain=this.addingDomain.replace(/\s/g,""),0==this.addingDomain.length)teaweb.warn("请输入要添加的域名",function(){t.$refs.addingDomain.focus()});else{if(this.supportWildcard){if("~"==this.addingDomain[0]){var e=this.addingDomain.substring(1);try{new RegExp(e)}catch(e){return void teaweb.warn("正则表达式错误:"+e.message,function(){t.$refs.addingDomain.focus()})}}}else if(/[*~^]/.test(this.addingDomain))return void teaweb.warn("当前只支持添加普通域名,域名中不能含有特殊符号",function(){t.$refs.addingDomain.focus()});this.isEditing&&0<=this.editingIndex?this.domains[this.editingIndex]=this.addingDomain:this.domains.push(this.addingDomain),this.cancel(),this.change()}}},confirmBatch:function(){let e=this.batchDomains.split("\n"),i=[],s=this,n=!1;e.forEach(function(e){if(!n&&0!=e.length){if(s.supportWildcard){if("~"==e){var t=e.substring(1);try{new RegExp(t)}catch(e){return n=!0,void teaweb.warn("正则表达式错误:"+e.message,function(){s.$refs.batchDomains.focus()})}}}else if(/[*~^]/.test(e))return n=!0,void teaweb.warn("当前只支持添加普通域名,域名中不能含有特殊符号",function(){s.$refs.batchDomains.focus()});i.push(e)}}),n||(0==i.length?teaweb.warn("请输入要添加的域名",function(){s.$refs.batchDomains.focus()}):(i.forEach(function(e){s.domains.push(e)}),this.cancel(),this.change()))},edit:function(e){this.addingDomain=this.domains[e],this.isEditing=!0,this.editingIndex=e;let t=this;setTimeout(function(){t.$refs.addingDomain.focus()},50)},remove:function(e){this.domains.$remove(e),this.change()},cancel:function(){this.isAdding=!1,this.mode="single",this.batchDomains="",this.isEditing=!1,this.editingIndex=-1,this.addingDomain=""},change:function(){this.$emit("change",this.domains)}},template:`<div>
|
||||
<input type="hidden" :name="realName" :value="JSON.stringify(domains)"/>
|
||||
<div v-if="domains.length > 0">
|
||||
<span class="ui label small basic" v-for="(domain, index) in domains">
|
||||
<span class="ui label small basic" v-for="(domain, index) in domains" :class="{blue: index == editingIndex}">
|
||||
<span v-if="domain.length > 0 && domain[0] == '~'" class="grey" style="font-style: normal">[正则]</span>
|
||||
<span v-if="domain.length > 0 && domain[0] == '.'" class="grey" style="font-style: normal">[后缀]</span>
|
||||
<span v-if="domain.length > 0 && domain[0] == '*'" class="grey" style="font-style: normal">[泛域名]</span>
|
||||
{{domain}}
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
<span v-if="!isAdding && !isEditing">
|
||||
<a href="" title="修改" @click.prevent="edit(index)"><i class="icon pencil small"></i></a>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</span>
|
||||
<span v-if="isAdding || isEditing">
|
||||
<a class="disabled"><i class="icon pencil small"></i></a>
|
||||
<a class="disabled"><i class="icon remove small"></i></a>
|
||||
</span>
|
||||
</span>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div v-if="isAdding">
|
||||
<div v-if="isAdding || isEditing">
|
||||
<div class="ui fields">
|
||||
<div class="ui field" v-if="isAdding">
|
||||
<select class="ui dropdown" v-model="mode">
|
||||
<option value="single">单个</option>
|
||||
<option value="batch">批量</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<input type="text" v-model="addingDomain" @keyup.enter="confirm()" @keypress.enter.prevent="1" ref="addingDomain" placeholder="*.xxx.com" size="30"/>
|
||||
<div v-show="mode == 'single'">
|
||||
<input type="text" v-model="addingDomain" @keyup.enter="confirm()" @keypress.enter.prevent="1" @keydown.esc="cancel()" ref="addingDomain" :placeholder="supportWildcard ? 'example.com、*.example.com' : 'example.com、www.example.com'" size="30" maxlength="100"/>
|
||||
</div>
|
||||
<div v-show="mode == 'batch'">
|
||||
<textarea cols="30" v-model="batchDomains" placeholder="example1.com
|
||||
example2.com
|
||||
每行一个域名" ref="batchDomains"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button class="ui button tiny" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancel"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">支持普通域名(<code-label>example.com</code-label>)、泛域名(<code-label>*.example.com</code-label>)、域名后缀(以点号开头,如<code-label>.example.com</code-label>)和正则表达式(以波浪号开头,如<code-label>~.*.example.com</code-label>)。</p>
|
||||
<p class="comment" v-if="supportWildcard">支持普通域名(<code-label>example.com</code-label>)、泛域名(<code-label>*.example.com</code-label>)、域名后缀(以点号开头,如<code-label>.example.com</code-label>)和正则表达式(以波浪号开头,如<code-label>~.*.example.com</code-label>)。</p>
|
||||
<p class="comment" v-if="!supportWildcard">只支持普通域名(<code-label>example.com</code-label>、<code-label>www.example.com</code-label>)。</p>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div style="margin-top: 0.5em" v-if="!isAdding">
|
||||
<button class="ui button tiny" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`}),Vue.component("http-referers-config-box",{props:["v-referers-config","v-is-location","v-is-group"],data:function(){let e=this.vReferersConfig;return null==(e=null==e?{isPrior:!1,isOn:!1,allowEmpty:!0,allowSameDomain:!0,allowDomains:[]}:e).allowDomains&&(e.allowDomains=[]),{config:e}},methods:{isOn:function(){return(!this.vIsLocation&&!this.vIsGroup||this.config.isPrior)&&this.config.isOn},changeAllowDomains:function(e){}},template:`<div>
|
||||
</div>`}),Vue.component("http-referers-config-box",{props:["v-referers-config","v-is-location","v-is-group"],data:function(){let e=this.vReferersConfig;return null==(e=null==e?{isPrior:!1,isOn:!1,allowEmpty:!0,allowSameDomain:!0,allowDomains:[],denyDomains:[]}:e).allowDomains&&(e.allowDomains=[]),null==e.denyDomains&&(e.denyDomains=[]),{config:e}},methods:{isOn:function(){return(!this.vIsLocation&&!this.vIsGroup||this.config.isPrior)&&this.config.isOn},changeAllowDomains:function(e){},changeDenyDomains:function(e){}},template:`<div>
|
||||
<input type="hidden" name="referersJSON" :value="JSON.stringify(config)"/>
|
||||
<table class="ui table selectable definition">
|
||||
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
||||
@@ -2236,6 +2472,13 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<p class="comment">允许的其他来源域名列表,比如<code-label>example.com</code-label>、<code-label>*.example.com</code-label>。单个星号<code-label>*</code-label>表示允许所有域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>禁止的来源域名</td>
|
||||
<td>
|
||||
<values-box :values="config.denyDomains" @change="changeDenyDomains"></values-box>
|
||||
<p class="comment">禁止的来源域名列表,比如<code-label>example.org</code-label>、<code-label>*.example.org</code-label>;除了这些禁止的来源域名外,其他域名都会被允许,除非限定了允许的来源域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="ui margin"></div>
|
||||
@@ -3149,7 +3392,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<span v-if="accessLog.requestTime != null"> - 耗时:{{formatCost(accessLog.requestTime)}} ms </span><span v-if="accessLog.humanTime != null && accessLog.humanTime.length > 0" class="grey small"> ({{accessLog.humanTime}})</span>
|
||||
<a href="" @click.prevent="showLog" title="查看详情"><i class="icon expand"></i></a>
|
||||
</div>
|
||||
</div>`});var punycode=new function(){this.utf16={decode:function(e){for(var t,i,s=[],n=0,o=e.length;n<o;){if(55296==(63488&(t=e.charCodeAt(n++)))){if(i=e.charCodeAt(n++),55296!=(64512&t)||56320!=(64512&i))throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence");t=((1023&t)<<10)+(1023&i)+65536}s.push(t)}return s},encode:function(e){for(var t,i=[],s=0,n=e.length;s<n;){if(55296==(63488&(t=e[s++])))throw new RangeError("UTF-16(encode): Illegal UTF-16 value");65535<t&&(t-=65536,i.push(String.fromCharCode(t>>>10&1023|55296)),t=56320|1023&t),i.push(String.fromCharCode(t))}return i.join("")}};var b=2147483647;function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function x(e,t,i){var s;for(e=i?Math.floor(e/700):e>>1,e+=Math.floor(e/t),s=0;455<e;s+=36)e=Math.floor(e/35);return Math.floor(s+36*e/(e+38))}this.decode=function(e,t){var i,s,n,o,a,l,c,r,d=[],p=[],u=e.length,h=128,v=0,m=72,f=e.lastIndexOf("-");for(f<0&&(f=0),s=0;s<f;++s){if(t&&(p[d.length]=e.charCodeAt(s)-65<26),128<=e.charCodeAt(s))throw new RangeError("Illegal input >= 0x80");d.push(e.charCodeAt(s))}for(n=0<f?f+1:0;n<u;){for(o=v,a=1,l=36;;l+=36){if(u<=n)throw RangeError("punycode_bad_input(1)");if(36<=(r=(r=e.charCodeAt(n++))-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36))throw RangeError("punycode_bad_input(2)");if(r>Math.floor((b-v)/a))throw RangeError("punycode_overflow(1)");if(v+=r*a,r<(r=l<=m?1:m+26<=l?26:l-m))break;if(a>Math.floor(b/(36-r)))throw RangeError("punycode_overflow(2)");a*=36-r}if(m=x(v-o,i=d.length+1,0===o),Math.floor(v/i)>b-h)throw RangeError("punycode_overflow(3)");h+=Math.floor(v/i),v%=i,t&&p.splice(v,0,e.charCodeAt(n-1)-65<26),d.splice(v,0,h),v++}if(t)for(v=0,c=d.length;v<c;v++)p[v]&&(d[v]=String.fromCharCode(d[v]).toUpperCase().charCodeAt(0));return this.utf16.encode(d)},this.encode=function(e,t){t&&(r=this.utf16.decode(e));var i,s,n,o,a,l,c,r,d=(e=this.utf16.decode(e.toLowerCase())).length;if(t)for(g=0;g<d;g++)r[g]=e[g]!=r[g];for(var p,u,h=[],v=128,m=0,f=72,g=0;g<d;++g)e[g]<128&&h.push(String.fromCharCode(r?(p=e[g],u=r[g],(p-=(p-97<26)<<5)+((!u&&p-65<26)<<5)):e[g]));for(i=s=h.length,0<s&&h.push("-");i<d;){for(n=b,g=0;g<d;++g)v<=(c=e[g])&&c<n&&(n=c);if(n-v>Math.floor((b-m)/(i+1)))throw RangeError("punycode_overflow (1)");for(m+=(n-v)*(i+1),v=n,g=0;g<d;++g){if((c=e[g])<v&&++m>b)return Error("punycode_overflow(2)");if(c==v){for(o=m,a=36;!(o<(l=a<=f?1:f+26<=a?26:a-f));a+=36)h.push(String.fromCharCode(y(l+(o-l)%(36-l),0))),o=Math.floor((o-l)/(36-l));h.push(String.fromCharCode(y(o,t&&r[g]?1:0))),f=x(m,i+1,i==s),m=0,++i}}++m,++v}return h.join("")},this.ToASCII=function(e){for(var t=e.split("."),i=[],s=0;s<t.length;++s){var n=t[s];i.push(n.match(/[^A-Za-z0-9-]/)?"xn--"+punycode.encode(n):n)}return i.join(".")},this.ToUnicode=function(e){for(var t=e.split("."),i=[],s=0;s<t.length;++s){var n=t[s];i.push(n.match(/^xn--/)?punycode.decode(n.slice(4)):n)}return i.join(".")}};function sortTable(n){let e=document.createElement("script");e.setAttribute("src","/js/sortable.min.js"),e.addEventListener("load",function(){let s=document.querySelector("#sortable-table");null!=s&&Sortable.create(s,{draggable:"tbody",handle:".icon.handle",onStart:function(){},onUpdate:function(e){let t=s.querySelectorAll("tbody"),i=[];t.forEach(function(e){i.push(parseInt(e.getAttribute("v-id")))}),n(i)}})}),document.head.appendChild(e)}function sortLoad(e){let t=document.createElement("script");t.setAttribute("src","/js/sortable.min.js"),t.addEventListener("load",function(){"function"==typeof e&&e()}),document.head.appendChild(t)}function emitClick(e,arguments){let t=["click"];for(let e=0;e<arguments.length;e++)t.push(arguments[e]);e.$emit.apply(e,t)}Vue.component("http-firewall-block-options-viewer",{props:["v-block-options"],data:function(){return{options:this.vBlockOptions}},template:`<div>
|
||||
</div>`});var punycode=new function(){this.utf16={decode:function(e){for(var t,i,s=[],n=0,o=e.length;n<o;){if(55296==(63488&(t=e.charCodeAt(n++)))){if(i=e.charCodeAt(n++),55296!=(64512&t)||56320!=(64512&i))throw new RangeError("UTF-16(decode): Illegal UTF-16 sequence");t=((1023&t)<<10)+(1023&i)+65536}s.push(t)}return s},encode:function(e){for(var t,i=[],s=0,n=e.length;s<n;){if(55296==(63488&(t=e[s++])))throw new RangeError("UTF-16(encode): Illegal UTF-16 value");65535<t&&(t-=65536,i.push(String.fromCharCode(t>>>10&1023|55296)),t=56320|1023&t),i.push(String.fromCharCode(t))}return i.join("")}};var b=2147483647;function y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function x(e,t,i){var s;for(e=i?Math.floor(e/700):e>>1,e+=Math.floor(e/t),s=0;455<e;s+=36)e=Math.floor(e/35);return Math.floor(s+36*e/(e+38))}this.decode=function(e,t){var i,s,n,o,a,l,c,r,d=[],p=[],u=e.length,h=128,m=0,v=72,f=e.lastIndexOf("-");for(f<0&&(f=0),s=0;s<f;++s){if(t&&(p[d.length]=e.charCodeAt(s)-65<26),128<=e.charCodeAt(s))throw new RangeError("Illegal input >= 0x80");d.push(e.charCodeAt(s))}for(n=0<f?f+1:0;n<u;){for(o=m,a=1,l=36;;l+=36){if(u<=n)throw RangeError("punycode_bad_input(1)");if(36<=(r=(r=e.charCodeAt(n++))-48<10?r-22:r-65<26?r-65:r-97<26?r-97:36))throw RangeError("punycode_bad_input(2)");if(r>Math.floor((b-m)/a))throw RangeError("punycode_overflow(1)");if(m+=r*a,r<(r=l<=v?1:v+26<=l?26:l-v))break;if(a>Math.floor(b/(36-r)))throw RangeError("punycode_overflow(2)");a*=36-r}if(v=x(m-o,i=d.length+1,0===o),Math.floor(m/i)>b-h)throw RangeError("punycode_overflow(3)");h+=Math.floor(m/i),m%=i,t&&p.splice(m,0,e.charCodeAt(n-1)-65<26),d.splice(m,0,h),m++}if(t)for(m=0,c=d.length;m<c;m++)p[m]&&(d[m]=String.fromCharCode(d[m]).toUpperCase().charCodeAt(0));return this.utf16.encode(d)},this.encode=function(e,t){t&&(r=this.utf16.decode(e));var i,s,n,o,a,l,c,r,d=(e=this.utf16.decode(e.toLowerCase())).length;if(t)for(g=0;g<d;g++)r[g]=e[g]!=r[g];for(var p,u,h=[],m=128,v=0,f=72,g=0;g<d;++g)e[g]<128&&h.push(String.fromCharCode(r?(p=e[g],u=r[g],(p-=(p-97<26)<<5)+((!u&&p-65<26)<<5)):e[g]));for(i=s=h.length,0<s&&h.push("-");i<d;){for(n=b,g=0;g<d;++g)m<=(c=e[g])&&c<n&&(n=c);if(n-m>Math.floor((b-v)/(i+1)))throw RangeError("punycode_overflow (1)");for(v+=(n-m)*(i+1),m=n,g=0;g<d;++g){if((c=e[g])<m&&++v>b)return Error("punycode_overflow(2)");if(c==m){for(o=v,a=36;!(o<(l=a<=f?1:f+26<=a?26:a-f));a+=36)h.push(String.fromCharCode(y(l+(o-l)%(36-l),0))),o=Math.floor((o-l)/(36-l));h.push(String.fromCharCode(y(o,t&&r[g]?1:0))),f=x(v,i+1,i==s),v=0,++i}}++v,++m}return h.join("")},this.ToASCII=function(e){for(var t=e.split("."),i=[],s=0;s<t.length;++s){var n=t[s];i.push(n.match(/[^A-Za-z0-9-]/)?"xn--"+punycode.encode(n):n)}return i.join(".")},this.ToUnicode=function(e){for(var t=e.split("."),i=[],s=0;s<t.length;++s){var n=t[s];i.push(n.match(/^xn--/)?punycode.decode(n.slice(4)):n)}return i.join(".")}};function sortTable(n){let e=document.createElement("script");e.setAttribute("src","/js/sortable.min.js"),e.addEventListener("load",function(){let s=document.querySelector("#sortable-table");null!=s&&Sortable.create(s,{draggable:"tbody",handle:".icon.handle",onStart:function(){},onUpdate:function(e){let t=s.querySelectorAll("tbody"),i=[];t.forEach(function(e){i.push(parseInt(e.getAttribute("v-id")))}),n(i)}})}),document.head.appendChild(e)}function sortLoad(e){let t=document.createElement("script");t.setAttribute("src","/js/sortable.min.js"),t.addEventListener("load",function(){"function"==typeof e&&e()}),document.head.appendChild(t)}function emitClick(e,arguments){let t=["click"];for(let e=0;e<arguments.length;e++)t.push(arguments[e]);e.$emit.apply(e,t)}Vue.component("http-firewall-block-options-viewer",{props:["v-block-options"],data:function(){return{options:this.vBlockOptions}},template:`<div>
|
||||
<span v-if="options == null">默认设置</span>
|
||||
<div v-else>
|
||||
状态码:{{options.statusCode}} / 提示内容:<span v-if="options.body != null && options.body.length > 0">[{{options.body.length}}字符]</span><span v-else class="disabled">[无]</span> / 超时时间:{{options.timeout}}秒
|
||||
@@ -3909,7 +4152,10 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
{{cond.value}}
|
||||
<sup v-if="cond.isCaseInsensitive" title="不区分大小写"><i class="icon info small"></i></sup>
|
||||
</span>
|
||||
</div>`}),Vue.component("http-firewall-rules-box",{props:["v-rules","v-type"],data:function(){let e=this.vRules;return{rules:e=null==e?[]:e}},methods:{addRule:function(){window.UPDATING_RULE=null;let t=this;teaweb.popup("/servers/components/waf/createRulePopup?type="+this.vType,{callback:function(e){t.rules.push(e.data.rule)}})},updateRule:function(t,e){window.UPDATING_RULE=e;let i=this;teaweb.popup("/servers/components/waf/createRulePopup?type="+this.vType,{callback:function(e){Vue.set(i.rules,t,e.data.rule)}})},removeRule:function(e){let t=this;teaweb.confirm("确定要删除此规则吗?",function(){t.rules.$remove(e)})}},template:`<div>
|
||||
</div>`}),Vue.component("http-header-assistant",{props:["v-type","v-value"],mounted:function(){let t=this;Tea.action("/servers/headers/options?type="+this.vType).post().success(function(e){t.allHeaders=e.data.headers})},data:function(){return{allHeaders:[],matchedHeaders:[],selectedHeaderName:""}},watch:{vValue:function(t){t!=this.selectedHeaderName&&(this.selectedHeaderName=""),0==t.length?this.matchedHeaders=[]:this.matchedHeaders=this.allHeaders.filter(function(e){return teaweb.match(e,t)}).slice(0,5)}},methods:{select:function(e){this.$emit("select",e),this.selectedHeaderName=e}},template:`<span v-if="selectedHeaderName.length == 0">
|
||||
<a href="" v-for="header in matchedHeaders" class="ui label basic tiny blue" style="font-weight: normal" @click.prevent="select(header)">{{header}}</a>
|
||||
<span v-if="matchedHeaders.length > 0"> </span>
|
||||
</span>`}),Vue.component("http-firewall-rules-box",{props:["v-rules","v-type"],data:function(){let e=this.vRules;return{rules:e=null==e?[]:e}},methods:{addRule:function(){window.UPDATING_RULE=null;let t=this;teaweb.popup("/servers/components/waf/createRulePopup?type="+this.vType,{callback:function(e){t.rules.push(e.data.rule)}})},updateRule:function(t,e){window.UPDATING_RULE=e;let i=this;teaweb.popup("/servers/components/waf/createRulePopup?type="+this.vType,{callback:function(e){Vue.set(i.rules,t,e.data.rule)}})},removeRule:function(e){let t=this;teaweb.confirm("确定要删除此规则吗?",function(){t.rules.$remove(e)})}},template:`<div>
|
||||
<input type="hidden" name="rulesJSON" :value="JSON.stringify(rules)"/>
|
||||
<div v-if="rules.length > 0">
|
||||
<div v-for="(rule, index) in rules" class="ui label small basic" style="margin-bottom: 0.5em">
|
||||
@@ -3922,7 +4168,8 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
|
||||
<!-- refererBlock -->
|
||||
<span v-if="rule.param == '\${refererBlock}'">
|
||||
{{rule.checkpointOptions.allowDomains}}
|
||||
<span v-if="rule.checkpointOptions.allowDomains != null && rule.checkpointOptions.allowDomains.length > 0">允许{{rule.checkpointOptions.allowDomains}}</span>
|
||||
<span v-if="rule.checkpointOptions.denyDomains != null && rule.checkpointOptions.denyDomains.length > 0">禁止{{rule.checkpointOptions.denyDomains}}</span>
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
@@ -4600,7 +4847,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<input type="hidden" :name="vName" :value="JSON.stringify(addrs)"/>
|
||||
<div v-if="addrs.length > 0">
|
||||
<div>
|
||||
<div v-for="(addr, index) in addrs" class="ui label small">
|
||||
<div v-for="(addr, index) in addrs" class="ui label small basic">
|
||||
{{addr.protocol}}://{{addr.host.quoteIP()}}:{{addr.portRange}}</span>
|
||||
<a href="" title="修改" @click.prevent="updateAddr(index, addr)"><i class="icon pencil small"></i></a>
|
||||
<a href="" title="删除" @click.prevent="removeAddr(index)"><i class="icon remove"></i></a>
|
||||
@@ -4636,7 +4883,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<tr>
|
||||
<td colspan="2"><a href="" @click.prevent="show()"><span v-if="!isVisible">更多选项</span><span v-if="isVisible">收起选项</span><i class="icon angle" :class="{down:!isVisible, up:isVisible}"></i></a></td>
|
||||
</tr>
|
||||
</tbody>`}),Vue.component("download-link",{props:["v-element","v-file","v-value"],created:function(){let e=this;setTimeout(function(){e.url=e.composeURL()},1e3)},data:function(){let e=this.vFile;return{file:e=null!=e&&0!=e.length?e:"unknown-file",url:this.composeURL()}},methods:{composeURL:function(){let e="";if(null!=this.vValue)e=this.vValue;else{var t=document.getElementById(this.vElement);if(null==t)return void teaweb.warn("找不到要下载的内容");null==(e=t.innerText)&&(e=t.textContent)}return Tea.url("/ui/download",{file:this.file,text:e})}},template:'<a :href="url" target="_blank" style="font-weight: normal"><slot></slot></a>'}),Vue.component("values-box",{props:["values","v-values","size","maxlength","name","placeholder"],data:function(){let e=this.values;return null==e&&(e=[]),{realValues:e=null!=this.vValues&&"object"==typeof this.vValues?this.vValues:e,isUpdating:!1,isAdding:!1,index:0,value:"",isEditing:!1}},methods:{create:function(){this.isAdding=!0;var e=this;setTimeout(function(){e.$refs.value.focus()},200)},update:function(e){this.cancel(),this.isUpdating=!0,this.index=e,this.value=this.realValues[e];var t=this;setTimeout(function(){t.$refs.value.focus()},200)},confirm:function(){0!=this.value.length&&(this.isUpdating?Vue.set(this.realValues,this.index,this.value):this.realValues.push(this.value),this.cancel(),this.$emit("change",this.realValues))},remove:function(e){this.realValues.$remove(e),this.$emit("change",this.realValues)},cancel:function(){this.isUpdating=!1,this.isAdding=!1,this.value=""},updateAll:function(e){this.realValues=e},addValue:function(e){this.realValues.push(e)},startEditing:function(){this.isEditing=!this.isEditing},allValues:function(){return this.realValues}},template:`<div>
|
||||
</tbody>`}),Vue.component("download-link",{props:["v-element","v-file","v-value"],created:function(){let e=this;setTimeout(function(){e.url=e.composeURL()},1e3)},data:function(){let e=this.vFile;return{file:e=null!=e&&0!=e.length?e:"unknown-file",url:this.composeURL()}},methods:{composeURL:function(){let e="";if(null!=this.vValue)e=this.vValue;else{var t=document.getElementById(this.vElement);if(null==t)return;null==(e=t.innerText)&&(e=t.textContent)}return Tea.url("/ui/download",{file:this.file,text:e})}},template:'<a :href="url" target="_blank" style="font-weight: normal"><slot></slot></a>'}),Vue.component("values-box",{props:["values","v-values","size","maxlength","name","placeholder"],data:function(){let e=this.values;return null==e&&(e=[]),{realValues:e=null!=this.vValues&&"object"==typeof this.vValues?this.vValues:e,isUpdating:!1,isAdding:!1,index:0,value:"",isEditing:!1}},methods:{create:function(){this.isAdding=!0;var e=this;setTimeout(function(){e.$refs.value.focus()},200)},update:function(e){this.cancel(),this.isUpdating=!0,this.index=e,this.value=this.realValues[e];var t=this;setTimeout(function(){t.$refs.value.focus()},200)},confirm:function(){0!=this.value.length&&(this.isUpdating?Vue.set(this.realValues,this.index,this.value):this.realValues.push(this.value),this.cancel(),this.$emit("change",this.realValues))},remove:function(e){this.realValues.$remove(e),this.$emit("change",this.realValues)},cancel:function(){this.isUpdating=!1,this.isAdding=!1,this.value=""},updateAll:function(e){this.realValues=e},addValue:function(e){this.realValues.push(e)},startEditing:function(){this.isEditing=!this.isEditing},allValues:function(){return this.realValues}},template:`<div>
|
||||
<div v-show="!isEditing && realValues.length > 0">
|
||||
<div class="ui label tiny basic" v-for="(value, index) in realValues" style="margin-top:0.4em;margin-bottom:0.4em">{{value}}</div>
|
||||
<a href="" @click.prevent="startEditing" style="font-size: 0.8em; margin-left: 0.2em">[修改]</a>
|
||||
@@ -4668,7 +4915,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<button class="ui button tiny" type="button" @click.prevent="create()">+</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`}),Vue.component("datetime-input",{props:["v-name","v-timestamp"],mounted:function(){let t=this;teaweb.datepicker(this.$refs.dayInput,function(e){t.day=e,t.hour="23",t.minute="59",t.second="59",t.change()})},data:function(){let t=this.vTimestamp,i=(null!=t?(t=parseInt(t),isNaN(t)&&(t=0)):t=0,""),s="",n="",o="";if(0<t){let e=new Date;e.setTime(1e3*t);var a=e.getFullYear().toString(),l=this.leadingZero((e.getMonth()+1).toString(),2);i=a+"-"+l+"-"+this.leadingZero(e.getDate().toString(),2),s=this.leadingZero(e.getHours().toString(),2),n=this.leadingZero(e.getMinutes().toString(),2),o=this.leadingZero(e.getSeconds().toString(),2)}return{timestamp:t,day:i,hour:s,minute:n,second:o,hasDayError:!1,hasHourError:!1,hasMinuteError:!1,hasSecondError:!1}},methods:{change:function(){let e=new Date;var t,i;/^\d{4}-\d{1,2}-\d{1,2}$/.test(this.day)?(i=this.day.split("-"),t=parseInt(i[0]),e.setFullYear(t),(t=parseInt(i[1]))<1||12<t?this.hasDayError=!0:(e.setMonth(t-1),(t=parseInt(i[2]))<1||32<t?this.hasDayError=!0:(e.setDate(t),this.hasDayError=!1,/^\d+$/.test(this.hour)?(i=parseInt(this.hour),isNaN(i)||i<0||24<=i?this.hasHourError=!0:(this.hasHourError=!1,e.setHours(i),/^\d+$/.test(this.minute)?(t=parseInt(this.minute),isNaN(t)||t<0||60<=t?this.hasMinuteError=!0:(this.hasMinuteError=!1,e.setMinutes(t),/^\d+$/.test(this.second)?(i=parseInt(this.second),isNaN(i)||i<0||60<=i?this.hasSecondError=!0:(this.hasSecondError=!1,e.setSeconds(i),this.timestamp=Math.floor(e.getTime()/1e3))):this.hasSecondError=!0)):this.hasMinuteError=!0)):this.hasHourError=!0))):this.hasDayError=!0},leadingZero:function(t,i){if(i<=(t=t.toString()).length)return t;for(let e=0;e<i-t.length;e++)t="0"+t;return t},resultTimestamp:function(){return this.timestamp},nextDays:function(e){let t=new Date;t.setTime(t.getTime()+86400*e*1e3),this.day=t.getFullYear()+"-"+this.leadingZero(t.getMonth()+1,2)+"-"+this.leadingZero(t.getDate(),2),this.hour=this.leadingZero(t.getHours(),2),this.minute=this.leadingZero(t.getMinutes(),2),this.second=this.leadingZero(t.getSeconds(),2),this.change()},nextHours:function(e){let t=new Date;t.setTime(t.getTime()+3600*e*1e3),this.day=t.getFullYear()+"-"+this.leadingZero(t.getMonth()+1,2)+"-"+this.leadingZero(t.getDate(),2),this.hour=this.leadingZero(t.getHours(),2),this.minute=this.leadingZero(t.getMinutes(),2),this.second=this.leadingZero(t.getSeconds(),2),this.change()}},template:`<div>
|
||||
</div>`}),Vue.component("datetime-input",{props:["v-name","v-timestamp"],mounted:function(){let t=this;teaweb.datepicker(this.$refs.dayInput,function(e){t.day=e,t.hour="23",t.minute="59",t.second="59",t.change()})},data:function(){let t=this.vTimestamp,i=(null!=t?(t=parseInt(t),isNaN(t)&&(t=0)):t=0,""),s="",n="",o="";if(0<t){let e=new Date;e.setTime(1e3*t);var a=e.getFullYear().toString(),l=this.leadingZero((e.getMonth()+1).toString(),2);i=a+"-"+l+"-"+this.leadingZero(e.getDate().toString(),2),s=this.leadingZero(e.getHours().toString(),2),n=this.leadingZero(e.getMinutes().toString(),2),o=this.leadingZero(e.getSeconds().toString(),2)}return{timestamp:t,day:i,hour:s,minute:n,second:o,hasDayError:!1,hasHourError:!1,hasMinuteError:!1,hasSecondError:!1}},methods:{change:function(){if(/^\d{4}-\d{1,2}-\d{1,2}$/.test(this.day)){var t=this.day.split("-"),i=parseInt(t[0]),s=parseInt(t[1]);if(s<1||12<s)this.hasDayError=!0;else{t=parseInt(t[2]);if(t<1||32<t)this.hasDayError=!0;else if(this.hasDayError=!1,/^\d+$/.test(this.hour)){var n=parseInt(this.hour);if(isNaN(n))this.hasHourError=!0;else if(n<0||24<=n)this.hasHourError=!0;else if(this.hasHourError=!1,/^\d+$/.test(this.minute)){var o=parseInt(this.minute);if(isNaN(o))this.hasMinuteError=!0;else if(o<0||60<=o)this.hasMinuteError=!0;else if(this.hasMinuteError=!1,/^\d+$/.test(this.second)){var a=parseInt(this.second);if(isNaN(a))this.hasSecondError=!0;else if(a<0||60<=a)this.hasSecondError=!0;else{this.hasSecondError=!1;let e=new Date(i,s-1,t,n,o,a);this.timestamp=Math.floor(e.getTime()/1e3)}}else this.hasSecondError=!0}else this.hasMinuteError=!0}else this.hasHourError=!0}}else this.hasDayError=!0},leadingZero:function(t,i){if(i<=(t=t.toString()).length)return t;for(let e=0;e<i-t.length;e++)t="0"+t;return t},resultTimestamp:function(){return this.timestamp},nextDays:function(e){let t=new Date;t.setTime(t.getTime()+86400*e*1e3),this.day=t.getFullYear()+"-"+this.leadingZero(t.getMonth()+1,2)+"-"+this.leadingZero(t.getDate(),2),this.hour=this.leadingZero(t.getHours(),2),this.minute=this.leadingZero(t.getMinutes(),2),this.second=this.leadingZero(t.getSeconds(),2),this.change()},nextHours:function(e){let t=new Date;t.setTime(t.getTime()+3600*e*1e3),this.day=t.getFullYear()+"-"+this.leadingZero(t.getMonth()+1,2)+"-"+this.leadingZero(t.getDate(),2),this.hour=this.leadingZero(t.getHours(),2),this.minute=this.leadingZero(t.getMinutes(),2),this.second=this.leadingZero(t.getSeconds(),2),this.change()}},template:`<div>
|
||||
<input type="hidden" :name="vName" :value="timestamp"/>
|
||||
<div class="ui fields inline" style="padding: 0; margin:0">
|
||||
<div class="ui field" :class="{error: hasDayError}">
|
||||
@@ -4681,7 +4928,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<div class="ui field" :class="{error: hasSecondError}"><input type="text" v-model="second" maxlength="2" style="width:4em" placeholder="秒" @input="change"/></div>
|
||||
</div>
|
||||
<p class="comment">常用时间:<a href="" @click.prevent="nextHours(1)"> 1小时 </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(1)"> 1天 </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(3)"> 3天 </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(7)"> 1周 </a> <span class="disabled">|</span> <a href="" @click.prevent="nextDays(30)"> 30天 </a> </p>
|
||||
</div>`}),Vue.component("label-on",{props:["v-is-on"],template:'<div><span v-if="vIsOn" class="ui label tiny green basic">已启用</span><span v-if="!vIsOn" class="ui label tiny red basic">已停用</span></div>'}),Vue.component("code-label",{methods:{click:function(e){this.$emit("click",e)}},template:'<span class="ui label basic tiny" style="padding: 3px;margin-left:2px;margin-right:2px" @click.prevent="click"><slot></slot></span>'}),Vue.component("code-label-plain",{template:'<span class="ui label basic tiny" style="padding: 3px;margin-left:2px;margin-right:2px"><slot></slot></span>'}),Vue.component("tiny-label",{template:'<span class="ui label tiny" style="margin-bottom: 0.5em"><slot></slot></span>'}),Vue.component("tiny-basic-label",{template:'<span class="ui label tiny basic" style="margin-bottom: 0.5em"><slot></slot></span>'}),Vue.component("micro-basic-label",{template:'<span class="ui label tiny basic" style="margin-bottom: 0.5em; font-size: 0.7em; padding: 4px"><slot></slot></span>'}),Vue.component("grey-label",{props:["color"],data:function(){let e="grey";return{labelColor:e=null!=this.color&&0<this.color.length?"red":e}},template:'<span class="ui label basic tiny" :class="labelColor" style="margin-top: 0.4em; font-size: 0.7em; border: 1px solid #ddd!important; font-weight: normal;"><slot></slot></span>'}),Vue.component("optional-label",{template:'<em><span class="grey">(可选)</span></em>'}),Vue.component("plus-label",{template:'<span style="color: #B18701;">Plus专属功能。</span>'}),Vue.component("pro-warning-label",{template:'<span><i class="icon warning circle yellow"></i>注意:通常不需要修改;如要修改,请在专家指导下进行。</span>'}),Vue.component("first-menu",{props:[],template:' \t\t<div class="first-menu"> \t\t\t<div class="ui menu text blue small">\t\t\t\t<slot></slot>\t\t\t</div> \t\t\t<div class="ui divider"></div> \t\t</div>'}),Vue.component("more-options-indicator",{data:function(){return{visible:!1}},methods:{changeVisible:function(){this.visible=!this.visible,null!=Tea.Vue&&(Tea.Vue.moreOptionsVisible=this.visible),this.$emit("change",this.visible)}},template:'<a href="" style="font-weight: normal" @click.prevent="changeVisible()"><slot><span v-if="!visible">更多选项</span><span v-if="visible">收起选项</span></slot> <i class="icon angle" :class="{down:!visible, up:visible}"></i> </a>'}),Vue.component("page-size-selector",{data:function(){let t=window.location.search,i=10;if(0<t.length){let e=(t=t.substr(1)).split("&");e.forEach(function(t){t=t.split("=");if(2==t.length&&"pageSize"==t[0]){let e=t[1];e.match(/^\d+$/)&&(i=parseInt(e,10),(isNaN(i)||i<1)&&(i=10))}})}return{pageSize:i}},watch:{pageSize:function(){window.ChangePageSize(this.pageSize)}},template:`<select class="ui dropdown" style="height:34px;padding-top:0;padding-bottom:0;margin-left:1em;color:#666" v-model="pageSize">
|
||||
</div>`}),Vue.component("label-on",{props:["v-is-on"],template:'<div><span v-if="vIsOn" class="green">已启用</span><span v-if="!vIsOn" class="red">已停用</span></div>'}),Vue.component("code-label",{methods:{click:function(e){this.$emit("click",e)}},template:'<span class="ui label basic tiny" style="padding: 3px;margin-left:2px;margin-right:2px" @click.prevent="click"><slot></slot></span>'}),Vue.component("code-label-plain",{template:'<span class="ui label basic tiny" style="padding: 3px;margin-left:2px;margin-right:2px"><slot></slot></span>'}),Vue.component("tiny-label",{template:'<span class="ui label tiny" style="margin-bottom: 0.5em"><slot></slot></span>'}),Vue.component("tiny-basic-label",{template:'<span class="ui label tiny basic" style="margin-bottom: 0.5em"><slot></slot></span>'}),Vue.component("micro-basic-label",{template:'<span class="ui label tiny basic" style="margin-bottom: 0.5em; font-size: 0.7em; padding: 4px"><slot></slot></span>'}),Vue.component("grey-label",{props:["color"],data:function(){let e="grey";return{labelColor:e=null!=this.color&&0<this.color.length?"red":e}},template:'<span class="ui label basic tiny" :class="labelColor" style="margin-top: 0.4em; font-size: 0.7em; border: 1px solid #ddd!important; font-weight: normal;"><slot></slot></span>'}),Vue.component("optional-label",{template:'<em><span class="grey">(可选)</span></em>'}),Vue.component("plus-label",{template:'<span style="color: #B18701;">Plus专属功能。</span>'}),Vue.component("pro-warning-label",{template:'<span><i class="icon warning circle yellow"></i>注意:通常不需要修改;如要修改,请在专家指导下进行。</span>'}),Vue.component("first-menu",{props:[],template:' \t\t<div class="first-menu"> \t\t\t<div class="ui menu text blue small">\t\t\t\t<slot></slot>\t\t\t</div> \t\t\t<div class="ui divider"></div> \t\t</div>'}),Vue.component("more-options-indicator",{data:function(){return{visible:!1}},methods:{changeVisible:function(){this.visible=!this.visible,null!=Tea.Vue&&(Tea.Vue.moreOptionsVisible=this.visible),this.$emit("change",this.visible)}},template:'<a href="" style="font-weight: normal" @click.prevent="changeVisible()"><slot><span v-if="!visible">更多选项</span><span v-if="visible">收起选项</span></slot> <i class="icon angle" :class="{down:!visible, up:visible}"></i> </a>'}),Vue.component("page-size-selector",{data:function(){let t=window.location.search,i=10;if(0<t.length){let e=(t=t.substr(1)).split("&");e.forEach(function(t){t=t.split("=");if(2==t.length&&"pageSize"==t[0]){let e=t[1];e.match(/^\d+$/)&&(i=parseInt(e,10),(isNaN(i)||i<1)&&(i=10))}})}return{pageSize:i}},watch:{pageSize:function(){window.ChangePageSize(this.pageSize)}},template:`<select class="ui dropdown" style="height:34px;padding-top:0;padding-bottom:0;margin-left:1em;color:#666" v-model="pageSize">
|
||||
<option value="10">[每页]</option><option value="10" selected="selected">10条</option><option value="20">20条</option><option value="30">30条</option><option value="40">40条</option><option value="50">50条</option><option value="60">60条</option><option value="70">70条</option><option value="80">80条</option><option value="90">90条</option><option value="100">100条</option>
|
||||
</select>`}),Vue.component("second-menu",{template:' \t\t<div class="second-menu"> \t\t\t<div class="ui menu text blue small">\t\t\t\t<slot></slot>\t\t\t</div> \t\t\t<div class="ui divider"></div> \t\t</div>'}),Vue.component("loading-message",{template:`<div class="ui message loading">
|
||||
<div class="ui active inline loader small"></div> <slot></slot>
|
||||
@@ -4891,7 +5138,11 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<div class="content">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>`}),Vue.component("digit-input",{props:["value","maxlength","size","min","max","required","placeholder"],mounted:function(){let e=this;setTimeout(function(){e.check()})},data:function(){let e=this.maxlength,t=(null==e&&(e=20),this.size);return null==t&&(t=6),{realValue:this.value,realMaxLength:e,realSize:t,isValid:!0}},watch:{realValue:function(e){this.notifyChange()}},methods:{notifyChange:function(){let e=parseInt(this.realValue.toString(),10);isNaN(e)&&(e=0),this.check(),this.$emit("input",e)},check:function(){var e;null!=this.realValue&&(e=this.realValue.toString(),/^\d+$/.test(e)?(e=parseInt(e,10),isNaN(e)?this.isValid=!1:this.required?this.isValid=(null==this.min||this.min<=e)&&(null==this.max||this.max>=e):this.isValid=0==e||(null==this.min||this.min<=e)&&(null==this.max||this.max>=e)):this.isValid=!1)}},template:'<input type="text" v-model="realValue" :maxlength="realMaxLength" :size="realSize" :class="{error: !this.isValid}" :placeholder="placeholder"/>'}),Vue.component("keyword",{props:["v-word"],data:function(){let e=this.vWord;e=null==e?"":(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\)/g,"\\)")).replace(/\(/g,"\\(")).replace(/\+/g,"\\+")).replace(/\^/g,"\\^")).replace(/\$/g,"\\$")).replace(/\?/g,"\\?")).replace(/\*/g,"\\*")).replace(/\[/g,"\\[")).replace(/{/g,"\\{")).replace(/\./g,"\\.");let t=this.$slots.default[0].text;if(0<e.length){let i=this,s=[],n=0;t=t.replaceAll(new RegExp("("+e+")","ig"),function(e){n++;var e='<span style="border: 1px #ccc dashed; color: #ef4d58">'+i.encodeHTML(e)+"</span>",t="$TMP__KEY__"+n.toString()+"$";return s.push([t,e]),t}),t=this.encodeHTML(t),s.forEach(function(e){t=t.replace(e[0],e[1])})}else t=this.encodeHTML(t);return{word:e,text:t}},methods:{encodeHTML:function(e){return e=(e=(e=(e=e.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/"/g,""")}},template:'<span><span style="display: none"><slot></slot></span><span v-html="text"></span></span>'}),Vue.component("node-log-row",{props:["v-log","v-keyword"],data:function(){return{log:this.vLog,keyword:this.vKeyword}},template:`<div>
|
||||
</div>`}),Vue.component("digit-input",{props:["value","maxlength","size","min","max","required","placeholder"],mounted:function(){let e=this;setTimeout(function(){e.check()})},data:function(){let e=this.maxlength,t=(null==e&&(e=20),this.size);return null==t&&(t=6),{realValue:this.value,realMaxLength:e,realSize:t,isValid:!0}},watch:{realValue:function(e){this.notifyChange()}},methods:{notifyChange:function(){let e=parseInt(this.realValue.toString(),10);isNaN(e)&&(e=0),this.check(),this.$emit("input",e)},check:function(){var e;null!=this.realValue&&(e=this.realValue.toString(),/^\d+$/.test(e)?(e=parseInt(e,10),isNaN(e)?this.isValid=!1:this.required?this.isValid=(null==this.min||this.min<=e)&&(null==this.max||this.max>=e):this.isValid=0==e||(null==this.min||this.min<=e)&&(null==this.max||this.max>=e)):this.isValid=!1)}},template:'<input type="text" v-model="realValue" :maxlength="realMaxLength" :size="realSize" :class="{error: !this.isValid}" :placeholder="placeholder"/>'}),Vue.component("keyword",{props:["v-word"],data:function(){let e=this.vWord;e=null==e?"":(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\)/g,"\\)")).replace(/\(/g,"\\(")).replace(/\+/g,"\\+")).replace(/\^/g,"\\^")).replace(/\$/g,"\\$")).replace(/\?/g,"\\?")).replace(/\*/g,"\\*")).replace(/\[/g,"\\[")).replace(/{/g,"\\{")).replace(/\./g,"\\.");let t=this.$slots.default[0].text;if(0<e.length){let i=this,s=[],n=0;t=t.replaceAll(new RegExp("("+e+")","ig"),function(e){n++;var e='<span style="border: 1px #ccc dashed; color: #ef4d58">'+i.encodeHTML(e)+"</span>",t="$TMP__KEY__"+n.toString()+"$";return s.push([t,e]),t}),t=this.encodeHTML(t),s.forEach(function(e){t=t.replace(e[0],e[1])})}else t=this.encodeHTML(t);return{word:e,text:t}},methods:{encodeHTML:function(e){return e=(e=(e=(e=e.replace(/&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/"/g,""")}},template:'<span><span style="display: none"><slot></slot></span><span v-html="text"></span></span>'}),Vue.component("bits-var",{props:["v-bits"],data:function(){let e=this.vBits;return"number"!=typeof e&&(e=0),{format:teaweb.splitFormat(teaweb.formatBits(e))}},template:`<var class="normal">
|
||||
<span>{{format[0]}}</span>{{format[1]}}
|
||||
</var>`}),Vue.component("bytes-var",{props:["v-bytes"],data:function(){let e=this.vBytes;return"number"!=typeof e&&(e=0),{format:teaweb.splitFormat(teaweb.formatBytes(e))}},template:`<var class="normal">
|
||||
<span>{{format[0]}}</span>{{format[1]}}
|
||||
</var>`}),Vue.component("node-log-row",{props:["v-log","v-keyword"],data:function(){return{log:this.vLog,keyword:this.vKeyword}},template:`<div>
|
||||
<pre class="log-box" style="margin: 0; padding: 0"><span :class="{red:log.level == 'error', orange:log.level == 'warning', green: log.level == 'success'}"><span v-if="!log.isToday">[{{log.createdTime}}]</span><strong v-if="log.isToday">[{{log.createdTime}}]</strong><keyword :v-word="keyword">[{{log.tag}}]{{log.description}}</keyword></span> <span v-if="log.count > 1" class="ui label tiny" :class="{red:log.level == 'error', orange:log.level == 'warning'}">共{{log.count}}条</span> <span v-if="log.server != null && log.server.id > 0"><a :href="'/servers/server?serverId=' + log.server.id" class="ui label tiny basic">{{log.server.name}}</a></span></pre>
|
||||
</div>`}),Vue.component("provinces-selector",{props:["v-provinces"],data:function(){let e=this.vProvinces;var t=(e=null==e?[]:e).$map(function(e,t){return t.id});return{provinces:e,provinceIds:t}},methods:{add:function(){let e=this.provinceIds.map(function(e){return e.toString()}),t=this;teaweb.popup("/ui/selectProvincesPopup?provinceIds="+e.join(","),{width:"48em",height:"23em",callback:function(e){t.provinces=e.data.provinces,t.change()}})},remove:function(e){this.provinces.$remove(e),this.change()},change:function(){this.provinceIds=this.provinces.$map(function(e,t){return t.id})}},template:`<div>
|
||||
<input type="hidden" name="provinceIdsJSON" :value="JSON.stringify(provinceIds)"/>
|
||||
@@ -4929,8 +5180,8 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
|
||||
<div class="ui menu text blue small">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>`}),Vue.component("datepicker",{props:["v-name","v-value","v-bottom-left"],mounted:function(){let t=this;teaweb.datepicker(this.$refs.dayInput,function(e){t.day=e,t.change()},!!this.vBottomLeft)},data:function(){let e=this.vName,t=(null==e&&(e="day"),this.vValue);return null==t&&(t=""),{name:e,day:t}},methods:{change:function(){this.$emit("change",this.day)}},template:`<div style="display: inline-block">
|
||||
<input type="text" :name="name" v-model="day" placeholder="YYYY-MM-DD" style="width:8.6em" maxlength="10" @input="change" ref="dayInput" autocomplete="off"/>
|
||||
</div>`}),Vue.component("datepicker",{props:["value","v-name","name","v-value","v-bottom-left","placeholder"],mounted:function(){let t=this;teaweb.datepicker(this.$refs.dayInput,function(e){t.day=e,t.change()},!!this.vBottomLeft)},data:function(){let e=this.vName,t=(null==(e=null==e?this.name:e)&&(e="day"),this.vValue),i=(null==t&&null==(t=this.value)&&(t=""),"YYYY-MM-DD");return null!=this.placeholder&&(i=this.placeholder),{realName:e,realPlaceholder:i,day:t}},watch:{value:function(e){this.day=e}},methods:{change:function(){this.$emit("input",this.day),this.$emit("change",this.day)}},template:`<div style="display: inline-block">
|
||||
<input type="text" :name="realName" v-model="day" :placeholder="realPlaceholder" style="width:8.6em" maxlength="10" @input="change" ref="dayInput" autocomplete="off"/>
|
||||
</div>`}),Vue.component("sort-arrow",{props:["name"],data:function(){let e=window.location.toString(),n="",t="",o=[];if(null!=window.location.search&&0<window.location.search.length){let e=window.location.search.substring(1),t=e.split("&"),s=this;t.forEach(function(e){var t,i=e.indexOf("=");0<i?(t=e.substring(0,i),i=e.substring(i+1),t==s.name?n=i:"page"!=t&&"asc"!=i&&"desc"!=i&&o.push(e)):o.push(e)})}t="asc"!=n&&"desc"==n?(o.push(this.name+"=asc"),"当前倒序排列"):(o.push(this.name+"=desc"),"当前正序排列");var i=e.indexOf("?");return e=0<i?e.substring(0,i)+"?"+o.join("&"):e+"?"+o.join("&"),{order:n,url:e,iconTitle:t}},template:`<a :href="url" :title="iconTitle"> <i class="ui icon long arrow small" :class="{down: order == 'asc', up: order == 'desc', 'down grey': order == '' || order == null}"></i></a>`}),Vue.component("user-link",{props:["v-user","v-keyword"],data:function(){let e=this.vUser;return{user:e=null==e?{id:0,username:"",fullname:""}:e}},template:`<div style="display: inline-block">
|
||||
<span v-if="user.id > 0"><keyword :v-word="vKeyword">{{user.fullname}}</keyword><span class="small grey">(<keyword :v-word="vKeyword">{{user.username}}</keyword>)</span></span>
|
||||
<span v-else class="disabled">[已删除]</span>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
web/public/js/components/.gitignore
vendored
Normal file
1
web/public/js/components/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*-plus.js
|
||||
@@ -41,7 +41,7 @@ Vue.component("api-node-addresses-box", {
|
||||
<input type="hidden" :name="vName" :value="JSON.stringify(addrs)"/>
|
||||
<div v-if="addrs.length > 0">
|
||||
<div>
|
||||
<div v-for="(addr, index) in addrs" class="ui label small">
|
||||
<div v-for="(addr, index) in addrs" class="ui label small basic">
|
||||
{{addr.protocol}}://{{addr.host.quoteIP()}}:{{addr.portRange}}</span>
|
||||
<a href="" title="修改" @click.prevent="updateAddr(index, addr)"><i class="icon pencil small"></i></a>
|
||||
<a href="" title="删除" @click.prevent="removeAddr(index)"><i class="icon remove"></i></a>
|
||||
|
||||
16
web/public/js/components/common/bits-var.js
Normal file
16
web/public/js/components/common/bits-var.js
Normal file
@@ -0,0 +1,16 @@
|
||||
Vue.component("bits-var", {
|
||||
props: ["v-bits"],
|
||||
data: function () {
|
||||
let bits = this.vBits
|
||||
if (typeof bits != "number") {
|
||||
bits = 0
|
||||
}
|
||||
let format = teaweb.splitFormat(teaweb.formatBits(bits))
|
||||
return {
|
||||
format: format
|
||||
}
|
||||
},
|
||||
template:`<var class="normal">
|
||||
<span>{{format[0]}}</span>{{format[1]}}
|
||||
</var>`
|
||||
})
|
||||
16
web/public/js/components/common/bytes-var.js
Normal file
16
web/public/js/components/common/bytes-var.js
Normal file
@@ -0,0 +1,16 @@
|
||||
Vue.component("bytes-var", {
|
||||
props: ["v-bytes"],
|
||||
data: function () {
|
||||
let bytes = this.vBytes
|
||||
if (typeof bytes != "number") {
|
||||
bytes = 0
|
||||
}
|
||||
let format = teaweb.splitFormat(teaweb.formatBytes(bytes))
|
||||
return {
|
||||
format: format
|
||||
}
|
||||
},
|
||||
template:`<var class="normal">
|
||||
<span>{{format[0]}}</span>{{format[1]}}
|
||||
</var>`
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("datepicker", {
|
||||
props: ["v-name", "v-value", "v-bottom-left"],
|
||||
props: ["value", "v-name", "name", "v-value", "v-bottom-left", "placeholder"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
teaweb.datepicker(this.$refs.dayInput, function (v) {
|
||||
@@ -9,26 +9,44 @@ Vue.component("datepicker", {
|
||||
},
|
||||
data: function () {
|
||||
let name = this.vName
|
||||
if (name == null) {
|
||||
name = this.name
|
||||
}
|
||||
if (name == null) {
|
||||
name = "day"
|
||||
}
|
||||
|
||||
let day = this.vValue
|
||||
if (day == null) {
|
||||
day = ""
|
||||
day = this.value
|
||||
if (day == null) {
|
||||
day = ""
|
||||
}
|
||||
}
|
||||
|
||||
let placeholder = "YYYY-MM-DD"
|
||||
if (this.placeholder != null) {
|
||||
placeholder = this.placeholder
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
realName: name,
|
||||
realPlaceholder: placeholder,
|
||||
day: day
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value: function (v) {
|
||||
this.day = v
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
change: function () {
|
||||
this.$emit("input", this.day) // support v-model,事件触发需要在 change 之前
|
||||
this.$emit("change", this.day)
|
||||
}
|
||||
},
|
||||
template: `<div style="display: inline-block">
|
||||
<input type="text" :name="name" v-model="day" placeholder="YYYY-MM-DD" style="width:8.6em" maxlength="10" @input="change" ref="dayInput" autocomplete="off"/>
|
||||
<input type="text" :name="realName" v-model="day" :placeholder="realPlaceholder" style="width:8.6em" maxlength="10" @input="change" ref="dayInput" autocomplete="off"/>
|
||||
</div>`
|
||||
})
|
||||
@@ -54,8 +54,6 @@ Vue.component("datetime-input", {
|
||||
},
|
||||
methods: {
|
||||
change: function () {
|
||||
let date = new Date()
|
||||
|
||||
// day
|
||||
if (!/^\d{4}-\d{1,2}-\d{1,2}$/.test(this.day)) {
|
||||
this.hasDayError = true
|
||||
@@ -63,21 +61,18 @@ Vue.component("datetime-input", {
|
||||
}
|
||||
let pieces = this.day.split("-")
|
||||
let year = parseInt(pieces[0])
|
||||
date.setFullYear(year)
|
||||
|
||||
let month = parseInt(pieces[1])
|
||||
if (month < 1 || month > 12) {
|
||||
this.hasDayError = true
|
||||
return
|
||||
}
|
||||
date.setMonth(month - 1)
|
||||
|
||||
let day = parseInt(pieces[2])
|
||||
if (day < 1 || day > 32) {
|
||||
this.hasDayError = true
|
||||
return
|
||||
}
|
||||
date.setDate(day)
|
||||
|
||||
this.hasDayError = false
|
||||
|
||||
@@ -96,7 +91,6 @@ Vue.component("datetime-input", {
|
||||
return
|
||||
}
|
||||
this.hasHourError = false
|
||||
date.setHours(hour)
|
||||
|
||||
// minute
|
||||
if (!/^\d+$/.test(this.minute)) {
|
||||
@@ -113,7 +107,6 @@ Vue.component("datetime-input", {
|
||||
return
|
||||
}
|
||||
this.hasMinuteError = false
|
||||
date.setMinutes(minute)
|
||||
|
||||
// second
|
||||
if (!/^\d+$/.test(this.second)) {
|
||||
@@ -130,8 +123,8 @@ Vue.component("datetime-input", {
|
||||
return
|
||||
}
|
||||
this.hasSecondError = false
|
||||
date.setSeconds(second)
|
||||
|
||||
let date = new Date(year, month - 1, day, hour, minute, second)
|
||||
this.timestamp = Math.floor(date.getTime() / 1000)
|
||||
},
|
||||
leadingZero: function (s, l) {
|
||||
|
||||
@@ -24,7 +24,7 @@ Vue.component("download-link", {
|
||||
} else {
|
||||
let e = document.getElementById(this.vElement)
|
||||
if (e == null) {
|
||||
teaweb.warn("找不到要下载的内容")
|
||||
// 不提示错误,因为此时可能页面未加载完整
|
||||
return
|
||||
}
|
||||
text = e.innerText
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 启用状态标签
|
||||
Vue.component("label-on", {
|
||||
props: ["v-is-on"],
|
||||
template: '<div><span v-if="vIsOn" class="ui label tiny green basic">已启用</span><span v-if="!vIsOn" class="ui label tiny red basic">已停用</span></div>'
|
||||
template: '<div><span v-if="vIsOn" class="green">已启用</span><span v-if="!vIsOn" class="red">已停用</span></div>'
|
||||
})
|
||||
|
||||
// 文字代码标签
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
Vue.component("plan-bandwidth-ranges", {
|
||||
props: ["v-ranges"],
|
||||
data: function () {
|
||||
let ranges = this.vRanges
|
||||
if (ranges == null) {
|
||||
ranges = []
|
||||
}
|
||||
return {
|
||||
ranges: ranges,
|
||||
isAdding: false,
|
||||
|
||||
minMB: "",
|
||||
maxMB: "",
|
||||
pricePerMB: "",
|
||||
totalPrice: "",
|
||||
addingRange: {
|
||||
minMB: 0,
|
||||
maxMB: 0,
|
||||
pricePerMB: 0,
|
||||
totalPrice: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add: function () {
|
||||
this.isAdding = !this.isAdding
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
that.$refs.minMB.focus()
|
||||
})
|
||||
},
|
||||
cancelAdding: function () {
|
||||
this.isAdding = false
|
||||
},
|
||||
confirm: function () {
|
||||
this.isAdding = false
|
||||
this.minMB = ""
|
||||
this.maxMB = ""
|
||||
this.pricePerMB = ""
|
||||
this.totalPrice = ""
|
||||
this.ranges.push(this.addingRange)
|
||||
this.ranges.$sort(function (v1, v2) {
|
||||
if (v1.minMB < v2.minMB) {
|
||||
return -1
|
||||
}
|
||||
if (v1.minMB == v2.minMB) {
|
||||
if (v2.maxMB == 0 || v1.maxMB < v2.maxMB) {
|
||||
return -1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
})
|
||||
this.change()
|
||||
this.addingRange = {
|
||||
minMB: 0,
|
||||
maxMB: 0,
|
||||
pricePerMB: 0,
|
||||
totalPrice: 0
|
||||
}
|
||||
},
|
||||
remove: function (index) {
|
||||
this.ranges.$remove(index)
|
||||
this.change()
|
||||
},
|
||||
change: function () {
|
||||
this.$emit("change", this.ranges)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
minMB: function (v) {
|
||||
let minMB = parseInt(v.toString())
|
||||
if (isNaN(minMB) || minMB < 0) {
|
||||
minMB = 0
|
||||
}
|
||||
this.addingRange.minMB = minMB
|
||||
},
|
||||
maxMB: function (v) {
|
||||
let maxMB = parseInt(v.toString())
|
||||
if (isNaN(maxMB) || maxMB < 0) {
|
||||
maxMB = 0
|
||||
}
|
||||
this.addingRange.maxMB = maxMB
|
||||
},
|
||||
pricePerMB: function (v) {
|
||||
let pricePerMB = parseFloat(v.toString())
|
||||
if (isNaN(pricePerMB) || pricePerMB < 0) {
|
||||
pricePerMB = 0
|
||||
}
|
||||
this.addingRange.pricePerMB = pricePerMB
|
||||
},
|
||||
totalPrice: function (v) {
|
||||
let totalPrice = parseFloat(v.toString())
|
||||
if (isNaN(totalPrice) || totalPrice < 0) {
|
||||
totalPrice = 0
|
||||
}
|
||||
this.addingRange.totalPrice = totalPrice
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<!-- 已有价格 -->
|
||||
<div v-if="ranges.length > 0">
|
||||
<div class="ui label basic small" v-for="(range, index) in ranges" style="margin-bottom: 0.5em">
|
||||
{{range.minMB}}MB - <span v-if="range.maxMB > 0">{{range.maxMB}}MB</span><span v-else>∞</span> 价格:<span v-if="range.totalPrice > 0">{{range.totalPrice}}元</span><span v-else="">{{range.pricePerMB}}元/MB</span>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
|
||||
<!-- 添加 -->
|
||||
<div v-if="isAdding">
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">带宽下限 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="最小带宽" style="width: 7em" maxlength="10" ref="minMB" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="minMB"/>
|
||||
<span class="ui label">MB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">带宽上限 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="最大带宽" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="maxMB"/>
|
||||
<span class="ui label">MB</span>
|
||||
</div>
|
||||
<p class="comment">如果填0,表示上不封顶。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>总价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="总价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="totalPrice"/>
|
||||
<span class="ui label">元/MB</span>
|
||||
</div>
|
||||
<p class="comment">和单位价格二选一。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">单位价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" placeholder="单位价格" style="width: 7em" maxlength="10" @keyup.enter="confirm()" @keypress.enter.prevent="1" v-model="pricePerMB"/>
|
||||
<span class="ui label">元/MB</span>
|
||||
</div>
|
||||
<p class="comment">和总价格二选一。如果设置了单位价格,那么"总价格 = 单位价格 x 带宽"。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="ui button small" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancelAdding"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<div v-if="!isAdding">
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
@@ -1,220 +0,0 @@
|
||||
// 套餐价格配置
|
||||
Vue.component("plan-price-config-box", {
|
||||
props: ["v-price-type", "v-monthly-price", "v-seasonally-price", "v-yearly-price", "v-traffic-price", "v-bandwidth-price", "v-disable-period"],
|
||||
data: function () {
|
||||
let priceType = this.vPriceType
|
||||
if (priceType == null) {
|
||||
priceType = "bandwidth"
|
||||
}
|
||||
|
||||
// 按时间周期计费
|
||||
let monthlyPriceNumber = 0
|
||||
let monthlyPrice = this.vMonthlyPrice
|
||||
if (monthlyPrice == null || monthlyPrice <= 0) {
|
||||
monthlyPrice = ""
|
||||
} else {
|
||||
monthlyPrice = monthlyPrice.toString()
|
||||
monthlyPriceNumber = parseFloat(monthlyPrice)
|
||||
if (isNaN(monthlyPriceNumber)) {
|
||||
monthlyPriceNumber = 0
|
||||
}
|
||||
}
|
||||
|
||||
let seasonallyPriceNumber = 0
|
||||
let seasonallyPrice = this.vSeasonallyPrice
|
||||
if (seasonallyPrice == null || seasonallyPrice <= 0) {
|
||||
seasonallyPrice = ""
|
||||
} else {
|
||||
seasonallyPrice = seasonallyPrice.toString()
|
||||
seasonallyPriceNumber = parseFloat(seasonallyPrice)
|
||||
if (isNaN(seasonallyPriceNumber)) {
|
||||
seasonallyPriceNumber = 0
|
||||
}
|
||||
}
|
||||
|
||||
let yearlyPriceNumber = 0
|
||||
let yearlyPrice = this.vYearlyPrice
|
||||
if (yearlyPrice == null || yearlyPrice <= 0) {
|
||||
yearlyPrice = ""
|
||||
} else {
|
||||
yearlyPrice = yearlyPrice.toString()
|
||||
yearlyPriceNumber = parseFloat(yearlyPrice)
|
||||
if (isNaN(yearlyPriceNumber)) {
|
||||
yearlyPriceNumber = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 按流量计费
|
||||
let trafficPrice = this.vTrafficPrice
|
||||
let trafficPriceBaseNumber = 0
|
||||
if (trafficPrice != null) {
|
||||
trafficPriceBaseNumber = trafficPrice.base
|
||||
} else {
|
||||
trafficPrice = {
|
||||
base: 0
|
||||
}
|
||||
}
|
||||
let trafficPriceBase = ""
|
||||
if (trafficPriceBaseNumber > 0) {
|
||||
trafficPriceBase = trafficPriceBaseNumber.toString()
|
||||
}
|
||||
|
||||
// 按带宽计费
|
||||
let bandwidthPrice = this.vBandwidthPrice
|
||||
if (bandwidthPrice == null) {
|
||||
bandwidthPrice = {
|
||||
percentile: 95,
|
||||
ranges: []
|
||||
}
|
||||
} else if (bandwidthPrice.ranges == null) {
|
||||
bandwidthPrice.ranges = []
|
||||
}
|
||||
|
||||
return {
|
||||
priceType: priceType,
|
||||
monthlyPrice: monthlyPrice,
|
||||
seasonallyPrice: seasonallyPrice,
|
||||
yearlyPrice: yearlyPrice,
|
||||
|
||||
monthlyPriceNumber: monthlyPriceNumber,
|
||||
seasonallyPriceNumber: seasonallyPriceNumber,
|
||||
yearlyPriceNumber: yearlyPriceNumber,
|
||||
|
||||
trafficPriceBase: trafficPriceBase,
|
||||
trafficPrice: trafficPrice,
|
||||
|
||||
bandwidthPrice: bandwidthPrice,
|
||||
bandwidthPercentile: bandwidthPrice.percentile
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeBandwidthPriceRanges: function (ranges) {
|
||||
this.bandwidthPrice.ranges = ranges
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
monthlyPrice: function (v) {
|
||||
let price = parseFloat(v)
|
||||
if (isNaN(price)) {
|
||||
price = 0
|
||||
}
|
||||
this.monthlyPriceNumber = price
|
||||
},
|
||||
seasonallyPrice: function (v) {
|
||||
let price = parseFloat(v)
|
||||
if (isNaN(price)) {
|
||||
price = 0
|
||||
}
|
||||
this.seasonallyPriceNumber = price
|
||||
},
|
||||
yearlyPrice: function (v) {
|
||||
let price = parseFloat(v)
|
||||
if (isNaN(price)) {
|
||||
price = 0
|
||||
}
|
||||
this.yearlyPriceNumber = price
|
||||
},
|
||||
trafficPriceBase: function (v) {
|
||||
let price = parseFloat(v)
|
||||
if (isNaN(price)) {
|
||||
price = 0
|
||||
}
|
||||
this.trafficPrice.base = price
|
||||
},
|
||||
bandwidthPercentile: function (v) {
|
||||
let percentile = parseInt(v)
|
||||
if (isNaN(percentile) || percentile <= 0) {
|
||||
percentile = 95
|
||||
} else if (percentile > 100) {
|
||||
percentile = 100
|
||||
}
|
||||
this.bandwidthPrice.percentile = percentile
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="priceType" :value="priceType"/>
|
||||
<input type="hidden" name="monthlyPrice" :value="monthlyPriceNumber"/>
|
||||
<input type="hidden" name="seasonallyPrice" :value="seasonallyPriceNumber"/>
|
||||
<input type="hidden" name="yearlyPrice" :value="yearlyPriceNumber"/>
|
||||
<input type="hidden" name="trafficPriceJSON" :value="JSON.stringify(trafficPrice)"/>
|
||||
<input type="hidden" name="bandwidthPriceJSON" :value="JSON.stringify(bandwidthPrice)"/>
|
||||
|
||||
<div>
|
||||
<radio :v-value="'bandwidth'" :value="priceType" v-model="priceType"> 按带宽</radio>
|
||||
<radio :v-value="'traffic'" :value="priceType" v-model="priceType"> 按流量</radio>
|
||||
<radio :v-value="'period'" :value="priceType" v-model="priceType" v-show="typeof(vDisablePeriod) != 'boolean' || !vDisablePeriod"> 按时间周期</radio>
|
||||
</div>
|
||||
|
||||
<!-- 按时间周期 -->
|
||||
<div v-show="priceType == 'period'">
|
||||
<div class="ui divider"></div>
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">月度价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 7em" maxlength="10" v-model="monthlyPrice"/>
|
||||
<span class="ui label">元</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">季度价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 7em" maxlength="10" v-model="seasonallyPrice"/>
|
||||
<span class="ui label">元</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">年度价格</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 7em" maxlength="10" v-model="yearlyPrice"/>
|
||||
<span class="ui label">元</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 按流量 -->
|
||||
<div v-show="priceType =='traffic'">
|
||||
<div class="ui divider"></div>
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">基础流量费用 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" v-model="trafficPriceBase" maxlength="10" style="width: 7em"/>
|
||||
<span class="ui label">元/GB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 按带宽 -->
|
||||
<div v-show="priceType == 'bandwidth'">
|
||||
<div class="ui divider"></div>
|
||||
<table class="ui table">
|
||||
<tr>
|
||||
<td class="title">带宽百分位 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" style="width: 4em" maxlength="3" v-model="bandwidthPercentile"/>
|
||||
<span class="ui label">th</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>带宽价格</td>
|
||||
<td>
|
||||
<plan-bandwidth-ranges :v-ranges="bandwidthPrice.ranges" @change="changeBandwidthPriceRanges"></plan-bandwidth-ranges>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
// 域名列表
|
||||
Vue.component("domains-box", {
|
||||
props: ["v-domains", "name"],
|
||||
props: ["v-domains", "name", "v-support-wildcard"],
|
||||
data: function () {
|
||||
let domains = this.vDomains
|
||||
if (domains == null) {
|
||||
@@ -11,11 +11,47 @@ Vue.component("domains-box", {
|
||||
if (this.name != null && typeof this.name == "string") {
|
||||
realName = this.name
|
||||
}
|
||||
|
||||
let supportWildcard = true
|
||||
if (typeof this.vSupportWildcard == "boolean") {
|
||||
supportWildcard = this.vSupportWildcard
|
||||
}
|
||||
|
||||
return {
|
||||
domains: domains,
|
||||
|
||||
mode: "single", // single | batch
|
||||
batchDomains: "",
|
||||
|
||||
isAdding: false,
|
||||
addingDomain: "",
|
||||
realName: realName
|
||||
|
||||
isEditing: false,
|
||||
editingIndex: -1,
|
||||
|
||||
realName: realName,
|
||||
supportWildcard: supportWildcard
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
vSupportWildcard: function (v) {
|
||||
if (typeof v == "boolean") {
|
||||
this.supportWildcard = v
|
||||
}
|
||||
},
|
||||
mode: function (mode) {
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
if (mode == "single") {
|
||||
if (that.$refs.addingDomain != null) {
|
||||
that.$refs.addingDomain.focus()
|
||||
}
|
||||
} else if (mode == "batch") {
|
||||
if (that.$refs.batchDomains != null) {
|
||||
that.$refs.batchDomains.focus()
|
||||
}
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -27,6 +63,11 @@ Vue.component("domains-box", {
|
||||
}, 100)
|
||||
},
|
||||
confirm: function () {
|
||||
if (this.mode == "batch") {
|
||||
this.confirmBatch()
|
||||
return
|
||||
}
|
||||
|
||||
let that = this
|
||||
|
||||
// 删除其中的空格
|
||||
@@ -39,54 +80,155 @@ Vue.component("domains-box", {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// 基本校验
|
||||
if (this.addingDomain[0] == "~") {
|
||||
let expr = this.addingDomain.substring(1)
|
||||
try {
|
||||
new RegExp(expr)
|
||||
} catch (e) {
|
||||
teaweb.warn("正则表达式错误:" + e.message, function () {
|
||||
if (this.supportWildcard) {
|
||||
if (this.addingDomain[0] == "~") {
|
||||
let expr = this.addingDomain.substring(1)
|
||||
try {
|
||||
new RegExp(expr)
|
||||
} catch (e) {
|
||||
teaweb.warn("正则表达式错误:" + e.message, function () {
|
||||
that.$refs.addingDomain.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (/[*~^]/.test(this.addingDomain)) {
|
||||
teaweb.warn("当前只支持添加普通域名,域名中不能含有特殊符号", function () {
|
||||
that.$refs.addingDomain.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.domains.push(this.addingDomain)
|
||||
if (this.isEditing && this.editingIndex >= 0) {
|
||||
this.domains[this.editingIndex] = this.addingDomain
|
||||
} else {
|
||||
this.domains.push(this.addingDomain)
|
||||
}
|
||||
this.cancel()
|
||||
this.change()
|
||||
},
|
||||
confirmBatch: function () {
|
||||
let domains = this.batchDomains.split("\n")
|
||||
let realDomains = []
|
||||
let that = this
|
||||
let hasProblems = false
|
||||
domains.forEach(function (domain) {
|
||||
if (hasProblems) {
|
||||
return
|
||||
}
|
||||
if (domain.length == 0) {
|
||||
return
|
||||
}
|
||||
if (that.supportWildcard) {
|
||||
if (domain == "~") {
|
||||
let expr = domain.substring(1)
|
||||
try {
|
||||
new RegExp(expr)
|
||||
} catch (e) {
|
||||
hasProblems = true
|
||||
teaweb.warn("正则表达式错误:" + e.message, function () {
|
||||
that.$refs.batchDomains.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (/[*~^]/.test(domain)) {
|
||||
hasProblems = true
|
||||
teaweb.warn("当前只支持添加普通域名,域名中不能含有特殊符号", function () {
|
||||
that.$refs.batchDomains.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
realDomains.push(domain)
|
||||
})
|
||||
if (hasProblems) {
|
||||
return
|
||||
}
|
||||
if (realDomains.length == 0) {
|
||||
teaweb.warn("请输入要添加的域名", function () {
|
||||
that.$refs.batchDomains.focus()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
realDomains.forEach(function (domain) {
|
||||
that.domains.push(domain)
|
||||
})
|
||||
this.cancel()
|
||||
this.change()
|
||||
},
|
||||
edit: function (index) {
|
||||
this.addingDomain = this.domains[index]
|
||||
this.isEditing = true
|
||||
this.editingIndex = index
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
that.$refs.addingDomain.focus()
|
||||
}, 50)
|
||||
},
|
||||
remove: function (index) {
|
||||
this.domains.$remove(index)
|
||||
this.change()
|
||||
},
|
||||
cancel: function () {
|
||||
this.isAdding = false
|
||||
this.mode = "single"
|
||||
this.batchDomains = ""
|
||||
this.isEditing = false
|
||||
this.editingIndex = -1
|
||||
this.addingDomain = ""
|
||||
},
|
||||
change: function () {
|
||||
this.$emit("change", this.domains)
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" :name="realName" :value="JSON.stringify(domains)"/>
|
||||
<div v-if="domains.length > 0">
|
||||
<span class="ui label small basic" v-for="(domain, index) in domains">
|
||||
<span class="ui label small basic" v-for="(domain, index) in domains" :class="{blue: index == editingIndex}">
|
||||
<span v-if="domain.length > 0 && domain[0] == '~'" class="grey" style="font-style: normal">[正则]</span>
|
||||
<span v-if="domain.length > 0 && domain[0] == '.'" class="grey" style="font-style: normal">[后缀]</span>
|
||||
<span v-if="domain.length > 0 && domain[0] == '*'" class="grey" style="font-style: normal">[泛域名]</span>
|
||||
{{domain}}
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
<span v-if="!isAdding && !isEditing">
|
||||
<a href="" title="修改" @click.prevent="edit(index)"><i class="icon pencil small"></i></a>
|
||||
<a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove small"></i></a>
|
||||
</span>
|
||||
<span v-if="isAdding || isEditing">
|
||||
<a class="disabled"><i class="icon pencil small"></i></a>
|
||||
<a class="disabled"><i class="icon remove small"></i></a>
|
||||
</span>
|
||||
</span>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div v-if="isAdding">
|
||||
<div v-if="isAdding || isEditing">
|
||||
<div class="ui fields">
|
||||
<div class="ui field" v-if="isAdding">
|
||||
<select class="ui dropdown" v-model="mode">
|
||||
<option value="single">单个</option>
|
||||
<option value="batch">批量</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<input type="text" v-model="addingDomain" @keyup.enter="confirm()" @keypress.enter.prevent="1" ref="addingDomain" placeholder="*.xxx.com" size="30"/>
|
||||
<div v-show="mode == 'single'">
|
||||
<input type="text" v-model="addingDomain" @keyup.enter="confirm()" @keypress.enter.prevent="1" @keydown.esc="cancel()" ref="addingDomain" :placeholder="supportWildcard ? 'example.com、*.example.com' : 'example.com、www.example.com'" size="30" maxlength="100"/>
|
||||
</div>
|
||||
<div v-show="mode == 'batch'">
|
||||
<textarea cols="30" v-model="batchDomains" placeholder="example1.com\nexample2.com\n每行一个域名" ref="batchDomains"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button class="ui button tiny" type="button" @click.prevent="confirm">确定</button>
|
||||
<a href="" title="取消" @click.prevent="cancel"><i class="icon remove small"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">支持普通域名(<code-label>example.com</code-label>)、泛域名(<code-label>*.example.com</code-label>)、域名后缀(以点号开头,如<code-label>.example.com</code-label>)和正则表达式(以波浪号开头,如<code-label>~.*.example.com</code-label>)。</p>
|
||||
<p class="comment" v-if="supportWildcard">支持普通域名(<code-label>example.com</code-label>)、泛域名(<code-label>*.example.com</code-label>)<span v-if="vSupportWildcard == undefined">、域名后缀(以点号开头,如<code-label>.example.com</code-label>)和正则表达式(以波浪号开头,如<code-label>~.*.example.com</code-label>)</span>。</p>
|
||||
<p class="comment" v-if="!supportWildcard">只支持普通域名(<code-label>example.com</code-label>、<code-label>www.example.com</code-label>)。</p>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div style="margin-top: 0.5em" v-if="!isAdding">
|
||||
|
||||
@@ -59,7 +59,7 @@ Vue.component("firewall-syn-flood-config-box", {
|
||||
<td class="title">启用</td>
|
||||
<td>
|
||||
<checkbox v-model="config.isOn"></checkbox>
|
||||
<p class="comment">启用后,WAF将会尝试自动检测并阻止SYN Flood攻击。此功能需要节点已安装并启用Firewalld。</p>
|
||||
<p class="comment">启用后,WAF将会尝试自动检测并阻止SYN Flood攻击。此功能需要节点已安装并启用nftables或Firewalld。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -8,7 +8,6 @@ Vue.component("http-firewall-rule-label", {
|
||||
},
|
||||
methods: {
|
||||
showErr: function (err) {
|
||||
|
||||
teaweb.popupTip("规则校验错误,请修正:<span class=\"red\">" + teaweb.encodeHTML(err) + "</span>")
|
||||
},
|
||||
|
||||
@@ -24,7 +23,8 @@ Vue.component("http-firewall-rule-label", {
|
||||
|
||||
<!-- refererBlock -->
|
||||
<span v-if="rule.param == '\${refererBlock}'">
|
||||
{{rule.checkpointOptions.allowDomains}}
|
||||
<span v-if="rule.checkpointOptions.allowDomains != null && rule.checkpointOptions.allowDomains.length > 0">允许{{rule.checkpointOptions.allowDomains}}</span>
|
||||
<span v-if="rule.checkpointOptions.denyDomains != null && rule.checkpointOptions.denyDomains.length > 0">禁止{{rule.checkpointOptions.denyDomains}}</span>
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
|
||||
@@ -48,7 +48,8 @@ Vue.component("http-firewall-rules-box", {
|
||||
|
||||
<!-- refererBlock -->
|
||||
<span v-if="rule.param == '\${refererBlock}'">
|
||||
{{rule.checkpointOptions.allowDomains}}
|
||||
<span v-if="rule.checkpointOptions.allowDomains != null && rule.checkpointOptions.allowDomains.length > 0">允许{{rule.checkpointOptions.allowDomains}}</span>
|
||||
<span v-if="rule.checkpointOptions.denyDomains != null && rule.checkpointOptions.denyDomains.length > 0">禁止{{rule.checkpointOptions.denyDomains}}</span>
|
||||
</span>
|
||||
|
||||
<span v-else>
|
||||
|
||||
@@ -236,6 +236,7 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
let allowEmpty = true
|
||||
let allowSameDomain = true
|
||||
let allowDomains = []
|
||||
let denyDomains = []
|
||||
|
||||
let options = {}
|
||||
if (window.parent.UPDATING_RULE != null) {
|
||||
@@ -254,6 +255,9 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
if (options.allowDomains != null && typeof (options.allowDomains) == "object") {
|
||||
allowDomains = options.allowDomains
|
||||
}
|
||||
if (options.denyDomains != null && typeof (options.denyDomains) == "object") {
|
||||
denyDomains = options.denyDomains
|
||||
}
|
||||
|
||||
let that = this
|
||||
setTimeout(function () {
|
||||
@@ -264,6 +268,7 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
allowEmpty: allowEmpty,
|
||||
allowSameDomain: allowSameDomain,
|
||||
allowDomains: allowDomains,
|
||||
denyDomains: denyDomains,
|
||||
options: {},
|
||||
value: 0
|
||||
}
|
||||
@@ -281,6 +286,10 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
this.allowDomains = values
|
||||
this.change()
|
||||
},
|
||||
changeDenyDomains: function (values) {
|
||||
this.denyDomains = values
|
||||
this.change()
|
||||
},
|
||||
change: function () {
|
||||
this.vCheckpoint.options = [
|
||||
{
|
||||
@@ -294,7 +303,11 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
{
|
||||
code: "allowDomains",
|
||||
value: this.allowDomains
|
||||
}
|
||||
},
|
||||
{
|
||||
code: "denyDomains",
|
||||
value: this.denyDomains
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -323,6 +336,13 @@ Vue.component("http-firewall-checkpoint-referer-block", {
|
||||
<p class="comment">允许的来源域名列表,比如<code-label>example.com</code-label>、<code-label>*.example.com</code-label>。单个星号<code-label>*</code-label>表示允许所有域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>禁止的来源域名</td>
|
||||
<td>
|
||||
<values-box :values="denyDomains" @change="changeDenyDomains"></values-box>
|
||||
<p class="comment">禁止的来源域名列表,比如<code-label>example.org</code-label>、<code-label>*.example.org</code-label>;除了这些禁止的来源域名外,其他域名都会被允许,除非限定了允许的来源域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>`
|
||||
})
|
||||
44
web/public/js/components/server/http-header-assitant.js
Normal file
44
web/public/js/components/server/http-header-assitant.js
Normal file
@@ -0,0 +1,44 @@
|
||||
Vue.component("http-header-assistant", {
|
||||
props: ["v-type", "v-value"],
|
||||
mounted: function () {
|
||||
let that = this
|
||||
Tea.action("/servers/headers/options?type=" + this.vType)
|
||||
.post()
|
||||
.success(function (resp) {
|
||||
that.allHeaders = resp.data.headers
|
||||
})
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
allHeaders: [],
|
||||
matchedHeaders: [],
|
||||
|
||||
selectedHeaderName: ""
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
vValue: function (v) {
|
||||
if (v != this.selectedHeaderName) {
|
||||
this.selectedHeaderName = ""
|
||||
}
|
||||
|
||||
if (v.length == 0) {
|
||||
this.matchedHeaders = []
|
||||
return
|
||||
}
|
||||
this.matchedHeaders = this.allHeaders.filter(function (header) {
|
||||
return teaweb.match(header, v)
|
||||
}).slice(0, 5)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
select: function (header) {
|
||||
this.$emit("select", header)
|
||||
this.selectedHeaderName = header
|
||||
}
|
||||
},
|
||||
template: `<span v-if="selectedHeaderName.length == 0">
|
||||
<a href="" v-for="header in matchedHeaders" class="ui label basic tiny blue" style="font-weight: normal" @click.prevent="select(header)">{{header}}</a>
|
||||
<span v-if="matchedHeaders.length > 0"> </span>
|
||||
</span>`
|
||||
})
|
||||
@@ -100,10 +100,9 @@ Vue.component("http-host-redirect-box", {
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 1em"></th>
|
||||
<th>跳转前URL</th>
|
||||
<th>跳转前</th>
|
||||
<th style="width: 1em"></th>
|
||||
<th>跳转后URL</th>
|
||||
<th>匹配模式</th>
|
||||
<th>跳转后</th>
|
||||
<th>HTTP状态码</th>
|
||||
<th class="two wide">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
@@ -113,17 +112,47 @@ Vue.component("http-host-redirect-box", {
|
||||
<tr>
|
||||
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
|
||||
<td>
|
||||
{{redirect.beforeURL}}
|
||||
<div v-if="redirect.type == '' || redirect.type == 'url'">
|
||||
{{redirect.beforeURL}}
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>URL跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.matchPrefix">匹配前缀</grey-label>
|
||||
<grey-label v-if="redirect.matchRegexp">正则匹配</grey-label>
|
||||
<grey-label v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="redirect.type == 'domain'">
|
||||
<span v-if="redirect.domainsAll">所有域名</span>
|
||||
<span v-if="!redirect.domainsAll && redirect.domainsBefore != null">
|
||||
<span v-if="redirect.domainsBefore.length == 1">{{redirect.domainsBefore[0]}}</span>
|
||||
<span v-if="redirect.domainsBefore.length > 1">{{redirect.domainsBefore[0]}}等{{redirect.domainsBefore.length}}个域名</span>
|
||||
</span>
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>域名跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.domainAfterScheme != null && redirect.domainAfterScheme.length > 0">{{redirect.domainAfterScheme}}</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="redirect.type == 'port'">
|
||||
<span v-if="redirect.portsAll">所有端口</span>
|
||||
<span v-if="!redirect.portsAll && redirect.portsBefore != null">
|
||||
<span v-if="redirect.portsBefore.length <= 5">{{redirect.portsBefore.join(", ")}}</span>
|
||||
<span v-if="redirect.portsBefore.length > 5">{{redirect.portsBefore.slice(0, 5).join(", ")}}等{{redirect.portsBefore.length}}个端口</span>
|
||||
</span>
|
||||
<div style="margin-top: 0.4em">
|
||||
<grey-label><strong>端口跳转</strong></grey-label>
|
||||
<grey-label v-if="redirect.portAfterScheme != null && redirect.portAfterScheme.length > 0">{{redirect.portAfterScheme}}</grey-label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 0.5em" v-if="redirect.conds != null && redirect.conds.groups != null && redirect.conds.groups.length > 0">
|
||||
<span class="ui label text basic tiny">匹配条件</span>
|
||||
<grey-label>匹配条件</grey-label>
|
||||
</div>
|
||||
</td>
|
||||
<td nowrap="">-></td>
|
||||
<td>{{redirect.afterURL}}</td>
|
||||
<td>
|
||||
<span v-if="redirect.matchPrefix">匹配前缀</span>
|
||||
<span v-if="redirect.matchRegexp">正则匹配</span>
|
||||
<span v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</span>
|
||||
<span v-if="redirect.type == '' || redirect.type == 'url'">{{redirect.afterURL}}</span>
|
||||
<span v-if="redirect.type == 'domain'">{{redirect.domainAfter}}</span>
|
||||
<span v-if="redirect.type == 'port'">{{redirect.portAfter}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="redirect.status > 0">{{redirect.status}}</span>
|
||||
|
||||
@@ -8,12 +8,16 @@ Vue.component("http-referers-config-box", {
|
||||
isOn: false,
|
||||
allowEmpty: true,
|
||||
allowSameDomain: true,
|
||||
allowDomains: []
|
||||
allowDomains: [],
|
||||
denyDomains: []
|
||||
}
|
||||
}
|
||||
if (config.allowDomains == null) {
|
||||
config.allowDomains = []
|
||||
}
|
||||
if (config.denyDomains == null) {
|
||||
config.denyDomains = []
|
||||
}
|
||||
return {
|
||||
config: config
|
||||
}
|
||||
@@ -23,6 +27,8 @@ Vue.component("http-referers-config-box", {
|
||||
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
|
||||
},
|
||||
changeAllowDomains: function (domains) {
|
||||
},
|
||||
changeDenyDomains: function (domains) {
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
@@ -59,10 +65,17 @@ Vue.component("http-referers-config-box", {
|
||||
<tr>
|
||||
<td>允许的来源域名</td>
|
||||
<td>
|
||||
<values-box :values="config.allowDomains" @change="changeAllowDomains"></values-box>
|
||||
<domains-box :v-domains="config.allowDomains" @change="changeAllowDomains">></domains-box>
|
||||
<p class="comment">允许的其他来源域名列表,比如<code-label>example.com</code-label>、<code-label>*.example.com</code-label>。单个星号<code-label>*</code-label>表示允许所有域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>禁止的来源域名</td>
|
||||
<td>
|
||||
<domains-box :v-domains="config.denyDomains" @change="changeDenyDomains"></domains-box>
|
||||
<p class="comment">禁止的来源域名列表,比如<code-label>example.org</code-label>、<code-label>*.example.org</code-label>;除了这些禁止的来源域名外,其他域名都会被允许,除非限定了允许的来源域名。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="ui margin"></div>
|
||||
|
||||
@@ -80,7 +80,7 @@ Vue.component("http-request-limit-config-box", {
|
||||
<td>单IP最大并发连接数</td>
|
||||
<td>
|
||||
<input type="text" maxlength="6" v-model="maxConnsPerIP"/>
|
||||
<p class="comment">单IP最大连接数,统计单个IP总连接数时不区分服务,超出此限制则响应用户<code-label>429</code-label>代码。为0表示不限制。<span v-if="maxConnsPerIP <= 3" class="red">当前设置的并发连接数过低,可能会影响正常用户访问,建议不小于3。</span></p>
|
||||
<p class="comment">单IP最大连接数,统计单个IP总连接数时不区分服务,超出此限制则响应用户<code-label>429</code-label>代码。为0表示不限制。<span v-if="maxConnsPerIP > 0 && maxConnsPerIP <= 3" class="red">当前设置的并发连接数过低,可能会影响正常用户访问,建议不小于3。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -9,6 +9,7 @@ Vue.component("origin-list-box", {
|
||||
methods: {
|
||||
createPrimaryOrigin: function () {
|
||||
teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&" + this.vParams, {
|
||||
width: "45em",
|
||||
height: "27em",
|
||||
callback: function (resp) {
|
||||
teaweb.success("保存成功", function () {
|
||||
@@ -19,6 +20,7 @@ Vue.component("origin-list-box", {
|
||||
},
|
||||
createBackupOrigin: function () {
|
||||
teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&" + this.vParams, {
|
||||
width: "45em",
|
||||
height: "27em",
|
||||
callback: function (resp) {
|
||||
teaweb.success("保存成功", function () {
|
||||
@@ -29,6 +31,7 @@ Vue.component("origin-list-box", {
|
||||
},
|
||||
updateOrigin: function (originId, originType) {
|
||||
teaweb.popup("/servers/server/settings/origins/updatePopup?originType=" + originType + "&" + this.vParams + "&originId=" + originId, {
|
||||
width: "45em",
|
||||
height: "27em",
|
||||
callback: function (resp) {
|
||||
teaweb.success("保存成功", function () {
|
||||
|
||||
@@ -416,7 +416,7 @@ Vue.component("ssl-config-box", {
|
||||
|
||||
<!-- HSTS -->
|
||||
<tr v-show="vProtocol == 'https'">
|
||||
<td :class="{'color-border':hsts.isOn}">是否开启HSTS</td>
|
||||
<td :class="{'color-border':hsts.isOn}">开启HSTS</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="hstsOn" v-model="hsts.isOn" value="1"/>
|
||||
|
||||
@@ -113,7 +113,6 @@ window.teaweb = {
|
||||
reposition: !bottomLeft
|
||||
})
|
||||
},
|
||||
|
||||
formatBytes: function (bytes) {
|
||||
bytes = Math.ceil(bytes);
|
||||
if (bytes < Math.pow(1024, 1)) {
|
||||
@@ -136,6 +135,28 @@ window.teaweb = {
|
||||
}
|
||||
return (Math.round(bytes * 100 / Math.pow(1024, 6)) / 100) + "EB";
|
||||
},
|
||||
formatBits: function (bits) {
|
||||
bits = Math.ceil(bits);
|
||||
if (bits < Math.pow(1024, 1)) {
|
||||
return bits + "bps";
|
||||
}
|
||||
if (bits < Math.pow(1024, 2)) {
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 1)) / 10000) + "Kbps";
|
||||
}
|
||||
if (bits < Math.pow(1024, 3)) {
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 2)) / 10000) + "Mbps";
|
||||
}
|
||||
if (bits < Math.pow(1024, 4)) {
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 3)) / 10000) + "Gbps";
|
||||
}
|
||||
if (bits < Math.pow(1024, 5)) {
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 4)) / 10000) + "Tbps";
|
||||
}
|
||||
if (bits < Math.pow(1024, 6)) {
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 5)) / 10000) + "Pbps";
|
||||
}
|
||||
return (Math.round(bits * 10000 / Math.pow(1024, 6)) / 10000) + "Ebps";
|
||||
},
|
||||
formatNumber: function (x) {
|
||||
if (x == null) {
|
||||
return "null"
|
||||
@@ -205,6 +226,19 @@ window.teaweb = {
|
||||
divider: divider
|
||||
}
|
||||
},
|
||||
bitsAxis: function (stats, countFunc) {
|
||||
let axis = this.bytesAxis(stats, countFunc)
|
||||
let unit = axis.unit
|
||||
if (unit == "B") {
|
||||
unit = "bps"
|
||||
} else {
|
||||
unit += "bps"
|
||||
}
|
||||
return {
|
||||
unit: unit,
|
||||
divider: axis.divider
|
||||
}
|
||||
},
|
||||
countAxis: function (stats, countFunc) {
|
||||
let max = Math.max.apply(this, stats.map(countFunc))
|
||||
let divider = 1
|
||||
@@ -559,12 +593,22 @@ window.teaweb = {
|
||||
let max = options.max
|
||||
let interval = options.interval
|
||||
|
||||
let left = options.left
|
||||
if (typeof left != "number") {
|
||||
left = 0
|
||||
}
|
||||
|
||||
let right = options.right
|
||||
if (typeof right != "number") {
|
||||
right = 0
|
||||
}
|
||||
|
||||
let chartBox = document.getElementById(chartId)
|
||||
if (chartBox == null) {
|
||||
console.error("chart id '" + chartId + "' not found")
|
||||
return
|
||||
}
|
||||
let chart = this.initChart(chartBox)
|
||||
let chart = this.initChart(chartBox, options.cache)
|
||||
let option = {
|
||||
xAxis: {
|
||||
data: values.map(xFunc),
|
||||
@@ -591,9 +635,9 @@ window.teaweb = {
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
left: 40,
|
||||
left: 40 + left,
|
||||
top: 10,
|
||||
right: 20,
|
||||
right: 20 + right,
|
||||
bottom: 20
|
||||
},
|
||||
series: [
|
||||
@@ -605,7 +649,8 @@ window.teaweb = {
|
||||
color: this.DefaultChartColor
|
||||
},
|
||||
areaStyle: {},
|
||||
smooth: true
|
||||
smooth: true,
|
||||
markLine: options.markLine
|
||||
}
|
||||
],
|
||||
animation: true,
|
||||
@@ -893,7 +938,11 @@ window.teaweb = {
|
||||
return [40, -20]
|
||||
},
|
||||
chartMap: {}, // dom id => chart
|
||||
initChart: function (dom) {
|
||||
initChart: function (dom, cache) {
|
||||
if (typeof(cache) != "boolean") {
|
||||
cache = true
|
||||
}
|
||||
|
||||
let domId = dom.getAttribute("id")
|
||||
if (domId != null && domId.length > 0 && typeof (this.chartMap[domId]) == "object") {
|
||||
return this.chartMap[domId]
|
||||
@@ -902,7 +951,9 @@ window.teaweb = {
|
||||
window.addEventListener("resize", function () {
|
||||
instance.resize()
|
||||
})
|
||||
this.chartMap[domId] = instance
|
||||
if (cache) {
|
||||
this.chartMap[domId] = instance
|
||||
}
|
||||
return instance
|
||||
},
|
||||
encodeHTML: function (s) {
|
||||
|
||||
@@ -731,6 +731,9 @@ var.olive {
|
||||
var.dash {
|
||||
border-bottom: 1px dashed grey;
|
||||
}
|
||||
var.normal {
|
||||
font-style: normal;
|
||||
}
|
||||
/** checkbox **/
|
||||
.checkbox label a,
|
||||
.checkbox label {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -133,7 +133,7 @@ Tea.context(function () {
|
||||
this.showNodeTasks = function () {
|
||||
teaweb.popup("/clusters/tasks/listPopup", {
|
||||
height: "24em",
|
||||
width: "50em"
|
||||
width: "54em"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ Tea.context(function () {
|
||||
this.showDNSTasks = function () {
|
||||
teaweb.popup("/dns/tasks/listPopup", {
|
||||
height: "24em",
|
||||
width: "50em"
|
||||
width: "54em"
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
@@ -752,6 +752,10 @@ var.dash {
|
||||
border-bottom: 1px dashed grey;
|
||||
}
|
||||
|
||||
var.normal {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/** checkbox **/
|
||||
.checkbox label a, .checkbox label {
|
||||
font-size: 0.9em !important;
|
||||
|
||||
@@ -39,6 +39,12 @@ table th.width5 {
|
||||
table th.width6 {
|
||||
width: 6em;
|
||||
}
|
||||
.ui.table tbody[style*="display: none;"],
|
||||
.ui.table tr[style*="display: none;"],
|
||||
.ui.table tr > td[style*="display: none;"],
|
||||
.ui.table tr > th[style*="display: none;"] {
|
||||
display: none!important;
|
||||
}
|
||||
textarea::-webkit-scrollbar {
|
||||
width: 6px !important;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["@layout_override.less"],"names":[],"mappings":"AACA,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,QAAO;EACrG,yBAAA;;AAGD,GAAG,OAAO,SAAU,MAAK,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,QAAS,QAAO;EACzF,yBAAA;;AAGD,GAAG,MAAM;EACR,kCAAA;;AAGD,GAAG,MAAM,MAAM;EACd,sBAAA;;AAGD,SAAU,IAAG;EACZ,WAAA;;AAID,IACC;EACC,2BAAA;;AAKF,KAAK;EACJ,sBAAA;;AAGD,KAAK,KAAK;EACT,cAAA;;AAID,KACC,GAAE;AADH,KACY,GAAE;EACZ,6BAAA;EACA,0BAAA;EACA,2BAAA;;AAJF,KAOC,GAAE;EACD,WAAA;;AARF,KAWC,GAAE;EACD,UAAA;;AAZF,KAeC,GAAE;EACD,UAAA;;AAKF,QAAQ;EACP,qBAAA;;AAID,MAAM;EACL,uBAAA;;AAID,QACC,MAAK;EACJ,yBAAA;;AAKF,IAAI;EACH,yBAAA;;AAID;EACC,0BAAA;;AAID,OACC;EACC,cAAA","file":"@layout_override.css"}
|
||||
{"version":3,"sources":["@layout_override.less"],"names":[],"mappings":"AACA,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,MAAM,QAAS,QAAO;EACrG,yBAAA;;AAGD,GAAG,OAAO,SAAU,MAAK,QAAS,OAAM;AAAS,GAAG,OAAO,SAAU,MAAK,QAAS,QAAO;EACzF,yBAAA;;AAGD,GAAG,MAAM;EACR,kCAAA;;AAGD,GAAG,MAAM,MAAM;EACd,sBAAA;;AAGD,SAAU,IAAG;EACZ,WAAA;;AAID,IACC;EACC,2BAAA;;AAKF,KAAK;EACJ,sBAAA;;AAGD,KAAK,KAAK;EACT,cAAA;;AAID,KACC,GAAE;AADH,KACY,GAAE;EACZ,6BAAA;EACA,0BAAA;EACA,2BAAA;;AAJF,KAOC,GAAE;EACD,WAAA;;AARF,KAWC,GAAE;EACD,UAAA;;AAZF,KAeC,GAAE;EACD,UAAA;;AAIF,GAAG,MAAO,MAAK;AAA2B,GAAG,MAAO,GAAE;AAA2B,GAAG,MAAO,GAAE,KAAG;AAA2B,GAAG,MAAO,GAAE,KAAG;EACzI,uBAAA;;AAID,QAAQ;EACP,qBAAA;;AAID,MAAM;EACL,uBAAA;;AAID,QACC,MAAK;EACJ,yBAAA;;AAKF,IAAI;EACH,yBAAA;;AAID;EACC,0BAAA;;AAID,OACC;EACC,cAAA","file":"@layout_override.css"}
|
||||
@@ -56,6 +56,10 @@ table {
|
||||
}
|
||||
}
|
||||
|
||||
.ui.table tbody[style*="display: none;"], .ui.table tr[style*="display: none;"], .ui.table tr>td[style*="display: none;"], .ui.table tr>th[style*="display: none;"] {
|
||||
display: none!important;
|
||||
}
|
||||
|
||||
// textarea
|
||||
textarea::-webkit-scrollbar {
|
||||
width: 6px !important;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>选择分组</h3>
|
||||
<h3>选择所属分组</h3>
|
||||
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="groupId" :value="groupId"/>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<td>{{node.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>状态</td>
|
||||
<td>启用状态</td>
|
||||
<td><label-on :v-is-on="node.isOn"></label-on></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -101,6 +101,13 @@
|
||||
<td colspan="2"><more-options-indicator>更多选项</more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>同步IP名单</td>
|
||||
<td>
|
||||
<span v-if="node.enableIPLists" class="green">Y</span>
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SSH主机地址</td>
|
||||
<td>
|
||||
@@ -168,7 +175,7 @@
|
||||
<h3>运行状态</h3>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">是否在运行</td>
|
||||
<td class="title">运行状态</td>
|
||||
<td>
|
||||
<div v-if="node.status.isActive">
|
||||
<span class="green">运行中</span>
|
||||
|
||||
@@ -61,6 +61,13 @@
|
||||
<p class="comment">如果不为空,边缘节点访问当前L2节点时将会使用这些IP地址;如果没有设置,将会使用当前节点已经填写的IP地址。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>同步IP名单</td>
|
||||
<td>
|
||||
<checkbox name="enableIPLists" v-model="node.enableIPLists"></checkbox>
|
||||
<p class="comment">选中后,表示启用IP名单同步,包括来自管理员、用户添加的IP名单,以及其他节点系统自动拦截的IP名单。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>启用节点</td>
|
||||
<td>
|
||||
|
||||
@@ -47,7 +47,39 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>日志</h4>
|
||||
<h4>访问日志</h4>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td>记录请求Header</td>
|
||||
<td>
|
||||
<checkbox name="httpAccessLogEnableRequestHeaders" v-model="config.httpAccessLog.enableRequestHeaders"></checkbox>
|
||||
<p class="comment">选中后,表示在访问日志中记录请求Header。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">只记录通用请求<br/>Header</td>
|
||||
<td>
|
||||
<checkbox name="httpAccessLogCommonRequestHeadersOnly" v-model="config.httpAccessLog.commonRequestHeadersOnly"></checkbox>
|
||||
<p class="comment">选中后,表示访问日志中只记录通用的HTTP请求Header(比如<code-label>User-Agent</code-label>),其他自定义或非标准的(比如<code-label>Test-Header</code-label>)将不记录。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录响应Header</td>
|
||||
<td>
|
||||
<checkbox name="httpAccessLogEnableResponseHeaders" v-model="config.httpAccessLog.enableResponseHeaders"></checkbox>
|
||||
<p class="comment">选中后,表示在访问日志中记录响应Header。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>记录Cookie</td>
|
||||
<td>
|
||||
<checkbox name="httpAccessLogEnableCookies" v-model="config.httpAccessLog.enableCookies"></checkbox>
|
||||
<p class="comment">选中后,表示访问日志中记录Cookie内容。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h4>运行日志</h4>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">记录服务错误</td>
|
||||
|
||||
@@ -11,12 +11,19 @@
|
||||
<td><input type="text" name="name" maxlength="50" ref="focus" v-model="cluster.name"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>默认SSH登录方式</td>
|
||||
<td>默认SSH认证</td>
|
||||
<td>
|
||||
<grant-selector :v-grant="grant"></grant-selector>
|
||||
<p class="comment">当节点没有单独设置SSH登录方式时,默认使用此设置。</p>
|
||||
<p class="comment">当节点没有单独设置SSH认证时,默认使用此设置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>默认SSH端口</td>
|
||||
<td>
|
||||
<input type="text" name="sshParamsPort" v-model="cluster.sshParams.port" maxlength="5" style="width: 5em"/>
|
||||
<p class="comment">节点默认SSH登录端口。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>节点安装目录</td>
|
||||
<td>
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
{$template "/left_menu_with_menu"}
|
||||
|
||||
<div class="right-box with-menu">
|
||||
<tip-icon content="TCP Option Address(TOA)可以在TCP选项中传递客户端IP,多用在源站需要获取客户端真实IP的场景。<br/><br/>如需修改配置,请在专业人士指导下操作。"></tip-icon>
|
||||
<tip-icon content="TCP Option Address(TOA)可以在TCP选项中传递客户端IP,多用在TCP负载均衡的源站需要获取客户端真实IP的场景。<br/><br/>注意:HTTP协议通常不需要此设置。<br/><br/>如需修改配置,请在专业人士指导下操作。"></tip-icon>
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="clusterId" :value="clusterId"/>
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<table class="ui table selectable definition">
|
||||
<tr>
|
||||
<td class="title">是否启用TOA</td>
|
||||
<td class="title">启用TOA</td>
|
||||
<td>
|
||||
<checkbox name="isOn" v-model="toa.isOn"></checkbox>
|
||||
<p class="comment">在启用之前,请确保当前集群下所有节点服务器已经安装libnetfilter_queue,并启用了IPTables。</p>
|
||||
@@ -18,7 +18,7 @@
|
||||
</tr>
|
||||
<tbody v-show="toa.isOn">
|
||||
<tr>
|
||||
<td>是否自动配置</td>
|
||||
<td>自动配置</td>
|
||||
<td>
|
||||
<checkbox name="autoSetup" v-model="toa.autoSetup"></checkbox>
|
||||
<p class="comment">TOA功能需要节点服务器安装并开启了IPTables,并将网络数据包转发到NFQueue中。如果选中了自动配置,则每次在启动时都会自动尝试配置IPTables规则。</p>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<first-menu>
|
||||
<menu-item href="/clusters/regions" code="region">区域</menu-item>
|
||||
<menu-item href="/clusters/regions/prices" code="price" v-if="teaShowFinance">价格</menu-item>
|
||||
<span class="item" v-if="teaShowFinance">|</span>
|
||||
<menu-item v-if="teaShowFinance"><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
|
||||
<menu-item href="." code="index">区域</menu-item>
|
||||
<menu-item href=".nodes" code="node">节点</menu-item>
|
||||
</first-menu>
|
||||
@@ -2,7 +2,7 @@
|
||||
{$template "menu"}
|
||||
|
||||
<second-menu>
|
||||
<menu-item @click.prevent="createRegion()">创建</menu-item>
|
||||
<menu-item @click.prevent="createRegion()">[创建区域]</menu-item>
|
||||
</second-menu>
|
||||
|
||||
<p class="comment" v-if="regions.length == 0">暂时还没有区域。</p>
|
||||
@@ -21,12 +21,14 @@
|
||||
<tbody v-for="region in regions" :v-id="region.id">
|
||||
<tr>
|
||||
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
|
||||
<td :class="{disabled: !region.isOn}">{{region.name}}</td>
|
||||
<td :class="{disabled: !region.isOn}">
|
||||
<a href="" @click.prevent="updateRegion(region.id)">{{region.name}} <i class="icon expand small"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="region.description.length > 0">{{region.description}}</span>
|
||||
<span v-else class="disabled">-</span>
|
||||
</td>
|
||||
<td class="center">{{region.countNodes}}</td>
|
||||
<td class="center"><a :href="'/clusters/regions/nodes?regionId=' + region.id"><span :class="{disabled: region.countNodes == 0}">{{region.countNodes}}</span></a></td>
|
||||
<td>
|
||||
<label-on :v-is-on="region.isOn"></label-on>
|
||||
</td>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>添加价格项</h3>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="100" ref="focus"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>最低流量 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="bitsFrom" maxlength="16" style="width:10em" v-model="bitsFrom" autocomplete="off"/>
|
||||
<span class="ui label">MBPS</span>
|
||||
</div>
|
||||
<p class="comment">采用1000进制<span v-if="bitsFromMB.length > 0">,相当于{{bitsFromMB}}</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>最高流量 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="bitsTo" maxlength="16" style="width:10em" v-model="bitsTo" autocomplete="off"/>
|
||||
<span class="ui label">MBPS</span>
|
||||
</div>
|
||||
<p class="comment">采用1000进制<span v-if="bitsToMB.length > 0">,相当于{{bitsToMB}}</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -1,46 +0,0 @@
|
||||
Tea.context(function () {
|
||||
this.bitsFrom = 0
|
||||
this.bitsFromMB = ""
|
||||
|
||||
this.bitsTo = 0
|
||||
this.bitsToMB = ""
|
||||
|
||||
this.$delay(function () {
|
||||
let that = this
|
||||
this.$watch("bitsFrom", function (v) {
|
||||
this.bitsFromMB = that.formatBits(v)
|
||||
})
|
||||
this.$watch("bitsTo", function (v) {
|
||||
this.bitsToMB = that.formatBits(v)
|
||||
})
|
||||
})
|
||||
|
||||
this.formatBits = function (bits) {
|
||||
bits = parseInt(bits)
|
||||
if (isNaN(bits)) {
|
||||
bits = 0
|
||||
}
|
||||
|
||||
if (bits < 1000) {
|
||||
return bits + "MB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000) {
|
||||
return (bits / 1000) + "GB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000) + "TB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000 / 1000) + "PB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000 / 1000 / 1000) + "EB"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
})
|
||||
@@ -1,37 +0,0 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>修改价格项</h3>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="itemId" :value="item.id"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="100" ref="focus" v-model="item.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>最低流量 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="bitsFrom" maxlength="16" style="width:10em" v-model="bitsFrom" autocomplete="off"/>
|
||||
<span class="ui label">MBPS</span>
|
||||
</div>
|
||||
<p class="comment">采用1000进制<span v-if="bitsFromMB.length > 0">,相当于{{bitsFromMB}}</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>最高流量 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="bitsTo" maxlength="16" style="width:10em" v-model="bitsTo" autocomplete="off"/>
|
||||
<span class="ui label">MBPS</span>
|
||||
</div>
|
||||
<p class="comment">采用1000进制<span v-if="bitsToMB.length > 0">,相当于{{bitsToMB}}</span>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -1,49 +0,0 @@
|
||||
Tea.context(function () {
|
||||
this.bitsFrom = this.item.bitsFrom / 1000 / 1000
|
||||
this.bitsFromMB = ""
|
||||
|
||||
this.bitsTo = this.item.bitsTo / 1000 / 1000
|
||||
this.bitsToMB = ""
|
||||
|
||||
this.$delay(function () {
|
||||
let that = this
|
||||
this.$watch("bitsFrom", function (v) {
|
||||
this.bitsFromMB = that.formatBits(v)
|
||||
})
|
||||
this.$watch("bitsTo", function (v) {
|
||||
this.bitsToMB = that.formatBits(v)
|
||||
})
|
||||
|
||||
this.bitsFromMB = that.formatBits(this.bitsFrom)
|
||||
this.bitsToMB = that.formatBits(this.bitsTo)
|
||||
})
|
||||
|
||||
this.formatBits = function (bits) {
|
||||
bits = parseInt(bits)
|
||||
if (isNaN(bits)) {
|
||||
bits = 0
|
||||
}
|
||||
|
||||
if (bits < 1000) {
|
||||
return bits + "MB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000) {
|
||||
return (bits / 1000) + "GB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000) + "TB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000 / 1000) + "PB"
|
||||
}
|
||||
|
||||
if (bits < 1000 * 1000 * 1000 * 1000 * 1000) {
|
||||
return (bits / 1000 / 1000 / 1000 / 1000) + "EB"
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
})
|
||||
58
web/views/@default/clusters/regions/nodes.html
Normal file
58
web/views/@default/clusters/regions/nodes.html
Normal file
@@ -0,0 +1,58 @@
|
||||
{$layout}
|
||||
{$template "menu"}
|
||||
|
||||
<form class="ui form" method="get" action="/clusters/regions/nodes" v-show="regions.length > 0">
|
||||
<div class="margin"></div>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<select class="ui dropdown" name="regionId" v-model="regionId">
|
||||
<option value="0">[所有区域]</option>
|
||||
<option v-for="region in regions" :value="region.id">{{region.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
<button type="submit" class="ui button">搜索</button>
|
||||
|
||||
<a href="/clusters/regions/nodes" v-if="regionId > 0">[清除条件]</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div v-if="nodes.length == 0">
|
||||
<p class="comment"><span v-if="regionId > 0">当前区域下</span>暂时还没有节点。</p>
|
||||
</div>
|
||||
|
||||
<div v-if="nodes.length > 0">
|
||||
<div class="margin"></div>
|
||||
<table class="ui table selectable celled">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>节点</th>
|
||||
<th style="width: 30%">集群</th>
|
||||
<th style="width: 30%">区域</th>
|
||||
<th class="one op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="node in nodes" v-if="node.cluster != null">
|
||||
<td>
|
||||
<link-icon :href="'/clusters/cluster/node/detail?clusterId=' + node.cluster.id + '&nodeId=' + node.id">{{node.name}}</link-icon>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="node.cluster != null">{{node.cluster.name}}</span>
|
||||
<span v-else class="disabled">-</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="node.region != null">{{node.region.name}}</span>
|
||||
<span v-else class="disabled">尚未设置</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="" v-if="node.region == null" @click.prevent="updateNodeRegion(node)">设置</a>
|
||||
<a href="" v-if="node.region != null" @click.prevent="updateNodeRegion(node)">修改</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="comment" v-if="hasNodesWithoutRegion">已经将未设置区域的节点排在了表格最前面。</p>
|
||||
|
||||
<page-box></page-box>
|
||||
</div>
|
||||
12
web/views/@default/clusters/regions/nodes.js
Normal file
12
web/views/@default/clusters/regions/nodes.js
Normal file
@@ -0,0 +1,12 @@
|
||||
Tea.context(function () {
|
||||
this.updateNodeRegion = function (node) {
|
||||
let nodeId = node.id
|
||||
let regionId = (node.region ? node.region.id : 0)
|
||||
|
||||
teaweb.popup(Tea.url(".updateNodeRegionPopup", { nodeId: nodeId, regionId: regionId }), {
|
||||
callback: function () {
|
||||
teaweb.successRefresh("保存成功")
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
th span {
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
color: grey;
|
||||
}
|
||||
th a {
|
||||
font-weight: normal;
|
||||
visibility: hidden;
|
||||
}
|
||||
th:hover a {
|
||||
visibility: visible;
|
||||
}
|
||||
td a {
|
||||
visibility: hidden;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
td:hover a {
|
||||
visibility: visible;
|
||||
}
|
||||
/*# sourceMappingURL=prices.css.map */
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["prices.less"],"names":[],"mappings":"AAAA,EACC;EACC,gBAAA;EACA,mBAAA;EACA,WAAA;;AAJF,EAOC;EACC,mBAAA;EACA,kBAAA;;AAIF,EAAE,MACD;EACC,mBAAA;;AAIF,EACC;EACC,kBAAA;EACA,gBAAA;;AAIF,EAAE,MACD;EACC,mBAAA","file":"prices.css"}
|
||||
@@ -1,36 +0,0 @@
|
||||
{$layout}
|
||||
{$template "menu"}
|
||||
|
||||
<p class="comment" v-if="regions.length == 0">暂时还没有区域。</p>
|
||||
|
||||
<table class="ui table selectable small definition celled">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 7em; border-left: 1px solid rgba(34,36,38,.15); border-top: 1px solid rgba(34,36,38,.15)">区域\范围</th>
|
||||
<th v-for="item in items" class="center">
|
||||
{{item.name}}
|
||||
<br/>
|
||||
<span>{{item.bitsFromString}}-{{item.bitsToString}}</span>
|
||||
<br/>
|
||||
<a href="" title="修改" @click.prevent="updateItem(item.id)"><i class="icon pencil small"></i></a>
|
||||
<a href="" title="删除" @click.prevent="deleteItem(item.id)"><i class="icon remove small"></i></a>
|
||||
</th>
|
||||
<th class="width10 center">
|
||||
<a href="" @click.prevent="createItem" style="visibility: visible">[+添加价格项]</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="region in regions">
|
||||
<td class="">{{region.name}}</td>
|
||||
<td v-for="item in items" class="center">
|
||||
<div>
|
||||
<span v-if="region.prices[item.id.toString()] != null">¥{{region.prices[item.id.toString()]}}元/GB </span>
|
||||
<span v-else> </span>
|
||||
</div>
|
||||
<div>
|
||||
<a href="" title="修改单位价格" @click.prevent="updatePrice(region.id, item.id)">[设置]</a>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1,42 +0,0 @@
|
||||
Tea.context(function () {
|
||||
this.createItem = function () {
|
||||
teaweb.popup(Tea.url(".items.createPopup"), {
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.updateItem = function (itemId) {
|
||||
teaweb.popup(Tea.url(".items.updatePopup", {itemId: itemId}), {
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.deleteItem = function (itemId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此价格项吗?", function () {
|
||||
that.$post(".items.delete")
|
||||
.params({
|
||||
itemId: itemId
|
||||
})
|
||||
.refresh()
|
||||
})
|
||||
}
|
||||
|
||||
this.updatePrice = function (regionId, itemId) {
|
||||
teaweb.popup(Tea.url(".updatePricePopup", {regionId: regionId, itemId: itemId}), {
|
||||
callback: function () {
|
||||
teaweb.success("保存成功", function () {
|
||||
teaweb.reload()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -1,31 +0,0 @@
|
||||
th {
|
||||
span {
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: normal;
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
th:hover {
|
||||
a {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
a {
|
||||
visibility: hidden;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
td:hover {
|
||||
a {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>选择分组</h3>
|
||||
<h3>选择所属区域</h3>
|
||||
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3 v-if="region.id > 0">修改节点区域</h3>
|
||||
<h3 v-if="region == null || region.id == 0">设置节点区域</h3>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<input type="hidden" name="nodeId" :value="node.id"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">节点</td>
|
||||
<td>{{node.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>区域 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="regionId" v-model="region.id">
|
||||
<option value="0">[选择区域]</option>
|
||||
<option v-for="r in regions" :value="r.id">{{r.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>是否启用</td>
|
||||
<td>启用</td>
|
||||
<td>
|
||||
<checkbox name="isOn" v-model="region.isOn"></checkbox>
|
||||
</td>
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>修改价格</h3>
|
||||
<form class="ui form" method="post" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="regionId" :value="region.id"/>
|
||||
<input type="hidden" name="itemId" :value="item.id"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">区域</td>
|
||||
<td>{{region.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>价格项</td>
|
||||
<td>{{item.name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">单位价格 *</td>
|
||||
<td>
|
||||
<div class="ui input right labeled">
|
||||
<input type="text" name="price" maxlength="10" style="width:6em" ref="focus" v-model="price"/>
|
||||
<span class="ui label">元/GB</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -27,11 +27,12 @@
|
||||
{{task.node.name}} <a :href="'/clusters/cluster/node?clusterId=' + cluster.id + '&nodeId=' + task.node.id" target="_blank"><i class="icon linkify small grey"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="task.type == 'configChanged'">同步配置</span>
|
||||
<span v-if="task.type == 'configChanged' || task.type == 'globalServerConfigChanged'">同步配置</span>
|
||||
<span v-if="task.type == 'ipItemChanged'">同步IP名单</span>
|
||||
<span v-if="task.type == 'scriptsChanged'">同步脚本</span>
|
||||
<span v-if="task.type == 'nodeLevelChanged'">同步L2节点</span>
|
||||
<span v-if="task.type == 'ddosProtectionChanged'">DDoS配置</span>
|
||||
<span v-if="task.type == 'userServersStateChanged'">用户服务状态</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="task.isDone" class="red">{{task.error}}</span>
|
||||
|
||||
@@ -73,9 +73,7 @@
|
||||
|
||||
<div class="ui column">
|
||||
<h4>用户<link-icon href="/users" v-if="dashboard.canGoUsers"></link-icon></h4>
|
||||
<div class="value"><span>{{dashboard.countUsers}}</span>个
|
||||
<span style="font-size: 1em" v-if="dashboard.countOfflineUserNodes > 0">/ <a href="/settings/userNodes" v-if="dashboard.canGoSettings"><span class="red" style="font-size: 1em">{{dashboard.countOfflineUserNodes}}节点离线</span></a><span class="red" style="font-size: 1em" v-else>{{dashboard.countOfflineUserNodes}}节点离线</span></span>
|
||||
</div>
|
||||
<div class="value"><span>{{dashboard.countUsers}}</span>个</div>
|
||||
</div>
|
||||
|
||||
<div class="ui column">
|
||||
|
||||
@@ -157,18 +157,18 @@
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="node.ipAddr.length > 0">{{node.ipAddr}}</span>
|
||||
<link-red title="点击设置" v-else @click.prevent="updateNode(node.clusterId, node.id)">没有设置</link-red>
|
||||
<link-red title="点击设置" v-else @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">没有设置</link-red>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="node.route.code.length > 0">{{node.route.name}}</span>
|
||||
<link-red v-else title="点击设置" @click.prevent="updateNode(node.clusterId, node.id)">没有设置</link-red>
|
||||
<link-red v-else title="点击设置" @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">没有设置</link-red>
|
||||
</td>
|
||||
<td>
|
||||
<span class="green" v-if="node.isResolved">已解析</span>
|
||||
<span v-else class="red">未解析</span>
|
||||
</td>
|
||||
<td>
|
||||
<link-popup @click.prevent="updateNode(node.clusterId, node.id)">修改</link-popup>
|
||||
<link-popup @click.prevent="updateNode(node.clusterId, node.id, node.ipAddrId)">修改</link-popup>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -10,8 +10,8 @@ Tea.context(function () {
|
||||
})
|
||||
}
|
||||
|
||||
this.updateNode = function (clusterId, nodeId) {
|
||||
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId, {
|
||||
this.updateNode = function (clusterId, nodeId, ipAddrId) {
|
||||
teaweb.popup("/dns/issues/updateNodePopup?clusterId=" + clusterId + "&nodeId=" + nodeId + "&ipAddrId=" + (ipAddrId ? ipAddrId : 0), {
|
||||
width: "46em",
|
||||
height: "26em",
|
||||
callback: function () {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="nodeId" :value="nodeId"/>
|
||||
<input type="hidden" name="domainId" :value="domainId"/>
|
||||
<input type="hidden" name="ipAddrId" :value="ipAddrId"/>
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user