2014-08-17 22:43:57 +00:00
< h2 > System Status Checks< / h2 >
2016-02-25 20:56:27 +00:00
< div id = "system-reboot-required" style = "display: none" >
< button type = "button" class = "btn btn-danger" onclick = "confirm_reboot(); return false;" > Reboot required< / button >
< / div >
2014-08-17 22:43:57 +00:00
< style >
#system-checks .heading td {
font-weight: bold;
font-size: 120%;
padding-top: 1.5em;
}
#system-checks .heading.first td {
border-top: none;
padding-top: 0;
}
2014-10-07 20:41:07 +00:00
#system-checks .status-error td {
2014-08-17 22:43:57 +00:00
color: #733;
}
2014-10-07 20:41:07 +00:00
#system-checks .status-warning td {
color: #770;
}
#system-checks .status-ok td {
color: #040;
2014-08-17 22:43:57 +00:00
}
#system-checks div.extra {
display: none;
margin-top: 1em;
max-width: 50em;
word-wrap: break-word;
}
#system-checks a.showhide {
display: none;
font-size: 85%;
}
#system-checks .pre {
margin: 1em;
font-family: monospace;
white-space: pre-wrap;
}
2016-02-25 20:56:27 +00:00
#system-reboot-required {
max-width: 20em;
margin-bottom: 1em;
}
2015-08-28 12:29:55 +00:00
#system-privacy-setting {
float: right;
max-width: 20em;
margin-bottom: 1em;
}
2014-08-17 22:43:57 +00:00
< / style >
2015-08-28 12:29:55 +00:00
< div id = "system-privacy-setting" style = "display: none" >
< div > < a onclick = "return enable_privacy(!current_privacy_setting)" href = "#" > < span > Enable/Disable< / span > New-Version Check< / a > < / div >
< p style = "line-height: 125%" > < small > (When enabled, status checks phone-home to check for a new release of Mail-in-a-Box.)< / small > < / p >
< / div >
2014-08-17 22:43:57 +00:00
< table id = "system-checks" class = "table" style = "max-width: 60em" >
< thead >
< / thead >
< tbody >
< / tbody >
< / table >
< script >
function show_system_status() {
$('#system-checks tbody').html("< tr > < td colspan = '2' class = 'text-muted' > Loading...< / td > < / tr > ")
2015-08-28 12:29:55 +00:00
api(
"/system/privacy",
"GET",
{ },
function(r) {
current_privacy_setting = r;
$('#system-privacy-setting').show();
$('#system-privacy-setting a span').text(r ? "Enable" : "Disable");
$('#system-privacy-setting p').toggle(r);
});
2016-02-25 20:56:27 +00:00
api(
"/system/reboot",
"GET",
{ },
function(r) {
$('#system-reboot-required').toggle(r);
});
2014-08-17 22:43:57 +00:00
api(
"/system/status",
"POST",
{ },
function(r) {
$('#system-checks tbody').html("");
for (var i = 0; i < r.length ; i + + ) {
var n = $("< tr > < td class = 'status' / > < td class = 'message' > < p style = 'margin: 0' / > < div class = 'extra' / > < a class = 'showhide' href = '#' / > < / tr > ");
if (i == 0) n.addClass('first')
2014-10-07 20:41:07 +00:00
if (r[i].type == "heading")
n.addClass(r[i].type)
else
n.addClass("status-" + r[i].type)
2014-08-17 22:43:57 +00:00
if (r[i].type == "ok") n.find('td.status').text("✓")
if (r[i].type == "error") n.find('td.status').text("✖")
2014-10-07 20:41:07 +00:00
if (r[i].type == "warning") n.find('td.status').text("?")
2014-08-17 22:43:57 +00:00
n.find('td.message p').text(r[i].text)
$('#system-checks tbody').append(n);
if (r[i].extra.length > 0) {
n.find('a.showhide').show().text("show more").click(function() {
$(this).hide();
$(this).parent().find('.extra').fadeIn();
return false;
});
}
for (var j = 0; j < r [ i ] . extra . length ; j + + ) {
var m = $("< div / > ").text(r[i].extra[j].text)
if (r[i].extra[j].monospace)
m.addClass("pre");
n.find('> td.message > div').append(m);
}
}
})
2015-08-28 12:29:55 +00:00
2014-08-17 22:43:57 +00:00
}
2015-08-28 12:29:55 +00:00
var current_privacy_setting = null;
function enable_privacy(status) {
2015-07-25 11:47:10 +00:00
api(
2015-08-28 12:29:55 +00:00
"/system/privacy",
"POST",
{
value: (status ? "private" : "off")
},
function(res) {
show_system_status();
});
return false; // disable link
2015-07-25 11:47:10 +00:00
}
2016-02-25 20:56:27 +00:00
function confirm_reboot() {
show_modal_confirm(
"Reboot server",
$("< p > This will reboot your server, until the server is fully restarted your users will not be able to send and receive email. The reboot can't be cancelled< / p > "),
"Reboot now",
function() {
api(
"/system/reboot",
"POST",
{ },
function(r) {
show_modal_error("Reboot", "Please refresh the page after a minute or so." + r);
});
});
}
2014-10-07 20:41:07 +00:00
< / script >