mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-22 17:30:29 +08:00
优化代码
This commit is contained in:
@@ -11,7 +11,9 @@ import (
|
|||||||
var plusConfigFile = "plus.cache.json"
|
var plusConfigFile = "plus.cache.json"
|
||||||
|
|
||||||
type PlusConfig struct {
|
type PlusConfig struct {
|
||||||
IsPlus bool `json:"isPlus"`
|
IsPlus bool `json:"isPlus"`
|
||||||
|
Components []string `json:"components"`
|
||||||
|
DayTo string `json:"dayTo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadPlusConfig() *PlusConfig {
|
func ReadPlusConfig() *PlusConfig {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
//go:build community
|
||||||
|
// +build community
|
||||||
|
|
||||||
package teaconst
|
package teaconst
|
||||||
|
|
||||||
// IsPlus 是否为企业版
|
|
||||||
var IsPlus = false
|
var IsPlus = false
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
||||||
|
|
||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/actions"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ActivateAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActivateAction) Init() {
|
|
||||||
this.Nav("", "", "activate")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActivateAction) RunGet(params struct{}) {
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActivateAction) RunPost(params struct {
|
|
||||||
Key string
|
|
||||||
|
|
||||||
Must *actions.Must
|
|
||||||
CSRF *actionutils.CSRF
|
|
||||||
}) {
|
|
||||||
if len(params.Key) == 0 {
|
|
||||||
this.FailField("key", "请输入激活码")
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := this.RPC().AuthorityKeyRPC().ValidateAuthorityKey(this.AdminContext(), &pb.ValidateAuthorityKeyRequest{Key: params.Key})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.IsOk {
|
|
||||||
_, err := this.RPC().AuthorityKeyRPC().UpdateAuthorityKey(this.AdminContext(), &pb.UpdateAuthorityKeyRequest{
|
|
||||||
Value: params.Key,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Success()
|
|
||||||
} else {
|
|
||||||
this.FailField("key", "无法激活:"+resp.Error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
||||||
|
|
||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IndexAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) Init() {
|
|
||||||
this.Nav("", "", "index")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
|
||||||
keyResp, err := this.RPC().AuthorityKeyRPC().ReadAuthorityKey(this.AdminContext(), &pb.ReadAuthorityKeyRequest{})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var keyMap maps.Map = nil
|
|
||||||
teaconst.IsPlus = false
|
|
||||||
var key = keyResp.AuthorityKey
|
|
||||||
if key != nil {
|
|
||||||
if len(key.MacAddresses) == 0 {
|
|
||||||
key.MacAddresses = []string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive := len(key.DayTo) > 0 && key.DayTo >= timeutil.Format("Y-m-d")
|
|
||||||
if isActive {
|
|
||||||
teaconst.IsPlus = true
|
|
||||||
}
|
|
||||||
|
|
||||||
isExpiring := isActive && key.DayTo < timeutil.Format("Y-m-d", time.Now().AddDate(0, 0, 7))
|
|
||||||
|
|
||||||
keyMap = maps.Map{
|
|
||||||
"dayFrom": key.DayFrom,
|
|
||||||
"dayTo": key.DayTo,
|
|
||||||
"macAddresses": key.MacAddresses,
|
|
||||||
"hostname": key.Hostname,
|
|
||||||
"company": key.Company,
|
|
||||||
"nodes": key.Nodes,
|
|
||||||
"isExpired": !isActive,
|
|
||||||
"isExpiring": isExpiring,
|
|
||||||
"updatedTime": timeutil.FormatTime("Y-m-d H:i:s", keyResp.AuthorityKey.UpdatedAt),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Data["key"] = keyMap
|
|
||||||
|
|
||||||
// 检查是否有认证节点,如果没有认证节点,则自动生成一个
|
|
||||||
countResp, err := this.RPC().AuthorityNodeRPC().CountAllEnabledAuthorityNodes(this.AdminContext(), &pb.CountAllEnabledAuthorityNodesRequest{})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if countResp.Count == 0 {
|
|
||||||
_, err = this.RPC().AuthorityNodeRPC().CreateAuthorityNode(this.AdminContext(), &pb.CreateAuthorityNodeRequest{
|
|
||||||
Name: "默认节点",
|
|
||||||
Description: "系统自动生成的默认节点",
|
|
||||||
IsOn: true,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package server
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
|
||||||
"github.com/iwind/TeaGo"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
|
||||||
server.
|
|
||||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
|
||||||
Helper(settingutils.NewAdvancedHelper("authority")).
|
|
||||||
Prefix("/settings/authority").
|
|
||||||
Get("", new(IndexAction)).
|
|
||||||
GetPost("/activate", new(ActivateAction)).
|
|
||||||
EndAll()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package nodes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DeleteAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *DeleteAction) RunPost(params struct {
|
|
||||||
NodeId int64
|
|
||||||
}) {
|
|
||||||
// TODO 检查权限
|
|
||||||
|
|
||||||
_, err := this.RPC().AuthorityNodeRPC().DeleteAuthorityNode(this.AdminContext(), &pb.DeleteAuthorityNodeRequest{AuthorityNodeId: params.NodeId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建日志
|
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "删除认证节点 %d", params.NodeId)
|
|
||||||
|
|
||||||
this.Success()
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package nodes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/iwind/TeaGo/actions"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Helper struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHelper() *Helper {
|
|
||||||
return &Helper{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package nodes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/logs"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IndexAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) Init() {
|
|
||||||
this.Nav("", "node", "node")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct{}) {
|
|
||||||
countResp, err := this.RPC().AuthorityNodeRPC().CountAllEnabledAuthorityNodes(this.AdminContext(), &pb.CountAllEnabledAuthorityNodesRequest{})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
count := countResp.Count
|
|
||||||
page := this.NewPage(count)
|
|
||||||
this.Data["page"] = page.AsHTML()
|
|
||||||
|
|
||||||
nodeMaps := []maps.Map{}
|
|
||||||
if count > 0 {
|
|
||||||
nodesResp, err := this.RPC().AuthorityNodeRPC().ListEnabledAuthorityNodes(this.AdminContext(), &pb.ListEnabledAuthorityNodesRequest{
|
|
||||||
Offset: page.Offset,
|
|
||||||
Size: page.Size,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, node := range nodesResp.AuthorityNodes {
|
|
||||||
// 状态
|
|
||||||
status := &nodeconfigs.NodeStatus{}
|
|
||||||
if len(node.StatusJSON) > 0 {
|
|
||||||
err = json.Unmarshal(node.StatusJSON, &status)
|
|
||||||
if err != nil {
|
|
||||||
logs.Error(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
status.IsActive = status.IsActive && time.Now().Unix()-status.UpdatedAt <= 60 // N秒之内认为活跃
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeMaps = append(nodeMaps, maps.Map{
|
|
||||||
"id": node.Id,
|
|
||||||
"isOn": node.IsOn,
|
|
||||||
"name": node.Name,
|
|
||||||
"status": maps.Map{
|
|
||||||
"isActive": status.IsActive,
|
|
||||||
"updatedAt": status.UpdatedAt,
|
|
||||||
"hostname": status.Hostname,
|
|
||||||
"cpuUsage": status.CPUUsage,
|
|
||||||
"cpuUsageText": fmt.Sprintf("%.2f%%", status.CPUUsage*100),
|
|
||||||
"memUsage": status.MemoryUsage,
|
|
||||||
"memUsageText": fmt.Sprintf("%.2f%%", status.MemoryUsage*100),
|
|
||||||
"buildVersion": status.BuildVersion,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Data["nodes"] = nodeMaps
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package nodes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/authority/nodes/node"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
|
||||||
"github.com/iwind/TeaGo"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
|
||||||
server.
|
|
||||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
|
||||||
Helper(NewHelper()).
|
|
||||||
Helper(settingutils.NewAdvancedHelper("authority")).
|
|
||||||
Prefix("/settings/authority/nodes").
|
|
||||||
Get("", new(IndexAction)).
|
|
||||||
GetPost("/node/createPopup", new(node.CreatePopupAction)).
|
|
||||||
Post("/delete", new(DeleteAction)).
|
|
||||||
EndAll()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/actions"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CreatePopupAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CreatePopupAction) Init() {
|
|
||||||
this.Nav("", "node", "create")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CreatePopupAction) RunPost(params struct {
|
|
||||||
Name string
|
|
||||||
Description string
|
|
||||||
IsOn bool
|
|
||||||
|
|
||||||
Must *actions.Must
|
|
||||||
}) {
|
|
||||||
params.Must.
|
|
||||||
Field("name", params.Name).
|
|
||||||
Require("请输入认证节点名称")
|
|
||||||
|
|
||||||
createResp, err := this.RPC().AuthorityNodeRPC().CreateAuthorityNode(this.AdminContext(), &pb.CreateAuthorityNodeRequest{
|
|
||||||
Name: params.Name,
|
|
||||||
Description: params.Description,
|
|
||||||
IsOn: params.IsOn,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建日志
|
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "创建认证节点 %d", createResp.AuthorityNodeId)
|
|
||||||
|
|
||||||
this.Success()
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/iwind/TeaGo/actions"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Helper struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHelper() *Helper {
|
|
||||||
return &Helper{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Helper) BeforeAction(action *actions.ActionObject) (goNext bool) {
|
|
||||||
if action.Request.Method != http.MethodGet {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
)
|
|
||||||
|
|
||||||
type IndexAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) Init() {
|
|
||||||
this.Nav("", "", "index")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *IndexAction) RunGet(params struct {
|
|
||||||
NodeId int64
|
|
||||||
}) {
|
|
||||||
nodeResp, err := this.RPC().AuthorityNodeRPC().FindEnabledAuthorityNode(this.AdminContext(), &pb.FindEnabledAuthorityNodeRequest{AuthorityNodeId: params.NodeId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
node := nodeResp.AuthorityNode
|
|
||||||
if node == nil {
|
|
||||||
this.NotFound("authorityNode", params.NodeId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Data["node"] = maps.Map{
|
|
||||||
"id": node.Id,
|
|
||||||
"name": node.Name,
|
|
||||||
"description": node.Description,
|
|
||||||
"isOn": node.IsOn,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
|
||||||
"github.com/iwind/TeaGo"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
|
||||||
server.
|
|
||||||
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
|
|
||||||
Helper(settingutils.NewAdvancedHelper("authority")).
|
|
||||||
Prefix("/settings/authority/nodes/node").
|
|
||||||
|
|
||||||
// 节点相关
|
|
||||||
Helper(NewHelper()).
|
|
||||||
Get("", new(IndexAction)).
|
|
||||||
Get("/logs", new(LogsAction)).
|
|
||||||
GetPost("/update", new(UpdateAction)).
|
|
||||||
Get("/install", new(InstallAction)).
|
|
||||||
|
|
||||||
EndAll()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type InstallAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *InstallAction) Init() {
|
|
||||||
this.Nav("", "", "install")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *InstallAction) RunGet(params struct {
|
|
||||||
NodeId int64
|
|
||||||
}) {
|
|
||||||
// 认证节点信息
|
|
||||||
nodeResp, err := this.RPC().AuthorityNodeRPC().FindEnabledAuthorityNode(this.AdminContext(), &pb.FindEnabledAuthorityNodeRequest{AuthorityNodeId: params.NodeId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
node := nodeResp.AuthorityNode
|
|
||||||
if node == nil {
|
|
||||||
this.NotFound("authorityNode", params.NodeId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Data["node"] = maps.Map{
|
|
||||||
"id": node.Id,
|
|
||||||
"name": node.Name,
|
|
||||||
"uniqueId": node.UniqueId,
|
|
||||||
"secret": node.Secret,
|
|
||||||
}
|
|
||||||
|
|
||||||
// API节点列表
|
|
||||||
apiNodesResp, err := this.RPC().APINodeRPC().FindAllEnabledAPINodes(this.AdminContext(), &pb.FindAllEnabledAPINodesRequest{})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
apiNodes := apiNodesResp.ApiNodes
|
|
||||||
apiEndpoints := []string{}
|
|
||||||
for _, apiNode := range apiNodes {
|
|
||||||
if !apiNode.IsOn {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
apiEndpoints = append(apiEndpoints, apiNode.AccessAddrs...)
|
|
||||||
}
|
|
||||||
this.Data["apiEndpoints"] = "\"" + strings.Join(apiEndpoints, "\", \"") + "\""
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type LogsAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *LogsAction) Init() {
|
|
||||||
this.Nav("", "node", "log")
|
|
||||||
this.SecondMenu("nodes")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *LogsAction) RunGet(params struct {
|
|
||||||
NodeId int64
|
|
||||||
|
|
||||||
DayFrom string
|
|
||||||
DayTo string
|
|
||||||
Keyword string
|
|
||||||
Level string
|
|
||||||
}) {
|
|
||||||
this.Data["nodeId"] = params.NodeId
|
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
|
||||||
this.Data["dayTo"] = params.DayTo
|
|
||||||
this.Data["keyword"] = params.Keyword
|
|
||||||
this.Data["level"] = params.Level
|
|
||||||
|
|
||||||
authorityNodeResp, err := this.RPC().AuthorityNodeRPC().FindEnabledAuthorityNode(this.AdminContext(), &pb.FindEnabledAuthorityNodeRequest{AuthorityNodeId: params.NodeId})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
authorityNode := authorityNodeResp.AuthorityNode
|
|
||||||
if authorityNode == nil {
|
|
||||||
this.NotFound("authorityNode", params.NodeId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Data["node"] = maps.Map{
|
|
||||||
"id": authorityNode.Id,
|
|
||||||
"name": authorityNode.Name,
|
|
||||||
}
|
|
||||||
|
|
||||||
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
|
||||||
Role: nodeconfigs.NodeRoleAuthority,
|
|
||||||
NodeId: params.NodeId,
|
|
||||||
DayFrom: params.DayFrom,
|
|
||||||
DayTo: params.DayTo,
|
|
||||||
Keyword: params.Keyword,
|
|
||||||
Level: params.Level,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
count := countResp.Count
|
|
||||||
page := this.NewPage(count, 20)
|
|
||||||
|
|
||||||
logsResp, err := this.RPC().NodeLogRPC().ListNodeLogs(this.AdminContext(), &pb.ListNodeLogsRequest{
|
|
||||||
NodeId: params.NodeId,
|
|
||||||
Role: nodeconfigs.NodeRoleAuthority,
|
|
||||||
DayFrom: params.DayFrom,
|
|
||||||
DayTo: params.DayTo,
|
|
||||||
Keyword: params.Keyword,
|
|
||||||
Level: params.Level,
|
|
||||||
|
|
||||||
Offset: page.Offset,
|
|
||||||
Size: page.Size,
|
|
||||||
})
|
|
||||||
|
|
||||||
logs := []maps.Map{}
|
|
||||||
for _, log := range logsResp.NodeLogs {
|
|
||||||
logs = append(logs, maps.Map{
|
|
||||||
"tag": log.Tag,
|
|
||||||
"description": log.Description,
|
|
||||||
"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
|
|
||||||
"level": log.Level,
|
|
||||||
"isToday": timeutil.FormatTime("Y-m-d", log.CreatedAt) == timeutil.Format("Y-m-d"),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
this.Data["logs"] = logs
|
|
||||||
|
|
||||||
this.Data["page"] = page.AsHTML()
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
package node
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
||||||
"github.com/iwind/TeaGo/actions"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UpdateAction struct {
|
|
||||||
actionutils.ParentAction
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *UpdateAction) Init() {
|
|
||||||
this.Nav("", "", "update")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *UpdateAction) RunGet(params struct {
|
|
||||||
NodeId int64
|
|
||||||
}) {
|
|
||||||
nodeResp, err := this.RPC().AuthorityNodeRPC().FindEnabledAuthorityNode(this.AdminContext(), &pb.FindEnabledAuthorityNodeRequest{
|
|
||||||
AuthorityNodeId: params.NodeId,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
node := nodeResp.AuthorityNode
|
|
||||||
if node == nil {
|
|
||||||
this.WriteString("要操作的节点不存在")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Data["node"] = maps.Map{
|
|
||||||
"id": node.Id,
|
|
||||||
"name": node.Name,
|
|
||||||
"description": node.Description,
|
|
||||||
"isOn": node.IsOn,
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存基础设置
|
|
||||||
func (this *UpdateAction) RunPost(params struct {
|
|
||||||
NodeId int64
|
|
||||||
Name string
|
|
||||||
Description string
|
|
||||||
IsOn bool
|
|
||||||
|
|
||||||
Must *actions.Must
|
|
||||||
}) {
|
|
||||||
params.Must.
|
|
||||||
Field("name", params.Name).
|
|
||||||
Require("请输入认证节点名称")
|
|
||||||
|
|
||||||
_, err := this.RPC().AuthorityNodeRPC().UpdateAuthorityNode(this.AdminContext(), &pb.UpdateAuthorityNodeRequest{
|
|
||||||
AuthorityNodeId: params.NodeId,
|
|
||||||
Name: params.Name,
|
|
||||||
Description: params.Description,
|
|
||||||
IsOn: params.IsOn,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
this.ErrorPage(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建日志
|
|
||||||
defer this.CreateLog(oplogs.LevelInfo, "修改认证节点 %d", params.NodeId)
|
|
||||||
|
|
||||||
this.Success()
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
//go:build community
|
||||||
|
// +build community
|
||||||
|
|
||||||
package settingutils
|
package settingutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
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/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
)
|
)
|
||||||
@@ -33,17 +35,8 @@ func (this *AdvancedHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNex
|
|||||||
if configloaders.AllowModule(adminId, configloaders.AdminModuleCodeSetting) {
|
if configloaders.AllowModule(adminId, configloaders.AdminModuleCodeSetting) {
|
||||||
tabbar.Add("数据库", "", "/settings/database", "", this.tab == "database")
|
tabbar.Add("数据库", "", "/settings/database", "", this.tab == "database")
|
||||||
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
||||||
if teaconst.IsPlus {
|
|
||||||
tabbar.Add("用户节点", "", "/settings/userNodes", "", this.tab == "userNodes")
|
|
||||||
}
|
|
||||||
tabbar.Add("日志数据库", "", "/db", "", this.tab == "dbNodes")
|
tabbar.Add("日志数据库", "", "/db", "", this.tab == "dbNodes")
|
||||||
if teaconst.IsPlus {
|
|
||||||
tabbar.Add("监控节点", "", "/settings/monitorNodes", "", this.tab == "monitorNodes")
|
|
||||||
}
|
|
||||||
tabbar.Add("迁移", "", "/settings/transfer", "", this.tab == "transfer")
|
tabbar.Add("迁移", "", "/settings/transfer", "", this.tab == "transfer")
|
||||||
if teaconst.BuildPlus {
|
|
||||||
tabbar.Add("商业版认证", "", "/settings/authority", "", this.tab == "authority")
|
|
||||||
}
|
|
||||||
|
|
||||||
//tabbar.Add("备份", "", "/settings/backup", "", this.tab == "backup")
|
//tabbar.Add("备份", "", "/settings/backup", "", this.tab == "backup")
|
||||||
}
|
}
|
||||||
|
|||||||
147
internal/web/helpers/menu.go
Normal file
147
internal/web/helpers/menu.go
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
//go:build community
|
||||||
|
// +build community
|
||||||
|
|
||||||
|
package helpers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
|
func FindAllMenuMaps(nodeLogsType string, countUnreadNodeLogs int64) []maps.Map {
|
||||||
|
return []maps.Map{
|
||||||
|
{
|
||||||
|
"code": "dashboard",
|
||||||
|
"module": configloaders.AdminModuleCodeDashboard,
|
||||||
|
"name": "数据看板",
|
||||||
|
"icon": "dashboard",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "servers",
|
||||||
|
"module": configloaders.AdminModuleCodeServer,
|
||||||
|
"name": "网站服务",
|
||||||
|
"subtitle": "服务列表",
|
||||||
|
"icon": "clone outsize",
|
||||||
|
"subItems": []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "服务分组",
|
||||||
|
"url": "/servers/groups",
|
||||||
|
"code": "group",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "证书管理",
|
||||||
|
"url": "/servers/certs",
|
||||||
|
"code": "cert",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "访问日志",
|
||||||
|
"url": "/servers/logs",
|
||||||
|
"code": "log",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "缓存策略",
|
||||||
|
"url": "/servers/components/cache",
|
||||||
|
"code": "cache",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "WAF策略",
|
||||||
|
"url": "/servers/components/waf",
|
||||||
|
"code": "waf",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "IP名单",
|
||||||
|
"url": "/servers/iplists",
|
||||||
|
"code": "iplist",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "统计指标",
|
||||||
|
"url": "/servers/metrics",
|
||||||
|
"code": "metric",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "通用设置",
|
||||||
|
"url": "/servers/components",
|
||||||
|
"code": "global",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "clusters",
|
||||||
|
"module": configloaders.AdminModuleCodeNode,
|
||||||
|
"name": "边缘节点",
|
||||||
|
"subtitle": "集群列表",
|
||||||
|
"icon": "cloud",
|
||||||
|
"subItems": []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "运行日志",
|
||||||
|
"url": "/clusters/logs?type=" + nodeLogsType,
|
||||||
|
"code": "log",
|
||||||
|
"badge": countUnreadNodeLogs,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SSH认证",
|
||||||
|
"url": "/clusters/grants",
|
||||||
|
"code": "grant",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "区域设置",
|
||||||
|
"url": "/clusters/regions",
|
||||||
|
"code": "region",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "dns",
|
||||||
|
"module": configloaders.AdminModuleCodeDNS,
|
||||||
|
"name": "域名解析",
|
||||||
|
"subtitle": "集群列表",
|
||||||
|
"icon": "globe",
|
||||||
|
"subItems": []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "问题修复",
|
||||||
|
"url": "/dns/issues",
|
||||||
|
"code": "issue",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DNS服务商",
|
||||||
|
"url": "/dns/providers",
|
||||||
|
"code": "provider",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "users",
|
||||||
|
"module": configloaders.AdminModuleCodeUser,
|
||||||
|
"name": "平台用户",
|
||||||
|
"icon": "users",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "admins",
|
||||||
|
"module": configloaders.AdminModuleCodeAdmin,
|
||||||
|
"name": "系统用户",
|
||||||
|
"subtitle": "用户列表",
|
||||||
|
"icon": "user secret",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "log",
|
||||||
|
"module": configloaders.AdminModuleCodeLog,
|
||||||
|
"name": "日志审计",
|
||||||
|
"icon": "history",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "settings",
|
||||||
|
"module": configloaders.AdminModuleCodeSetting,
|
||||||
|
"name": "系统设置",
|
||||||
|
"subtitle": "基本设置",
|
||||||
|
"icon": "setting",
|
||||||
|
"subItems": []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "高级设置",
|
||||||
|
"url": "/settings/advanced",
|
||||||
|
"code": "advanced",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -200,255 +200,8 @@ func (this *userMustAuth) modules(actionPtr actions.ActionWrapper, adminId int64
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allMaps := []maps.Map{
|
|
||||||
{
|
|
||||||
"code": "dashboard",
|
|
||||||
"module": configloaders.AdminModuleCodeDashboard,
|
|
||||||
"name": "数据看板",
|
|
||||||
"icon": "dashboard",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "servers",
|
|
||||||
"module": configloaders.AdminModuleCodeServer,
|
|
||||||
"name": "网站服务",
|
|
||||||
"subtitle": "服务列表",
|
|
||||||
"icon": "clone outsize",
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "服务分组",
|
|
||||||
"url": "/servers/groups",
|
|
||||||
"code": "group",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "证书管理",
|
|
||||||
"url": "/servers/certs",
|
|
||||||
"code": "cert",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "访问日志",
|
|
||||||
"url": "/servers/logs",
|
|
||||||
"code": "log",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "缓存策略",
|
|
||||||
"url": "/servers/components/cache",
|
|
||||||
"code": "cache",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "WAF策略",
|
|
||||||
"url": "/servers/components/waf",
|
|
||||||
"code": "waf",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "日志策略",
|
|
||||||
"url": "/servers/accesslogs",
|
|
||||||
"code": "accesslog",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "IP名单",
|
|
||||||
"url": "/servers/iplists",
|
|
||||||
"code": "iplist",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "统计指标",
|
|
||||||
"url": "/servers/metrics",
|
|
||||||
"code": "metric",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "通用设置",
|
|
||||||
"url": "/servers/components",
|
|
||||||
"code": "global",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "clusters",
|
|
||||||
"module": configloaders.AdminModuleCodeNode,
|
|
||||||
"name": "边缘节点",
|
|
||||||
"subtitle": "集群列表",
|
|
||||||
"icon": "cloud",
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "运行日志",
|
|
||||||
"url": "/clusters/logs?type=" + nodeLogsType,
|
|
||||||
"code": "log",
|
|
||||||
"badge": countUnreadNodeLogs,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "IP地址",
|
|
||||||
"url": "/clusters/ip-addrs",
|
|
||||||
"code": "ipAddr",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "区域监控",
|
|
||||||
"url": "/clusters/monitors",
|
|
||||||
"code": "monitor",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SSH认证",
|
|
||||||
"url": "/clusters/grants",
|
|
||||||
"code": "grant",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "区域设置",
|
|
||||||
"url": "/clusters/regions",
|
|
||||||
"code": "region",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "dns",
|
|
||||||
"module": configloaders.AdminModuleCodeDNS,
|
|
||||||
"name": "域名解析",
|
|
||||||
"subtitle": "集群列表",
|
|
||||||
"icon": "globe",
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "问题修复",
|
|
||||||
"url": "/dns/issues",
|
|
||||||
"code": "issue",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "DNS服务商",
|
|
||||||
"url": "/dns/providers",
|
|
||||||
"code": "provider",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "ns",
|
|
||||||
"module": configloaders.AdminModuleCodeNS,
|
|
||||||
"name": "智能DNS",
|
|
||||||
"icon": "cubes",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "域名管理",
|
|
||||||
"url": "/ns/domains",
|
|
||||||
"code": "domain",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "集群管理",
|
|
||||||
"url": "/ns/clusters",
|
|
||||||
"code": "cluster",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "线路管理",
|
|
||||||
"url": "/ns/routes",
|
|
||||||
"code": "route",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "访问日志",
|
|
||||||
"url": "/ns/clusters/accessLogs",
|
|
||||||
"code": "accessLog",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "运行日志",
|
|
||||||
"url": "/ns/clusters/logs",
|
|
||||||
"code": "log",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "全局配置",
|
|
||||||
"url": "/ns/settings",
|
|
||||||
"code": "setting",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "解析测试",
|
|
||||||
"url": "/ns/test",
|
|
||||||
"code": "test",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "users",
|
|
||||||
"module": configloaders.AdminModuleCodeUser,
|
|
||||||
"name": "平台用户",
|
|
||||||
"icon": "users",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "finance",
|
|
||||||
"module": configloaders.AdminModuleCodeFinance,
|
|
||||||
"name": "财务管理",
|
|
||||||
"icon": "yen sign",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "用户账户",
|
|
||||||
"url": "/finance/accounts",
|
|
||||||
"code": "accounts",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "收支明细",
|
|
||||||
"url": "/finance/logs",
|
|
||||||
"code": "logs",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "统计报表",
|
|
||||||
"url": "/finance/income",
|
|
||||||
"code": "income",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "plans",
|
|
||||||
"module": configloaders.AdminModuleCodePlan,
|
|
||||||
"name": "套餐管理",
|
|
||||||
"icon": "puzzle piece",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "已购套餐",
|
|
||||||
"url": "/plans/userPlans",
|
|
||||||
"code": "userPlans",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "admins",
|
|
||||||
"module": configloaders.AdminModuleCodeAdmin,
|
|
||||||
"name": "系统用户",
|
|
||||||
"subtitle": "用户列表",
|
|
||||||
"icon": "user secret",
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "通知媒介",
|
|
||||||
"url": "/admins/recipients",
|
|
||||||
"code": "recipients",
|
|
||||||
"isOn": teaconst.IsPlus,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "log",
|
|
||||||
"module": configloaders.AdminModuleCodeLog,
|
|
||||||
"name": "日志审计",
|
|
||||||
"icon": "history",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"code": "settings",
|
|
||||||
"module": configloaders.AdminModuleCodeSetting,
|
|
||||||
"name": "系统设置",
|
|
||||||
"subtitle": "基本设置",
|
|
||||||
"icon": "setting",
|
|
||||||
"subItems": []maps.Map{
|
|
||||||
{
|
|
||||||
"name": "高级设置",
|
|
||||||
"url": "/settings/advanced",
|
|
||||||
"code": "advanced",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
result := []maps.Map{}
|
result := []maps.Map{}
|
||||||
for _, m := range allMaps {
|
for _, m := range FindAllMenuMaps(nodeLogsType, countUnreadNodeLogs) {
|
||||||
if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
|
if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,9 +108,6 @@ import (
|
|||||||
|
|
||||||
// 设置相关
|
// 设置相关
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/authority"
|
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/authority/nodes"
|
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/authority/nodes/node"
|
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/backup"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/backup"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/database"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/database"
|
||||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library"
|
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library"
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
</div>
|
</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">
|
<div class="ui icon message warning" v-if="!isLoading && dashboard.defaultClusterId > 0 && dashboard.countNodes == 0">
|
||||||
<i class="icon warning circle"></i>
|
<i class="icon warning circle"></i>
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
{$layout}
|
|
||||||
{$template "menu"}
|
|
||||||
|
|
||||||
<warning-message v-if="key == null">激活之后,可以使用商业版功能,当前你还没有激活,<a href="http://edge.teaos.cn/docs/Plus/Authority/Index.md" target="_blank">[在这里看激活方法]</a>。</warning-message>
|
|
||||||
|
|
||||||
<div v-if="key != null">
|
|
||||||
<div class="margin"></div>
|
|
||||||
|
|
||||||
<div class="ui message green icon" v-if="!key.isExpired">
|
|
||||||
<i class="icon gem outline small yellow"></i>
|
|
||||||
<div class="content">
|
|
||||||
恭喜您已经成为尊贵的商业版用户。
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="margin"></div>
|
|
||||||
<table class="ui table definition selectable">
|
|
||||||
<tr>
|
|
||||||
<td class="title">状态</td>
|
|
||||||
<td>
|
|
||||||
<span class="red" v-if="key.isExpiring">即将过期</span>
|
|
||||||
<span class="red" v-else-if="key.isExpired">已过期</span>
|
|
||||||
<span class="green" v-else>已认证</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="key.nodes > 0">
|
|
||||||
<td>节点数限制</td>
|
|
||||||
<td>{{key.nodes}}个节点</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>公司/组织名</td>
|
|
||||||
<td>{{key.company}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="title">开始日期</td>
|
|
||||||
<td>{{key.dayFrom}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="title">结束日期</td>
|
|
||||||
<td>{{key.dayTo}}
|
|
||||||
<div v-if="key.isExpiring" style="margin-top: 0.5em">
|
|
||||||
<span class="red">即将过期</span>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="key.isExpired" style="margin-top: 0.5em">
|
|
||||||
<span class="red">已过期,请尽快更新认证信息。</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>主机名</td>
|
|
||||||
<td>{{key.hostname}}
|
|
||||||
<p class="comment">认证服务所在服务器主机名。</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>主机MAC地址</td>
|
|
||||||
<td>
|
|
||||||
<span v-for="address in key.macAddresses" class="ui label basic small">{{address}}</span>
|
|
||||||
<p class="comment">认证服务所在服务器的MAC地址。</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<p class="comment">数据更新于{{key.updatedTime}}。</p>
|
|
||||||
</div>
|
|
||||||
Reference in New Issue
Block a user