mirror of
https://github.com/nezhahq/nezha.git
synced 2025-02-02 01:28:13 -05:00
🚀 dashboard v0.13.29
前端断开后自动重连
This commit is contained in:
parent
fd697c5f44
commit
9bff4fae2f
@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||||
<br><br>
|
<br><br>
|
||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.28&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.10.6-brightgreen?style=for-the-badge&logo=linux">
|
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.29&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.10.6-brightgreen?style=for-the-badge&logo=linux">
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<p>:trollface: <b>Nezha Monitoring: Self-hosted, lightweight server and website monitoring and O&M tool.</b></p>
|
<p>:trollface: <b>Nezha Monitoring: Self-hosted, lightweight server and website monitoring and O&M tool.</b></p>
|
||||||
|
83
resource/template/theme-daynight/home.html
vendored
83
resource/template/theme-daynight/home.html
vendored
@ -256,45 +256,58 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
||||||
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
let canShowError = true;
|
||||||
ws.onopen = function (evt) {
|
function connect() {
|
||||||
Swal.fire({
|
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
||||||
position: 'top',
|
ws.onopen = function (evt) {
|
||||||
icon: 'success',
|
canShowError = true;
|
||||||
title: '{{tr "RealtimeChannelEstablished"}}',
|
Swal.fire({
|
||||||
text: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
position: 'top',
|
||||||
showConfirmButton: false,
|
icon: 'success',
|
||||||
timer: 2000
|
title: '{{tr "RealtimeChannelEstablished"}}',
|
||||||
});
|
text: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
||||||
}
|
showConfirmButton: false,
|
||||||
ws.onmessage = function (evt) {
|
timer: 2000
|
||||||
const data = JSON.parse(evt.data)
|
});
|
||||||
statusCards.servers = data.servers
|
}
|
||||||
const keys = Object.keys(statusCards.servers)
|
ws.onmessage = function (evt) {
|
||||||
for (let i = 0; i < keys.length; i++) {
|
const data = JSON.parse(evt.data)
|
||||||
const ns = statusCards.servers[keys[i]];
|
statusCards.servers = data.servers
|
||||||
if (!ns.Host) ns.live = false
|
const keys = Object.keys(statusCards.servers)
|
||||||
else {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
const lastActive = new Date(ns.LastActive).getTime()
|
const ns = statusCards.servers[keys[i]];
|
||||||
if (data.now - lastActive > 10 * 1000) {
|
if (!ns.Host) ns.live = false
|
||||||
ns.live = false
|
else {
|
||||||
} else {
|
const lastActive = new Date(ns.LastActive).getTime()
|
||||||
ns.live = true
|
if (data.now - lastActive > 10 * 1000) {
|
||||||
|
ns.live = false
|
||||||
|
} else {
|
||||||
|
ns.live = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ws.onclose = function () {
|
||||||
|
if (canShowError) {
|
||||||
|
canShowError = false;
|
||||||
|
Swal.fire({
|
||||||
|
position: 'top',
|
||||||
|
icon: 'error',
|
||||||
|
title: '{{tr "RealtimeChannelDisconnect"}}',
|
||||||
|
text: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
connect()
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
ws.onerror = function () {
|
||||||
|
ws.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ws.onclose = function () {
|
connect();
|
||||||
Swal.fire({
|
|
||||||
position: 'top',
|
|
||||||
icon: 'error',
|
|
||||||
title: '{{tr "RealtimeChannelDisconnect"}}',
|
|
||||||
text: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
|
||||||
showConfirmButton: false,
|
|
||||||
timer: 2000
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
88
resource/template/theme-default/home.html
vendored
88
resource/template/theme-default/home.html
vendored
@ -262,46 +262,60 @@
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
let canShowError = true;
|
||||||
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
function connect() {
|
||||||
ws.onopen = function (evt) {
|
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
||||||
$.suiAlert({
|
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
||||||
title: '{{tr "RealtimeChannelEstablished"}}',
|
ws.onopen = function (evt) {
|
||||||
description: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
canShowError = true;
|
||||||
type: 'success',
|
$.suiAlert({
|
||||||
time: '2',
|
title: '{{tr "RealtimeChannelEstablished"}}',
|
||||||
position: 'top-center',
|
description: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
||||||
});
|
type: 'success',
|
||||||
}
|
time: '2',
|
||||||
ws.onmessage = function (evt) {
|
position: 'top-center',
|
||||||
const oldServers = statusCards.servers
|
});
|
||||||
const data = JSON.parse(evt.data)
|
}
|
||||||
statusCards.servers = data.servers
|
ws.onmessage = function (evt) {
|
||||||
for (let i = 0; i < statusCards.servers.length; i++) {
|
const oldServers = statusCards.servers
|
||||||
const ns = statusCards.servers[i];
|
const data = JSON.parse(evt.data)
|
||||||
if (!ns.Host) ns.live = false
|
statusCards.servers = data.servers
|
||||||
else {
|
for (let i = 0; i < statusCards.servers.length; i++) {
|
||||||
const lastActive = new Date(ns.LastActive).getTime()
|
const ns = statusCards.servers[i];
|
||||||
if (data.now - lastActive > 10 * 1000) {
|
if (!ns.Host) ns.live = false
|
||||||
ns.live = false
|
else {
|
||||||
} else {
|
const lastActive = new Date(ns.LastActive).getTime()
|
||||||
ns.live = true
|
if (data.now - lastActive > 10 * 1000) {
|
||||||
|
ns.live = false
|
||||||
|
} else {
|
||||||
|
ns.live = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
statusCards.groups = groupingData(statusCards.servers, "Tag")
|
||||||
|
}
|
||||||
|
ws.onclose = function () {
|
||||||
|
if (canShowError) {
|
||||||
|
canShowError = false;
|
||||||
|
$.suiAlert({
|
||||||
|
title: '{{tr "RealtimeChannelDisconnect"}}',
|
||||||
|
description: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
||||||
|
type: 'warning',
|
||||||
|
time: '2',
|
||||||
|
position: 'top-center',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
connect()
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
ws.onerror = function () {
|
||||||
|
ws.close()
|
||||||
}
|
}
|
||||||
statusCards.groups = groupingData(statusCards.servers, "Tag")
|
|
||||||
}
|
}
|
||||||
ws.onclose = function () {
|
|
||||||
$.suiAlert({
|
connect();
|
||||||
title: '{{tr "RealtimeChannelDisconnect"}}',
|
|
||||||
description: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
$('.ui.accordion').accordion({ "exclusive": false });
|
||||||
type: 'warning',
|
|
||||||
time: '2',
|
|
||||||
position: 'top-center',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$('.ui.accordion')
|
|
||||||
.accordion({ "exclusive": false })
|
|
||||||
;
|
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
76
resource/template/theme-hotaru/home.html
vendored
76
resource/template/theme-hotaru/home.html
vendored
@ -243,41 +243,55 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
||||||
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
let canShowError = true;
|
||||||
ws.onopen = function (evt) {
|
function connect() {
|
||||||
$.suiAlert({
|
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
||||||
title: '{{tr "RealtimeChannelEstablished"}}',
|
ws.onopen = function (evt) {
|
||||||
description: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
canShowError = true;
|
||||||
type: 'success',
|
$.suiAlert({
|
||||||
time: '2',
|
title: '{{tr "RealtimeChannelEstablished"}}',
|
||||||
position: 'top-center',
|
description: '{{tr "GetTheLatestMonitoringDataInRealTime"}}',
|
||||||
});
|
type: 'success',
|
||||||
}
|
time: '2',
|
||||||
ws.onmessage = function (evt) {
|
position: 'top-center',
|
||||||
const data = JSON.parse(evt.data)
|
});
|
||||||
statusCards.servers = data.servers
|
}
|
||||||
for (let i = 0; i < statusCards.servers.length; i++) {
|
ws.onmessage = function (evt) {
|
||||||
const ns = statusCards.servers[i];
|
const data = JSON.parse(evt.data)
|
||||||
if (!ns.Host) ns.live = false
|
statusCards.servers = data.servers
|
||||||
else {
|
for (let i = 0; i < statusCards.servers.length; i++) {
|
||||||
const lastActive = new Date(ns.LastActive).getTime()
|
const ns = statusCards.servers[i];
|
||||||
if (data.now - lastActive > 10 * 1000) {
|
if (!ns.Host) ns.live = false
|
||||||
ns.live = false
|
else {
|
||||||
} else {
|
const lastActive = new Date(ns.LastActive).getTime()
|
||||||
ns.live = true
|
if (data.now - lastActive > 10 * 1000) {
|
||||||
|
ns.live = false
|
||||||
|
} else {
|
||||||
|
ns.live = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ws.onclose = function () {
|
||||||
|
if (canShowError) {
|
||||||
|
canShowError = false;
|
||||||
|
$.suiAlert({
|
||||||
|
title: '{{tr "RealtimeChannelDisconnect"}}',
|
||||||
|
description: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
||||||
|
type: 'warning',
|
||||||
|
time: '2',
|
||||||
|
position: 'top-center',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
connect()
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
ws.onerror = function () {
|
||||||
|
ws.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ws.onclose = function () {
|
connect()
|
||||||
$.suiAlert({
|
|
||||||
title: '{{tr "RealtimeChannelDisconnect"}}',
|
|
||||||
description: '{{tr "CanNotGetTheLatestMonitoringDataInRealTime"}}',
|
|
||||||
type: 'warning',
|
|
||||||
time: '2',
|
|
||||||
position: 'top-center',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
96
resource/template/theme-mdui/home.html
vendored
96
resource/template/theme-mdui/home.html
vendored
@ -228,66 +228,80 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
const wsProtocol = window.location.protocol == "https:" ? "wss" : "ws"
|
||||||
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
let canShowError = true;
|
||||||
ws.onopen = function (evt) {
|
function connect() {
|
||||||
|
const ws = new WebSocket(wsProtocol + '://' + window.location.host + '/ws');
|
||||||
|
ws.onopen = function (evt) {
|
||||||
|
canShowError = true;
|
||||||
mdui.snackbar({
|
mdui.snackbar({
|
||||||
message: '{{tr "RealtimeChannelEstablished"}}',
|
message: '{{tr "RealtimeChannelEstablished"}}',
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
position: 'top',
|
position: 'top',
|
||||||
onClosed: function(){
|
onClosed: function () {
|
||||||
mdui.mutation();
|
mdui.mutation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var infoTooltip = {}, memTooltip = {};
|
var infoTooltip = {}, memTooltip = {};
|
||||||
ws.onmessage = function (evt) {
|
ws.onmessage = function (evt) {
|
||||||
const data = JSON.parse(evt.data)
|
const data = JSON.parse(evt.data)
|
||||||
statusCards.servers = data.servers
|
statusCards.servers = data.servers
|
||||||
for (let i = 0; i < statusCards.servers.length; i++) {
|
for (let i = 0; i < statusCards.servers.length; i++) {
|
||||||
const ns = statusCards.servers[i];
|
const ns = statusCards.servers[i];
|
||||||
if (!ns.Host) ns.live = false
|
if (!ns.Host) ns.live = false
|
||||||
else {
|
else {
|
||||||
const lastActive = new Date(ns.LastActive).getTime()
|
const lastActive = new Date(ns.LastActive).getTime()
|
||||||
if (data.now - lastActive > 10 * 1000) {
|
if (data.now - lastActive > 10 * 1000) {
|
||||||
ns.live = false
|
ns.live = false
|
||||||
} else {
|
} else {
|
||||||
ns.live = true
|
ns.live = true
|
||||||
if (statusCards.showCard) {
|
if (statusCards.showCard) {
|
||||||
if (infoTooltip[ns.ID]) {
|
if (infoTooltip[ns.ID]) {
|
||||||
var disk = statusCards.formatByteSize(ns.State.DiskUsed) + '/' + statusCards.formatByteSize(ns.Host.DiskTotal);
|
var disk = statusCards.formatByteSize(ns.State.DiskUsed) + '/' + statusCards.formatByteSize(ns.Host.DiskTotal);
|
||||||
var upTime = statusCards.secondToDate(ns.State.Uptime);
|
var upTime = statusCards.secondToDate(ns.State.Uptime);
|
||||||
var content =
|
var content =
|
||||||
`System: ${ns.Host.Platform}-${ns.Host.PlatformVersion}[${ns.Host.Arch}]
|
`System: ${ns.Host.Platform}-${ns.Host.PlatformVersion}[${ns.Host.Arch}]
|
||||||
CPU: ${ns.Host.CPU}
|
CPU: ${ns.Host.CPU}
|
||||||
Disk: ${disk}
|
Disk: ${disk}
|
||||||
Online: ${upTime}
|
Online: ${upTime}
|
||||||
Version: ${ns.Host.Version}`;
|
Version: ${ns.Host.Version}`;
|
||||||
infoTooltip[ns.ID].$element[0].innerText = content;
|
infoTooltip[ns.ID].$element[0].innerText = content;
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (document.getElementById(`info-${ns.ID}`)) infoTooltip[ns.ID] = new mdui.Tooltip(`#info-${ns.ID}`, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memTooltip[ns.ID]) {
|
|
||||||
var content = `${statusCards.formatByteSize(ns.State.MemUsed)}/${statusCards.formatByteSize(ns.Host.MemTotal)}`;
|
|
||||||
memTooltip[ns.ID].$element[0].innerText = content;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (document.getElementById(`mem-${ns.ID}`)) memTooltip[ns.ID] = new mdui.Tooltip(`#mem-${ns.ID}`, {});
|
|
||||||
}
|
|
||||||
} else {mdui.$('div').remove('.mdui-tooltip'); infoTooltip = {}; memTooltip = {};}
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (document.getElementById(`info-${ns.ID}`)) infoTooltip[ns.ID] = new mdui.Tooltip(`#info-${ns.ID}`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memTooltip[ns.ID]) {
|
||||||
|
var content = `${statusCards.formatByteSize(ns.State.MemUsed)}/${statusCards.formatByteSize(ns.Host.MemTotal)}`;
|
||||||
|
memTooltip[ns.ID].$element[0].innerText = content;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (document.getElementById(`mem-${ns.ID}`)) memTooltip[ns.ID] = new mdui.Tooltip(`#mem-${ns.ID}`, {});
|
||||||
|
}
|
||||||
|
} else { mdui.$('div').remove('.mdui-tooltip'); infoTooltip = {}; memTooltip = {}; }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mdui.mutation();
|
mdui.mutation();
|
||||||
|
}
|
||||||
|
ws.onclose = function () {
|
||||||
|
if (canShowError) {
|
||||||
|
canShowError = false;
|
||||||
|
mdui.snackbar({
|
||||||
|
message: '{{tr "RealtimeChannelDisconnect"}}',
|
||||||
|
timeout: 2000,
|
||||||
|
position: 'top',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
connect()
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
ws.onerror = function () {
|
||||||
|
ws.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ws.onclose = function () {
|
connect();
|
||||||
mdui.snackbar({
|
|
||||||
message: '{{tr "RealtimeChannelDisconnect"}}',
|
|
||||||
timeout: 2000,
|
|
||||||
position: 'top',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/naiba/nezha/pkg/utils"
|
"github.com/naiba/nezha/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "v0.13.28" // !!记得修改 README 中的 badge 版本!!
|
var Version = "v0.13.29" // !!记得修改 README 中的 badge 版本!!
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Conf *model.Config
|
Conf *model.Config
|
||||||
|
Loading…
Reference in New Issue
Block a user