summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-11-17 13:07:09 +0100
committerSimon Rettberg2020-11-17 13:07:09 +0100
commit9c2c64312771673012b3143a073bb6c227f4745f (patch)
treea9ac2e401217be2fecc0328e41bbf26eab7413f6
parent[style/default.css] Fix margin/padding of slx-ellipsis hack (diff)
downloadslx-admin-9c2c64312771673012b3143a073bb6c227f4745f.tar.gz
slx-admin-9c2c64312771673012b3143a073bb6c227f4745f.tar.xz
slx-admin-9c2c64312771673012b3143a073bb6c227f4745f.zip
[sysconfig] Dynamically update warnings button
As we use AJAX to query build state for configs that don't have state === 'OK', the warnings list might be out of date. Hide the warnings button for all modules that aren't up to date, and dynamically load their warnings. The warnings button will be shown when the module finished building, assuming any warnings were generated.
-rw-r--r--modules-available/sysconfig/clientscript.js38
-rw-r--r--modules-available/sysconfig/page.inc.php13
-rw-r--r--modules-available/sysconfig/templates/list-configs.html16
-rw-r--r--modules-available/sysconfig/templates/list-modules.html8
4 files changed, 35 insertions, 40 deletions
diff --git a/modules-available/sysconfig/clientscript.js b/modules-available/sysconfig/clientscript.js
index cafe7b02..a9b85251 100644
--- a/modules-available/sysconfig/clientscript.js
+++ b/modules-available/sysconfig/clientscript.js
@@ -5,7 +5,7 @@
var boldItem = false;
var revList = false;
- var $ct = $('#conftable').find('.confrow');
+ var $ct = $('#conftable').find('.confrow .title');
$ct.click(function () {
showmod(this, 'bold');
}).mouseenter(function () {
@@ -13,7 +13,7 @@
}).mouseleave(function () {
showmod(this, 'reset');
});
- var $mt = $('#modtable').find('.modrow');
+ var $mt = $('#modtable').find('.modrow .title');
$mt.click(function () {
showconf(this, 'bold');
}).mouseenter(function () {
@@ -33,7 +33,7 @@
var $msgs = $confirm.find('ul').empty();
for (var i = 0; i < list.length; ++i) {
$msgs.append($('<li>').text(
- $('.confrow[data-id="' + list[i] + '"]').text()
+ $('.confrow[data-id="' + list[i] + '"] .title').text()
));
}
$confirm.removeClass('hidden');
@@ -56,7 +56,7 @@
function buildRevList() {
revList = {};
$ct.each(function () {
- var elem = $(this);
+ var elem = $(this).parent();
var cid = elem.data('id') + '';
var list = (elem.data('modlist') + '').split(',');
for (var i = 0; i < list.length; ++i) {
@@ -71,11 +71,11 @@
if (action === 'reset') return;
var $e = $(e);
if (!revList) buildRevList();
- var mid = $e.data('id') + '';
+ var mid = $e.parent().data('id') + '';
var list = revList[mid];
if (list && list.length > 0) $ct.each(function () {
var elem = $(this);
- var cid = elem.data('id') + '';
+ var cid = elem.parent().data('id') + '';
if (list.indexOf(cid) === -1)
elem.addClass('slx-fade');
else if (action === 'bold')
@@ -91,10 +91,10 @@
action = showpre(e, action);
if (action === 'reset') return;
var $e = $(e);
- var list = ($e.data('modlist') + '').split(',');
+ var list = ($e.parent().data('modlist') + '').split(',');
$mt.each(function () {
var elem = $(this);
- if (list.indexOf(elem.data('id') + '') === -1)
+ if (list.indexOf(elem.parent().data('id') + '') === -1)
elem.addClass("slx-fade");
else if (action === 'bold')
elem.addClass("slx-bold");
@@ -113,23 +113,29 @@ var statusChecks = 0;
function checkBuildStatus() {
var mods = [];
var confs = [];
- $(".refmod.btn-primary").each(function (index) {
+ $(".modrow .btn-rebuild.btn-primary").each(function (index) {
mods.push($(this).val());
});
- $(".refconf.btn-primary").each(function (index) {
+ $(".confrow .btn-rebuild.btn-primary").each(function (index) {
confs.push($(this).val());
});
if (mods.length === 0 && confs.length === 0) return;
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);
- if (typeof data.confs === 'object') updateButtonColor($(".refconf.btn-primary"), data.confs);
+ if (typeof data.mods === 'object') updateButtonColor('.modrow', data.mods);
+ if (typeof data.confs === 'object') updateButtonColor('.confrow', data.confs);
}, 'json');
}
-function updateButtonColor(list,ids) {
- list.each(function() {
- if (ids.indexOf($(this).val()) >= 0) $(this).removeClass('btn-primary').addClass('btn-default');
- });
+function updateButtonColor(rowclass,ids) {
+ for (var i = 0; i < ids.length; ++i) {
+ var e = ids[i];
+ var $row = $(rowclass + '[data-id=' + e.id + ']');
+ $row.find('.btn-rebuild').removeClass('btn-primary').addClass('btn-default');
+ if (e.warnings && (typeof e.warnings === 'string') && e.warnings.length > 0) {
+ $row.find('.row-warnings').text(e.warnings);
+ $row.find('.btn-warnings').removeClass('hidden');
+ }
+ }
}
diff --git a/modules-available/sysconfig/page.inc.php b/modules-available/sysconfig/page.inc.php
index ede80aa7..1ef478b3 100644
--- a/modules-available/sysconfig/page.inc.php
+++ b/modules-available/sysconfig/page.inc.php
@@ -209,6 +209,7 @@ class Page_SysConfig extends Page
}
$configs[] = array(
'warnings' => $row['warnings'],
+ 'warnings_hidden' => (!empty($row['warnings']) && $row['status'] === 'OK') ? '' : 'hidden',
'configid' => $row['configid'],
'config' => $row['title'],
'modlist' => $row['modlist'],
@@ -482,22 +483,14 @@ class Page_SysConfig extends Page
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
+ $outMods = Database::queryAll("SELECT moduleid AS id 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
+ $outConfs = Database::queryAll("SELECT configid AS id, warnings 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)));
}
diff --git a/modules-available/sysconfig/templates/list-configs.html b/modules-available/sysconfig/templates/list-configs.html
index b5367f8b..1370155f 100644
--- a/modules-available/sysconfig/templates/list-configs.html
+++ b/modules-available/sysconfig/templates/list-configs.html
@@ -20,21 +20,17 @@
<input type="hidden" name="locationid" value="{{locationid}}">
<table id="conftable" class="slx-table table-hover" style="width:100%">
{{#configs}}
- <tr>
- <td data-id="{{configid}}" data-modlist="{{modlist}}" class="confrow slx-pointer" width="100%" title="{{dateline_s}}">
+ <tr data-id="{{configid}}" data-modlist="{{modlist}}" class="confrow">
+ <td class="title slx-pointer" width="100%" title="{{dateline_s}}">
<table class="slx-ellipsis"><tr><td>
- {{#warnings}}
- <button type="button" class="btn btn-xs btn-default" data-confirm="#confirm-mod-{{configid}}">
+ <button type="button" class="btn btn-xs btn-default btn-warnings {{warnings_hidden}}" data-confirm="#confirm-mod-{{configid}}">
<span class="glyphicon glyphicon-exclamation-sign text-danger"></span>
</button>
- {{/warnings}}
{{config}}
</td></tr></table>
</td>
<td>
- {{#warnings}}
- <pre id="confirm-mod-{{configid}}" class="hidden">{{.}}</pre>
- {{/warnings}}
+ <pre id="confirm-mod-{{configid}}" class="hidden row-warnings">{{warnings}}</pre>
{{^current}}
<button class="btn btn-primary btn-xs" name="activate" value="{{configid}}" {{perms.config.assign.disabled}}>
<span class="glyphicon glyphicon-flag"></span>
@@ -59,10 +55,10 @@
{{^locationid}}
<button
{{#needrebuild}}
- class="refconf btn btn-primary btn-xs"
+ class="btn-rebuild btn btn-primary btn-xs"
{{/needrebuild}}
{{^needrebuild}}
- class="refconf btn btn-default btn-xs"
+ class="btn-rebuild btn btn-default btn-xs"
{{/needrebuild}}
name="rebuild" value="{{configid}}" title="{{lang_rebuild}}"
{{perms.config.edit.disabled}}>
diff --git a/modules-available/sysconfig/templates/list-modules.html b/modules-available/sysconfig/templates/list-modules.html
index b8783c59..9284bb24 100644
--- a/modules-available/sysconfig/templates/list-modules.html
+++ b/modules-available/sysconfig/templates/list-modules.html
@@ -10,9 +10,9 @@
<input type="hidden" name="action" value="module">
<table id="modtable" class="slx-table table-hover" style="width:100%">
{{#modules}}
- <tr>
+ <tr data-id="{{id}}" class="modrow">
<td class="badge text-nowrap">{{moduleType}}</td>
- <td data-id="{{id}}" class="modrow slx-pointer" width="100%" title="{{lang_lastEdited}} {{dateline_s}}">
+ <td class="title slx-pointer" width="100%" title="{{lang_lastEdited}} {{dateline_s}}">
<table class="slx-ellipsis"><tr><td>{{title}}</td></tr></table>
</td>
<td class="text-nowrap">
@@ -27,10 +27,10 @@
<td class="text-nowrap">
<button
{{#needRebuild}}
- class="refmod btn btn-primary btn-xs"
+ class="btn-rebuild btn btn-primary btn-xs"
{{/needRebuild}}
{{^needRebuild}}
- class="refmod btn btn-default btn-xs"
+ class="btn-rebuild btn btn-default btn-xs"
{{/needRebuild}}
name="rebuild" value="{{id}}" title="{{lang_rebuild}}" {{perms.module.edit.disabled}}>
<span class="glyphicon glyphicon-refresh"></span>