mirror of
https://github.com/unraid/webgui.git
synced 2026-03-07 01:30:59 -06:00
Get rid of 'heartbeat' event.
Footer status now updated via websocket.
This commit is contained in:
@@ -545,8 +545,8 @@ function toggle_net(init) {
|
||||
}
|
||||
function parseINI(data){
|
||||
var regex = {
|
||||
section: /^\s*\[\s*([^\]]*)\s*\]\s*$/,
|
||||
param: /^\s*([^=]+?)\s*=\s*(.*?)\s*$/,
|
||||
section: /^\s*\[\s*\"*([^\]]*)\s*\"*\]\s*$/,
|
||||
param: /^\s*([^=]+?)\s*=\s*\"*(.*?)\s*\"*$/,
|
||||
comment: /^\s*;.*$/
|
||||
};
|
||||
var value = {};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?PHP
|
||||
// todo: this should generate/publish json-encoded string and let subscriber handle html
|
||||
require_once "/usr/local/emhttp/webGui/include/publish.php";
|
||||
$var = @parse_ini_file("/var/local/emhttp/var.ini");
|
||||
$fsState=$var['fsState'];
|
||||
if ($fsState == "Stopped")
|
||||
$state = "<span class='red strong'>Array Stopped</span>";
|
||||
elseif ($fsState == "Starting")
|
||||
$state = "<span class='orange strong'>Array Starting</span>";
|
||||
else {
|
||||
$state = "<span class='green strong'>Array Started</span>";
|
||||
$mdResync = $var['mdResync'];
|
||||
if ($mdResync > 0) {
|
||||
$mdResyncAction = $var['mdResyncAction'];
|
||||
if (strstr($mdResyncAction, "recon")) $action="Parity-Sync / Data-Rebuild";
|
||||
elseif (strstr($mdResyncAction, "clear")) $action="Clearing";
|
||||
elseif ($mdResyncAction == "check") $action="Read-Check";
|
||||
elseif (strstr($mdResyncAction, "check")) $action="Parity-Check";
|
||||
$mdResyncPos = $var['mdResyncPos'];
|
||||
$progress = number_format($mdResyncPos/($mdResync/100+1),1);
|
||||
$state .= "•<span class='orange strong'>$action $progress %</span>";
|
||||
}
|
||||
}
|
||||
publish("watchdog", $state);
|
||||
?>
|
||||
@@ -395,6 +395,35 @@ echo " <a href='http://lime-technology.com/wiki/index.php/Official_Documentation
|
||||
echo "</span></div>";
|
||||
?>
|
||||
<script>
|
||||
function parseINI(data){
|
||||
var regex = {
|
||||
section: /^\s*\[\s*\"*([^\]]*)\s*\"*\]\s*$/,
|
||||
param: /^\s*([^=]+?)\s*=\s*\"*(.*?)\s*\"*$/,
|
||||
comment: /^\s*;.*$/
|
||||
};
|
||||
var value = {};
|
||||
var lines = data.split(/[\r\n]+/);
|
||||
var section = null;
|
||||
lines.forEach(function(line){
|
||||
if(regex.comment.test(line)){
|
||||
return;
|
||||
}else if(regex.param.test(line)){
|
||||
var match = line.match(regex.param);
|
||||
if(section){
|
||||
value[section][match[1]] = match[2];
|
||||
}else{
|
||||
value[match[1]] = match[2];
|
||||
}
|
||||
}else if(regex.section.test(line)){
|
||||
var match = line.match(regex.section);
|
||||
value[match[1]] = {};
|
||||
section = match[1];
|
||||
}else if(line.length == 0 && section){
|
||||
section = null;
|
||||
};
|
||||
});
|
||||
return value;
|
||||
}
|
||||
$(function() {
|
||||
<?if ($notify['entity'] & 1 == 1):?>
|
||||
$.post('/webGui/include/Notify.php',{cmd:'init'},function(){timers.notifier = setTimeout(notifier,0);});
|
||||
@@ -470,8 +499,29 @@ $(function() {
|
||||
}
|
||||
|
||||
$('form').append($('<input>').attr({type:'hidden', name:'csrf_token', value:'<?=$var['csrf_token']?>'}));
|
||||
var watchdog = new NchanSubscriber('/sub/watchdog');
|
||||
watchdog.on('message', function(data){$('#statusbar').html(data);});
|
||||
|
||||
var watchdog = new NchanSubscriber('/sub/var');
|
||||
watchdog.on('message', function(data){
|
||||
var ini=parseINI(data);
|
||||
var status;
|
||||
if (ini['fsState']=="Stopped") {
|
||||
status="<span class='red strong'>Array Stopped</span>";
|
||||
}else if (ini['fsState']=="Starting") {
|
||||
status="<span class='orange strong'>Array Starting</span>";
|
||||
}else {
|
||||
status="<span class='green strong'>Array Started</span>";
|
||||
if (ini['mdResync'] > 0) {
|
||||
var action;
|
||||
if (ini['mdResyncAction'].indexOf("recon")) action="Parity-Sync / Data-Rebuild";
|
||||
else if (ini['mdResyncAction'].indexOf("clear")) action="Clearing";
|
||||
else if (ini['mdResyncAction'] == "check") action="Read-Check";
|
||||
else if (ini['mdResyncAction'].indexOf("check")) action="Parity-Check";
|
||||
action += " " + (ini['mdResyncPos']/(ini['mdResync']/100+1)).toFixed(1) + " %";
|
||||
status += "•<span class='orange strong'>"+action+"</span>";
|
||||
}
|
||||
}
|
||||
$('#statusbar').html(status);
|
||||
});
|
||||
watchdog.start();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user