实现HTTP部分功能

This commit is contained in:
GoEdgeLab
2020-09-26 08:07:18 +08:00
parent 72865127b7
commit 86229e5a6f
32 changed files with 280 additions and 147 deletions

View File

@@ -4,7 +4,7 @@ env: prod
# http # http
http: http:
"on": true "on": true
listen: [ "0.0.0.0:8001" ] listen: [ "0.0.0.0:7788" ]
# https # https
https: https:

2
go.mod
View File

@@ -9,7 +9,7 @@ require (
github.com/go-redis/redis v6.15.8+incompatible // indirect github.com/go-redis/redis v6.15.8+incompatible // indirect
github.com/go-yaml/yaml v2.1.0+incompatible github.com/go-yaml/yaml v2.1.0+incompatible
github.com/golang/protobuf v1.4.2 // indirect github.com/golang/protobuf v1.4.2 // indirect
github.com/iwind/TeaGo v0.0.0-20200910072805-729cffe36729 github.com/iwind/TeaGo v0.0.0-20200924024009-d088df3778a6
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect

4
go.sum
View File

@@ -59,6 +59,10 @@ github.com/iwind/TeaGo v0.0.0-20200909062051-96811444bb22 h1:bCv4Emo49CZyZFbnq9l
github.com/iwind/TeaGo v0.0.0-20200909062051-96811444bb22/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc= github.com/iwind/TeaGo v0.0.0-20200909062051-96811444bb22/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/iwind/TeaGo v0.0.0-20200910072805-729cffe36729 h1:/v0WhSFVeNay/dA5zU9iCBXlgVDfxnztuanlauXE0gM= github.com/iwind/TeaGo v0.0.0-20200910072805-729cffe36729 h1:/v0WhSFVeNay/dA5zU9iCBXlgVDfxnztuanlauXE0gM=
github.com/iwind/TeaGo v0.0.0-20200910072805-729cffe36729/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc= github.com/iwind/TeaGo v0.0.0-20200910072805-729cffe36729/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/iwind/TeaGo v0.0.0-20200923021120-f5d76441fe9e h1:/xn7wUvlwaoA5IkdBUctv2OQbJSZ0/Dw8qRJmn55sJk=
github.com/iwind/TeaGo v0.0.0-20200923021120-f5d76441fe9e/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/iwind/TeaGo v0.0.0-20200924024009-d088df3778a6 h1:7OZC/Qy7Z/hK9vG6YQOwHNOUPunSImYYJMiIfvuDQZ0=
github.com/iwind/TeaGo v0.0.0-20200924024009-d088df3778a6/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=

View File

@@ -2,6 +2,9 @@ package nodes
// 节点状态 // 节点状态
type NodeStatus struct { type NodeStatus struct {
BuildVersion string `json:"buildVersion"` // 编译版本
ConfigVersion int64 `json:"configVersion"` // 节点配置版本
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
HostIP string `json:"hostIP"` HostIP string `json:"hostIP"`
CPUUsage float64 `json:"cpuUsage"` CPUUsage float64 `json:"cpuUsage"`

View File

@@ -4,8 +4,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/configs/nodes" "github.com/TeaOSLab/EdgeAdmin/internal/configs/nodes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"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/iwind/TeaGo/logs" "github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types" "github.com/iwind/TeaGo/types"
@@ -24,12 +24,15 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct { func (this *IndexAction) RunGet(params struct {
ClusterId int64 ClusterId int64
InstalledState int InstalledState int
ActiveState int
}) { }) {
this.Data["installState"] = params.InstalledState this.Data["installState"] = params.InstalledState
this.Data["activeState"] = params.ActiveState
countResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{ countResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{
ClusterId: params.ClusterId, ClusterId: params.ClusterId,
InstallState: types.Int32(params.InstalledState), InstallState: types.Int32(params.InstalledState),
ActiveState: types.Int32(params.ActiveState),
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -44,10 +47,12 @@ func (this *IndexAction) RunGet(params struct {
Size: page.Size, Size: page.Size,
ClusterId: params.ClusterId, ClusterId: params.ClusterId,
InstallState: types.Int32(params.InstalledState), InstallState: types.Int32(params.InstalledState),
ActiveState: types.Int32(params.ActiveState),
}) })
nodeMaps := []maps.Map{} nodeMaps := []maps.Map{}
for _, node := range nodesResp.Nodes { for _, node := range nodesResp.Nodes {
// 状态 // 状态
isSynced := false
status := &nodes.NodeStatus{} status := &nodes.NodeStatus{}
if len(node.Status) > 0 && node.Status != "null" { if len(node.Status) > 0 && node.Status != "null" {
err = json.Unmarshal([]byte(node.Status), &status) err = json.Unmarshal([]byte(node.Status), &status)
@@ -55,7 +60,8 @@ func (this *IndexAction) RunGet(params struct {
logs.Error(err) logs.Error(err)
continue continue
} }
status.IsActive = time.Now().Unix()-status.UpdatedAt < 120 // 2分钟之内认为活跃 status.IsActive = time.Now().Unix()-status.UpdatedAt <= 60 // N秒之内认为活跃
isSynced = status.ConfigVersion == node.Version
} }
// IP // IP
@@ -96,6 +102,7 @@ func (this *IndexAction) RunGet(params struct {
"id": node.Cluster.Id, "id": node.Cluster.Id,
"name": node.Cluster.Name, "name": node.Cluster.Name,
}, },
"isSynced": isSynced,
"ipAddresses": ipAddresses, "ipAddresses": ipAddresses,
}) })
} }

