mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	服务看板改成异步
This commit is contained in:
		@@ -41,6 +41,12 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
		"name": server.Name,
 | 
							"name": server.Name,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunPost(params struct {
 | 
				
			||||||
 | 
						ServerId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
	resp, err := this.RPC().ServerStatBoardRPC().ComposeServerStatBoard(this.AdminContext(), &pb.ComposeServerStatBoardRequest{ServerId: params.ServerId})
 | 
						resp, err := this.RPC().ServerStatBoardRPC().ComposeServerStatBoard(this.AdminContext(), &pb.ComposeServerStatBoardRequest{ServerId: params.ServerId})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
@@ -151,6 +157,5 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		this.Data["metricCharts"] = chartMaps
 | 
							this.Data["metricCharts"] = chartMaps
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
	this.Show()
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ func init() {
 | 
				
			|||||||
			Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)).
 | 
								Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)).
 | 
				
			||||||
			Helper(serverutils.NewServerHelper()).
 | 
								Helper(serverutils.NewServerHelper()).
 | 
				
			||||||
			Prefix("/servers/server/boards").
 | 
								Prefix("/servers/server/boards").
 | 
				
			||||||
			Get("", new(IndexAction)).
 | 
								GetPost("", new(IndexAction)).
 | 
				
			||||||
			EndAll()
 | 
								EndAll()
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,13 @@
 | 
				
			|||||||
    <menu-item :href="'/servers/server?serverId=' + server.id" active="true">"{{server.name}}"看板</menu-item>
 | 
					    <menu-item :href="'/servers/server?serverId=' + server.id" active="true">"{{server.name}}"看板</menu-item>
 | 
				
			||||||
</first-menu>
 | 
					</first-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 menu tabular">
 | 
					<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 == 'hourly'}" @click.prevent="selectTrafficTab('hourly')">24小时流量趋势</a>
 | 
				
			||||||
    <a href="" class="item" :class="{active: trafficTab == 'daily'}" @click.prevent="selectTrafficTab('daily')">15天流量趋势</a>
 | 
					    <a href="" class="item" :class="{active: trafficTab == 'daily'}" @click.prevent="selectTrafficTab('daily')">15天流量趋势</a>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,7 @@
 | 
				
			|||||||
Tea.context(function () {
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.isLoading = true
 | 
				
			||||||
 | 
						this.metricCharts = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.formatCount = function (count) {
 | 
						this.formatCount = function (count) {
 | 
				
			||||||
		if (count < 1000) {
 | 
							if (count < 1000) {
 | 
				
			||||||
			return count.toString()
 | 
								return count.toString()
 | 
				
			||||||
@@ -15,11 +18,27 @@ Tea.context(function () {
 | 
				
			|||||||
	this.trafficTab = "hourly"
 | 
						this.trafficTab = "hourly"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.$delay(function () {
 | 
						this.$delay(function () {
 | 
				
			||||||
		this.reloadHourlyTrafficChart()
 | 
							this.load()
 | 
				
			||||||
		this.reloadHourlyRequestsChart()
 | 
					 | 
				
			||||||
		this.reloadTopDomainsChart()
 | 
					 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.load = function () {
 | 
				
			||||||
 | 
							this.$post("$")
 | 
				
			||||||
 | 
								.params({
 | 
				
			||||||
 | 
									serverId: this.server.id
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.success(function (resp) {
 | 
				
			||||||
 | 
									for (let k in resp.data) {
 | 
				
			||||||
 | 
										this[k] = resp.data[k]
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									this.reloadHourlyTrafficChart()
 | 
				
			||||||
 | 
									this.reloadHourlyRequestsChart()
 | 
				
			||||||
 | 
									this.reloadTopDomainsChart()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									this.isLoading = false
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.selectTrafficTab = function (tab) {
 | 
						this.selectTrafficTab = function (tab) {
 | 
				
			||||||
		this.trafficTab = tab
 | 
							this.trafficTab = tab
 | 
				
			||||||
		if (tab == "hourly") {
 | 
							if (tab == "hourly") {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user