Preserve reboot notices across pages

This commit is contained in:
Andrew Z
2020-01-19 15:57:59 -05:00
parent 986d8e7bdb
commit acc869c739
5 changed files with 87 additions and 29 deletions

View File

@@ -283,6 +283,23 @@ function showUpgrade(data,noDismiss=false) {
osUpgradeWarning = addBannerWarning(data.replace(/<a>(.*)<\/a>/,"<a href='#' onclick='hideUpgrade();openUpgrade();'>$1</a>"),false,noDismiss);
}
}
function addRebootNotice(message="You must reboot for changes to take effect") {
addBannerWarning("<i class='fa fa-warning' style='float:initial;'></i> "+message,false,true);
$.post("/plugins/dynamix.plugin.manager/scripts/PluginAPI.php",{action:'addRebootNotice',message:message});
}
function removeRebootNotice(message="You must reboot for changes to take effect") {
var bannerIndex = bannerWarnings.indexOf("<i class='fa fa-warning' style='float:initial;'></i> "+message);
if ( bannerIndex < 0 ) {
return;
}
console.log(bannerIndex);
removeBannerWarning(bannerIndex);
$.post("/plugins/dynamix.plugin.manager/scripts/PluginAPI.php",{action:'removeRebootNotice',message:message});
}
function hideUpgrade(set) {
removeBannerWarning(osUpgradeWarning);
if (set)
@@ -388,6 +405,21 @@ $.ajaxPrefilter(function(s, orig, xhr){
s.data += "csrf_token=<?=$var['csrf_token']?>";
}
});
// add any pre-existing reboot notices
$(function() {
<?
$rebootNotice = @file("/tmp/reboot_notifications") ?: array();
foreach ($rebootNotice as $notice):
?>
var rebootMessage = "<?=trim($notice)?>";
if ( rebootMessage ) {
addBannerWarning("<i class='fa fa-warning' style='float:initial;'></i> "+rebootMessage,false,true);
}
<?
endforeach;
?>
});
</script>
</head>
<body>