summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-11 16:49:58 +0100
committerSimon Rettberg2019-01-11 16:49:58 +0100
commit59f6f89a2b7950e7b5fb4bdb0e2cdaf4998f1e9e (patch)
treee1ba06ea7fde2a5178ad16f1693c2b1b009b2d58
parent[serversetup-bwlp] Decouple location assigning from menu editing (diff)
downloadslx-admin-59f6f89a2b7950e7b5fb4bdb0e2cdaf4998f1e9e.tar.gz
slx-admin-59f6f89a2b7950e7b5fb4bdb0e2cdaf4998f1e9e.tar.xz
slx-admin-59f6f89a2b7950e7b5fb4bdb0e2cdaf4998f1e9e.zip
[locations] Show current boot menu per location, add edit button
-rw-r--r--modules-available/locations/lang/de/template-tags.json1
-rw-r--r--modules-available/locations/lang/en/template-tags.json1
-rw-r--r--modules-available/locations/page.inc.php60
-rw-r--r--modules-available/locations/templates/locations.html17
4 files changed, 61 insertions, 18 deletions
diff --git a/modules-available/locations/lang/de/template-tags.json b/modules-available/locations/lang/de/template-tags.json
index 43142555..96273ce4 100644
--- a/modules-available/locations/lang/de/template-tags.json
+++ b/modules-available/locations/lang/de/template-tags.json
@@ -3,6 +3,7 @@
"lang_areYouSureNoUndo": "Sind Sie sicher? Diese Aktion kann nicht r\u00fcckg\u00e4ngig gemacht werden.",
"lang_assignSubnetExplanation": "Rechner, die in einen der hier aufgef\u00fchrten Adressbereiche fallen, werden diesem Ort zugeschrieben und erhalten damit z.B. f\u00fcr diesen Raum angepasste Veranstaltungslisten.",
"lang_assignedSubnets": "Zugeordnete Subnetze bzw. IP-Bereiche",
+ "lang_bootMenu": "Bootmen\u00fc",
"lang_deleteChildLocations": "Untergeordnete Orte ebenfalls l\u00f6schen",
"lang_deleteLocation": "Ort l\u00f6schen",
"lang_deleteSubnet": "Bereich l\u00f6schen",
diff --git a/modules-available/locations/lang/en/template-tags.json b/modules-available/locations/lang/en/template-tags.json
index 41261726..64211e27 100644
--- a/modules-available/locations/lang/en/template-tags.json
+++ b/modules-available/locations/lang/en/template-tags.json
@@ -3,6 +3,7 @@
"lang_areYouSureNoUndo": "Are you sure? This cannot be undone!",
"lang_assignSubnetExplanation": "Client machines which fall into an IP range listed below will be assigned to this location and will see an according lecture list (e.g. they will see lectures that are exclusively assigned to this location).",
"lang_assignedSubnets": "Assigned subnets \/ IP ranges",
+ "lang_bootMenu": "Boot menu",
"lang_deleteChildLocations": "Delete child locations aswell",
"lang_deleteLocation": "Delete location",
"lang_deleteSubnet": "Delete range",
diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php
index 9beae163..2d8f5ff9 100644
--- a/modules-available/locations/page.inc.php
+++ b/modules-available/locations/page.inc.php
@@ -375,6 +375,11 @@ class Page_Locations extends Page
} else {
$locationList[$lid]['havestatistics'] = false;
}
+ if (User::hasPermission('.serversetup.ipxe.menu.assign', $lid)) {
+ $visibleLocationIds[] = $lid;
+ } else {
+ $locationList[$lid]['haveipxe'] = false;
+ }
if (!in_array($lid, $visibleLocationIds)) {
unset($locationList[$lid]);
} elseif (!in_array($lid, $allowedLocationIds)) {
@@ -440,22 +445,7 @@ class Page_Locations extends Page
$locationList[$locId] += array('configName' => $conf['title'], 'configClass' => 'slx-bold');
}
}
- $depth = array();
- foreach ($locationList as &$loc) {
- $d = $loc['depth'];
- if (!isset($loc['configName'])) {
- // Has no explicit config assignment
- if ($d === 0) {
- $loc['configName'] = $defaultConfig;
- } else {
- $loc['configName'] = $depth[$d - 1];
- }
- $loc['configClass'] = 'gray';
- }
- $depth[$d] = $loc['configName'];
- unset($depth[$d + 1]);
- }
- unset($loc);
+ $this->propagateFields($locationList, $defaultConfig, 'configName', 'configClass');
}
// Count overridden config vars
if (Module::get('baseconfig') !== false) {
@@ -467,6 +457,24 @@ class Page_Locations extends Page
$locationList[$lid]['overriddenVars'] = $row['cnt'];
}
}
+ // Confusing because the count might be inaccurate within a branch
+ //$this->propagateFields($locationList, '', 'overriddenVars', 'overriddenClass');
+ }
+ // Show ipxe menu
+ if (Module::get('serversetup') !== false) {
+ $res = Database::simpleQuery("SELECT ml.locationid, m.title, ml.defaultentryid FROM serversetup_menu m
+ INNER JOIN serversetup_menu_location ml USING (menuid)
+ WHERE locationid IN (:allowedLocationIds) GROUP BY locationid", compact('allowedLocationIds'));
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $lid = (int)$row['locationid'];
+ if (isset($locationList[$lid])) {
+ if ($row['defaultentryid'] !== null) {
+ $row['title'] .= '(*)';
+ }
+ $locationList[$lid]['customMenu'] = $row['title'];
+ }
+ }
+ $this->propagateFields($locationList, '', 'customMenu', 'customMenuClass');
}
$addAllowedLocs = User::getAllowedLocations("location.add");
@@ -484,6 +492,7 @@ class Page_Locations extends Page
'havestatistics' => Module::get('statistics') !== false,
'havebaseconfig' => Module::get('baseconfig') !== false,
'havesysconfig' => Module::get('sysconfig') !== false,
+ 'haveipxe' => Module::get('serversetup') !== false,
'overlapSelf' => $overlapSelf,
'overlapOther' => $overlapOther,
'haveOverlapSelf' => !empty($overlapSelf),
@@ -637,4 +646,23 @@ class Page_Locations extends Page
return $result;
}
+ private function propagateFields(&$locationList, $defaultValue, $name, $class)
+ {
+ $depth = array();
+ foreach ($locationList as &$loc) {
+ $d = $loc['depth'];
+ if (!isset($loc[$name])) {
+ // Has no explicit config assignment
+ if ($d === 0) {
+ $loc[$name] = $defaultValue;
+ } else {
+ $loc[$name] = $depth[$d - 1];
+ }
+ $loc[$class] = 'gray';
+ }
+ $depth[$d] = $loc[$name];
+ unset($depth[$d + 1]);
+ }
+ }
+
}
diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html
index 67f22744..06d32020 100644
--- a/modules-available/locations/templates/locations.html
+++ b/modules-available/locations/templates/locations.html
@@ -37,6 +37,9 @@
<th class="text-nowrap">
{{#havesysconfig}}{{lang_sysConfig}}{{/havesysconfig}}
</th>
+ <th class="text-nowrap">
+ {{#haveipxe}}{{lang_bootMenu}}{{/haveipxe}}
+ </th>
</tr>
{{#list}}
<tr>
@@ -67,7 +70,7 @@
{{clientLoad}}
{{/havestatistics}}
</td>
- <td class="text-nowrap">
+ <td class="text-nowrap {{overriddenClass}}">
{{#havebaseconfig}}
<div class="pull-right" style="z-index:-1">
<a class="btn btn-default btn-xs" href="?do=baseconfig&amp;module=locations&amp;locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a>
@@ -87,6 +90,16 @@
</span>
{{/havesysconfig}}
</td>
+ <td class="text-nowrap">
+ {{#haveipxe}}
+ <div class="pull-right">
+ <a class="btn btn-default btn-xs" href="?do=serversetup&amp;show=assignlocation&amp;locationid={{locationid}}"><span class="glyphicon glyphicon-edit"></span></a>
+ </div>
+ <span class="{{customMenuClass}}">
+ {{customMenu}}&emsp;&emsp;
+ </span>
+ {{/haveipxe}}
+ </td>
</tr>
{{/list}}
{{#unassignedCount}}
@@ -170,7 +183,7 @@ function slxOpenLocation(e, lid) {
}
return;
}
- var td = $('<td>').attr('colspan', '5').css('padding', '0px 0px 12px');
+ var td = $('<td>').attr('colspan', '6').css('padding', '0px 0px 12px');
var tr = $('<tr>').attr('id', 'location-details-' + lid);
tr.append(td);
$(e).closest('tr').addClass('active slx-bold').after(tr);