From abe781507604c875eab9a52142b8dc2725e0e594 Mon Sep 17 00:00:00 2001 From: tom mortensen Date: Fri, 24 Jan 2020 16:32:10 -0800 Subject: [PATCH] Revert "Preserve reboot notices across GUI pages" --- .../scripts/PluginAPI.php | 72 +++++++------------ plugins/dynamix.vm.manager/VMSettings.page | 5 +- plugins/dynamix/CPUisol.page | 1 + plugins/dynamix/CPUvms.page | 3 +- plugins/dynamix/include/DefaultPageLayout.php | 39 +--------- 5 files changed, 33 insertions(+), 87 deletions(-) diff --git a/plugins/dynamix.plugin.manager/scripts/PluginAPI.php b/plugins/dynamix.plugin.manager/scripts/PluginAPI.php index 7aa3a976f..b3b0974e3 100644 --- a/plugins/dynamix.plugin.manager/scripts/PluginAPI.php +++ b/plugins/dynamix.plugin.manager/scripts/PluginAPI.php @@ -31,55 +31,35 @@ function download_url($url, $path = "") { return $out ?: false; } -switch ($_POST['action']) { - case 'checkPlugin': - $options = $_POST['options']; - $plugin = $options['plugin']; +$options = $_POST['options']; +$plugin = $options['plugin']; - if ( ! $plugin || ! file_exists("/var/log/plugins/$plugin") ) { - echo json_encode(array("updateAvailable"=>false)); - break; - } +if ( ! $plugin || ! file_exists("/var/log/plugins/$plugin") ) { + echo json_encode(array("updateAvailable"=>false)); + return; +} - exec("mkdir -p /tmp/plugins"); - @unlink("/tmp/plugins/$plugin"); - $url = @plugin("pluginURL","/boot/config/plugins/$plugin"); - download_url($url,"/tmp/plugins/$plugin"); +exec("mkdir -p /tmp/plugins"); +@unlink("/tmp/plugins/$plugin"); +$url = @plugin("pluginURL","/boot/config/plugins/$plugin"); +download_url($url,"/tmp/plugins/$plugin"); - $changes = @plugin("changes","/tmp/plugins/$plugin"); - $version = @plugin("version","/tmp/plugins/$plugin"); - $installedVersion = @plugin("version","/boot/config/plugins/$plugin"); - $min = @plugin("min","/tmp/plugins/$plugin") ?: "6.4.0"; - if ( $changes ) { - file_put_contents("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt",$changes); - } else { - @unlink("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt"); - } +$changes = @plugin("changes","/tmp/plugins/$plugin"); +$version = @plugin("version","/tmp/plugins/$plugin"); +$installedVersion = @plugin("version","/boot/config/plugins/$plugin"); +$min = @plugin("min","/tmp/plugins/$plugin") ?: "6.4.0"; +if ( $changes ) { + file_put_contents("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt",$changes); +} else { + @unlink("/tmp/plugins/".pathinfo($plugin, PATHINFO_FILENAME).".txt"); +} - $update = false; - if ( strcmp($version,$installedVersion) > 0 ) { - $unraid = parse_ini_file("/etc/unraid-version"); - $update = (version_compare($min,$unraid['version'],">")) ? false : true; - } +$update = false; +if ( strcmp($version,$installedVersion) > 0 ) { + $unraid = parse_ini_file("/etc/unraid-version"); + $update = (version_compare($min,$unraid['version'],">")) ? false : true; +} + +echo json_encode(array("updateAvailable" => $update,"version" => $version,"min"=>$min,"changes"=>$changes,"installedVersion"=>$installedVersion)); - echo json_encode(array("updateAvailable" => $update,"version" => $version,"min"=>$min,"changes"=>$changes,"installedVersion"=>$installedVersion)); - break; - - case 'addRebootNotice': - $message = htmlspecialchars(trim($_POST['message'])); - if (!$message) break; - - $existing = @file("/tmp/reboot_notifications",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: array(); - $existing[] = $message; - - file_put_contents("/tmp/reboot_notifications",implode("\n",array_unique($existing))); - break; - - case 'removeRebootNotice': - $message = htmlspecialchars(trim($_POST['message'])); - $existing = file_get_contents("/tmp/reboot_notifications"); - $newReboots = str_replace($message,"",$existing); - file_put_contents("/tmp/reboot_notifications",$newReboots); - break; -} ?> diff --git a/plugins/dynamix.vm.manager/VMSettings.page b/plugins/dynamix.vm.manager/VMSettings.page index 22138943a..15641ba7a 100644 --- a/plugins/dynamix.vm.manager/VMSettings.page +++ b/plugins/dynamix.vm.manager/VMSettings.page @@ -232,6 +232,8 @@ VFIO allow unsafe interrupts: : + + > View the log for libvirt: /var/log/libvirt/libvirtd.log @@ -444,8 +446,7 @@ $(function(){ }); } $.post("/plugins/dynamix.vm.manager/include/VMajax.php", {action:'reboot'}, function(data){ - var rebootMessage = "VM Settings: A reboot is required to apply changes"; - if (data.modified) addRebootNotice(rebootMessage); else removeRebootNotice(rebootMessage); + if (data.modified) $('div.notice.reboot').show(); else $('div.notice.reboot').hide(); }); }); diff --git a/plugins/dynamix/CPUisol.page b/plugins/dynamix/CPUisol.page index f9e75a07e..c2825377a 100644 --- a/plugins/dynamix/CPUisol.page +++ b/plugins/dynamix/CPUisol.page @@ -23,6 +23,7 @@ Tag="icon-cpu" +
CPU isolation is prohibited while system is running in SAFE MODE!
diff --git a/plugins/dynamix/CPUvms.page b/plugins/dynamix/CPUvms.page index 725dd3dbd..e6f3d4b9e 100644 --- a/plugins/dynamix/CPUvms.page +++ b/plugins/dynamix/CPUvms.page @@ -152,9 +152,8 @@ function is() { } function notice() { // notice to reboot system after changes - var message = "CPU Isolation: A reboot is required to apply changes"; $.post('/webGui/include/CPUset.php',{id:'cmd'},function(d){ - if (d==1) addRebootNotice(message); else removeRebootNotice(message); + if (d==1) $('div.notice.isol').show(); else $('div.notice.isol').hide(); }); } function reset(form) { diff --git a/plugins/dynamix/include/DefaultPageLayout.php b/plugins/dynamix/include/DefaultPageLayout.php index f367a6ab3..28b4321a2 100644 --- a/plugins/dynamix/include/DefaultPageLayout.php +++ b/plugins/dynamix/include/DefaultPageLayout.php @@ -227,15 +227,11 @@ function addBannerWarning(text,warning=true,noDismiss=false) { if ( warning ) { text = " "+text; } - + var arrayEntry = bannerWarnings.push("placeholder") - 1; if ( ! noDismiss ) { text = text + ""; } - if ( bannerWarnings.indexOf(text) < 0 ) { - var arrayEntry = bannerWarnings.push("placeholder") - 1; - bannerWarnings[arrayEntry] = text; - } else return bannerWarnings.indexOf(text); - + bannerWarnings[arrayEntry] = text; if ( ! bannerWarningInterval ) { showBannerWarnings(); bannerWarningInterval = setInterval(function() { @@ -287,22 +283,6 @@ function showUpgrade(data,noDismiss=false) { osUpgradeWarning = addBannerWarning(data.replace(/(.*)<\/a>/,"$1"),false,noDismiss); } } - -function addRebootNotice(message="You must reboot for changes to take effect") { - addBannerWarning(" "+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(" "+message); - if ( bannerIndex < 0 ) { - return; - } - console.log("banner index: "+bannerIndex); - removeBannerWarning(bannerIndex); - $.post("/plugins/dynamix.plugin.manager/scripts/PluginAPI.php",{action:'removeRebootNotice',message:message}); -} - function hideUpgrade(set) { removeBannerWarning(osUpgradeWarning); if (set) @@ -408,21 +388,6 @@ $.ajaxPrefilter(function(s, orig, xhr){ s.data += "csrf_token="; } }); - -// add any pre-existing reboot notices -$(function() { - - var rebootMessage = ""; - if ( rebootMessage ) { - addBannerWarning(" "+rebootMessage,false,true); - } - -});