Skip to content

Commit

Permalink
💄 优化 server-status 主题服务页流量统计
Browse files Browse the repository at this point in the history
  • Loading branch information
naiba committed Nov 7, 2023
1 parent 1c00cc8 commit b6c2410
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br>
<img src="https://img.shields.io/github/actions/workflow/status/naiba/nezha/dashboard.yml?branch=master&label=Dash%20v0.15.7&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?branch=v0.15.7&label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
<img src="https://img.shields.io/github/actions/workflow/status/naiba/nezha/dashboard.yml?branch=master&label=Dash%20v0.15.8&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?branch=v0.15.8&label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
<br>
<br>
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
Expand Down
4 changes: 2 additions & 2 deletions resource/l10n/en-US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ other = "Light Mode"
[DarkMode]
other = "Dark Mode"

[SystemMode]
other = "System Mode"
[FollowSystem]
other = "Follow System"

[GridLayout]
other = "Grid Layout"
Expand Down
4 changes: 2 additions & 2 deletions resource/l10n/es-ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ other = "Modo luminoso"
[DarkMode]
other = "Modo oscuro"

[SystemMode]
other = "Modo del sistema"
[FollowSystem]
other = "Seguir el sistema"

[GridLayout]
other = "Grid Layout"
Expand Down
2 changes: 1 addition & 1 deletion resource/l10n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ other = "白昼模式"
[DarkMode]
other = "暗黑模式"

[SystemMode]
[FollowSystem]
other = "跟随系统"

[GridLayout]
Expand Down
4 changes: 2 additions & 2 deletions resource/l10n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ other = "白晝模式"
[DarkMode]
other = "暗黑模式"

[SystemMode]
other = "系統模式"
[FollowSystem]
other = "跟隨系統"

[GridLayout]
other = "網格視圖"
Expand Down
2 changes: 1 addition & 1 deletion resource/template/theme-server-status/content-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{else}}
<li><a href="/login">{{tr "Login" }}</a></li>
{{end}}
<li><a href="#" @click="setSystemTheme">{{tr "SystemMode" }}
<li><a href="#" @click="setSystemTheme">{{tr "FollowSystem" }}
<span style="color: #fff" v-if="isSystemTheme"> ✔️</span></a>
</li>
<li><a href="#" @click="setTheme('dark', true)">{{tr "DarkMode" }}
Expand Down
2 changes: 1 addition & 1 deletion resource/template/theme-server-status/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</td>
<td style="text-align: center;" class="node-cell location">
<i :class="node.location + ' flag'"></i>&nbsp;
<span>@#node.location#@</span>
<span class="text-uppercase">@#node.location#@</span>
</td>
<td style="text-align: center;" class="node-cell uptime">@#node.uptime#@</td>
<td style="text-align: center;" class="node-cell load">@#node.load#@</td>
Expand Down
97 changes: 45 additions & 52 deletions resource/template/theme-server-status/service.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,59 +44,52 @@
</table>
</div>

<div class="ui container">
<div class="service-status" style="margin-bottom: 20px;">
{{if .CycleTransferStats}}

<h2 style="text-align: center;">{{tr "CycleTransferStats"}}</h2>

