summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apis/taskmanager.inc.php1
-rw-r--r--inc/up_json_encode.php7
-rw-r--r--lang/de/messages.json1
-rw-r--r--lang/en/messages.json1
-rw-r--r--modules/sysconfig.inc.php35
-rw-r--r--modules/sysconfig/addmodule.inc.php2
-rw-r--r--modules/sysconfig/addmodule_branding.inc.php2
-rw-r--r--modules/sysconfig/addmodule_custommodule.inc.php27
-rw-r--r--script/custom.js19
-rw-r--r--templates/sysconfig/_page.html34
-rw-r--r--templates/sysconfig/custom-fileselect.html3
-rw-r--r--templates/sysconfig/custom-upload.html1
12 files changed, 116 insertions, 17 deletions
diff --git a/apis/taskmanager.inc.php b/apis/taskmanager.inc.php
index 102352d2..c7cdb881 100644
--- a/apis/taskmanager.inc.php
+++ b/apis/taskmanager.inc.php
@@ -32,4 +32,5 @@ foreach ($_POST['ids'] as $id) {
}
}
+Header('Content-Type: application/json');
echo json_encode(array('tasks' => $return));
diff --git a/inc/up_json_encode.php b/inc/up_json_encode.php
index 28556923..c33cb012 100644
--- a/inc/up_json_encode.php
+++ b/inc/up_json_encode.php
@@ -1,5 +1,10 @@
<?php
+if (defined('JSON_PRETTY_PRINT'))
+ define('JSON_NATIVE', true);
+else
+ define('JSON_NATIVE', false);
+
/**
* api: php
* title: upgrade.php
@@ -78,6 +83,8 @@ if (!defined("JSON_UNESCAPED_SLASHES")) {
function up_json_encode($var, $options = 0, $_indent = "")
{
+ if (defined('JSON_NATIVE') && JSON_NATIVE)
+ return json_encode($var, $options);
global ${'.json_last_error'};
${'.json_last_error'} = JSON_ERROR_NONE;
diff --git a/lang/de/messages.json b/lang/de/messages.json
index b344fd41..c9b25b31 100644
--- a/lang/de/messages.json
+++ b/lang/de/messages.json
@@ -41,6 +41,7 @@
"reboot-unconfirmed": "Sicherheitsabfrage zum Reboot nicht best\u00e4tigt",
"remote-parse-failed": "Parsen der empfangenen Daten fehlgeschlagen ({{0}})",
"remote-timeout": "Konnte Ressource {{0}} nicht herunterladen ({{1}})",
+ "replacing-module": "Ersetzen von Modul {{0}}",
"restore-done": "Wiederherstellung abgeschlossen",
"settings-updated": "Einstellungen wurden aktualisiert",
"task-error": "Ausf\u00fchrung fehlgeschlagen: {{0}}",
diff --git a/lang/en/messages.json b/lang/en/messages.json
index 889b5406..2e9263ac 100644
--- a/lang/en/messages.json
+++ b/lang/en/messages.json
@@ -41,6 +41,7 @@
"reboot-unconfirmed": "Confirmation prompt to reboot not confirmed",
"remote-parse-failed": "Parsing the received data failed ({{0}})",
"remote-timeout": "Could not download resource {{0}} ({{1}})",
+ "replacing-module": "Replace module {{0}}",
"restore-done": "Restore done",
"settings-updated": "Settings have been updated",
"task-error": "Execution failed: {{0}}",
diff --git a/modules/sysconfig.inc.php b/modules/sysconfig.inc.php
index e9b7e677..8c08af4f 100644
--- a/modules/sysconfig.inc.php
+++ b/modules/sysconfig.inc.php
@@ -91,6 +91,41 @@ class Page_SysConfig extends Page
}
Message::addError('invalid-action', $action);
}
+
+ protected function doAjax()
+ {
+ if (Request::post('action') === 'status') {
+ $mods = Request::post('mods');
+ $confs = Request::post('confs');
+ error_log('Hit. Mods: ' . $mods . ', Confs: ' . $confs);
+ $outMods = array();
+ $outConfs = array();
+ $mods = explode(',', $mods);
+ $confs = explode(',', $confs);
+ // Mods
+ $string = '0';
+ foreach ($mods as $mod) {
+ if (is_numeric($mod))
+ $string .= ',' . $mod;
+ }
+ $res = Database::simpleQuery("SELECT moduleid FROM configtgz_module WHERE moduleid in ($string) AND status = 'OK'");
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $outMods[] = $row['moduleid'];
+ }
+ // Confs
+ $string = '0';
+ foreach ($confs as $conf) {
+ if (is_numeric($conf))
+ $string .= ',' . $conf;
+ }
+ $res = Database::simpleQuery("SELECT configid FROM configtgz WHERE configid in ($string) AND status = 'OK'");
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $outConfs[] = $row['configid'];
+ }
+ Header('Content-Type: application/json');
+ die(json_encode(array('mods' => $outMods, 'confs' => $outConfs)));
+ }
+ }
/**
* List all configurations and configuration modules.
diff --git a/modules/sysconfig/addmodule.inc.php b/modules/sysconfig/addmodule.inc.php
index 5e9ecb3a..31f3823a 100644
--- a/modules/sysconfig/addmodule.inc.php
+++ b/modules/sysconfig/addmodule.inc.php
@@ -100,6 +100,8 @@ abstract class AddModule_Base
if (self::$instance === false) {
Util::traceError('No step instance yet');
}
+ if (self::$instance->edit !== false)
+ Message::addInfo('replacing-module', self::$instance->edit->title ());
self::$instance->renderInternal();
}
diff --git a/modules/sysconfig/addmodule_branding.inc.php b/modules/sysconfig/addmodule_branding.inc.php
index 527b2e7b..7fc7abc5 100644
--- a/modules/sysconfig/addmodule_branding.inc.php
+++ b/modules/sysconfig/addmodule_branding.inc.php
@@ -58,7 +58,7 @@ class Branding_ProcessFile extends AddModule_Base
'tarFile' => $this->tarFile,
'svgFile' => $this->svgFile
));
- $this->task = Taskmanager::waitComplete($this->task);
+ $this->task = Taskmanager::waitComplete($this->task, 5000);
if (Taskmanager::isFailed($this->task)) {
@unlink($this->svgFile);
Taskmanager::addErrorMessage($this->task);
diff --git a/modules/sysconfig/addmodule_custommodule.inc.php b/modules/sysconfig/addmodule_custommodule.inc.php
index bd66f417..dfa03a19 100644
--- a/modules/sysconfig/addmodule_custommodule.inc.php
+++ b/modules/sysconfig/addmodule_custommodule.inc.php
@@ -13,7 +13,8 @@ class CustomModule_Start extends AddModule_Base
{
Session::set('mod_temp', false);
Render::addDialog(Dictionary::translate('config-module', 'custom_title'), false, 'sysconfig/custom-upload', array(
- 'step' => 'CustomModule_ProcessUpload'
+ 'step' => 'CustomModule_ProcessUpload',
+ 'edit' => $this->edit ? $this->edit->id() : false
));
}
@@ -84,9 +85,17 @@ class CustomModule_ProcessUpload extends AddModule_Base
$list[] = $file;
}
}
+ if ($this->edit !== false)
+ $title = $this->edit->title();
+ elseif (isset($_FILES['modulefile']['name']))
+ $title = basename($_FILES['modulefile']['name']);
+ else
+ $title = '';
Render::addDialog(Dictionary::translate('config-module', 'custom_title'), false, 'sysconfig/custom-fileselect', array(
'step' => 'CustomModule_CompressModule',
'files' => $list,
+ 'edit' => $this->edit ? $this->edit->id() : false,
+ 'title' => $title
));
Session::save();
}
@@ -123,20 +132,30 @@ class CustomModule_CompressModule extends AddModule_Base
$this->taskError($status);
}
// Seems ok, create entry
- $module = ConfigModule::getInstance('CustomModule');
+ if ($this->edit === false)
+ $module = ConfigModule::getInstance('CustomModule');
+ else
+ $module = $this->edit;
if ($module === false) {
Message::addError('error-read', 'custommodule.inc.php');
Util::redirect('?do=SysConfig&action=addmodule&step=CustomModule_Start');
}
$module->setData('tmpFile', $destFile);
- if (!$module->insert($title))
+ if ($this->edit !== false)
+ $ret = $module->update();
+ else
+ $ret = $module->insert($title);
+ if (!$ret)
Util::redirect('?do=SysConfig&action=addmodule&step=CustomModule_Start');
elseif (!$module->generate(true, NULL, 200))
Util::redirect('?do=SysConfig&action=addmodule&step=CustomModule_Start');
Session::set('mod_temp', false);
Session::save();
// Yay
- Message::addSuccess('module-added');
+ if ($this->edit !== false)
+ Message::addSuccess('module-edited');
+ else
+ Message::addSuccess('module-added');
Util::redirect('?do=SysConfig');
}
diff --git a/script/custom.js b/script/custom.js
index 675bf581..b2c5b2a7 100644
--- a/script/custom.js
+++ b/script/custom.js
@@ -13,15 +13,20 @@ function loadContent(elem, source)
function forceTable(t)
{
var pwidth = t.parent().innerWidth();
- t.width(pwidth - 5);
var rows = t.find('tr');
+ var row = rows.first();
+ pwidth = Math.round(pwidth);
+ t.width(pwidth);
var sum = 0;
- rows.first().find('td').each(function (index) {
+ row.find('td').each(function() {
if (!$(this).hasClass('slx-width-ignore'))
- sum += $(this).outerWidth();
- });
- var w = pwidth - (sum + 30);
- rows.find('.slx-dyn-ellipsis').each(function (index) {
- $(this).width(w).css('width', w + 'px').css('max-width', w + 'px');
+ sum += $(this).outerWidth(true);
});
+ var w = Math.round(pwidth - sum);
+ do {
+ rows.find('.slx-dyn-ellipsis').each(function() {
+ $(this).width(w).css('width', w + 'px').css('max-width', w + 'px');
+ });
+ w -= 3;
+ } while (t.width() > pwidth);
} \ No newline at end of file
diff --git a/templates/sysconfig/_page.html b/templates/sysconfig/_page.html
index 93169e6a..2f46f2cf 100644
--- a/templates/sysconfig/_page.html
+++ b/templates/sysconfig/_page.html
@@ -30,10 +30,10 @@
<td class="slx-nowrap">
<button
{{#needrebuild}}
- class="btn btn-primary btn-xs"
+ class="refconf btn btn-primary btn-xs"
{{/needrebuild}}
{{^needrebuild}}
- class="btn btn-default btn-xs"
+ class="refconf btn btn-default btn-xs"
{{/needrebuild}}
name="rebuild" value="{{configid}}" title="{{lang_rebuild}}"><span class="glyphicon glyphicon-refresh"></span></button>
</td>
@@ -88,10 +88,10 @@
<td class="slx-nowrap">
<button
{{#needrebuild}}
- class="btn btn-primary btn-xs"
+ class="refmod btn btn-primary btn-xs"
{{/needrebuild}}
{{^needrebuild}}
- class="btn btn-default btn-xs"
+ class="refmod btn btn-default btn-xs"
{{/needrebuild}}
name="rebuild" value="{{moduleid}}" title="{{lang_rebuild}}"><span class="glyphicon glyphicon-refresh"></span></button>
<a class="btn btn-success btn-xs" href="?do=SysConfig&amp;action=addmodule&amp;step={{moduletype}}_Start&amp;edit={{moduleid}}" title="{{lang_edit}}"><span class="glyphicon glyphicon-edit"></span></a>
@@ -187,4 +187,30 @@
$(e).addClass("slx-bold");
}
}
+
+ var statusChecks = 0;
+ function checkBuildStatus() {
+ var mods = [];
+ var confs = [];
+ $(".refmod.btn-primary").each(function (index) {
+ mods.push($(this).val());
+ });
+ $(".refconf.btn-primary").each(function (index) {
+ confs.push($(this).val());
+ });
+ if (mods.length === 0 && confs.length === 0) return;
+ if (++statusChecks < 10) setTimeout(checkBuildStatus, 200 + 50 * statusChecks);
+ console.log("POSTING");
+ $.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);
+ }, 'json');
+ }
+ function updateButtonColor(list,ids) {
+ list.each(function() {
+ if (ids.indexOf($(this).val()) >= 0) $(this).removeClass('btn-primary').addClass('btn-default');
+ });
+ }
+ setTimeout(checkBuildStatus, 300);
// --></script> \ No newline at end of file
diff --git a/templates/sysconfig/custom-fileselect.html b/templates/sysconfig/custom-fileselect.html
index 0c2d88e9..000c8d10 100644
--- a/templates/sysconfig/custom-fileselect.html
+++ b/templates/sysconfig/custom-fileselect.html
@@ -1,9 +1,10 @@
<form role="form" method="post" action="?do=SysConfig&amp;action=addmodule&amp;step={{step}}">
<input type="hidden" name="modid" value="{{modid}}">
<input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="edit" value="{{edit}}">
<div class="input-group">
<span class="input-group-addon">{{lang_moduleName}}</span>
- <input type="text" name="title" class="form-control" placeholder="Mein Konfigurationsmodul" autofocus="autofocus">
+ <input type="text" name="title" value="{{title}}" class="form-control" placeholder="Mein Konfigurationsmodul" autofocus="autofocus">
</div>
<div class="pull-right">
<button type="submit" class="btn btn-primary">{{lang_next}} &raquo;</button>
diff --git a/templates/sysconfig/custom-upload.html b/templates/sysconfig/custom-upload.html
index 9ab71eaa..02f813f6 100644
--- a/templates/sysconfig/custom-upload.html
+++ b/templates/sysconfig/custom-upload.html
@@ -4,6 +4,7 @@
<form role="form" enctype="multipart/form-data" method="post" action="?do=SysConfig&amp;action=addmodule&amp;step={{step}}">
<input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="edit" value="{{edit}}">
<div class="input-group">
<span class="input-group-addon">{{lang_file}}</span>
<input class="form-control" type="file" name="modulefile">