mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
增加自动检查系统更新设置
This commit is contained in:
@@ -4,9 +4,10 @@ package teaconst
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
IsRecoverMode = false
|
IsRecoverMode = false
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
IsDemoMode = false
|
IsDemoMode = false
|
||||||
ErrorDemoOperation = "DEMO模式下无法进行创建、修改、删除等操作"
|
ErrorDemoOperation = "DEMO模式下无法进行创建、修改、删除等操作"
|
||||||
|
|
||||||
|
NewVersionCode = "" // 有新的版本
|
||||||
|
NewVersionDownloadURL = "" // 新版本下载地址
|
||||||
)
|
)
|
||||||
|
|||||||
12
internal/goman/instance.go
Normal file
12
internal/goman/instance.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
81
internal/goman/lib.go
Normal file
81
internal/goman/lib.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
28
internal/goman/lib_test.go
Normal file
28
internal/goman/lib_test.go
Normal file
@@ -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)
|
||||||
|
}
|
||||||
104
internal/tasks/task_check_updates.go
Normal file
104
internal/tasks/task_check_updates.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configs"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/goman"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
@@ -23,7 +24,9 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
events.On(events.EventStart, func() {
|
events.On(events.EventStart, func() {
|
||||||
task := NewSyncAPINodesTask()
|
task := NewSyncAPINodesTask()
|
||||||
go task.Start()
|
goman.New(func() {
|
||||||
|
task.Start()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package tasks
|
|||||||
import (
|
import (
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
"github.com/TeaOSLab/EdgeAdmin/internal/events"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/goman"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/nodeutils"
|
||||||
@@ -17,7 +18,9 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
events.On(events.EventStart, func() {
|
events.On(events.EventStart, func() {
|
||||||
task := NewSyncClusterTask()
|
task := NewSyncClusterTask()
|
||||||
go task.Start()
|
goman.New(func() {
|
||||||
|
task.Start()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (this *PolicyAction) RunGet(params struct {
|
|||||||
|
|
||||||
// 检查是否有升级
|
// 检查是否有升级
|
||||||
var templatePolicy = firewallconfigs.HTTPFirewallTemplate()
|
var templatePolicy = firewallconfigs.HTTPFirewallTemplate()
|
||||||
var upgradeItems = []string{}
|
var upgradeItems = []maps.Map{}
|
||||||
if templatePolicy.Inbound != nil {
|
if templatePolicy.Inbound != nil {
|
||||||
for _, group := range templatePolicy.Inbound.Groups {
|
for _, group := range templatePolicy.Inbound.Groups {
|
||||||
if len(group.Code) == 0 {
|
if len(group.Code) == 0 {
|
||||||
@@ -57,7 +57,10 @@ func (this *PolicyAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
var oldGroup = firewallPolicy.FindRuleGroupWithCode(group.Code)
|
var oldGroup = firewallPolicy.FindRuleGroupWithCode(group.Code)
|
||||||
if oldGroup == nil {
|
if oldGroup == nil {
|
||||||
upgradeItems = append(upgradeItems, group.Name)
|
upgradeItems = append(upgradeItems, maps.Map{
|
||||||
|
"name": group.Name,
|
||||||
|
"isOn": group.IsOn,
|
||||||
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, set := range group.Sets {
|
for _, set := range group.Sets {
|
||||||
@@ -66,7 +69,10 @@ func (this *PolicyAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
var oldSet = oldGroup.FindRuleSetWithCode(set.Code)
|
var oldSet = oldGroup.FindRuleSetWithCode(set.Code)
|
||||||
if oldSet == nil {
|
if oldSet == nil {
|
||||||
upgradeItems = append(upgradeItems, group.Name+" -- "+set.Name)
|
upgradeItems = append(upgradeItems, maps.Map{
|
||||||
|
"name": group.Name + " -- " + set.Name,
|
||||||
|
"isOn": set.IsOn,
|
||||||
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"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/maps"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
stringutil "github.com/iwind/TeaGo/utils/string"
|
stringutil "github.com/iwind/TeaGo/utils/string"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -25,6 +28,22 @@ func (this *IndexAction) Init() {
|
|||||||
func (this *IndexAction) RunGet(params struct{}) {
|
func (this *IndexAction) RunGet(params struct{}) {
|
||||||
this.Data["version"] = teaconst.Version
|
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()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +56,8 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var apiURL = teaconst.UpdatesURL
|
var apiURL = teaconst.UpdatesURL
|
||||||
apiURL = strings.ReplaceAll(apiURL, "${os}", "linux") //runtime.GOOS)
|
apiURL = strings.ReplaceAll(apiURL, "${os}", runtime.GOOS)
|
||||||
apiURL = strings.ReplaceAll(apiURL, "${arch}", "amd64") // runtime.GOARCH)
|
apiURL = strings.ReplaceAll(apiURL, "${arch}", runtime.GOARCH)
|
||||||
resp, err := http.Get(apiURL)
|
resp, err := http.Get(apiURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Data["result"] = maps.Map{
|
this.Data["result"] = maps.Map{
|
||||||
@@ -109,7 +128,6 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
"isOk": false,
|
"isOk": false,
|
||||||
"message": "找不到更新信息",
|
"message": "找不到更新信息",
|
||||||
}
|
}
|
||||||
this.Success()
|
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func init() {
|
|||||||
Helper(settingutils.NewHelper("updates")).
|
Helper(settingutils.NewHelper("updates")).
|
||||||
Prefix("/settings/updates").
|
Prefix("/settings/updates").
|
||||||
GetPost("", new(IndexAction)).
|
GetPost("", new(IndexAction)).
|
||||||
|
Post("/update", new(UpdateAction)).
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
52
internal/web/actions/default/settings/updates/update.go
Normal file
52
internal/web/actions/default/settings/updates/update.go
Normal file
@@ -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()
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<first-menu>
|
|
||||||
<menu-item href="/dashboard/boards" code="index">概况</menu-item>
|
|
||||||
<menu-item href="/dashboard/boards/waf" code="waf">WAF</menu-item>
|
|
||||||
<menu-item href="/dashboard/boards/dns" code="dns">DNS</menu-item>
|
|
||||||
<menu-item href="/dashboard/boards/user" code="user">用户</menu-item>
|
|
||||||
<menu-item href="/dashboard/boards/events" code="event">事件<span :class="{red: countEvents > 0}">({{countEvents}})</span></menu-item>
|
|
||||||
</first-menu>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
{$template "menu"}
|
|
||||||
{$template "/echarts"}
|
|
||||||
|
|
||||||
<div class="ui four columns grid">
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>域名<link-icon href="/ns/domains"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.countDomains}}</span>个</div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>记录<link-icon href="/ns/domains"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.countRecords}}</span>个</div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>集群<link-icon href="/ns/clusters"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.countClusters}}</span>个</div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column no-border">
|
|
||||||
<h4>节点<link-icon href="/ns/clusters"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.countNodes}}</span>
|
|
||||||
<span v-if="board.countOfflineNodes > 0" style="font-size: 1em">
|
|
||||||
/ <a href="/ns/clusters"><span class="red" style="font-size: 1em">{{board.countOfflineNodes}}离线</span></a>
|
|
||||||
</span>
|
|
||||||
<span v-else style="font-size: 1em">个</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 流量统计 -->
|
|
||||||
<div class="ui menu tabular">
|
|
||||||
<a href="" class="item" :class="{active: trafficTab == 'hourly'}" @click.prevent="selectTrafficTab('hourly')">24小时流量趋势</a>
|
|
||||||
<a href="" class="item" :class="{active: trafficTab == 'daily'}" @click.prevent="selectTrafficTab('daily')">15天流量趋势</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 按小时统计流量 -->
|
|
||||||
<div class="chart-box" id="hourly-traffic-chart" v-show="trafficTab == 'hourly'"></div>
|
|
||||||
|
|
||||||
<!-- 按日统计流量 -->
|
|
||||||
<div class="chart-box" id="daily-traffic-chart" v-show="trafficTab == 'daily'"></div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 域名排行 -->
|
|
||||||
<h4>域名访问排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-domains-chart"></div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 节点排行 -->
|
|
||||||
<h4>节点访问排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-nodes-chart"></div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 系统信息 -->
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
<div class="ui menu tabular">
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'cpu'}" @click.prevent="selectNodeStatusTab('cpu')">DNS节点CPU</a>
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'memory'}" @click.prevent="selectNodeStatusTab('memory')">DNS节点内存</a>
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'load'}" @click.prevent="selectNodeStatusTab('load')">DNS节点负载</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="chart-box" id="cpu-chart" v-show="nodeStatusTab == 'cpu'"></div>
|
|
||||||
<div class="chart-box" id="memory-chart" v-show="nodeStatusTab == 'memory'"></div>
|
|
||||||
<div class="chart-box" id="load-chart" v-show="nodeStatusTab == 'load'"></div>
|
|
||||||
@@ -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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
{$template "menu"}
|
|
||||||
|
|
||||||
<p class="comment" v-if="logs.length == 0">暂时还没有事件。</p>
|
|
||||||
|
|
||||||
<second-menu v-if="logs.length > 0">
|
|
||||||
<a href="" class="item" @click.prevent="updatePageRead()">[本页已读]</a>
|
|
||||||
<a href="" class="item" @click.prevent="updateAllRead()">[全部已读]</a>
|
|
||||||
</second-menu>
|
|
||||||
|
|
||||||
<table class="ui table selectable celled" v-if="logs.length > 0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th nowrap="">节点类型</th>
|
|
||||||
<th nowrap="">集群</th>
|
|
||||||
<th nowrap="">节点</th>
|
|
||||||
<th>信息</th>
|
|
||||||
<th class="one op">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tr v-for="log in logs">
|
|
||||||
<td>
|
|
||||||
<node-role-name :v-role="log.role"></node-role-name>
|
|
||||||
</td>
|
|
||||||
<td nowrap="">
|
|
||||||
<span v-if="log.role == 'node'">
|
|
||||||
<link-icon :href="'/clusters/cluster?clusterId=' + log.node.cluster.id">{{log.node.cluster.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-else-if="log.role == 'dns'">
|
|
||||||
<link-icon :href="'/ns/clusters/cluster?clusterId=' + log.node.cluster.id">{{log.node.cluster.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-else class="disabled">-</span>
|
|
||||||
</td>
|
|
||||||
<td nowrap="">
|
|
||||||
<span v-if="log.role == 'node'">
|
|
||||||
<link-icon :href="'/clusters/cluster/node?clusterId=' + log.node.cluster.id + '&nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'api'">
|
|
||||||
<link-icon :href="'/api/node?nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'dns'">
|
|
||||||
<link-icon :href="'/ns/clusters/cluster/node?clusterId=' + log.node.cluster.id + '&nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'database'">
|
|
||||||
<link-icon :href="'/db/node?nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'admin'">管理平台</span>
|
|
||||||
<span v-if="log.role == 'user'">
|
|
||||||
<link-icon :href="'/settings/userNodes/node?nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'monitor'">
|
|
||||||
<link-icon :href="'/settings/monitorNodes/node?nodeId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
<span v-if="log.role == 'report'">
|
|
||||||
<link-icon :href="'/clusters/monitors/reporters/reporter?reporterId=' + log.node.id">{{log.node.name}}</link-icon>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<node-log-row :v-log="log" :v-keyword="keyword"></node-log-row>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="" @click.prevent="updateRead(log.id)">已读</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="page" v-html="page"></div>
|
|
||||||
@@ -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()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
|
|
||||||
{$var "header"}
|
|
||||||
<!-- world map -->
|
|
||||||
<script type="text/javascript" src="/js/echarts/echarts.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/js/world.js"></script>
|
|
||||||
<script type="text/javascript" src="/js/world-countries-map.js"></script>
|
|
||||||
{$end}
|
|
||||||
|
|
||||||
{$template "menu"}
|
|
||||||
|
|
||||||
<!-- 加载中 -->
|
|
||||||
<div style="margin-top: 0.8em">
|
|
||||||
<div class="ui message loading" v-if="isLoading">
|
|
||||||
<div class="ui active inline loader small"></div> 数据加载中...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 商业版错误 -->
|
|
||||||
<div class="ui icon message error" v-if="plusErr.length > 0">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
{{plusErr}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 没有节点提醒 -->
|
|
||||||
<div class="ui icon message warning" v-if="!isLoading && dashboard.defaultClusterId > 0 && dashboard.countNodes == 0">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a :href="'/clusters/cluster/createNode?clusterId=' + dashboard.defaultClusterId">还没有在集群中添加节点,现在去添加?添加节点后才可部署网站服务。</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 过期提醒 -->
|
|
||||||
<div class="ui icon message error" v-if="plusExpireDay.length > 0">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/settings/authority">续费提醒:商业版服务即将在 {{plusExpireDay}} 过期,请及时续费。</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 升级提醒 -->
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && nodeUpgradeInfo.count > 0">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/clusters">
|
|
||||||
升级提醒:有 {{nodeUpgradeInfo.count}} 个边缘节点需要升级到 v{{nodeUpgradeInfo.version}} 版本,系统正在尝试自动升级...</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
|
||||||
</div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && monitorNodeUpgradeInfo.count > 0 && teaIsPlus">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/settings/monitorNodes">升级提醒:有 {{monitorNodeUpgradeInfo.count}} 个监控节点需要升级到 v{{monitorNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && userNodeUpgradeInfo.count > 0 && teaIsPlus">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/settings/userNodes">升级提醒:有 {{userNodeUpgradeInfo.count}} 个用户节点需要升级到 v{{userNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && apiNodeUpgradeInfo.count > 0">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/api">升级提醒:有 {{apiNodeUpgradeInfo.count}} 个API节点需要升级到 v{{apiNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a></div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && nsNodeUpgradeInfo.count > 0 && teaIsPlus">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/ns/clusters">升级提醒:有 {{nsNodeUpgradeInfo.count}} 个DNS节点需要升级到 v{{nsNodeUpgradeInfo.version}} 版本,系统正在尝试自动升级...</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
|
||||||
</div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && reportNodeUpgradeInfo.count > 0 && teaIsPlus">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/clusters/monitors/reporters">升级提醒:有 {{reportNodeUpgradeInfo.count}} 个区域监控终端需要升级到 v{{reportNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
|
||||||
</div>
|
|
||||||
<div class="ui icon message error" v-if="!isLoading && authorityNodeUpgradeInfo.count > 0 && teaIsPlus">
|
|
||||||
<i class="icon warning circle"></i>
|
|
||||||
<a href="/settings/authority/nodes">升级提醒:有 {{authorityNodeUpgradeInfo.count}} 个商业版认证节点需要升级到 v{{authorityNodeUpgradeInfo.version}} 版本</a><a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 统计图表 -->
|
|
||||||
<div class="ui four columns grid" v-if="!isLoading">
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>集群<link-icon href="/clusters" v-if="dashboard.canGoNodes"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{dashboard.countNodeClusters}}</span>个</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>边缘节点<link-icon href="/clusters" v-if="dashboard.canGoNodes"></link-icon></h4>
|
|
||||||
<div class="value">
|
|
||||||
<span>{{dashboard.countNodes}}</span>个
|
|
||||||
<span style="font-size: 1em" v-if="dashboard.countOfflineNodes > 0">/ <a href="/clusters" v-if="dashboard.canGoNodes"><span class="red" style="font-size: 1em">{{dashboard.countOfflineNodes}}离线</span></a><span class="red" style="font-size: 1em" v-else>{{dashboard.countOfflineNodes}}离线</span></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>API节点<link-icon href="/api" v-if="dashboard.canGoSettings"></link-icon></h4>
|
|
||||||
<div class="value">
|
|
||||||
<span>{{dashboard.countAPINodes}}</span>个
|
|
||||||
<span style="font-size: 1em" v-if="dashboard.countOfflineAPINodes > 0">/ <a href="/api" v-if="dashboard.canGoSettings"><span class="red" style="font-size: 1em">{{dashboard.countOfflineAPINodes}}离线</span></a><span class="red" style="font-size: 1em" v-else>{{dashboard.countOfflineAPINodes}}离线</span></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>服务<link-icon href="/servers" v-if="dashboard.canGoServers"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{dashboard.countServers}}</span>个
|
|
||||||
<span style="font-size: 1em" v-if="dashboard.countAuditingServers > 0">/ <a href="/servers?auditingFlag=1" v-if="dashboard.canGoServers"><span class="red" style="font-size: 1em">{{dashboard.countAuditingServers}}审核</span></a><span class="red" style="font-size: 1em" v-else>{{dashboard.countAuditingServers}}审核</span></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>本周流量</h4>
|
|
||||||
<div class="value"><span>{{weekTraffic}}</span>{{weekTrafficUnit}}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>昨日流量</h4>
|
|
||||||
<div class="value"><span>{{yesterdayTraffic}}</span>{{yesterdayTrafficUnit}}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column no-border">
|
|
||||||
<h4>今日流量</h4>
|
|
||||||
<div class="value"><span>{{todayTraffic}}</span>{{todayTrafficUnit}}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 流量地图 -->
|
|
||||||
<div v-if="!isLoading">
|
|
||||||
<traffic-map-box :v-stats="topCountryStats"></traffic-map-box>
|
|
||||||
</div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 流量 -->
|
|
||||||
<div class="ui menu tabular" v-show="!isLoading">
|
|
||||||
<a href="" class="item" :class="{active: trafficTab == 'hourly'}" @click.prevent="selectTrafficTab('hourly')">24小时流量趋势</a>
|
|
||||||
<a href="" class="item" :class="{active: trafficTab == 'daily'}" @click.prevent="selectTrafficTab('daily')">15天流量趋势</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 按小时统计 -->
|
|
||||||
<div class="chart-box" id="hourly-traffic-chart-box" v-show="trafficTab == 'hourly'"></div>
|
|
||||||
|
|
||||||
<!-- 按日统计 -->
|
|
||||||
<div class="chart-box" id="daily-traffic-chart-box" v-show="trafficTab == 'daily'"></div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<div class="ui menu tabular" v-show="!isLoading">
|
|
||||||
<a href="" class="item" :class="{active: requestsTab == 'hourly'}" @click.prevent="selectRequestsTab('hourly')">24小时访问量趋势</a>
|
|
||||||
<a href="" class="item" :class="{active: requestsTab == 'daily'}" @click.prevent="selectRequestsTab('daily')">15天访问量趋势</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 按小时统计访问量 -->
|
|
||||||
<div class="chart-box" id="hourly-requests-chart" v-show="requestsTab == 'hourly'"></div>
|
|
||||||
|
|
||||||
<!-- 按日统计访问量 -->
|
|
||||||
<div class="chart-box" id="daily-requests-chart" v-show="requestsTab == 'daily'"></div>
|
|
||||||
|
|
||||||
<!-- 域名排行 -->
|
|
||||||
<h4 v-show="!isLoading">域名访问排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-domains-chart"></div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 节点排行 -->
|
|
||||||
<h4 v-show="!isLoading">节点访问排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-nodes-chart"></div>
|
|
||||||
|
|
||||||
<!-- 指标 -->
|
|
||||||
<div class="ui divider" v-if="metricCharts.length > 0"></div>
|
|
||||||
<metric-board>
|
|
||||||
<metric-chart v-for="chart in metricCharts"
|
|
||||||
:key="chart.id"
|
|
||||||
:v-chart="chart.chart"
|
|
||||||
:v-stats="chart.stats"
|
|
||||||
:v-item="chart.item">
|
|
||||||
</metric-chart>
|
|
||||||
</metric-board>
|
|
||||||
@@ -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 + "时<br/>总流量:" + teaweb.formatBytes(stats[index].bytes) + "<br/>缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "<br/>拦截比例:" + 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 + "<br/>总流量:" + teaweb.formatBytes(stats[index].bytes) + "<br/>缓存流量:" + teaweb.formatBytes(stats[index].cachedBytes) + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击流量:" + teaweb.formatBytes(stats[index].attackBytes) + "<br/>拦截比例:" + 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 + "时<br/>总请求数:" + stats[index].countRequests + "<br/>缓存请求数:" + stats[index].countCachedRequests + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击数:" + stats[index].countAttackRequests + "<br/>拦截比例:" + 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 + "<br/>总请求数:" + stats[index].countRequests + "<br/>缓存请求数:" + stats[index].countCachedRequests + "<br/>缓存命中率:" + cachedRatio + "%<br/>拦截攻击数:" + stats[index].countAttackRequests + "<br/>拦截比例:" + 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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
{$template "menu"}
|
|
||||||
{$template "/echarts"}
|
|
||||||
|
|
||||||
<div class="ui four columns grid">
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>用户总数<link-icon href="/users"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.totalUsers}}</span></div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>今日新增</h4>
|
|
||||||
<div class="value"><span>{{board.countTodayUsers}}</span></div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>本周新增</h4>
|
|
||||||
<div class="value"><span>{{board.countWeeklyUsers}}</span></div>
|
|
||||||
</div>
|
|
||||||
<div class="ui column no-border">
|
|
||||||
<h4>用户节点<link-icon href="/settings/userNodes"></link-icon></h4>
|
|
||||||
<div class="value"><span>{{board.countUserNodes}}</span>
|
|
||||||
<span v-if="board.countOfflineUserNodes > 0" style="font-size: 1em">
|
|
||||||
/ <a href="/settings/userNodes"><span class="red" style="font-size: 1em">{{board.countOfflineUserNodes}}离线</span></a>
|
|
||||||
</span>
|
|
||||||
<span v-else style="font-size: 1em">个</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4>用户增长趋势</h4>
|
|
||||||
<div class="chart-box" id="daily-stat-chart"></div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<h4>流量排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-traffic-chart"></div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 系统信息 -->
|
|
||||||
<div class="ui menu tabular">
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'cpu'}" @click.prevent="selectNodeStatusTab('cpu')">用户节点CPU</a>
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'memory'}" @click.prevent="selectNodeStatusTab('memory')">用户节点内存</a>
|
|
||||||
<a href="" class="item" :class="{active: nodeStatusTab == 'load'}" @click.prevent="selectNodeStatusTab('load')">用户节点负载</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="chart-box" id="cpu-chart" v-show="nodeStatusTab == 'cpu'"></div>
|
|
||||||
<div class="chart-box" id="memory-chart" v-show="nodeStatusTab == 'memory'"></div>
|
|
||||||
<div class="chart-box" id="load-chart" v-show="nodeStatusTab == 'load'"></div>
|
|
||||||
@@ -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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[index].countRequests) + "<br/>流量:" + teaweb.formatBytes(stats[index].bytes)
|
|
||||||
},
|
|
||||||
value: function (v) {
|
|
||||||
return v.bytes / axis.divider;
|
|
||||||
},
|
|
||||||
axis: axis
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
|
|
||||||
{$var "header"}
|
|
||||||
<!-- world map -->
|
|
||||||
<script type="text/javascript" src="/js/echarts/echarts.min.js"></script>
|
|
||||||
<script type="text/javascript" src="/js/world.js"></script>
|
|
||||||
<script type="text/javascript" src="/js/world-countries-map.js"></script>
|
|
||||||
{$end}
|
|
||||||
|
|
||||||
{$template "menu"}
|
|
||||||
|
|
||||||
<div class="ui four columns grid">
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>今日拦截</h4>
|
|
||||||
<div class="value"><span>{{board.countDailyBlocks}}</span>次</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>今日验证码验证</h4>
|
|
||||||
<div class="value"><span>{{board.countDailyCaptcha}}</span>次</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>今日记录</h4>
|
|
||||||
<div class="value"><span>{{board.countDailyLogs}}</span>次</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui column">
|
|
||||||
<h4>本周拦截</h4>
|
|
||||||
<div class="value"><span>{{board.countWeeklyBlocks}}</span>次</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 流量地图 -->
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
<div v-if="!isLoading">
|
|
||||||
<traffic-map-box :v-stats="topCountryStats" :v-is-attack="true"></traffic-map-box>
|
|
||||||
</div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 最近日志 -->
|
|
||||||
<div v-if="accessLogs.length > 0">
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
<h4 class="header">最新拦截记录 <a href="/servers/logs?hasWAF=1">更多 »</a></h4>
|
|
||||||
<table class="ui table selectable">
|
|
||||||
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
|
|
||||||
<td><http-access-log-box :v-access-log="accessLog"></http-access-log-box></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 按小时/天统计 -->
|
|
||||||
<div class="ui menu tabular">
|
|
||||||
<a href="" class="item" :class="{active: requestsTab == 'hourly'}" @click.prevent="selectRequestsTab('hourly')">24小时趋势</a>
|
|
||||||
<a href="" class="item" :class="{active: requestsTab == 'daily'}" @click.prevent="selectRequestsTab('daily')">15天趋势</a>
|
|
||||||
<div class="item right">
|
|
||||||
<span class="color-span" style="background: #F39494">拦截</span>
|
|
||||||
<span class="color-span" style="background: #FBD88A">验证码</span>
|
|
||||||
<span class="color-span" style="background: #879BD7">记录</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="chart-box" id="hourly-chart" v-show="requestsTab == 'hourly'"></div>
|
|
||||||
<div class="chart-box" id="daily-chart" v-show="requestsTab == 'daily'"></div>
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
|
|
||||||
<h4>拦截类型分布</h4>
|
|
||||||
<div class="chart-box" id="group-chart"></div>
|
|
||||||
|
|
||||||
<!-- 域名排行 -->
|
|
||||||
<h4 v-show="!isLoading">域名拦截排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-domains-chart"></div>
|
|
||||||
|
|
||||||
<div class="ui divider"></div>
|
|
||||||
|
|
||||||
<!-- 节点排行 -->
|
|
||||||
<h4 v-show="!isLoading">节点拦截排行 <span>(24小时)</span></h4>
|
|
||||||
<div class="chart-box" id="top-nodes-chart"></div>
|
|
||||||
@@ -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 + "时<br/>拦截: "
|
|
||||||
+ teaweb.formatNumber(that.hourlyStats[index].countBlocks) + "<br/>验证码: " + teaweb.formatNumber(that.hourlyStats[index].countCaptcha) + "<br/>记录: " + 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 + "<br/>拦截: "
|
|
||||||
+ teaweb.formatNumber(that.dailyStats[index].countBlocks) + "<br/>验证码: " + teaweb.formatNumber(that.dailyStats[index].countCaptcha) + "<br/>记录: " + 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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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 + "<br/>请求数:" + " " + teaweb.formatNumber(stats[args.dataIndex].countRequests) + "<br/>流量:" + 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
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -14,6 +14,15 @@
|
|||||||
<a :href="'/clusters/cluster/createNode?clusterId=' + dashboard.defaultClusterId">还没有在集群中添加节点,现在去添加?添加节点后才可部署网站服务。</a>
|
<a :href="'/clusters/cluster/createNode?clusterId=' + dashboard.defaultClusterId">还没有在集群中添加节点,现在去添加?添加节点后才可部署网站服务。</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 新版本更新提醒 -->
|
||||||
|
<div class="ui icon message error" v-if="!isLoading && newVersionCode.length > 0">
|
||||||
|
<i class="icon warning circle"></i>
|
||||||
|
升级提醒:有新版本管理系统可以更新:v{{currentVersionCode}} -> v{{newVersionCode}}
|
||||||
|
<a href="https://goedge.cn/docs/Releases/Index.md?nav=1" target="_blank">[去官网查看]</a> <a :href="newVersionDownloadURL" target="_blank">[直接下载]</a>
|
||||||
|
|
||||||
|
<a href="" title="关闭" @click.prevent="closeMessage"><i class="ui icon remove small"></i></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 升级提醒 -->
|
<!-- 升级提醒 -->
|
||||||
<div class="ui icon message error" v-if="!isLoading && nodeUpgradeInfo.count > 0">
|
<div class="ui icon message error" v-if="!isLoading && nodeUpgradeInfo.count > 0">
|
||||||
<i class="icon warning circle"></i>
|
<i class="icon warning circle"></i>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<span class="ui label tiny basic" v-for="group in firewallPolicy.groups" style="margin-bottom:0.5em" :class="{disabled:!group.isOn}">{{group.name}}</span>
|
<span class="ui label tiny basic" v-for="group in firewallPolicy.groups" style="margin-bottom:0.5em" :class="{disabled:!group.isOn}">{{group.name}}</span>
|
||||||
<div v-if="upgradeItems.length > 0">
|
<div v-if="upgradeItems.length > 0">
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
<a href=""><span class="red">升级提醒:官方提供了新的规则,是否要加入以下规则:<span class="ui label tiny basic" v-for="item in upgradeItems" style="margin-bottom: 0.2em">{{item}}</span></span></a> <a href="" @click.prevent="upgradeTemplate">[加入]</a>
|
<a href=""><span class="red">升级提醒:官方提供了新的规则,是否要加入以下规则:<span class="ui label tiny basic" v-for="item in upgradeItems" style="margin-bottom: 0.2em">{{item.name}}<span v-if="!item.isOn" class="small">(默认不启用)</span></span></span></a> <a href="" @click.prevent="upgradeTemplate">[加入]</a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
<td class="title">当前已安装版本</td>
|
<td class="title">当前已安装版本</td>
|
||||||
<td>v{{version}}</td>
|
<td>v{{version}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>自动检查</td>
|
||||||
|
<td>
|
||||||
|
<checkbox v-model="config.autoCheck" @input="changeAutoCheck"></checkbox>
|
||||||
|
<p class="comment">选中后系统将定时检查是否有新版本更新。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr v-if="isStarted">
|
<tr v-if="isStarted">
|
||||||
<td>最新版本</td>
|
<td>最新版本</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -21,4 +21,11 @@ Tea.context(function () {
|
|||||||
this.isChecking = false
|
this.isChecking = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.changeAutoCheck = function () {
|
||||||
|
this.$post(".update")
|
||||||
|
.params({
|
||||||
|
autoCheck: this.config.autoCheck ? 1 : 0
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user