diff options
author | Simon Rettberg | 2017-12-22 14:25:01 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-22 14:25:01 +0100 |
commit | cffcbd0dff64c7d512d35eef8863f0cdfe5b0d6f (patch) | |
tree | 9fd76addeeb30890282f0d51113c6de52cd99f91 /modules-available/sysconfig | |
parent | [sysconfig] Fix home directory attribute detection (diff) | |
download | slx-admin-cffcbd0dff64c7d512d35eef8863f0cdfe5b0d6f.tar.gz slx-admin-cffcbd0dff64c7d512d35eef8863f0cdfe5b0d6f.tar.xz slx-admin-cffcbd0dff64c7d512d35eef8863f0cdfe5b0d6f.zip |
[sysconfig] Restore long lost ajax functionality
If any modules need rebuild, we can now successfully query their status
while the page is displayed and change the refresh button color
to white once an ongoing rebuild is complete.
Diffstat (limited to 'modules-available/sysconfig')
-rw-r--r-- | modules-available/sysconfig/clientscript.js | 2 | ||||
-rw-r--r-- | modules-available/sysconfig/page.inc.php | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/modules-available/sysconfig/clientscript.js b/modules-available/sysconfig/clientscript.js index f3a47824..1553d678 100644 --- a/modules-available/sysconfig/clientscript.js +++ b/modules-available/sysconfig/clientscript.js @@ -98,7 +98,7 @@ function checkBuildStatus() { confs.push($(this).val()); }); if (mods.length === 0 && confs.length === 0) return; - if (++statusChecks < 10) setTimeout(checkBuildStatus, 200 + 50 * statusChecks); + if (++statusChecks < 10) setTimeout(checkBuildStatus, 150 + 100 * statusChecks); $.post('?do=SysConfig', { mods: mods.join(), confs: confs.join(), token: TOKEN, action: 'status' }, function (data) { if (typeof data === 'undefined') return; if (typeof data.mods === 'object') updateButtonColor($(".refmod.btn-primary"), data.mods); diff --git a/modules-available/sysconfig/page.inc.php b/modules-available/sysconfig/page.inc.php index 8053ab43..30271514 100644 --- a/modules-available/sysconfig/page.inc.php +++ b/modules-available/sysconfig/page.inc.php @@ -479,4 +479,36 @@ class Page_SysConfig extends Page AddConfig_Base::setStep($step); } + /** + * If modules need updates (blue refresh buttons), we query their state + * via ajax, in case they are about to generate. This happens for example + * if you edit a module and a bunch of configs depend on it and will be + * rebuilt. + */ + protected function doAjax() + { + if (Request::post('action') === 'status') { + $mods = Request::post('mods'); + $confs = Request::post('confs'); + $outMods = array(); + $outConfs = array(); + $mods = explode(',', $mods); + $confs = explode(',', $confs); + // Mods + $res = Database::simpleQuery("SELECT moduleid FROM configtgz_module + WHERE moduleid in (:mods) AND status = 'OK'", compact('mods')); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $outMods[] = $row['moduleid']; + } + // Confs + $res = Database::simpleQuery("SELECT configid FROM configtgz + WHERE configid in (:confs) AND status = 'OK'", compact('confs')); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $outConfs[] = $row['configid']; + } + Header('Content-Type: application/json'); + die(json_encode(array('mods' => $outMods, 'confs' => $outConfs))); + } + } + } |