summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-12-08 15:46:50 +0100
committerSimon Rettberg2022-12-08 15:46:50 +0100
commitacd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0 (patch)
treeddb3bd392fe4cec3634fd740964a4c2bef39eff8
parent[statistics] Add ID45 partition size filter (diff)
downloadslx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.tar.gz
slx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.tar.xz
slx-admin-acd63d1b88bf8605b3ef0f05ce9a2e25e10abcd0.zip
[remoteaccess] Add list of active locations to overview page
References #3767
-rw-r--r--modules-available/remoteaccess/lang/de/template-tags.json3
-rw-r--r--modules-available/remoteaccess/lang/en/template-tags.json3
-rw-r--r--modules-available/remoteaccess/page.inc.php54
-rw-r--r--modules-available/remoteaccess/templates/edit-settings.html31
4 files changed, 82 insertions, 9 deletions
diff --git a/modules-available/remoteaccess/lang/de/template-tags.json b/modules-available/remoteaccess/lang/de/template-tags.json
index bc9ef969..1a502a6b 100644
--- a/modules-available/remoteaccess/lang/de/template-tags.json
+++ b/modules-available/remoteaccess/lang/de/template-tags.json
@@ -9,7 +9,10 @@
"lang_groupListText": "Liste verf\u00fcgbarer Gruppen (\"virtuelle R\u00e4ume\")",
"lang_groups": "Gruppen",
"lang_keepAvailableWol": "WoL#",
+ "lang_location": "Ort",
"lang_locationSelectionText": "Ausgew\u00e4hlte Orte werden in den Remote-Modus geschaltet (beim n\u00e4chsten Boot des Clients) und sind damit im Pool f\u00fcr den Fernzugriff.",
+ "lang_locations": "Konfigurierte Orte",
+ "lang_locationsInUse": "Liste der Orte, die in mindestens einer Gruppe verwendet werden",
"lang_numLocs": "R\u00e4ume",
"lang_pluginVersion": "Plugin-Version",
"lang_pluginVersionOldOrUnknown": "Unbekannt oder zu alt",
diff --git a/modules-available/remoteaccess/lang/en/template-tags.json b/modules-available/remoteaccess/lang/en/template-tags.json
index 87dc8161..037550e4 100644
--- a/modules-available/remoteaccess/lang/en/template-tags.json
+++ b/modules-available/remoteaccess/lang/en/template-tags.json
@@ -9,7 +9,10 @@
"lang_groupListText": "Available groups (\"virtual locations\")",
"lang_groups": "Groups",
"lang_keepAvailableWol": "WoL#",
+ "lang_location": "Location",
"lang_locationSelectionText": "Clients in the selected locations will start the remoteaccess-mode after the next reboot.",
+ "lang_locations": "Configured locations",
+ "lang_locationsInUse": "List of locations that are active in at least one group",
"lang_numLocs": "Locations",
"lang_pluginVersion": "Plugin version",
"lang_pluginVersionOldOrUnknown": "Unknown or too old",
diff --git a/modules-available/remoteaccess/page.inc.php b/modules-available/remoteaccess/page.inc.php
index fa94e193..ee9305dc 100644
--- a/modules-available/remoteaccess/page.inc.php
+++ b/modules-available/remoteaccess/page.inc.php
@@ -105,6 +105,36 @@ class Page_RemoteAccess extends Page
];
$data['plugin_version'] = Property::get(RemoteAccess::PROP_PLUGIN_VERSION);
Permission::addGlobalTags($data['perms'], null, ['group.locations', 'group.add', 'group.edit', 'set-proxy-ip']);
+ // List of locations used in at least one group
+ $res = Database::simpleQuery("SELECT l.locationid, l.locationname, g.groupid, g.groupname, g.active
+ FROM location l
+ INNER JOIN remoteaccess_x_location rxl USING (locationid)
+ INNER JOIN remoteaccess_group g USING (groupid)
+ ORDER BY locationname, locationid");
+ $data['locations'] = [];
+ $last = null;
+ foreach ($res as $row) {
+ if ($last === null || $last['locationid'] !== $row['locationid']) {
+ unset($last);
+ $last = [
+ 'locationid' => $row['locationid'],
+ 'locationname' => $row['locationname'],
+ 'lclass' => 'slx-strike',
+ 'groups' => [],
+ ];
+ $data['locations'][] =& $last;
+ }
+ $last['groups'][] = [
+ 'groupid' => $row['groupid'],
+ 'groupname' => $row['groupname'],
+ 'gclass' => $row['active'] ?: 'slx-strike',
+ ];
+ if ($row['active']) {
+ $last['lclass'] = '';
+ }
+ }
+ unset($last);
+ $this->addSchedulerTags($data['locations']);
Render::addTemplate('edit-settings', $data);
} else {
// Edit locations for group
@@ -117,19 +147,11 @@ class Page_RemoteAccess extends Page
$locationList[$lid]['checked'] = 'checked';
}
}
- $scheduler = Module::isAvailable('rebootcontrol');
+ $this->addSchedulerTags($locationList);
foreach ($locationList as $lid => &$loc) {
if (!in_array($lid, $allowed)) {
$loc['disabled'] = 'disabled';
}
- if ($scheduler) {
- $options = Scheduler::getLocationOptions($lid);
- if ($options['ra-mode'] === Scheduler::RA_SELECTIVE) {
- $loc['ra_selective'] = true;
- } elseif ($options['ra-mode'] === Scheduler::RA_NEVER) {
- $loc['ra_never'] = true;
- }
- }
}
$data = [
'groupid' => $groupid,
@@ -157,4 +179,18 @@ class Page_RemoteAccess extends Page
return empty($diff);
}
+ private function addSchedulerTags(array &$locationList)
+ {
+ if (!Module::isAvailable('rebootcontrol'))
+ return;
+ foreach ($locationList as $lid => &$loc) {
+ $options = Scheduler::getLocationOptions($loc['locationid'] ?? $lid);
+ if ($options['ra-mode'] === Scheduler::RA_SELECTIVE) {
+ $loc['ra_selective'] = true;
+ } elseif ($options['ra-mode'] === Scheduler::RA_NEVER) {
+ $loc['ra_never'] = true;
+ }
+ }
+ }
+
}
diff --git a/modules-available/remoteaccess/templates/edit-settings.html b/modules-available/remoteaccess/templates/edit-settings.html
index a14bac45..4c4c011a 100644
--- a/modules-available/remoteaccess/templates/edit-settings.html
+++ b/modules-available/remoteaccess/templates/edit-settings.html
@@ -109,3 +109,34 @@
</div>
<div class="clearfix"></div>
</form>
+
+<h3>{{lang_locations}}</h3>
+
+<p>{{lang_locationsInUse}}</p>
+
+<table class="table">
+ <thead>
+ <tr>
+ <th>{{lang_location}}</th>
+ <th>{{lang_groups}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#locations}}
+ <tr>
+ <td class="{{lclass}}">
+ {{locationname}}
+ {{#ra_never}}
+ <span class="glyphicon glyphicon-remove text-danger" title="{{lang_roomRemoteAccessDisabled}}"></span>
+ {{/ra_never}}
+ {{#ra_selective}}
+ <span class="glyphicon glyphicon-time text-danger" title="{{lang_roomRemoteAccessWhenClosed}}"></span>
+ {{/ra_selective}}
+ </td>
+ <td>{{#groups}}
+ [<a class="{{gclass}}" href="?do=remoteaccess&amp;groupid={{groupid}}">{{groupname}}</a>]
+ {{/groups}}</td>
+ </tr>
+ {{/locations}}
+ </tbody>
+</table> \ No newline at end of file