<table class="ui celled table">
<thead>
<tr>
<th class="ui center aligned">ID</th>
<th class="ui center aligned">{{tr "Rules"}}</th>
<th class="ui center aligned">{{tr "Server"}}</th>
<th class="ui center aligned">{{tr "From"}}</th>
<th class="ui center aligned">{{tr "To"}}</th>
<th class="ui center aligned">MAX</th>
<th class="ui center aligned">MIN</th>
<th class="ui center aligned">{{tr "NextCheck"}}</th>
<th class="ui center aligned">{{tr "CurrentUsage"}}</th>
<th class='ui center aligned' style='padding: 0px 31px 0px 31px;'>{{tr "Transleft"}}</th>
</tr>
</thead>
<tbody>
{{range $id, $stats := .CycleTransferStats}}
{{range $innerId, $transfer := $stats.Transfer}}
{{$TransLeftPercent := TransLeftPercent (UintToFloat $transfer) (UintToFloat $stats.Max)}}
<tr>
<td class="ui center aligned">{{$id}}</td>
<td class="ui center aligned">{{$stats.Name}}</td>
<td class="ui center aligned">{{index $stats.ServerName $innerId}}</td>
<td class="ui center aligned">{{$stats.From|tf}}</td>
<td class="ui center aligned">{{$stats.To|tf}}</td>
<td class="ui center aligned">{{$stats.Max|bf}}</td>
<td class="ui center aligned">{{$stats.Min|bf}}</td>
<td class="ui center aligned">{{(index $stats.NextUpdate $innerId)|sft}}</td>
<td class="ui center aligned">{{$transfer|bf}}</td>
<td class="ui center aligned" style="padding: 14px 0px 0px 0px; position: relative;">
<div class="thirteen wide column">
<div class="ui progress {{TransClassName $TransLeftPercent}}"
style=" background: rgba(0,0,0,.1); background-color: rgba(0,0,0,.1)!important; height: 25px;">
<div class="bar"
style="transition-duration: 300ms; min-width: unset; background-color: rgb(10, 148, 242); width: {{$TransLeftPercent}}% !important;"></div>
<small style="position: relative; top: -2em;">{{TransLeft $stats.Max $transfer}} /
{{$TransLeftPercent}} %</small></div>
</div>
</td>
</tr>
{{end}}
{{end}}
</tbody>
</table>

<div class="ui container" style="margin-bottom: 20px;">
{{if .CycleTransferStats}}
<h2 style="text-align: center;">{{tr "CycleTransferStats"}}</h2>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>{{tr "Rules"}}</th>
<th>{{tr "Server"}}</th>
<th>{{tr "From"}}</th>
<th>{{tr "To"}}</th>
<th>MAX</th>
<th>MIN</th>
<th>{{tr "NextCheck"}}</th>
<th>{{tr "CurrentUsage"}}</th>
<th class='ui center aligned'>{{tr "Transleft"}}</th>
</tr>
</thead>
<tbody>
{{range $id, $stats := .CycleTransferStats}}
{{range $innerId, $transfer := $stats.Transfer}}
{{$TransLeftPercent := TransLeftPercent (UintToFloat $transfer) (UintToFloat $stats.Max)}}
<tr>
<td>{{$id}}</td>
<td>{{$stats.Name}}</td>
<td>{{index $stats.ServerName $innerId}}</td>
<td>{{$stats.From|tf}}</td>
<td>{{$stats.To|tf}}</td>
<td>{{$stats.Max|bf}}</td>
<td>{{$stats.Min|bf}}</td>
<td>{{(index $stats.NextUpdate $innerId)|sft}}</td>
<td>{{$transfer|bf}}</td>
<td>
<div class="ui progress {{TransClassName $TransLeftPercent}}"
style=" background: rgba(0,0,0,.1); background-color: rgba(0,0,0,.1)!important; height: 25px; margin: unset !important">
<div class="bar"
style="transition-duration: 300ms; min-width: unset; background-color: rgb(10, 148, 242); width: {{$TransLeftPercent}}% !important"></div>
<small style="position: relative; top: -2em;">{{TransLeft $stats.Max $transfer}} /
{{$TransLeftPercent}} %</small></div>
</td>
</tr>
{{end}}
{{end}}
</div>
</tbody>
</table>
{{end}}
</div>
{{template "theme-server-status/content-footer" .}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion service/singleton/singleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/naiba/nezha/pkg/utils"
)

var Version = "v0.15.7" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.15.8" // !!记得修改 README 中的 badge 版本!!

var (
Conf *model.Config
Expand Down

0 comments on commit b6c2410

Please sign in to comment.