diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d5f01..a54af3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog # +**2021-08-27** + +* v1.5.0 : + * Added dark mode that follows the device switch + * Added automatic jumping to the login page when not logged in + * Some other optimizations + * Updated dependencies + **2021-08-24** * v1.4.1 : diff --git a/Makefile b/Makefile index c6244c6..f43447a 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ # @Description: Golang implementation of pi-dashboard # @Author: github.com/plutobell # @Creation: 2020-08-10 -# @Last modification: 2021-08-24 -# @Version: 1.4.1 +# @Last modification: 2021-08-27 +# @Version: 1.5.0 PROGRAM = pi-dashboard-go OUTPUT = build diff --git a/README.md b/README.md index 2b8c385..85ed7ec 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ ![](./screenshots/screenshot_login.png) +![](./screenshots/screenshot_index_dark.png) + +![](./screenshots/screenshot_login_dark.png) + + + ## Install @@ -38,7 +44,7 @@ chmod +x pi-dashboard-go **Pi Dashboard Go** can be configured via command line parameters: ```bash -Pi Dashboard Go version: v1.4.1 +Pi Dashboard Go version: v1.5.0 Project address: https://github.com/plutobell/pi-dashboard-go Usage: Pi Dashboard Go [-auth USR:PSW] [-disk Paths] [-help] diff --git a/config/config.go b/config/config.go index ca23f32..7dccbfa 100644 --- a/config/config.go +++ b/config/config.go @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 package config @@ -15,7 +15,7 @@ const ( //AUTHOR 作者信息 AUTHOR string = "github:plutobell" //VERSION 版本信息 - VERSION string = "1.4.1" + VERSION string = "1.5.0" //USERNAME 默认用户 USERNAME string = "pi" //PASSWORD 默认密码 diff --git a/device/device.go b/device/device.go index 3b63167..b836f0f 100644 --- a/device/device.go +++ b/device/device.go @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 package device diff --git a/go.mod b/go.mod index 5ec8ee8..e15a1a1 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/labstack/echo/v4 v4.5.0 github.com/mattn/go-isatty v0.0.13 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect - golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect + golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect diff --git a/go.sum b/go.sum index 33d44de..971dd83 100644 --- a/go.sum +++ b/go.sum @@ -363,8 +363,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d h1:LO7XpTYMwTqxjLcGWPijK3vRXg1aWdlNOVOHRq45d7c= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw= +golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/main.go b/main.go index a8d5088..2815380 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 package main diff --git a/screenshots/screenshot_index_dark.png b/screenshots/screenshot_index_dark.png new file mode 100644 index 0000000..b1d7553 Binary files /dev/null and b/screenshots/screenshot_index_dark.png differ diff --git a/screenshots/screenshot_login_dark.png b/screenshots/screenshot_login_dark.png new file mode 100644 index 0000000..974b1f2 Binary files /dev/null and b/screenshots/screenshot_login_dark.png differ diff --git a/server/assets/css/common.css b/server/assets/css/common.css index ccdca8c..4cd1c10 100644 --- a/server/assets/css/common.css +++ b/server/assets/css/common.css @@ -3,8 +3,8 @@ @Description: Golang implementation of pi-dashboard @Author: github.com/plutobell @Creation: 2020-08-01 -@Last modification: 2021-08-24 -@Version: 1.4.1 +@Last modification: 2021-08-27 +@Version: 1.5.0 */ ::-webkit-scrollbar { @@ -36,11 +36,19 @@ --real-memory-color: #D9E4DD; --swap-color: #D9E4DD; --disk-color: #CDC9C3; - --net-in-color: #D9E4DD; - --net-out-color: #CDC9C3; --box-bg-color: #eaebe9; /* #E8EAE6 */ --backdrop-color: #363636; + --guage-font-color: black; + --guage-stops-color-1: #D9E4DD; + --guage-stops-color-5: #CDC9C3; + --guage-stops-color-9: #919191; + + --net-in-color: #D9E4DD; + --net-out-color: #CDC9C3; + --net-grid-line-color: #e6e6e6; + --net-line-color: #ccd6eb; + --box-radius: 15px; } @@ -140,4 +148,86 @@ and (max-device-width : 768px) { .btn-close:focus { outline: none !important; box-shadow: none !important; +} +.inverted { + filter: invert(100%); +} + + +@media (prefers-color-scheme: dark) { + ::-webkit-scrollbar-track { + background: #3f3f3f; + -webkit-box-shadow: inset 0 0 5px #3f3f3f; + } + ::-webkit-scrollbar-thumb { + background: #7c7c7c; + -webkit-box-shadow: inset 0 0 10px #7c7c7c; + } + + body{ + background-color: #2d2d2d; + color: #c9d1d9; + } + input { + background-color: #3b3b3b !important; + border-color: #3b3b3b !important; + color: #c9d1d9 !important; + } + input:focus { + border: 1px solid #6b6b6b !important; + } + + :root { + --label-color: #959c9c; + --navbar-color: #474747; + --cache-color: #414141; + --cpu-memory-title-color: #5e5e5e; + --temperature-color: #4b4b4b; + --ip-color: #414141; + --time-color: #5e5e5e; + --uptime-color: #4b4b4b; + --cpu-color: #414141; + --memory-color: #414141; + --real-memory-color: #414141; + --swap-color: #414141; + --disk-color: #5e5e5e; + --box-bg-color: #373938; + --backdrop-color: #363636; + + --guage-font-color: #b9bebe; + --guage-stops-color-1: #626464; + --guage-stops-color-5: #878b8b; + --guage-stops-color-9: #b6b6b6; + + --net-in-color: #414141; + --net-out-color: #5e5e5e; + --net-grid-line-color: #3d3d3d; + --net-line-color: #575757; + + --box-radius: 15px; + } + + .modal-content { + background-color: #252525; + color: #c9d1d9; + } + .dark-bg { + background-color: #505050 !important; + } + .spinner > div { + background-color: #c9d1d9; + } + .navbar-toggler { + color: #505050 !important; + } + + #login-tips { + color: #c9d1d9; + } + #pimodel { + color: #c9d1d9; + } + #command-btns li img:hover{ + border: 1px solid #606060 !important; + } } \ No newline at end of file diff --git a/server/assets/css/index.css b/server/assets/css/index.css index 878ecce..981dcd2 100644 --- a/server/assets/css/index.css +++ b/server/assets/css/index.css @@ -3,8 +3,8 @@ @Description: Golang implementation of pi-dashboard @Author: github.com/plutobell @Creation: 2020-08-01 -@Last modification: 2021-08-24 -@Version: 1.4.1 +@Last modification: 2021-08-27 +@Version: 1.5.0 */ #loading{ diff --git a/server/assets/css/login.css b/server/assets/css/login.css index 55f65a8..b36519d 100644 --- a/server/assets/css/login.css +++ b/server/assets/css/login.css @@ -3,8 +3,8 @@ @Description: Golang implementation of pi-dashboard @Author: github.com/plutobell @Creation: 2020-08-01 -@Last modification: 2021-08-24 -@Version: 1.4.1 +@Last modification: 2021-08-27 +@Version: 1.5.0 */ .box-radius { @@ -19,5 +19,5 @@ input:focus { outline: none !important; box-shadow: none !important; - border: 1px solid var(--navbar-color) !important; + border: 1px solid var(--label-color) !important; } \ No newline at end of file diff --git a/server/assets/favicons/linux_light.ico b/server/assets/favicons/linux_light.ico new file mode 100644 index 0000000..7d0ccd5 Binary files /dev/null and b/server/assets/favicons/linux_light.ico differ diff --git a/server/assets/js/common.js b/server/assets/js/common.js index e3a2abf..c874ad5 100644 --- a/server/assets/js/common.js +++ b/server/assets/js/common.js @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 window.oncontextmenu=function(){return false;} window.onkeydown = window.onkeyup = window.onkeypress = function (event) { @@ -18,6 +18,60 @@ window.addEventListener('keydown', function (event) { } }) +$(document).ready(function() { + if(window.matchMedia('(prefers-color-scheme: dark)').matches){ + $("#modal-close-btn").addClass("btn-close-white"); + $("footer").eq(0).addClass("border-secondary"); + if ($("#favicon").text() == "linux.ico") { + $("#device-photo").addClass("inverted"); + $("#icon").attr("href", "favicons/linux_light.ico"); + $("#shortcut-icon").attr("href", "favicons/linux_light.ico"); + } + } else { + $("#modal-close-btn").removeClass("btn-close-white"); + $("footer").eq(0).removeClass("border-secondary"); + $("#device-photo").removeClass("inverted"); + if ($("#favicon").text() == "linux.ico") { + $("#icon").attr("href", "favicons/linux.ico"); + $("#shortcut-icon").attr("href", "favicons/linux.ico"); + } else { + $("#icon").attr("href", "favicons/raspberrypi.ico"); + $("#shortcut-icon").attr("href", "favicons/raspberrypi.ico"); + } + } +}); + +let media = window.matchMedia('(prefers-color-scheme: dark)'); +let callback = (e) => { + let prefersDarkMode = e.matches; + if (prefersDarkMode) { + $("#modal-close-btn").addClass("btn-close-white"); + $("footer").eq(0).addClass("border-secondary"); + if ($("#favicon").text() == "linux.ico") { + $("#device-photo").addClass("inverted"); + $("#icon").attr("href", "favicons/linux_light.ico"); + $("#shortcut-icon").attr("href", "favicons/linux_light.ico"); + } + $.getScript('js/index.js', function() {}); + } else { + $("#modal-close-btn").removeClass("btn-close-white"); + $("footer").eq(0).removeClass("border-secondary"); + $("#device-photo").removeClass("inverted"); + if ($("#favicon").text() == "linux.ico") { + $("#icon").attr("href", "favicons/linux.ico"); + $("#shortcut-icon").attr("href", "favicons/linux.ico"); + } else { + $("#icon").attr("href", "favicons/raspberrypi.ico"); + $("#shortcut-icon").attr("href", "favicons/raspberrypi.ico"); + } + $.getScript('js/index.js', function() {}); + } +}; +if (typeof media.addEventListener === 'function') { + media.addEventListener('change', callback); +} else if (typeof media.addEventListener === 'function') { + media.addEventListener(callback); +} function getCookie(name) { var cookieValue = null; diff --git a/server/assets/js/index.js b/server/assets/js/index.js index d2c62d8..0a5feae 100644 --- a/server/assets/js/index.js +++ b/server/assets/js/index.js @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 var new_version = "" var new_version_notes = "" @@ -15,6 +15,12 @@ unScroll(); $(document).ready(function() { var net_in_color = $(":root").css("--net-in-color"); var net_out_color = $(":root").css("--net-out-color"); + var net_grid_line_color = $(":root").css("--net-grid-line-color"); + var net_line_color = $(":root").css("--net-line-color"); + var guage_font_color = $(":root").css("--guage-font-color"); + var guage_stops_color_1 = $(":root").css("--guage-stops-color-1"); + var guage_stops_color_5 = $(":root").css("--guage-stops-color-5"); + var guage_stops_color_9 = $(":root").css("--guage-stops-color-9"); $("#year").text(new Date().getFullYear()); $("#loading").hide(); @@ -38,7 +44,8 @@ $(document).ready(function() { var gaugeOptions = { chart: { - type: 'solidgauge' + type: 'solidgauge', + backgroundColor: 'transparent' }, title: null, @@ -49,7 +56,8 @@ $(document).ready(function() { startAngle: -90, endAngle: 90, background: { - backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#FFFFFF', + // backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#FFFFFF', + backgroundColor: 'transparent', innerRadius: '60%', outerRadius: '100%', shape: 'arc' @@ -63,9 +71,9 @@ $(document).ready(function() { // the value axis yAxis: { stops: [ - [0.1, '#D9E4DD'], - [0.5, '#CDC9C3'], - [0.9, '#919191'] + [0.1, guage_stops_color_1], + [0.5, guage_stops_color_5], + [0.9, guage_stops_color_9] ], lineWidth: 0, minorTickInterval: null, @@ -104,7 +112,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y}' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y}' + '%
' }, tooltip: { @@ -128,7 +136,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y:.1f}
' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y:.1f}
' + 'MB
' }, tooltip: { @@ -152,7 +160,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y:.1f}
' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y:.1f}
' + 'MB
' }, tooltip: { @@ -176,7 +184,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y:.1f}
' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y:.1f}
' + 'MB
' }, tooltip: { @@ -200,7 +208,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y:.1f}
' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y:.1f}
' + 'MB
' }, tooltip: { @@ -224,7 +232,7 @@ $(document).ready(function() { data: [0], dataLabels: { format: '
{y:.1f}
' + + ((Highcharts.theme && Highcharts.theme.contrastTextColor) || guage_font_color) + '">{y:.1f}
' + 'GB
' }, tooltip: { @@ -236,6 +244,10 @@ $(document).ready(function() { var chartNetInterface1 = Highcharts.chart('container-net-interface-1', { + chart: { + backgroundColor: 'transparent', + type: 'line' + }, title: { text: '' }, @@ -246,7 +258,8 @@ $(document).ready(function() { categories: [], title: { text: '' - } + }, + lineColor: net_line_color }, yAxis: { title: { @@ -254,7 +267,13 @@ $(document).ready(function() { style: { fontWeight: 'normal' } - } + }, + gridLineColor: net_grid_line_color + // labels: { + // style: { + // color: '#ffffff', + // } + // } }, series: [ { @@ -279,6 +298,10 @@ $(document).ready(function() { net_Out1 = [0,0,0,0,0,0,0,0,0,0]; var chartNetInterface2 = Highcharts.chart('container-net-interface-2', { + chart: { + backgroundColor: 'transparent', + type: 'line' + }, title: { text: '' }, @@ -289,7 +312,8 @@ $(document).ready(function() { categories: [], title: { text: '' - } + }, + lineColor: net_line_color }, yAxis: { title: { @@ -297,7 +321,8 @@ $(document).ready(function() { style: { fontWeight: 'normal' } - } + }, + gridLineColor: net_grid_line_color }, series: [ { @@ -321,73 +346,77 @@ $(document).ready(function() { net_In2 = [0,0,0,0,0,0,0,0,0,0]; net_Out2 = [0,0,0,0,0,0,0,0,0,0]; - setInterval(function() { - var date = new Date(); - var year = date.getFullYear(); - var month = date.getMonth(); - var day = date.getDate(); + var interval = setInterval(function() { + // var date = new Date(); + // var year = date.getFullYear(); $.ajaxSetup(csrfAddToAjaxHeader()); $.post('api/device', function(data){ - $("#loading").hide(); - removeUnScroll(); - - $("#login-users").text(data.login_user_count); - $("#hostip").text(data.ip); - $("#hostname").text(data.hostname); - $("#uname").text(data.uname); - $("#system").text(data.system); - // $("#time").text(data.now_time_hms); - // $("#date").text(data.now_time_ymd); - $("#uptime").text(data.uptime); - $("#cpu-temp").text(data.cpu_temperature); - $("#cpu-freq").text(data.cpu_freq); - $("#cpu-stat-idl").text(data.cpu_status_idle); - $("#cpu-stat-use").text(data.cpu_status_user); - $("#cpu-stat-sys").text(data.cpu_status_system); - $("#cpu-stat-nic").text(data.cpu_status_nice); - $("#cpu-stat-iow").text(data.cpu_status_iowait); - $("#cpu-stat-irq").text(data.cpu_status_irq); - $("#cpu-stat-sirq").text(data.cpu_status_softirq); - $("#mem-percent").text(data.memory_percent); - $("#mem-free").text(data.memory_free); - $("#mem-cached").text(data.memory_cached); - $("#mem-swap-total").text(data.swap_total); - $("#mem-cache-percent").text(data.memory_cached_percent); - $("#mem-buffers").text(data.memory_buffers); - $("#mem-real-percent").text(data.memory_real_percent); - $("#mem-real-free").text(data.memory_available); - $("#mem-swap-percent").text(data.swap_used_percent); - $("#mem-swap-free").text(data.swap_free); - $("#disk-percent").text(data.disk_used_percent); - $("#disk-free").text(data.disk_free); - $("#loadavg-1m").text(data.load_average_1m); - $("#loadavg-5m").text(data.load_average_5m); - $("#loadavg-10m").text(data.load_average_15m); - $("#loadavg-running").text(data.load_average_process_running); - $("#loadavg-threads").text(data.load_average_process_total); - - $("#net-interface-1-total-in").text(data.net_status_lo_in_data_format); - $("#net-interface-1-total-out").text(data.net_status_lo_out_data_format); - $("#net-interface-2-total-in").text(data.net_status_in_data_format); - $("#net-interface-2-total-out").text(data.net_status_out_data_format); - - $("#version").text("v" + data.version); - $("#version").attr('data-bs-original-title', "Compiled with " + data.go_version); - - // $("#year").text(new Date().getFullYear()); - - if(window.dashboard != null) - { - window.dashboard_old = window.dashboard; - } - window.dashboard = data; - - }).fail(function() { + if (data.status == "Unauthorized") { $("#loading").show(); - $('#ModalBox').modal('hide'); unScroll(); - }); + clearInterval(interval); + $(window).attr('location','/login'); + } else { + $("#loading").hide(); + removeUnScroll(); + + $("#login-users").text(data.login_user_count); + $("#hostip").text(data.ip); + $("#hostname").text(data.hostname); + $("#uname").text(data.uname); + $("#system").text(data.system); + // $("#time").text(data.now_time_hms); + // $("#date").text(data.now_time_ymd); + $("#uptime").text(data.uptime); + $("#cpu-temp").text(data.cpu_temperature); + $("#cpu-freq").text(data.cpu_freq); + $("#cpu-stat-idl").text(data.cpu_status_idle); + $("#cpu-stat-use").text(data.cpu_status_user); + $("#cpu-stat-sys").text(data.cpu_status_system); + $("#cpu-stat-nic").text(data.cpu_status_nice); + $("#cpu-stat-iow").text(data.cpu_status_iowait); + $("#cpu-stat-irq").text(data.cpu_status_irq); + $("#cpu-stat-sirq").text(data.cpu_status_softirq); + $("#mem-percent").text(data.memory_percent); + $("#mem-free").text(data.memory_free); + $("#mem-cached").text(data.memory_cached); + $("#mem-swap-total").text(data.swap_total); + $("#mem-cache-percent").text(data.memory_cached_percent); + $("#mem-buffers").text(data.memory_buffers); + $("#mem-real-percent").text(data.memory_real_percent); + $("#mem-real-free").text(data.memory_available); + $("#mem-swap-percent").text(data.swap_used_percent); + $("#mem-swap-free").text(data.swap_free); + $("#disk-percent").text(data.disk_used_percent); + $("#disk-free").text(data.disk_free); + $("#loadavg-1m").text(data.load_average_1m); + $("#loadavg-5m").text(data.load_average_5m); + $("#loadavg-10m").text(data.load_average_15m); + $("#loadavg-running").text(data.load_average_process_running); + $("#loadavg-threads").text(data.load_average_process_total); + + $("#net-interface-1-total-in").text(data.net_status_lo_in_data_format); + $("#net-interface-1-total-out").text(data.net_status_lo_out_data_format); + $("#net-interface-2-total-in").text(data.net_status_in_data_format); + $("#net-interface-2-total-out").text(data.net_status_out_data_format); + + $("#version").text("v" + data.version); + $("#version").attr('data-bs-original-title', "Compiled with " + data.go_version); + + // $("#year").text(new Date().getFullYear()); + + if(window.dashboard != null) + { + window.dashboard_old = window.dashboard; + } + window.dashboard = data; + } + }).fail(function() { + $("#loading").show(); + $('#ModalBox').modal('hide'); + unScroll(); + }); if(window.dashboard != null){ var point; @@ -531,6 +560,8 @@ $("#reboot").click(function(){ showModalBox("Reboot Device", '"Reboot Device" requires running Pi Dashboard Go as root user') unScroll(); $("#reboot").css("pointer-events", "auto"); + } else if (data.status == "Unauthorized") { + $(window).attr('location','/login'); } else { showModalBox("Reboot Device", "Unknown Error"); $("#loading").show(); @@ -558,6 +589,8 @@ $("#shutdown").click(function(){ showModalBox("Shutdown Device", '"Shutdown Device" requires running Pi Dashboard Go as root user') unScroll(); $("#shutdown").css("pointer-events", "auto"); + } else if (data.status == "Unauthorized") { + $(window).attr('location','/login'); } else { showModalBox("Shutdown Device", "Unknown Error"); $("#loading").show(); @@ -586,6 +619,8 @@ $("#dropcaches").click(function(){ // $("#loading").show(); // unScroll(); $("#dropcaches").css("pointer-events", "auto"); + } else if (data.status == "Unauthorized") { + $(window).attr('location','/login'); } else { showModalBox("Drop Caches", "Unknown Error"); // $("#loading").show(); diff --git a/server/assets/js/login.js b/server/assets/js/login.js index 39c7674..7e0eba2 100644 --- a/server/assets/js/login.js +++ b/server/assets/js/login.js @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 $("form").keyup(function(event){ if(event.keyCode == 13){ diff --git a/server/assets/views/index.tmpl b/server/assets/views/index.tmpl index cccf3f4..81227e5 100644 --- a/server/assets/views/index.tmpl +++ b/server/assets/views/index.tmpl @@ -6,11 +6,11 @@ - - + + - + @@ -66,18 +66,18 @@
-
Device
+
Device
-
{{.model}}
+
{{.model}}
IP
{{.ip}}
TIME
{{.now_time_hms}}
{{.now_time_ymd}}
UPTIME
{{.uptime}}
-
LOGIN USER(S)
{{.login_user_count}}
+
LOGIN USER(S)
{{.login_user_count}}
-
SYSTEM
{{.system}}
-
HOSTNAME
{{.hostname}}
-
+
SYSTEM
{{.system}}
+
HOSTNAME
{{.hostname}}
+
OPERATION
    @@ -315,7 +315,7 @@ - + + +@Last modification: 2021-08-27 +@Version: 1.5.0 --> \ No newline at end of file diff --git a/server/assets/views/login.tmpl b/server/assets/views/login.tmpl index 81a3826..acc30af 100644 --- a/server/assets/views/login.tmpl +++ b/server/assets/views/login.tmpl @@ -6,11 +6,11 @@ - - + + - + @@ -50,7 +50,7 @@
-
Device
+
Device
@@ -72,14 +72,15 @@
- + + +@Last modification: 2021-08-27 +@Version: 1.5.0 --> \ No newline at end of file diff --git a/server/server.go b/server/server.go index 7c41528..073bbfb 100644 --- a/server/server.go +++ b/server/server.go @@ -2,8 +2,8 @@ // @Description: Golang implementation of pi-dashboard // @Author: github.com/plutobell // @Creation: 2020-08-01 -// @Last modification: 2021-08-24 -// @Version: 1.4.1 +// @Last modification: 2021-08-27 +// @Version: 1.5.0 package server @@ -236,7 +236,7 @@ func API(c echo.Context) error { status := map[string]string{ "status": "Unauthorized", } - return c.JSON(http.StatusUnauthorized, status) + return c.JSON(http.StatusOK, status) } device := device.Info() @@ -259,7 +259,7 @@ func API(c echo.Context) error { status := map[string]string{ "status": "Unauthorized", } - return c.JSON(http.StatusUnauthorized, status) + return c.JSON(http.StatusOK, status) } operation := c.QueryParam("action")