summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-12-11 16:33:42 +0100
committerSimon Rettberg2019-12-11 16:33:42 +0100
commita5eb6f1f99a6e22d3e5461b028aae8a49b23d4e8 (patch)
treec3f646f8a90c2a8b5146fd81bb8f846656c698f7
parentMerge branch 'master' into wol (diff)
downloadslx-admin-wol.tar.gz
slx-admin-wol.tar.xz
slx-admin-wol.zip
[rebootcontrol] Only use Session to pass machine list to exec formwol
-rw-r--r--modules-available/rebootcontrol/inc/rebootcontrol.inc.php1
-rw-r--r--modules-available/rebootcontrol/pages/exec.inc.php11
-rw-r--r--modules-available/rebootcontrol/templates/exec-enter-command.html52
3 files changed, 33 insertions, 31 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
index 667c8bbd..f287e728 100644
--- a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
@@ -508,7 +508,6 @@ class RebootControl
$machines = RebootUtils::getFilteredMachineList($uuids, 'action.exec');
if ($machines === false)
return;
- RebootUtils::sortRunningFirst($machines);
$id = mt_rand();
Session::set('exec-' . $id, $machines, 60);
Session::save();
diff --git a/modules-available/rebootcontrol/pages/exec.inc.php b/modules-available/rebootcontrol/pages/exec.inc.php
index 0c40c313..e5fe3cd8 100644
--- a/modules-available/rebootcontrol/pages/exec.inc.php
+++ b/modules-available/rebootcontrol/pages/exec.inc.php
@@ -13,12 +13,11 @@ class SubPage
private static function execExec()
{
- $id = Request::post('id', Request::REQUIRED, 'int');
- $machines = Session::get('exec-' . $id);
- if (!is_array($machines)) {
- Message::addError('unknown-exec-job', $id);
+ $uuids = array_values(Request::post('uuid', Request::REQUIRED, 'array'));
+ $machines = RebootUtils::getFilteredMachineList($uuids, 'action.exec');
+ if (empty($machines))
return;
- }
+ RebootUtils::sortRunningFirst($machines);
$script = preg_replace('/\r\n?/', "\n", Request::post('script', Request::REQUIRED, 'string'));
$task = RebootControl::runScript($machines, $script);
if (Taskmanager::isTask($task)) {
@@ -46,6 +45,8 @@ class SubPage
Message::addError('unknown-exec-job', $id);
return;
}
+ Session::set('exec-' . $id, false);
+ Session::save();
Render::addTemplate('exec-enter-command', ['clients' => $machines, 'id' => $id]);
}
diff --git a/modules-available/rebootcontrol/templates/exec-enter-command.html b/modules-available/rebootcontrol/templates/exec-enter-command.html
index 5916e2a8..8bf81605 100644
--- a/modules-available/rebootcontrol/templates/exec-enter-command.html
+++ b/modules-available/rebootcontrol/templates/exec-enter-command.html
@@ -1,33 +1,35 @@
<h2>{{lang_execRemoteCommand}}</h2>
-<table class="table table-hover stupidtable" id="dataTable">
- <thead>
- <tr>
- <th data-sort="string">{{lang_client}}</th>
- <th data-sort="ipv4">{{lang_ip}}</th>
- <th data-sort="string">
- {{lang_status}}
- </th>
- </tr>
- </thead>
-
- <tbody>
- {{#clients}}
- <tr>
- <td>{{hostname}}{{^hostname}}{{machineuuid}}{{/hostname}}</td>
- <td>{{clientip}}</td>
- <td>{{state}}</td>
- </tr>
- {{/clients}}
- </tbody>
-</table>
-
-<h3>{{lang_enterCommand}}</h3>
-
<form method="post" action="?do=rebootcontrol" id="list-form">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="show" value="exec">
- <input type="hidden" name="id" value="{{id}}">
+ <table class="table table-hover stupidtable" id="dataTable">
+ <thead>
+ <tr>
+ <th data-sort="string">{{lang_client}}</th>
+ <th data-sort="ipv4">{{lang_ip}}</th>
+ <th data-sort="string">
+ {{lang_status}}
+ </th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {{#clients}}
+ <tr>
+ <td>
+ {{hostname}}{{^hostname}}{{machineuuid}}{{/hostname}}
+ <input type="hidden" name="uuid[]" value="{{machineuuid}}">
+ </td>
+ <td>{{clientip}}</td>
+ <td>{{state}}</td>
+ </tr>
+ {{/clients}}
+ </tbody>
+ </table>
+
+ <h3>{{lang_enterCommand}}</h3>
+
<div>
<label for="script-text">{{lang_scriptOrCommand}}</label>
<textarea id="script-text" class="form-control" name="script" rows="10"></textarea>