View File

@@ -1,9 +1,11 @@
package clusters package clusters
import ( import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
) )
type IndexAction struct { type IndexAction struct {
@@ -35,19 +37,30 @@ func (this *IndexAction) RunGet(params struct{}) {
return return
} }
for _, cluster := range clustersResp.Clusters { for _, cluster := range clustersResp.Clusters {
// 节点数量 // 全部节点数量
countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{ClusterId: cluster.Id}) countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{ClusterId: cluster.Id})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
// 在线节点
countActiveNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{
ClusterId: cluster.Id,
ActiveState: types.Int32(configutils.BoolStateYes),
})
if err != nil {
this.ErrorPage(err)
return
}
clusterMaps = append(clusterMaps, maps.Map{ clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id, "id": cluster.Id,
"name": cluster.Name, "name": cluster.Name,
"installDir": cluster.InstallDir, "installDir": cluster.InstallDir,
"hasGrant": cluster.GrantId > 0, "hasGrant": cluster.GrantId > 0,
"countNodes": countNodesResp.Count, "countAllNodes": countNodesResp.Count,
"countActiveNodes": countActiveNodesResp.Count,
}) })
} }
} }

View File

@@ -1,11 +1,13 @@
package common package common
import ( import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"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/iwind/TeaGo/maps" "github.com/iwind/TeaGo/maps"
"time"
) )
// 检查变更的集群列表
type ChangedClustersAction struct { type ChangedClustersAction struct {
actionutils.ParentAction actionutils.ParentAction
} }
@@ -14,7 +16,24 @@ func (this *ChangedClustersAction) Init() {
this.Nav("", "", "") this.Nav("", "", "")
} }
func (this *ChangedClustersAction) RunGet(params struct{}) { func (this *ChangedClustersAction) RunGet(params struct {
IsNotifying bool
}) {
timeout := time.NewTimer(55 * time.Second) // 比客户端提前结束,避免在客户端产生一个请求错误
this.Data["clusters"] = []interface{}{}
Loop:
for {
select {
case <-this.Request.Context().Done():
break Loop
case <-timeout.C:
break Loop
default:
// 继续
}
resp, err := this.RPC().NodeClusterRPC().FindAllChangedNodeClusters(this.AdminContext(), &pb.FindAllChangedNodeClustersRequest{}) resp, err := this.RPC().NodeClusterRPC().FindAllChangedNodeClusters(this.AdminContext(), &pb.FindAllChangedNodeClustersRequest{})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -29,7 +48,18 @@ func (this *ChangedClustersAction) RunGet(params struct{}) {
}) })
} }
// 从提醒到提醒消失
if len(result) == 0 && params.IsNotifying {
break
}
this.Data["clusters"] = result this.Data["clusters"] = result
if len(result) > 0 {
break
}
time.Sleep(1 * time.Second)
}
this.Success() this.Success()
} }

View File

@@ -1,10 +1,11 @@
package common package common
import ( import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
) )
// 同步集群
type SyncClustersAction struct { type SyncClustersAction struct {
actionutils.ParentAction actionutils.ParentAction
} }

View File

