Skip to content

Commit

Permalink
fix: add toggle to service (#317)
Browse files Browse the repository at this point in the history
* fix: short nework word

* fix: add toggle on service

* fix: delete console log update main.js version

---------

Co-authored-by: LvGJ <[email protected]>
  • Loading branch information
lvgj-stack and LvGJ authored Feb 13, 2024
1 parent b86b73a commit 6266134
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 9 deletions.
2 changes: 2 additions & 0 deletions cmd/dashboard/controller/member_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ type monitorForm struct {
MaxLatency float32
LatencyNotify string
EnableTriggerTask string
EnableShowInService string
FailTriggerTasksRaw string
RecoverTriggerTasksRaw string
}
Expand All @@ -415,6 +416,7 @@ func (ma *memberAPI) addOrEditMonitor(c *gin.Context) {
m.LatencyNotify = mf.LatencyNotify == "on"
m.MinLatency = mf.MinLatency
m.MaxLatency = mf.MaxLatency
m.EnableShowInService = mf.EnableShowInService == "on"
m.EnableTriggerTask = mf.EnableTriggerTask == "on"
m.RecoverTriggerTasksRaw = mf.RecoverTriggerTasksRaw
m.FailTriggerTasksRaw = mf.FailTriggerTasksRaw
Expand Down
1 change: 1 addition & 0 deletions model/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Monitor struct {
Cover uint8

EnableTriggerTask bool `gorm:"default: false"`
EnableShowInService bool `gorm:"default: false"`
FailTriggerTasksRaw string `gorm:"default:'[]'"`
RecoverTriggerTasksRaw string `gorm:"default:'[]'"`
FailTriggerTasks []uint64 `gorm:"-" json:"-"` // 失败时执行的触发任务id
Expand Down
5 changes: 4 additions & 1 deletion resource/l10n/en-US.toml
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,7 @@ other = "Hide for Guest"
other = "Menu"

[NetworkSpiter]
other = "Network Monitor"
other = "Network"

[EnableShowInService]
other = "Enable Show in Service"
5 changes: 4 additions & 1 deletion resource/l10n/es-ES.toml
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,7 @@ other = "Ocultar para Invitados"
other = "Menú"

[NetworkSpiter]
other = "Supervisión De Redes"
other = "Red"

[EnableShowInService]
other = "Mostrar en servicio"
5 changes: 4 additions & 1 deletion resource/l10n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,7 @@ other = "对游客隐藏"
other = "菜单"

[NetworkSpiter]
other = "网络监控"
other = "网络"

[EnableShowInService]
other = "在服务中显示"
5 changes: 4 additions & 1 deletion resource/l10n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,7 @@ other = "對遊客隱藏"
other = "菜單"

[NetworkSpiter]
other = "網絡監控"
other = "網絡"

[EnableShowInService]
other = "在服務中顯示"
5 changes: 5 additions & 0 deletions resource/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ function addOrEditMonitor(monitor) {
modal.find("select[name=Type]").val(monitor ? monitor.Type : 1);
modal.find("select[name=Cover]").val(monitor ? monitor.Cover : 0);
modal.find("input[name=NotificationTag]").val(monitor ? monitor.NotificationTag : null);
if (monitor && monitor.EnableShowInService) {
modal.find(".ui.nb-show-in-service.checkbox").checkbox("set checked")
} else {
modal.find(".ui.nb-show-in-service.checkbox").checkbox("set unchecked")
}
if (monitor && monitor.Notify) {
modal.find(".ui.nb-notify.checkbox").checkbox("set checked");
} else {
Expand Down
2 changes: 1 addition & 1 deletion resource/template/common/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20230614"></script>
<script src="/static/main.js?v20240213"></script>
<script>
(function () {
updateLang({{.LANG }});
Expand Down
7 changes: 7 additions & 0 deletions resource/template/component/monitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<option value="3">TCP-Ping</option>
</select>
</div>
<div class="field">
<div class="ui nb-show-in-service checkbox">
<input name="EnableShowInService" type="checkbox" tabindex="0" class="hidden" />
<label>{{tr "EnableShowInService"}}</label>
</div>
</div>
<div class="field">
<label>{{tr "Duration"}}</label>
<input type="number" name="Duration" placeholder="{{tr "Seconds"}}" />
Expand Down Expand Up @@ -110,3 +116,4 @@
</div>
</div>
{{end}}

2 changes: 1 addition & 1 deletion resource/template/dashboard-default/monitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
<script>
$(".checkbox").checkbox();
</script>
{{end}}
{{end}}
2 changes: 1 addition & 1 deletion resource/template/theme-angel-kanade/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/semantic-ui/2.4.1/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/vue/2.6.14/vue.min.js"></script>
<script src="/static/main.js?v20230614"></script>
<script src="/static/main.js?v20240213"></script>
<script>
(function () {
updateLang({{.LANG }});
Expand Down
2 changes: 2 additions & 0 deletions resource/template/theme-daynight/service.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ <h4>{{tr "30DaysOnline"}}</h4>
</section>
<section class="monitor-container">
{{range $service := .Services}}
{{if $service.Monitor.EnableShowInService}}
<section class="monitor-info-container">
<div class="monitor-state">
<span class="monitor-state-dot {{className (divU64 $service.CurrentUp (addU64 $service.CurrentUp $service.CurrentDown))}}"></span>
Expand All @@ -81,6 +82,7 @@ <h4>{{tr "30DaysOnline"}}</h4>
{{end}}
</div>
</section>
{{end}}
{{end}}
</section>
{{if .CycleTransferStats}}
Expand Down
3 changes: 2 additions & 1 deletion resource/template/theme-default/service.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</thead>
<tbody>
{{range $service := .Services}}
{{if $service.Monitor.EnableShowInService}}
<tr>
<td class="ui center aligned">{{$service.Monitor.Name}}</td>
<td class="ui center aligned">
Expand All @@ -33,7 +34,7 @@
class="delay-today {{className (divU64 $service.CurrentUp (addU64 $service.CurrentUp $service.CurrentDown))}}"></i>
{{statusName (divU64 $service.CurrentUp (addU64 $service.CurrentUp $service.CurrentDown))}}
</td>
</tr> {{end}}
</tr> {{end}} {{end}}
</tbody>
</table>

Expand Down
3 changes: 2 additions & 1 deletion resource/template/theme-server-status/service.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</thead>
<tbody id="servers">
<template v-for="service in services">
<tr>
<tr v-if="service.enableShow === 'true'">
<td class="node-cell center">
<div class="delay-today">
<i class="delay-today" :class="service.health.className"></i>
Expand Down Expand Up @@ -137,6 +137,7 @@ <h4 style="text-align: center;">{{tr "CycleTransferStats"}}</h4>
delay: '{{$service.Delay}}'.replaceAll("[","").replaceAll("]","").split(" "),
up: '{{$service.Up}}'.replaceAll("[","").replaceAll("]","").split(" "),
down: '{{$service.Down}}'.replaceAll("[","").replaceAll("]","").split(" "),
enableShow: '{{$service.Monitor.EnableShowInService}}',
})
{{end}}
// @formatter:on
Expand Down

0 comments on commit 6266134

Please sign in to comment.