diff --git a/internal/const/vars.go b/internal/const/vars.go index 27656aa7..5e80d002 100644 --- a/internal/const/vars.go +++ b/internal/const/vars.go @@ -4,9 +4,10 @@ package teaconst var ( IsRecoverMode = false -) -var ( IsDemoMode = false ErrorDemoOperation = "DEMO模式下无法进行创建、修改、删除等操作" + + NewVersionCode = "" // 有新的版本 + NewVersionDownloadURL = "" // 新版本下载地址 ) diff --git a/internal/goman/instance.go b/internal/goman/instance.go new file mode 100644 index 00000000..f7659242 --- /dev/null +++ b/internal/goman/instance.go @@ -0,0 +1,12 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package goman + +import "time" + +type Instance struct { + Id uint64 + CreatedTime time.Time + File string + Line int +} diff --git a/internal/goman/lib.go b/internal/goman/lib.go new file mode 100644 index 00000000..0d0feaaf --- /dev/null +++ b/internal/goman/lib.go @@ -0,0 +1,81 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package goman + +import ( + "runtime" + "sync" + "time" +) + +var locker = &sync.Mutex{} +var instanceMap = map[uint64]*Instance{} // id => *Instance +var instanceId = uint64(0) + +// New 新创建goroutine +func New(f func()) { + _, file, line, _ := runtime.Caller(1) + + go func() { + locker.Lock() + instanceId++ + + var instance = &Instance{ + Id: instanceId, + CreatedTime: time.Now(), + } + + instance.File = file + instance.Line = line + + instanceMap[instanceId] = instance + locker.Unlock() + + // run function + f() + + locker.Lock() + delete(instanceMap, instanceId) + locker.Unlock() + }() +} + +// NewWithArgs 创建带有参数的goroutine +func NewWithArgs(f func(args ...interface{}), args ...interface{}) { + _, file, line, _ := runtime.Caller(1) + + go func() { + locker.Lock() + instanceId++ + + var instance = &Instance{ + Id: instanceId, + CreatedTime: time.Now(), + } + + instance.File = file + instance.Line = line + + instanceMap[instanceId] = instance + locker.Unlock() + + // run function + f(args...) + + locker.Lock() + delete(instanceMap, instanceId) + locker.Unlock() + }() +} + +// List 列出所有正在运行goroutine +func List() []*Instance { + locker.Lock() + defer locker.Unlock() + + var result = []*Instance{} + for _, instance := range instanceMap { + result = append(result, instance) + } + return result +} diff --git a/internal/goman/lib_test.go b/internal/goman/lib_test.go new file mode 100644 index 00000000..11358d1b --- /dev/null +++ b/internal/goman/lib_test.go @@ -0,0 +1,28 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package goman + +import ( + "testing" + "time" +) + +func TestNew(t *testing.T) { + New(func() { + t.Log("Hello") + + t.Log(List()) + }) + + time.Sleep(1 * time.Second) + t.Log(List()) + + time.Sleep(1 * time.Second) +} + +func TestNewWithArgs(t *testing.T) { + NewWithArgs(func(args ...interface{}) { + t.Log(args[0], args[1]) + }, 1, 2) + time.Sleep(1 * time.Second) +} diff --git a/internal/tasks/task_check_updates.go b/internal/tasks/task_check_updates.go new file mode 100644 index 00000000..22c4d179 --- /dev/null +++ b/internal/tasks/task_check_updates.go @@ -0,0 +1,104 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package tasks + +import ( + "encoding/json" + "errors" + teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" + "github.com/TeaOSLab/EdgeAdmin/internal/events" + "github.com/TeaOSLab/EdgeAdmin/internal/goman" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/maps" + stringutil "github.com/iwind/TeaGo/utils/string" + "io/ioutil" + "net/http" + "runtime" + "strings" + "time" +) + +func init() { + events.On(events.EventStart, func() { + var task = NewCheckUpdatesTask() + goman.New(func() { + task.Start() + }) + }) +} + +type CheckUpdatesTask struct { + ticker *time.Ticker +} + +func NewCheckUpdatesTask() *CheckUpdatesTask { + return &CheckUpdatesTask{} +} + +func (this *CheckUpdatesTask) Start() { + this.ticker = time.NewTicker(12 * time.Hour) + for range this.ticker.C { + err := this.Loop() + if err != nil { + logs.Println("[TASK][CHECK_UPDATES_TASK]" + err.Error()) + } + } +} + +func (this *CheckUpdatesTask) Loop() error { + type Response struct { + Code int `json:"code"` + Message string `json:"message"` + Data interface{} `json:"data"` + } + + // 目前支持Linux + if runtime.GOOS != "linux" { + return nil + } + + var apiURL = teaconst.UpdatesURL + apiURL = strings.ReplaceAll(apiURL, "${os}", runtime.GOOS) + apiURL = strings.ReplaceAll(apiURL, "${arch}", runtime.GOARCH) + resp, err := http.Get(apiURL) + if err != nil { + return errors.New("read api failed: " + err.Error()) + } + + defer func() { + _ = resp.Body.Close() + }() + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + return errors.New("read api failed: " + err.Error()) + } + + var apiResponse = &Response{} + err = json.Unmarshal(data, apiResponse) + if err != nil { + return errors.New("decode version data failed: " + err.Error()) + } + + if apiResponse.Code != 200 { + return errors.New("invalid response: " + apiResponse.Message) + } + + var m = maps.NewMap(apiResponse.Data) + var dlHost = m.GetString("host") + var versions = m.GetSlice("versions") + if len(versions) > 0 { + for _, version := range versions { + var vMap = maps.NewMap(version) + if vMap.GetString("code") == "admin" { + var latestVersion = vMap.GetString("version") + if stringutil.VersionCompare(teaconst.Version, latestVersion) < 0 { + teaconst.NewVersionCode = latestVersion + teaconst.NewVersionDownloadURL = dlHost + vMap.GetString("url") + return nil + } + } + } + } + + return nil +} diff --git a/internal/tasks/task_sync_api_nodes.go b/internal/tasks/task_sync_api_nodes.go index ef533fc5..5f332b19 100644 --- a/internal/tasks/task_sync_api_nodes.go +++ b/internal/tasks/task_sync_api_nodes.go @@ -6,6 +6,7 @@ import ( "github.com/TeaOSLab/EdgeAdmin/internal/configs" teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/events" + "github.com/TeaOSLab/EdgeAdmin/internal/goman" "github.com/TeaOSLab/EdgeAdmin/internal/rpc" "github.com/TeaOSLab/EdgeAdmin/internal/setup" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" @@ -23,7 +24,9 @@ import ( func init() { events.On(events.EventStart, func() { task := NewSyncAPINodesTask() - go task.Start() + goman.New(func() { + task.Start() + }) }) } diff --git a/internal/tasks/task_sync_cluster.go b/internal/tasks/task_sync_cluster.go index 9a055752..b5b329b7 100644 --- a/internal/tasks/task_sync_cluster.go +++ b/internal/tasks/task_sync_cluster.go @@ -3,6 +3,7 @@ package tasks import ( teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/events" + "github.com/TeaOSLab/EdgeAdmin/internal/goman" "github.com/TeaOSLab/EdgeAdmin/internal/rpc" "github.com/TeaOSLab/EdgeAdmin/internal/setup" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils" @@ -17,7 +18,9 @@ import ( func init() { events.On(events.EventStart, func() { task := NewSyncClusterTask() - go task.Start() + goman.New(func() { + task.Start() + }) }) } diff --git a/internal/web/actions/default/dashboard/index.go b/internal/web/actions/default/dashboard/index.go index e6ec58ae..318fecfd 100644 --- a/internal/web/actions/default/dashboard/index.go +++ b/internal/web/actions/default/dashboard/index.go @@ -40,6 +40,11 @@ func (this *IndexAction) RunGet(params struct{}) { } } + // 版本更新 + this.Data["currentVersionCode"] = teaconst.Version + this.Data["newVersionCode"] = teaconst.NewVersionCode + this.Data["newVersionDownloadURL"] = teaconst.NewVersionDownloadURL + this.Show() } diff --git a/internal/web/actions/default/servers/components/waf/policy.go b/internal/web/actions/default/servers/components/waf/policy.go index 7092b388..6f2abec9 100644 --- a/internal/web/actions/default/servers/components/waf/policy.go +++ b/internal/web/actions/default/servers/components/waf/policy.go @@ -49,7 +49,7 @@ func (this *PolicyAction) RunGet(params struct { // 检查是否有升级 var templatePolicy = firewallconfigs.HTTPFirewallTemplate() - var upgradeItems = []string{} + var upgradeItems = []maps.Map{} if templatePolicy.Inbound != nil { for _, group := range templatePolicy.Inbound.Groups { if len(group.Code) == 0 { @@ -57,7 +57,10 @@ func (this *PolicyAction) RunGet(params struct { } var oldGroup = firewallPolicy.FindRuleGroupWithCode(group.Code) if oldGroup == nil { - upgradeItems = append(upgradeItems, group.Name) + upgradeItems = append(upgradeItems, maps.Map{ + "name": group.Name, + "isOn": group.IsOn, + }) continue } for _, set := range group.Sets { @@ -66,7 +69,10 @@ func (this *PolicyAction) RunGet(params struct { } var oldSet = oldGroup.FindRuleSetWithCode(set.Code) if oldSet == nil { - upgradeItems = append(upgradeItems, group.Name+" -- "+set.Name) + upgradeItems = append(upgradeItems, maps.Map{ + "name": group.Name + " -- " + set.Name, + "isOn": set.IsOn, + }) continue } } diff --git a/internal/web/actions/default/settings/updates/index.go b/internal/web/actions/default/settings/updates/index.go index f7e033a4..495135b5 100644 --- a/internal/web/actions/default/settings/updates/index.go +++ b/internal/web/actions/default/settings/updates/index.go @@ -6,11 +6,14 @@ import ( "encoding/json" teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" "io/ioutil" "net/http" + "runtime" "strings" ) @@ -25,6 +28,22 @@ func (this *IndexAction) Init() { func (this *IndexAction) RunGet(params struct{}) { this.Data["version"] = teaconst.Version + valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates}) + if err != nil { + this.ErrorPage(err) + return + } + var valueJSON = valueResp.ValueJSON + var config = &systemconfigs.CheckUpdatesConfig{AutoCheck: false} + if len(valueJSON) > 0 { + err = json.Unmarshal(valueJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + } + this.Data["config"] = config + this.Show() } @@ -37,8 +56,8 @@ func (this *IndexAction) RunPost(params struct { } var apiURL = teaconst.UpdatesURL - apiURL = strings.ReplaceAll(apiURL, "${os}", "linux") //runtime.GOOS) - apiURL = strings.ReplaceAll(apiURL, "${arch}", "amd64") // runtime.GOARCH) + apiURL = strings.ReplaceAll(apiURL, "${os}", runtime.GOOS) + apiURL = strings.ReplaceAll(apiURL, "${arch}", runtime.GOARCH) resp, err := http.Get(apiURL) if err != nil { this.Data["result"] = maps.Map{ @@ -109,7 +128,6 @@ func (this *IndexAction) RunPost(params struct { "isOk": false, "message": "找不到更新信息", } - this.Success() this.Success() } diff --git a/internal/web/actions/default/settings/updates/init.go b/internal/web/actions/default/settings/updates/init.go index d219021b..f9df6999 100644 --- a/internal/web/actions/default/settings/updates/init.go +++ b/internal/web/actions/default/settings/updates/init.go @@ -14,6 +14,7 @@ func init() { Helper(settingutils.NewHelper("updates")). Prefix("/settings/updates"). GetPost("", new(IndexAction)). + Post("/update", new(UpdateAction)). EndAll() }) } diff --git a/internal/web/actions/default/settings/updates/update.go b/internal/web/actions/default/settings/updates/update.go new file mode 100644 index 00000000..95ba021c --- /dev/null +++ b/internal/web/actions/default/settings/updates/update.go @@ -0,0 +1,52 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package updates + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" +) + +type UpdateAction struct { + actionutils.ParentAction +} + +func (this *UpdateAction) RunPost(params struct { + AutoCheck bool +}) { + valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates}) + if err != nil { + this.ErrorPage(err) + return + } + var valueJSON = valueResp.ValueJSON + var config = &systemconfigs.CheckUpdatesConfig{AutoCheck: false} + if len(valueJSON) > 0 { + err = json.Unmarshal(valueJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + } + + config.AutoCheck = params.AutoCheck + + configJSON, err := json.Marshal(config) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().SysSettingRPC().UpdateSysSetting(this.AdminContext(), &pb.UpdateSysSettingRequest{ + Code: systemconfigs.SettingCodeCheckUpdates, + ValueJSON: configJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + + this.Success() +} diff --git a/web/views/@default/dashboard/boards/@menu.html b/web/views/@default/dashboard/boards/@menu.html deleted file mode 100644 index 4c827744..00000000 --- a/web/views/@default/dashboard/boards/@menu.html +++ /dev/null @@ -1,7 +0,0 @@ - - 概况 - WAF - DNS - 用户 - 事件({{countEvents}}) - \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/dns.html b/web/views/@default/dashboard/boards/dns.html deleted file mode 100644 index 40139985..00000000 --- a/web/views/@default/dashboard/boards/dns.html +++ /dev/null @@ -1,63 +0,0 @@ -{$layout} -{$template "menu"} -{$template "/echarts"} - -
-
-

域名

-
{{board.countDomains}}
-
-
-

记录

-
{{board.countRecords}}
-
-
-

集群

-
{{board.countClusters}}
-
-
-

节点

-
{{board.countNodes}} - - / {{board.countOfflineNodes}}离线 - - -
-
-
- - - - - - -
- - -
-
- - -

域名访问排行 (24小时)

-
-
- - -

节点访问排行 (24小时)

-
-
- - -
- - -
-
-
\ No newline at end of file diff --git a/web/views/@default/dashboard/boards/dns.js b/web/views/@default/dashboard/boards/dns.js deleted file mode 100644 index 985524f5..00000000 --- a/web/views/@default/dashboard/boards/dns.js +++ /dev/null @@ -1,246 +0,0 @@ -Tea.context(function () { - this.$delay(function () { - this.reloadHourlyTrafficChart() - this.reloadTopDomainsChart() - this.reloadTopNodesChart() - this.reloadCPUChart() - }) - - /** - * 流量统计 - */ - this.trafficTab = "hourly" - - this.selectTrafficTab = function (tab) { - this.trafficTab = tab - if (tab == "hourly") { - this.$delay(function () { - this.reloadHourlyTrafficChart() - }) - } else if (tab == "daily") { - this.$delay(function () { - this.reloadDailyTrafficChart() - }) - } - } - - this.reloadHourlyTrafficChart = function () { - let stats = this.hourlyStats - this.reloadTrafficChart("hourly-traffic-chart", "流量统计", stats, function (args) { - return stats[args.dataIndex].day + " " + stats[args.dataIndex].hour + "时 流量: " + teaweb.formatBytes(stats[args.dataIndex].bytes) - }) - } - - this.reloadDailyTrafficChart = function () { - let stats = this.dailyStats - this.reloadTrafficChart("daily-traffic-chart", "流量统计", stats, function (args) { - return stats[args.dataIndex].day + " 流量: " + teaweb.formatBytes(stats[args.dataIndex].bytes) - }) - } - - this.reloadTrafficChart = function (chartId, name, stats, tooltipFunc) { - let chartBox = document.getElementById(chartId) - if (chartBox == null) { - return - } - - let axis = teaweb.bytesAxis(stats, function (v) { - return v.bytes - }) - - let chart = teaweb.initChart(chartBox) - let option = { - xAxis: { - data: stats.map(function (v) { - if (v.hour != null) { - return v.hour - } - return v.day - }) - }, - yAxis: { - axisLabel: { - formatter: function (value) { - return value + axis.unit - } - } - }, - tooltip: { - show: true, - trigger: "item", - formatter: tooltipFunc - }, - grid: { - left: 50, - top: 40, - right: 20, - bottom: 20 - }, - series: [ - { - name: "流量", - type: "line", - data: stats.map(function (v) { - return v.bytes / axis.divider - }), - itemStyle: { - color: "#9DD3E8" - }, - areaStyle: { - color: "#9DD3E8" - }, - smooth: true - } - ], - animation: true - } - chart.setOption(option) - chart.resize() - } - - // 域名排行 - this.reloadTopDomainsChart = function () { - let that = this - let axis = teaweb.countAxis(this.topDomainStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-domains-chart", - name: "域名", - values: this.topDomainStats, - x: function (v) { - return v.domainName - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].domainName + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - window.location = "/ns/domains/domain?domainId=" + stats[args.dataIndex].domainId - } - }) - } - - // 节点排行 - this.reloadTopNodesChart = function () { - let that = this - let axis = teaweb.countAxis(this.topNodeStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-nodes-chart", - name: "节点", - values: this.topNodeStats, - x: function (v) { - return v.nodeName - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].nodeName + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - window.location = "/ns/clusters/cluster/node?nodeId=" + stats[args.dataIndex].nodeId + "&clusterId=" + stats[args.dataIndex].clusterId - } - }) - } - - /** - * 系统信息 - */ - this.nodeStatusTab = "cpu" - - this.selectNodeStatusTab = function (tab) { - this.nodeStatusTab = tab - this.$delay(function () { - switch (tab) { - case "cpu": - this.reloadCPUChart() - break - case "memory": - this.reloadMemoryChart() - break - case "load": - this.reloadLoadChart() - break - } - }) - } - - this.reloadCPUChart = function () { - let axis = {unit: "%", divider: 1} - teaweb.renderLineChart({ - id: "cpu-chart", - name: "CPU", - values: this.cpuValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100 * 100) / 100) + "%" - }, - value: function (v) { - return v.value * 100; - }, - axis: axis, - max: 100 - }) - } - - this.reloadMemoryChart = function () { - let axis = {unit: "%", divider: 1} - teaweb.renderLineChart({ - id: "memory-chart", - name: "内存", - values: this.memoryValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100 * 100) / 100) + "%" - }, - value: function (v) { - return v.value * 100; - }, - axis: axis, - max: 100 - }) - } - - this.reloadLoadChart = function () { - let axis = {unit: "", divider: 1} - let max = this.loadValues.$map(function (k, v) { - return v.value - }).$max() - if (max < 10) { - max = 10 - } else if (max < 20) { - max = 20 - } else if (max < 100) { - max = 100 - } else { - max = null - } - teaweb.renderLineChart({ - id: "load-chart", - name: "负载", - values: this.loadValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100) / 100) - }, - value: function (v) { - return v.value; - }, - axis: axis, - max: max - }) - } -}) \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/dns.css b/web/views/@default/dashboard/boards/dns_plus.css similarity index 100% rename from web/views/@default/dashboard/boards/dns.css rename to web/views/@default/dashboard/boards/dns_plus.css diff --git a/web/views/@default/dashboard/boards/dns.css.map b/web/views/@default/dashboard/boards/dns_plus.css.map similarity index 100% rename from web/views/@default/dashboard/boards/dns.css.map rename to web/views/@default/dashboard/boards/dns_plus.css.map diff --git a/web/views/@default/dashboard/boards/dns.less b/web/views/@default/dashboard/boards/dns_plus.less similarity index 100% rename from web/views/@default/dashboard/boards/dns.less rename to web/views/@default/dashboard/boards/dns_plus.less diff --git a/web/views/@default/dashboard/boards/events.html b/web/views/@default/dashboard/boards/events.html deleted file mode 100644 index 9b4cdf71..00000000 --- a/web/views/@default/dashboard/boards/events.html +++ /dev/null @@ -1,67 +0,0 @@ -{$layout} -{$template "menu"} - -

暂时还没有事件。

- - - [本页已读] - [全部已读] - - - - - - - - - - - - - - - - - - - -
节点类型集群节点信息操作
- - - - {{log.node.cluster.name}} - - - {{log.node.cluster.name}} - - - - - - {{log.node.name}} - - - {{log.node.name}} - - - {{log.node.name}} - - - {{log.node.name}} - - 管理平台 - - {{log.node.name}} - - - {{log.node.name}} - - - {{log.node.name}} - - - - - 已读 -
- -
\ No newline at end of file diff --git a/web/views/@default/dashboard/boards/events.js b/web/views/@default/dashboard/boards/events.js deleted file mode 100644 index 8421f8f9..00000000 --- a/web/views/@default/dashboard/boards/events.js +++ /dev/null @@ -1,36 +0,0 @@ -Tea.context(function () { - this.updateRead = function (logId) { - this.$post(".readLogs") - .params({ - logIds: [logId] - }) - .success(function () { - teaweb.reload() - }) - } - - this.updatePageRead = function () { - let logIds = this.logs.map(function (v) { - return v.id - }) - teaweb.confirm("确定要设置本页日志为已读吗?", function () { - this.$post(".readLogs") - .params({ - logIds: logIds - }) - .success(function () { - teaweb.reload() - }) - }) - } - - this.updateAllRead = function () { - teaweb.confirm("确定要设置所有日志为已读吗?", function () { - this.$post(".readAllLogs") - .params({}) - .success(function () { - teaweb.reload() - }) - }) - } -}) \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/index.html b/web/views/@default/dashboard/boards/index.html deleted file mode 100644 index 243b7a08..00000000 --- a/web/views/@default/dashboard/boards/index.html +++ /dev/null @@ -1,170 +0,0 @@ -{$layout} - -{$var "header"} - - - - -{$end} - -{$template "menu"} - - -
-
-
  数据加载中... -
-
- - -
- - {{plusErr}} -
- - -
- - 还没有在集群中添加节点,现在去添加?添加节点后才可部署网站服务。 -
- - -
- - 续费提醒:商业版服务即将在 {{plusExpireDay}} 过期,请及时续费。 -
- - -
- - - 升级提醒:有 {{nodeUpgradeInfo.count}} 个边缘节点需要升级到 v{{nodeUpgradeInfo.version}} 版本,系统正在尝试自动升级... -
-
- - 升级提醒:有 {{monitorNodeUpgradeInfo.count}} 个监控节点需要升级到 v{{monitorNodeUpgradeInfo.version}} 版本
-
- - 升级提醒:有 {{userNodeUpgradeInfo.count}} 个用户节点需要升级到 v{{userNodeUpgradeInfo.version}} 版本
-
- - 升级提醒:有 {{apiNodeUpgradeInfo.count}} 个API节点需要升级到 v{{apiNodeUpgradeInfo.version}} 版本
-
- - 升级提醒:有 {{nsNodeUpgradeInfo.count}} 个DNS节点需要升级到 v{{nsNodeUpgradeInfo.version}} 版本,系统正在尝试自动升级... -
-
- - 升级提醒:有 {{reportNodeUpgradeInfo.count}} 个区域监控终端需要升级到 v{{reportNodeUpgradeInfo.version}} 版本 -
-
- - 升级提醒:有 {{authorityNodeUpgradeInfo.count}} 个商业版认证节点需要升级到 v{{authorityNodeUpgradeInfo.version}} 版本 -
- - -
-
-

集群

-
{{dashboard.countNodeClusters}}
-
- -
-

边缘节点

-
- {{dashboard.countNodes}}个 - / {{dashboard.countOfflineNodes}}离线{{dashboard.countOfflineNodes}}离线 -
-
- -
-

API节点

-
- {{dashboard.countAPINodes}}个 - / {{dashboard.countOfflineAPINodes}}离线{{dashboard.countOfflineAPINodes}}离线 -
-
- -
-

用户

-
{{dashboard.countUsers}}个 - / {{dashboard.countOfflineUserNodes}}节点离线{{dashboard.countOfflineUserNodes}}节点离线 -
-
- -
-

服务

-
{{dashboard.countServers}}个 - / {{dashboard.countAuditingServers}}审核{{dashboard.countAuditingServers}}审核 -
-
- -
-

本周流量

-
{{weekTraffic}}{{weekTrafficUnit}}
-
- -
-

昨日流量

-
{{yesterdayTraffic}}{{yesterdayTrafficUnit}}
-
- -
-

今日流量

-
{{todayTraffic}}{{todayTrafficUnit}}
-
-
- -
- - -
- -
-
- - - - - -
- - -
- -
- - - - -
- - -
- - -

域名访问排行 (24小时)

-
- -
- - -

节点访问排行 (24小时)

-
- - -
- - - - \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/index.js b/web/views/@default/dashboard/boards/index.js deleted file mode 100644 index d6eb1bce..00000000 --- a/web/views/@default/dashboard/boards/index.js +++ /dev/null @@ -1,367 +0,0 @@ -Tea.context(function () { - this.isLoading = true - this.trafficTab = "hourly" - this.metricCharts = [] - this.plusExpireDay = "" - this.topCountryStats = [] - - this.$delay(function () { - this.$post("$") - .success(function (resp) { - for (let k in resp.data) { - this[k] = resp.data[k] - } - - this.isLoading = false - - this.$delay(function () { - this.reloadHourlyTrafficChart() - this.reloadHourlyRequestsChart() - this.reloadTopDomainsChart() - this.reloadTopNodesChart() - }) - }) - }) - - this.selectTrafficTab = function (tab) { - this.trafficTab = tab - if (tab == "hourly") { - this.$delay(function () { - this.reloadHourlyTrafficChart() - }) - } else if (tab == "daily") { - this.$delay(function () { - this.reloadDailyTrafficChart() - }) - } - } - - this.reloadHourlyTrafficChart = function () { - let stats = this.hourlyTrafficStats - this.reloadTrafficChart("hourly-traffic-chart-box", stats, function (args) { - let index = args.dataIndex - let cachedRatio = 0 - let attackRatio = 0 - if (stats[index].bytes > 0) { - cachedRatio = Math.round(stats[index].cachedBytes * 10000 / stats[index].bytes) / 100 - attackRatio = Math.round(stats[index].attackBytes * 10000 / stats[index].bytes) / 100 - } - - return stats[index].day + " " + stats[index].hour + "时
总流量:" + teaweb.formatBytes(stats[index].bytes) + "
缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "
缓存命中率:" + cachedRatio + "%
拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "
拦截比例:" + attackRatio + "%" - }) - } - - this.reloadDailyTrafficChart = function () { - let stats = this.dailyTrafficStats - this.reloadTrafficChart("daily-traffic-chart-box", stats, function (args) { - let index = args.dataIndex - let cachedRatio = 0 - let attackRatio = 0 - if (stats[index].bytes > 0) { - cachedRatio = Math.round(stats[index].cachedBytes * 10000 / stats[index].bytes) / 100 - attackRatio = Math.round(stats[index].attackBytes * 10000 / stats[index].bytes) / 100 - } - - return stats[index].day + "
总流量:" + teaweb.formatBytes(stats[index].bytes) + "
缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "
缓存命中率:" + cachedRatio + "%
拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "
拦截比例:" + attackRatio + "%" - }) - } - - - this.reloadTrafficChart = function (chartId, stats, tooltipFunc) { - let axis = teaweb.bytesAxis(stats, function (v) { - return v.bytes - }) - let chartBox = document.getElementById(chartId) - let chart = teaweb.initChart(chartBox) - let option = { - xAxis: { - data: stats.map(function (v) { - if (v.hour != null) { - return v.hour - } - return v.day - }) - }, - yAxis: { - axisLabel: { - formatter: function (v) { - return v + axis.unit - } - } - }, - tooltip: { - show: true, - trigger: "item", - formatter: tooltipFunc - }, - grid: { - left: 50, - top: 40, - right: 20, - bottom: 20 - }, - series: [ - { - name: "总流量", - type: "line", - data: stats.map(function (v) { - return v.bytes / axis.divider; - }), - itemStyle: { - color: "#9DD3E8" - }, - lineStyle: { - color: "#9DD3E8" - }, - areaStyle: { - color: "#9DD3E8" - }, - smooth: true - }, - { - name: "缓存流量", - type: "line", - data: stats.map(function (v) { - return v.cachedBytes / axis.divider; - }), - itemStyle: { - color: "#61A0A8" - }, - lineStyle: { - color: "#61A0A8" - }, - areaStyle: {}, - smooth: true - }, - { - name: "攻击流量", - type: "line", - data: stats.map(function (v) { - return v.attackBytes / axis.divider; - }), - itemStyle: { - color: "#F39494" - }, - areaStyle: { - color: "#F39494" - }, - smooth: true - } - ], - legend: { - data: ["总流量", "缓存流量", "攻击流量"] - }, - animation: false - } - chart.setOption(option) - chart.resize() - } - - /** - * 请求数统计 - */ - this.requestsTab = "hourly" - - this.selectRequestsTab = function (tab) { - this.requestsTab = tab - if (tab == "hourly") { - this.$delay(function () { - this.reloadHourlyRequestsChart() - }) - } else if (tab == "daily") { - this.$delay(function () { - this.reloadDailyRequestsChart() - }) - } - } - - this.reloadHourlyRequestsChart = function () { - let stats = this.hourlyTrafficStats - this.reloadRequestsChart("hourly-requests-chart", "请求数统计", stats, function (args) { - let index = args.dataIndex - let cachedRatio = 0 - let attackRatio = 0 - if (stats[index].countRequests > 0) { - cachedRatio = Math.round(stats[index].countCachedRequests * 10000 / stats[index].countRequests) / 100 - attackRatio = Math.round(stats[index].countAttackRequests * 10000 / stats[index].countRequests) / 100 - } - - return stats[index].day + " " + stats[index].hour + "时
总请求数:" + stats[index].countRequests + "
缓存请求数:" + stats[index].countCachedRequests + "
缓存命中率:" + cachedRatio + "%
拦截攻击数:" + stats[index].countAttackRequests + "
拦截比例:" + attackRatio + "%" - }) - } - - this.reloadDailyRequestsChart = function () { - let stats = this.dailyTrafficStats - this.reloadRequestsChart("daily-requests-chart", "请求数统计", stats, function (args) { - let index = args.dataIndex - let cachedRatio = 0 - let attackRatio = 0 - if (stats[index].countRequests > 0) { - cachedRatio = Math.round(stats[index].countCachedRequests * 10000 / stats[index].countRequests) / 100 - attackRatio = Math.round(stats[index].countAttackRequests * 10000 / stats[index].countRequests) / 100 - } - - return stats[index].day + "
总请求数:" + stats[index].countRequests + "
缓存请求数:" + stats[index].countCachedRequests + "
缓存命中率:" + cachedRatio + "%
拦截攻击数:" + stats[index].countAttackRequests + "
拦截比例:" + attackRatio + "%" - }) - } - - this.reloadRequestsChart = function (chartId, name, stats, tooltipFunc) { - let chartBox = document.getElementById(chartId) - if (chartBox == null) { - return - } - - let axis = teaweb.countAxis(stats, function (v) { - return Math.max(v.countRequests, v.countCachedRequests) - }) - - let chart = teaweb.initChart(chartBox) - let option = { - xAxis: { - data: stats.map(function (v) { - if (v.hour != null) { - return v.hour - } - if (v.day != null) { - return v.day - } - return "" - }) - }, - yAxis: { - axisLabel: { - formatter: function (value) { - return value + axis.unit - } - } - }, - tooltip: { - show: true, - trigger: "item", - formatter: tooltipFunc - }, - grid: { - left: 50, - top: 40, - right: 20, - bottom: 20 - }, - series: [ - { - name: "请求数", - type: "line", - data: stats.map(function (v) { - return v.countRequests / axis.divider - }), - itemStyle: { - color: "#9DD3E8" - }, - areaStyle: { - color: "#9DD3E8" - }, - smooth: true - }, - { - name: "缓存请求数", - type: "line", - data: stats.map(function (v) { - return v.countCachedRequests / axis.divider - }), - itemStyle: { - color: "#61A0A8" - }, - areaStyle: { - color: "#61A0A8" - }, - smooth: true - }, - { - name: "攻击请求数", - type: "line", - data: stats.map(function (v) { - return v.countAttackRequests / axis.divider; - }), - itemStyle: { - color: "#F39494" - }, - areaStyle: { - color: "#F39494" - }, - smooth: true - } - ], - legend: { - data: ["请求数", "缓存请求数", "攻击请求数"] - }, - animation: true - } - chart.setOption(option) - chart.resize() - } - - // 节点排行 - this.reloadTopNodesChart = function () { - let that = this - let axis = teaweb.countAxis(this.topNodeStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-nodes-chart", - name: "节点", - values: this.topNodeStats, - x: function (v) { - return v.nodeName - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].nodeName + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - window.location = "/clusters/cluster/node?nodeId=" + stats[args.dataIndex].nodeId + "&clusterId=" + that.clusterId - } - }) - } - - // 域名排行 - this.reloadTopDomainsChart = function () { - let axis = teaweb.countAxis(this.topDomainStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-domains-chart", - name: "域名", - values: this.topDomainStats, - x: function (v) { - return v.domain - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].domain + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - let index = args.dataIndex - window.location = "/servers/server?serverId=" + stats[index].serverId - } - }) - } - - /** - * 升级提醒 - */ - this.closeMessage = function (e) { - let target = e.target - while (true) { - target = target.parentNode - if (target.tagName.toUpperCase() == "DIV") { - target.style.cssText = "display: none" - break - } - } - } -}) diff --git a/web/views/@default/dashboard/boards/index.css b/web/views/@default/dashboard/boards/index_plus.css similarity index 100% rename from web/views/@default/dashboard/boards/index.css rename to web/views/@default/dashboard/boards/index_plus.css diff --git a/web/views/@default/dashboard/boards/index.css.map b/web/views/@default/dashboard/boards/index_plus.css.map similarity index 100% rename from web/views/@default/dashboard/boards/index.css.map rename to web/views/@default/dashboard/boards/index_plus.css.map diff --git a/web/views/@default/dashboard/boards/index.less b/web/views/@default/dashboard/boards/index_plus.less similarity index 100% rename from web/views/@default/dashboard/boards/index.less rename to web/views/@default/dashboard/boards/index_plus.less diff --git a/web/views/@default/dashboard/boards/user.html b/web/views/@default/dashboard/boards/user.html deleted file mode 100644 index 845accea..00000000 --- a/web/views/@default/dashboard/boards/user.html +++ /dev/null @@ -1,48 +0,0 @@ -{$layout} -{$template "menu"} -{$template "/echarts"} - -
-
-

用户总数

-
{{board.totalUsers}}
-
-
-

今日新增

-
{{board.countTodayUsers}}
-
-
-

本周新增

-
{{board.countWeeklyUsers}}
-
-
-

用户节点

-
{{board.countUserNodes}} - - / {{board.countOfflineUserNodes}}离线 - - -
-
-
- -

用户增长趋势

-
- -
- -

流量排行 (24小时)

-
- -
- - - - -
-
-
diff --git a/web/views/@default/dashboard/boards/user.js b/web/views/@default/dashboard/boards/user.js deleted file mode 100644 index abc9f0fd..00000000 --- a/web/views/@default/dashboard/boards/user.js +++ /dev/null @@ -1,154 +0,0 @@ -Tea.context(function () { - this.$delay(function () { - this.reloadDailyStats() - this.reloadCPUChart() - this.reloadTopTrafficChart() - }) - - this.reloadDailyStats = function () { - let axis = teaweb.countAxis(this.dailyStats, function (v) { - return v.count - }) - let max = axis.max - if (max < 10) { - max = 10 - } else if (max < 100) { - max = 100 - } - teaweb.renderLineChart({ - id: "daily-stat-chart", - name: "用户", - values: this.dailyStats, - x: function (v) { - return v.day.substring(4, 6) + "-" + v.day.substring(6) - }, - tooltip: function (args, stats) { - let index = args.dataIndex - return stats[index].day.substring(4, 6) + "-" + stats[index].day.substring(6) + ":" + stats[index].count - }, - value: function (v) { - return v.count; - }, - axis: axis, - max: max - }) - } - - /** - * 系统信息 - */ - this.nodeStatusTab = "cpu" - - this.selectNodeStatusTab = function (tab) { - this.nodeStatusTab = tab - this.$delay(function () { - switch (tab) { - case "cpu": - this.reloadCPUChart() - break - case "memory": - this.reloadMemoryChart() - break - case "load": - this.reloadLoadChart() - break - } - }) - } - - this.reloadCPUChart = function () { - let axis = {unit: "%", divider: 1} - teaweb.renderLineChart({ - id: "cpu-chart", - name: "CPU", - values: this.cpuValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100 * 100) / 100) + "%" - }, - value: function (v) { - return v.value * 100; - }, - axis: axis, - max: 100 - }) - } - - this.reloadMemoryChart = function () { - let axis = {unit: "%", divider: 1} - teaweb.renderLineChart({ - id: "memory-chart", - name: "内存", - values: this.memoryValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100 * 100) / 100) + "%" - }, - value: function (v) { - return v.value * 100; - }, - axis: axis, - max: 100 - }) - } - - this.reloadLoadChart = function () { - let axis = {unit: "", divider: 1} - let max = this.loadValues.$map(function (k, v) { - return v.value - }).$max() - if (max < 10) { - max = 10 - } else if (max < 20) { - max = 20 - } else if (max < 100) { - max = 100 - } else { - max = null - } - teaweb.renderLineChart({ - id: "load-chart", - name: "负载", - values: this.loadValues, - x: function (v) { - return v.time - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].time + ":" + (Math.ceil(stats[args.dataIndex].value * 100) / 100) - }, - value: function (v) { - return v.value; - }, - axis: axis, - max: max - }) - } - - // 流量排行 - this.reloadTopTrafficChart = function () { - let that = this - let axis = teaweb.bytesAxis(this.topTrafficStats, function (v) { - return v.bytes - }) - teaweb.renderBarChart({ - id: "top-traffic-chart", - name: "流量", - values: this.topTrafficStats, - x: function (v) { - return v.userName - }, - tooltip: function (args, stats) { - let index = args.dataIndex - return stats[index].userName + "
请求数:" + " " + teaweb.formatNumber(stats[index].countRequests) + "
流量:" + teaweb.formatBytes(stats[index].bytes) - }, - value: function (v) { - return v.bytes / axis.divider; - }, - axis: axis - }) - } -}) \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/user.css b/web/views/@default/dashboard/boards/user_plus.css similarity index 100% rename from web/views/@default/dashboard/boards/user.css rename to web/views/@default/dashboard/boards/user_plus.css diff --git a/web/views/@default/dashboard/boards/user.css.map b/web/views/@default/dashboard/boards/user_plus.css.map similarity index 100% rename from web/views/@default/dashboard/boards/user.css.map rename to web/views/@default/dashboard/boards/user_plus.css.map diff --git a/web/views/@default/dashboard/boards/user.less b/web/views/@default/dashboard/boards/user_plus.less similarity index 100% rename from web/views/@default/dashboard/boards/user.less rename to web/views/@default/dashboard/boards/user_plus.less diff --git a/web/views/@default/dashboard/boards/waf.html b/web/views/@default/dashboard/boards/waf.html deleted file mode 100644 index 98c317b1..00000000 --- a/web/views/@default/dashboard/boards/waf.html +++ /dev/null @@ -1,80 +0,0 @@ -{$layout} - -{$var "header"} - - - - -{$end} - -{$template "menu"} - -
-
-

今日拦截

-
{{board.countDailyBlocks}}
-
- -
-

今日验证码验证

-
{{board.countDailyCaptcha}}
-
- -
-

今日记录

-
{{board.countDailyLogs}}
-
- -
-

本周拦截

-
{{board.countWeeklyBlocks}}
-
-
- - -
-
- -
-
- - -
-
-

最新拦截记录 更多 »

- - - - -
-
-
- - - - -
-
-
- - -

拦截类型分布

-
- - -

域名拦截排行 (24小时)

-
- -
- - -

节点拦截排行 (24小时)

-
\ No newline at end of file diff --git a/web/views/@default/dashboard/boards/waf.js b/web/views/@default/dashboard/boards/waf.js deleted file mode 100644 index edfa9fce..00000000 --- a/web/views/@default/dashboard/boards/waf.js +++ /dev/null @@ -1,248 +0,0 @@ -Tea.context(function () { - this.isLoading = false - - this.$delay(function () { - this.board.countDailyBlocks = teaweb.formatCount(this.board.countDailyBlocks) - this.board.countDailyCaptcha = teaweb.formatCount(this.board.countDailyCaptcha) - this.board.countDailyLogs = teaweb.formatCount(this.board.countDailyLogs) - this.board.countWeeklyBlocks = teaweb.formatCount(this.board.countWeeklyBlocks) - - this.reloadHourlyChart() - this.reloadGroupChart() - this.reloadAccessLogs() - this.reloadTopNodesChart() - this.reloadTopDomainsChart() - }) - - this.requestsTab = "hourly" - - this.selectRequestsTab = function (tab) { - this.requestsTab = tab - this.$delay(function () { - switch (tab) { - case "hourly": - this.reloadHourlyChart() - break - case "daily": - this.reloadDailyChart() - break - } - }) - } - - this.reloadHourlyChart = function () { - let axis = teaweb.countAxis(this.hourlyStats, function (v) { - return [v.countLogs, v.countCaptcha, v.countBlocks].$max() - }) - let that = this - this.reloadLineChart("hourly-chart", "按小时统计", this.hourlyStats, function (v) { - return v.hour.substring(8, 10) - }, function (args) { - let index = args.dataIndex - let hour = that.hourlyStats[index].hour.substring(0, 4) + "-" + that.hourlyStats[index].hour.substring(4, 6) + "-" + that.hourlyStats[index].hour.substring(6, 8) + " " + that.hourlyStats[index].hour.substring(8) - return hour + "时
拦截: " - + teaweb.formatNumber(that.hourlyStats[index].countBlocks) + "
验证码: " + teaweb.formatNumber(that.hourlyStats[index].countCaptcha) + "
记录: " + teaweb.formatNumber(that.hourlyStats[index].countLogs) - }, axis) - } - - this.reloadDailyChart = function () { - let axis = teaweb.countAxis(this.dailyStats, function (v) { - return [v.countLogs, v.countCaptcha, v.countBlocks].$max() - }) - let that = this - this.reloadLineChart("daily-chart", "按天统计", this.dailyStats, function (v) { - return v.day.substring(4, 6) + "月" + v.day.substring(6, 8) + "日" - }, function (args) { - let index = args.dataIndex - let day = that.dailyStats[index].day.substring(0, 4) + "-" + that.dailyStats[index].day.substring(4, 6) + "-" + that.dailyStats[index].day.substring(6, 8) - return day + "
拦截: " - + teaweb.formatNumber(that.dailyStats[index].countBlocks) + "
验证码: " + teaweb.formatNumber(that.dailyStats[index].countCaptcha) + "
记录: " + teaweb.formatNumber(that.dailyStats[index].countLogs) - }, axis) - } - - this.reloadLineChart = function (chartId, name, stats, xFunc, tooltipFunc, axis) { - let chartBox = document.getElementById(chartId) - if (chartBox == null) { - return - } - let chart = teaweb.initChart(chartBox) - let option = { - xAxis: { - data: stats.map(xFunc) - }, - yAxis: { - axisLabel: { - formatter: function (value) { - return value + axis.unit - } - } - }, - tooltip: { - show: true, - trigger: "item", - formatter: tooltipFunc - }, - grid: { - left: 42, - top: 10, - right: 20, - bottom: 20 - }, - series: [ - { - name: name, - type: "line", - data: stats.map(function (v) { - return v.countLogs / axis.divider; - }), - itemStyle: { - color: "#879BD7" - }, - areaStyle: {}, - stack: "总量", - smooth: true - }, - { - name: name, - type: "line", - data: stats.map(function (v) { - return v.countCaptcha / axis.divider; - }), - itemStyle: { - color: "#FBD88A" - }, - areaStyle: {}, - stack: "总量", - smooth: true - }, - { - name: name, - type: "line", - data: stats.map(function (v) { - return v.countBlocks / axis.divider; - }), - itemStyle: { - color: "#F39494" - }, - areaStyle: {}, - stack: "总量", - smooth: true - } - ], - animation: true - } - chart.setOption(option) - chart.resize() - } - - this.reloadGroupChart = function () { - let axis = teaweb.countAxis(this.groupStats, function (v) { - return v.count - }) - teaweb.renderBarChart({ - id: "group-chart", - values: this.groupStats, - x: function (v) { - return v.name - }, - value: function (v) { - return v.count / axis.divider - }, - tooltip: function (args, stats) { - let index = args.dataIndex - return stats[index].name + ": " + stats[index].count - }, - axis: axis - }) - } - - this.accessLogs = [] - this.reloadAccessLogs = function () { - this.$post(".wafLogs") - .success(function (resp) { - if (resp.data.accessLogs != null) { - let regions = resp.data.regions - - let that = this - resp.data.accessLogs.forEach(function (accessLog) { - that.formatTime(accessLog) - - if (typeof (regions[accessLog.remoteAddr]) == "string") { - accessLog.region = regions[accessLog.remoteAddr] - } else { - accessLog.region = "" - } - }) - this.accessLogs = resp.data.accessLogs - } - }) - .done(function () { - this.$delay(this.reloadAccessLogs, 10000) - }) - } - - this.formatTime = function (accessLog) { - let elapsedSeconds = Math.ceil(new Date().getTime() / 1000) - accessLog.timestamp - if (elapsedSeconds >= 0) { - if (elapsedSeconds < 60) { - accessLog.humanTime = elapsedSeconds + "秒前" - } else if (elapsedSeconds < 3600) { - accessLog.humanTime = Math.ceil(elapsedSeconds / 60) + "分钟前" - } else if (elapsedSeconds < 3600 * 24) { - accessLog.humanTime = Math.ceil(elapsedSeconds / 3600) + "小时前" - } - } - } - - // 节点排行 - this.reloadTopNodesChart = function () { - let that = this - let axis = teaweb.countAxis(this.topNodeStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-nodes-chart", - name: "节点", - values: this.topNodeStats, - x: function (v) { - return v.nodeName - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].nodeName + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - window.location = "/clusters/cluster/node?nodeId=" + stats[args.dataIndex].nodeId + "&clusterId=" + that.clusterId - } - }) - } - - // 域名排行 - this.reloadTopDomainsChart = function () { - let axis = teaweb.countAxis(this.topDomainStats, function (v) { - return v.countRequests - }) - teaweb.renderBarChart({ - id: "top-domains-chart", - name: "域名", - values: this.topDomainStats, - x: function (v) { - return v.domain - }, - tooltip: function (args, stats) { - return stats[args.dataIndex].domain + "
请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "
流量:" + teaweb.formatBytes(stats[args.dataIndex].bytes) - }, - value: function (v) { - return v.countRequests / axis.divider; - }, - axis: axis, - click: function (args, stats) { - let index = args.dataIndex - window.location = "/servers/server?serverId=" + stats[index].serverId - } - }) - } -}) \ No newline at end of file diff --git a/web/views/@default/dashboard/boards/waf.css b/web/views/@default/dashboard/boards/waf_plus.css similarity index 100% rename from web/views/@default/dashboard/boards/waf.css rename to web/views/@default/dashboard/boards/waf_plus.css diff --git a/web/views/@default/dashboard/boards/waf.css.map b/web/views/@default/dashboard/boards/waf_plus.css.map similarity index 100% rename from web/views/@default/dashboard/boards/waf.css.map rename to web/views/@default/dashboard/boards/waf_plus.css.map diff --git a/web/views/@default/dashboard/boards/waf.less b/web/views/@default/dashboard/boards/waf_plus.less similarity index 100% rename from web/views/@default/dashboard/boards/waf.less rename to web/views/@default/dashboard/boards/waf_plus.less diff --git a/web/views/@default/dashboard/index.html b/web/views/@default/dashboard/index.html index b2b42a27..e1549212 100644 --- a/web/views/@default/dashboard/index.html +++ b/web/views/@default/dashboard/index.html @@ -14,6 +14,15 @@ 还没有在集群中添加节点,现在去添加?添加节点后才可部署网站服务。 + +
+ + 升级提醒:有新版本管理系统可以更新:v{{currentVersionCode}} -> v{{newVersionCode}}     + [去官网查看]     [直接下载] + + +
+
diff --git a/web/views/@default/servers/components/waf/policy.html b/web/views/@default/servers/components/waf/policy.html index 3562c6df..539be22a 100644 --- a/web/views/@default/servers/components/waf/policy.html +++ b/web/views/@default/servers/components/waf/policy.html @@ -22,7 +22,7 @@ {{group.name}}
- 升级提醒:官方提供了新的规则,是否要加入以下规则:{{item}}     [加入] + 升级提醒:官方提供了新的规则,是否要加入以下规则:{{item.name}}(默认不启用)     [加入]
diff --git a/web/views/@default/settings/updates/index.html b/web/views/@default/settings/updates/index.html index 578dd153..f2e42918 100644 --- a/web/views/@default/settings/updates/index.html +++ b/web/views/@default/settings/updates/index.html @@ -7,6 +7,13 @@ 当前已安装版本 v{{version}} + + 自动检查 + + +

选中后系统将定时检查是否有新版本更新。

+ + 最新版本 diff --git a/web/views/@default/settings/updates/index.js b/web/views/@default/settings/updates/index.js index ba188327..880c6b9f 100644 --- a/web/views/@default/settings/updates/index.js +++ b/web/views/@default/settings/updates/index.js @@ -21,4 +21,11 @@ Tea.context(function () { this.isChecking = false }) } + + this.changeAutoCheck = function () { + this.$post(".update") + .params({ + autoCheck: this.config.autoCheck ? 1 : 0 + }) + } }) \ No newline at end of file