@@ -3,8 +3,8 @@ package charset
import ( import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
) )

View File

@@ -42,7 +42,7 @@ func (this *CreateDeletePopupAction) RunPost(params struct {
return return
} }
deleteHeaders := policyConfig.DeletedHeaders deleteHeaders := policyConfig.DeleteHeaders
deleteHeaders = append(deleteHeaders, params.Name) deleteHeaders = append(deleteHeaders, params.Name)
_, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicyDeletingHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicyDeletingHeadersRequest{ _, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicyDeletingHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicyDeletingHeadersRequest{
HeaderPolicyId: params.HeaderPolicyId, HeaderPolicyId: params.HeaderPolicyId,

View File

@@ -60,14 +60,12 @@ func (this *CreateSetPopupAction) RunPost(params struct {
headerId := createHeaderResp.HeaderId headerId := createHeaderResp.HeaderId
// 保存 // 保存
policyConfig.SetHeaders = append(policyConfig.SetHeaders, &shared.HTTPHeaderConfig{ refs := policyConfig.SetHeaderRefs
Id: headerId, refs = append(refs, &shared.HTTPHeaderRef{
IsOn: true, IsOn: true,
Name: params.Name, HeaderId: headerId,
Value: params.Value,
Status: nil,
}) })
setHeadersJSON, err := json.Marshal(policyConfig.SetHeaders) refsJSON, err := json.Marshal(refs)
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
@@ -75,7 +73,7 @@ func (this *CreateSetPopupAction) RunPost(params struct {
_, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicySettingHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicySettingHeadersRequest{ _, err = this.RPC().HTTPHeaderPolicyRPC().UpdateHTTPHeaderPolicySettingHeaders(this.AdminContext(), &pb.UpdateHTTPHeaderPolicySettingHeadersRequest{
HeaderPolicyId: params.HeaderPolicyId, HeaderPolicyId: params.HeaderPolicyId,
HeadersJSON: setHeadersJSON, HeadersJSON: refsJSON,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)

View File

@@ -33,9 +33,9 @@ func (this *DeleteAction) RunPost(params struct {
switch params.Type { switch params.Type {
case "addHeader": case "addHeader":
result := []*shared.HTTPHeaderConfig{} result := []*shared.HTTPHeaderRef{}
for _, h := range policyConfig.AddHeaders { for _, h := range policyConfig.AddHeaderRefs {
if h.Id != params.HeaderId { if h.HeaderId != params.HeaderId {
result = append(result, h) result = append(result, h)
} }
} }
@@ -53,9 +53,9 @@ func (this *DeleteAction) RunPost(params struct {
return return
} }
case "setHeader": case "setHeader":
result := []*shared.HTTPHeaderConfig{} result := []*shared.HTTPHeaderRef{}
for _, h := range policyConfig.SetHeaders { for _, h := range policyConfig.SetHeaderRefs {
if h.Id != params.HeaderId { if h.HeaderId != params.HeaderId {
result = append(result, h) result = append(result, h)
} }
} }
@@ -73,9 +73,9 @@ func (this *DeleteAction) RunPost(params struct {
return return
} }
case "replace": case "replace":
result := []*shared.HTTPHeaderConfig{} result := []*shared.HTTPHeaderRef{}
for _, h := range policyConfig.ReplaceHeaders { for _, h := range policyConfig.ReplaceHeaderRefs {
if h.Id != params.HeaderId { if h.HeaderId != params.HeaderId {
result = append(result, h) result = append(result, h)
} }
} }
@@ -93,9 +93,9 @@ func (this *DeleteAction) RunPost(params struct {
return return
} }
case "addTrailer": case "addTrailer":
result := []*shared.HTTPHeaderConfig{} result := []*shared.HTTPHeaderRef{}
for _, h := range policyConfig.AddTrailers { for _, h := range policyConfig.AddTrailerRefs {
if h.Id != params.HeaderId { if h.HeaderId != params.HeaderId {
result = append(result, h) result = append(result, h)
} }
} }

View File

@@ -29,7 +29,7 @@ func (this *DeleteDeletingHeaderAction) RunPost(params struct {
} }
headerNames := []string{} headerNames := []string{}
for _, h := range policyConfig.DeletedHeaders { for _, h := range policyConfig.DeleteHeaders {
if h == params.HeaderName { if h == params.HeaderName {
continue continue
} }

View File

@@ -3,8 +3,8 @@ package charset
import ( import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/configutils"
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
) )

View File

@@ -78,7 +78,7 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) {
// TABBAR // TABBAR
selectedTabbar, _ := action.Data["mainTab"] selectedTabbar, _ := action.Data["mainTab"]
tabbar := actionutils.NewTabbar() tabbar := actionutils.NewTabbar()
tabbar.Add("当前服务:"+serverConfig.Name, "", "/servers", "left long alternate arrow", false) tabbar.Add("当前服务:"+server.Name, "", "/servers", "left long alternate arrow", false)
//tabbar.Add("看板", "", "/servers/server/board?serverId="+serverIdString, "dashboard", selectedTabbar == "board") //tabbar.Add("看板", "", "/servers/server/board?serverId="+serverIdString, "dashboard", selectedTabbar == "board")
tabbar.Add("日志", "", "/servers/server/log?serverId="+serverIdString, "history", selectedTabbar == "log") tabbar.Add("日志", "", "/servers/server/log?serverId="+serverIdString, "history", selectedTabbar == "log")
//tabbar.Add("统计", "", "/servers/server/stat?serverId="+serverIdString, "chart area", selectedTabbar == "stat") //tabbar.Add("统计", "", "/servers/server/stat?serverId="+serverIdString, "chart area", selectedTabbar == "stat")

View File

@@ -0,0 +1,14 @@
Vue.component("more-options-angle", {
data: function () {
return {
isVisible: false
}
},
methods: {
show: function () {
this.isVisible = !this.isVisible
this.$emit("change", this.isVisible)
}
},
template: `<a href="" @click.prevent="show()"><span v-if="!isVisible">更多选项</span><span v-if="isVisible">收起选项</span><i class="icon angle" :class="{down:!isVisible, up:isVisible}"></i></a>`
})

View File

@@ -1,11 +1,12 @@
Vue.component("http-pages-and-shutdown-box", { Vue.component("http-pages-and-shutdown-box", {
props: ["v-pages", "v-shutdown-config"], props: ["v-pages", "v-shutdown-config", "v-is-location"],
data: function () { data: function () {
let pages = [] let pages = []
if (this.vPages != null) { if (this.vPages != null) {
pages = this.vPages pages = this.vPages
} }
let shutdownConfig = { let shutdownConfig = {
isPrior: false,
isOn: false, isOn: false,
url: "", url: "",
status: 0 status: 0
@@ -84,25 +85,33 @@ Vue.component("http-pages-and-shutdown-box", {
<td>临时关闭页面</td> <td>临时关闭页面</td>
<td> <td>
<div> <div>
<table class="ui table selectable definition">
<prior-checkbox :v-config="shutdownConfig" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || shutdownConfig.isPrior">
<tr>
<td class="title">是否开启</td>
<td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" value="1" v-model="shutdownConfig.isOn" /> <input type="checkbox" value="1" v-model="shutdownConfig.isOn" />
<label></label> <label></label>
</div> </div>
<div v-show="shutdownConfig.isOn"> </td>
<table class="ui table selectable definition"> </tr>
</tbody>
<tbody v-show="(!vIsLocation || shutdownConfig.isPrior) && shutdownConfig.isOn">
<tr> <tr>
<td class="title">页面URL</td> <td class="title">页面URL</td>
<td> <td>
<input type="text" v-model="shutdownConfig.url" placeholder="页面文件路径或一个完整URL"/> <input type="text" v-model="shutdownConfig.url" placeholder="页面文件路径或一个完整URL"/>
<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html或者一个完整的URL。</p> <p class="comment">页面文件是相对于节点安装目录的页面文件比如pages/40x.html或者一个完整的URL。</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>状态码</td> <td>状态码</td>
<td><input type="text" size="3" maxlength="3" name="shutdownStatus" style="width:5.2em" placeholder="状态码" v-model="shutdownStatus"/></td> <td><input type="text" size="3" maxlength="3" name="shutdownStatus" style="width:5.2em" placeholder="状态码" v-model="shutdownStatus"/></td>
</tr> </tr>
</tbody>
</table> </table>
</div>
<p class="comment">开启临时关闭页面时,所有请求的响应都会显示此页面。可用于临时升级网站使用。</p> <p class="comment">开启临时关闭页面时,所有请求的响应都会显示此页面。可用于临时升级网站使用。</p>
</div> </div>
</td> </td>

View File

@@ -5,11 +5,41 @@ Vue.component("http-redirect-to-https-box", {
if (redirectToHttpsConfig == null) { if (redirectToHttpsConfig == null) {
redirectToHttpsConfig = { redirectToHttpsConfig = {
isPrior: false, isPrior: false,
isOn: false isOn: false,
host: "",
port: 0,
status: 0
} }
} }
return { return {
redirectToHttpsConfig: redirectToHttpsConfig redirectToHttpsConfig: redirectToHttpsConfig,
portString: (redirectToHttpsConfig.port > 0) ? redirectToHttpsConfig.port.toString() : "",
moreOptionsVisible: false,
statusOptions: [
{"code": 301, "text": "Moved Permanently"},
{"code": 308, "text": "Permanent Redirect"},
{"code": 302, "text": "Found"},
{"code": 303, "text": "See Other"},
{"code": 307, "text": "Temporary Redirect"}
]
}
},
watch: {
"redirectToHttpsConfig.status": function () {
this.redirectToHttpsConfig.status = parseInt(this.redirectToHttpsConfig.status)
},
portString: function (v) {
let port = parseInt(v)
if (!isNaN(port)) {
this.redirectToHttpsConfig.port = port
} else {
this.redirectToHttpsConfig.port = 0
}
}
},
methods: {
changeMoreOptions: function (isVisible) {
this.moreOptionsVisible = isVisible
} }
}, },
template: `<div> template: `<div>
@@ -26,7 +56,34 @@ Vue.component("http-redirect-to-https-box", {
<input type="checkbox" v-model="redirectToHttpsConfig.isOn"/> <input type="checkbox" v-model="redirectToHttpsConfig.isOn"/>
<label></label> <label></label>
</div> </div>
<p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上</p> <p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上<more-options-angle @change="changeMoreOptions"></more-options-angle></p>
<!-- TODO 如果已经设置了特殊设置,需要在界面上显示 -->
<table class="ui table" v-show="moreOptionsVisible">
<tr>
<td class="title">状态码</td>
<td>
<select class="ui dropdown auto-width" v-model="redirectToHttpsConfig.status">
<option value="0">[使用默认]</option>
<option v-for="option in statusOptions" :value="option.code">{{option.code}} {{option.text}}</option>
</select>
</td>
</tr>
<tr>
<td>域名或IP地址</td>
<td>
<input type="text" name="host" v-model="redirectToHttpsConfig.host"/>
<p class="comment">默认和用户正在访问的域名或IP地址一致。</p>
</td>
</tr>
<tr>
<td>端口</td>
<td>
<input type="text" name="port" v-model="portString" maxlength="5" style="width:6em"/>
<p class="comment">默认端口为443。</p>
</td>
</tr>
</table>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -38,7 +95,34 @@ Vue.component("http-redirect-to-https-box", {
<input type="checkbox" v-model="redirectToHttpsConfig.isOn"/> <input type="checkbox" v-model="redirectToHttpsConfig.isOn"/>
<label></label> <label></label>
</div> </div>
<p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上</p> <p class="comment">开启后所有HTTP的请求都会自动跳转到对应的HTTPS URL上<more-options-angle @change="changeMoreOptions"></more-options-angle></p>
<!-- TODO 如果已经设置了特殊设置,需要在界面上显示 -->
<table class="ui table" v-show="moreOptionsVisible">
<tr>
<td class="title">状态码</td>
<td>
<select class="ui dropdown auto-width" v-model="redirectToHttpsConfig.status">
<option value="0">[使用默认]</option>
<option v-for="option in statusOptions" :value="option.code">{{option.code}} {{option.text}}</option>
</select>
</td>
</tr>
<tr>
<td>域名或IP地址</td>
<td>
<input type="text" name="host" v-model="redirectToHttpsConfig.host"/>
<p class="comment">默认和用户正在访问的域名或IP地址一致。</p>
</td>
</tr>
<tr>
<td>端口</td>
<td>
<input type="text" name="port" v-model="portString" maxlength="5" style="width:6em"/>
<p class="comment">默认端口为443。</p>
</td>
</tr>
</table>
</div> </div>
<div class="margin"></div> <div class="margin"></div>
</div>` </div>`

View File

@@ -38,11 +38,21 @@ Tea.context(function () {
*/ */
this.checkClusterChanges = function () { this.checkClusterChanges = function () {
this.$get("/common/changedClusters") this.$get("/common/changedClusters")
.params({
isNotifying: (this.globalChangedClusters.length > 0) ? 1 : 0
})
.timeout(60)
.success(function (resp) { .success(function (resp) {
this.globalChangedClusters = resp.data.clusters; this.globalChangedClusters = resp.data.clusters;
}).fail(function () { })
.fail(function () {
this.globalChangedClusters = []; this.globalChangedClusters = [];
}) })
.done(function () {
this.$delay(function () {
this.checkClusterChanges()
}, 3000)
})
}; };
/** /**

View File

@@ -17,6 +17,16 @@
<option value="2">未安装</option> <option value="2">未安装</option>
</select> </select>
</div> </div>
<div class="ui field">
在线状态:
</div>
<div class="ui field">
<select class="ui dropdown" name="activeState" v-model="activeState">
<option value="0">[全部]</option>
<option value="1">在线</option>
<option value="2">不在线</option>
</select>
</div>
<div class="ui field"> <div class="ui field">
<button class="ui button" type="submit">搜索</button> <button class="ui button" type="submit">搜索</button>
</div> </div>
@@ -63,7 +73,10 @@
</td> </td>
<td> <td>
<div v-if="node.isInstalled"> <div v-if="node.isInstalled">
<span v-if="node.status.isActive"><span class="green">运行中</span></span> <div v-if="node.status.isActive">
<span v-if="!node.isSynced" class="red">同步中</span>
<span v-else class="green">运行中</span>
</div>
<span v-else-if="node.status.updatedAt > 0" class="red">已断开</span> <span v-else-if="node.status.updatedAt > 0" class="red">已断开</span>
<span v-else-if="node.status.updatedAt == 0" class="red">未连接</span> <span v-else-if="node.status.updatedAt == 0" class="red">未连接</span>
</div> </div>

View File

@@ -8,13 +8,21 @@
<tr> <tr>
<th>集群名称</th> <th>集群名称</th>
<th>节点数量</th> <th>节点数量</th>
<th>在线节点数量</th>
<th>默认认证</th> <th>默认认证</th>
<th class="two op">操作</th> <th class="two op">操作</th>
</tr> </tr>
</thead> </thead>
<tr v-for="cluster in clusters"> <tr v-for="cluster in clusters">
<td>{{cluster.name}}</td> <td>{{cluster.name}}</td>
<td>{{cluster.countNodes}}</td> <td>
<a :href="'/clusters/cluster?clusterId=' + cluster.id" v-if="cluster.countAllNodes > 0">{{cluster.countAllNodes}}</a>
<span class="disabled" v-else="">-</span>
</td>
<td>
<a :href="'/clusters/cluster?clusterId=' + cluster.id + '&activeState=1'" v-if="cluster.countActiveNodes > 0"><span class="green">{{cluster.countActiveNodes}}</span></a>
<span class="disabled" v-else>-</span>
</td>
<td> <td>
<span v-if="cluster.hasGrant" class="green">Y</span> <span v-if="cluster.hasGrant" class="green">Y</span>
<span v-else class="disabled">N</span> <span v-else class="disabled">N</span>

View File

@@ -15,7 +15,6 @@
<div> <div>
{$template "/menu"} {$template "/menu"}
<div class="form-box"> <div class="form-box">
<form class="ui form" data-tea-action="$" data-tea-before="submitBefore" data-tea-done="submitDone" data-tea-success="submitSuccess" autocomplete="off"> <form class="ui form" data-tea-action="$" data-tea-before="submitBefore" data-tea-done="submitDone" data-tea-success="submitSuccess" autocomplete="off">
<input type="hidden" name="password" v-model="passwordMd5"/> <input type="hidden" name="password" v-model="passwordMd5"/>

View File

@@ -9,6 +9,8 @@
<th>服务名称</th> <th>服务名称</th>
<th>服务类型</th> <th>服务类型</th>
<th>部署集群</th> <th>部署集群</th>
<th>运行节点数</th>
<th>未运行节点数</th>
<th>端口</th> <th>端口</th>
<th>状态</th> <th>状态</th>
<th class="two op">操作</th> <th class="two op">操作</th>
@@ -18,13 +20,17 @@
<td>{{server.name}}</td> <td>{{server.name}}</td>
<td>{{server.serverTypeName}}</td> <td>{{server.serverTypeName}}</td>
<td>{{server.cluster.name}}</td> <td>{{server.cluster.name}}</td>
<td><span class="disabled">[暂无]</span></td>
<td><span class="disabled">[暂无]</span></td>
<td> <td>
<span v-if="server.ports.length == 0">-</span> <span v-if="server.ports.length == 0">-</span>
<div v-for="port in server.ports" class="ui label small"> <div v-for="port in server.ports" class="ui label small">
{{port.portRange}}<span class="small">{{port.protocol}}</span> {{port.portRange}}<span class="small">{{port.protocol}}</span>
</div> </div>
</td> </td>
<td></td> <td>
<span class="disabled">[暂无]</span>
</td>
<td> <td>
<a :href="'/servers/server?serverId=' + server.id">详情</a> <a :href="'/servers/server?serverId=' + server.id">详情</a>
</td> </td>

View File

@@ -6,7 +6,9 @@ Tea.context(function () {
"serverId": serverId "serverId": serverId
}) })
.success(function () { .success(function () {
teaweb.successURL("删除成功", "/servers") teaweb.success("删除成功", function () {
window.location = "/servers"
})
}) })
}) })
} }

View File

@@ -1,28 +0,0 @@
{$layout "layout_popup"}
<h3>添加特殊页面</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<table class="ui table selectable definition">
<tr>
<td class="title">响应状态码 *</td>
<td>
<input type="text" name="status" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" ref="focus"/>
<p class="comment">比如404或者50x。</p>
</td>
</tr>
<tr>
<td>URL *</td>
<td>
<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL"/>
<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html或者一个完整的URL。</p>
</td>
</tr>
<tr>
<td>新状态码</td>
<td>
<input type="text" name="newStatus" size="3" placeholder="状态码" maxlength="3" style="width:5.2em"/>
<p class="comment">可以用来修改响应的状态码,不填表示不改变原有状态码。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -1,3 +0,0 @@
Tea.context(function () {
this.success = NotifyPopup
})

View File

@@ -9,7 +9,7 @@
<div class="right-box tiny"> <div class="right-box tiny">
<form class="ui form" data-tea-action="$" data-tea-success="success"> <form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="webId" :value="webId"/> <input type="hidden" name="webId" :value="webId"/>
<http-pages-and-shutdown-box :v-pages="pages" :v-shutdown-config="shutdownConfig"></http-pages-and-shutdown-box> <http-pages-and-shutdown-box :v-pages="pages" :v-shutdown-config="shutdownConfig" :v-is-location="true"></http-pages-and-shutdown-box>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>
</div> </div>

View File

@@ -1,29 +0,0 @@
{$layout "layout_popup"}
<h3>修改特殊页面</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="pageId" :value="pageConfig.id"/>
<table class="ui table selectable definition">
<tr>
<td class="title">响应状态码 *</td>
<td>
<input type="text" name="status" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" ref="focus" v-model="pageConfig.status"/>
<p class="comment">比如404或者50x。</p>
</td>
</tr>
<tr>
<td>URL *</td>
<td>
<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL" v-model="pageConfig.url"/>
<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html或者一个完整的URL。</p>
</td>
</tr>
<tr>
<td>新状态码</td>
<td>
<input type="text" name="newStatus" size="3" placeholder="状态码" maxlength="3" style="width:5.2em" v-model="newStatus"/>
<p class="comment">可以用来修改响应的状态码,不填表示不改变原有状态码。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -1,8 +0,0 @@
Tea.context(function () {
this.success = NotifyPopup
this.newStatus = ""
if (this.pageConfig.newStatus > 0) {
this.newStatus = this.pageConfig.newStatus
}
})

View File

@@ -13,7 +13,7 @@
<tr> <tr>
<td class="title">Web目录</td> <td class="title">Web目录</td>
<td> <td>
<input type="text" name="root" v-model="webConfig.root"/> <input type="text" name="root" v-model="webConfig.root" ref="focus"/>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -10,7 +10,7 @@
<tr> <tr>
<td class="title">Web目录</td> <td class="title">Web目录</td>
<td> <td>
<input type="text" name="root" v-model="webConfig.root"/> <input type="text" name="root" v-model="webConfig.root" ref="focus"/>
</td> </td>
</tr> </tr>
</table> </table>