summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorChristian Hofmaier2018-07-24 15:36:48 +0200
committerChristian Hofmaier2018-07-24 15:36:48 +0200
commit60b1fc7329725612fb5e6289295c5efd0f31f36d (patch)
tree04ca772c475aa78ed6675cb5880f65f594f7cbc5 /modules-available
parent[ipxe] added add-menu-button, added delete-menu-buttons, fixed bug that timeo... (diff)
downloadslx-admin-60b1fc7329725612fb5e6289295c5efd0f31f36d.tar.gz
slx-admin-60b1fc7329725612fb5e6289295c5efd0f31f36d.tar.xz
slx-admin-60b1fc7329725612fb5e6289295c5efd0f31f36d.zip
[ipxe] Add Bootentry list
Bootentry list with add/edit/delete functionality
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/serversetup-bwlp/lang/de/template-tags.json3
-rw-r--r--modules-available/serversetup-bwlp/lang/en/template-tags.json3
-rw-r--r--modules-available/serversetup-bwlp/page.inc.php47
-rw-r--r--modules-available/serversetup-bwlp/permissions/permissions.json6
-rw-r--r--modules-available/serversetup-bwlp/templates/bootentry-list.html71
5 files changed, 129 insertions, 1 deletions
diff --git a/modules-available/serversetup-bwlp/lang/de/template-tags.json b/modules-available/serversetup-bwlp/lang/de/template-tags.json
index 14f1c134..bda890c1 100644
--- a/modules-available/serversetup-bwlp/lang/de/template-tags.json
+++ b/modules-available/serversetup-bwlp/lang/de/template-tags.json
@@ -1,14 +1,17 @@
{
"lang_active": "Aktiv",
+ "lang_addBootentry": "Booteintrag hinzufügen",
"lang_addMenu": "Menü hinzufügen",
"lang_bootAddress": "Boot-Adresse des Servers",
"lang_bootBehavior": "Standard-Bootverhalten",
+ "lang_bootentryTitle": "Booteintrag",
"lang_bootHint": "Das Bootmen\u00fc muss nach einer \u00c4nderung der IP-Adresse neu generiert werden. In der Regel geschieht dies automatisch, der Vorgang kann in der Sektion Bootmen\u00fc allerdings auch manuell ausgel\u00f6st werden.",
"lang_bootInfo": "Hier k\u00f6nnen Anpassungen am Erscheinungsbild des Bootmen\u00fcs vorgenommen werden.",
"lang_bootMenu": "Bootmen\u00fc",
"lang_bootMenuCreate": "Bootmen\u00fc erzeugen",
"lang_chooseIP": "Bitte w\u00e4hlen Sie die IP-Adresse, \u00fcber die der Server von den Clients zum Booten angesprochen werden soll.",
"lang_customEntry": "Eigener Eintrag",
+ "lang_bootentryDeleteConfirm": "Sind Sie sicher, dass Sie diesen Booteintrag löschen wollen?",
"lang_menuDeleteConfirm": "Sind Sie sicher, dass Sie dieses Menü löschen wollen?",
"lang_downloadImage": "USB-Image herunterladen",
"lang_downloadRufus": "Rufus herunterladen",
diff --git a/modules-available/serversetup-bwlp/lang/en/template-tags.json b/modules-available/serversetup-bwlp/lang/en/template-tags.json
index d70159e2..121ed3e7 100644
--- a/modules-available/serversetup-bwlp/lang/en/template-tags.json
+++ b/modules-available/serversetup-bwlp/lang/en/template-tags.json
@@ -1,14 +1,17 @@
{
"lang_active": "Active",
+ "lang_addBootentry": "Add Bootentry",
"lang_addMenu": "Add Menu",
"lang_bootAddress": "Boot Address of the Server",
"lang_bootBehavior": "Default Boot Behavior",
+ "lang_bootentryTitle": "Bootentry",
"lang_bootHint": "The Boot menu must be recreated after changing the IP address. Usually this is done automatically, but the process can also be triggered manually in the section of the boot menu.",
"lang_bootInfo": "Here adjustments can be made to the appearance of the boot menu.",
"lang_bootMenu": "Boot Menu",
"lang_bootMenuCreate": "Create Boot Menu",
"lang_chooseIP": "Please select the IP address that the client server will use to boot.",
"lang_customEntry": "Custom entry",
+ "lang_bootentryDeleteConfirm": "Are you sure you want to delete this bootentry?",
"lang_menuDeleteConfirm": "Are you sure you want to delete this menu?",
"lang_downloadImage": "Download USB Image",
"lang_downloadRufus": "Download Rufus",
diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php
index 6df4c49c..3ef4371f 100644
--- a/modules-available/serversetup-bwlp/page.inc.php
+++ b/modules-available/serversetup-bwlp/page.inc.php
@@ -55,6 +55,11 @@ class Page_ServerSetup extends Page
$this->saveBootEntry();
}
+ if ($action === 'deleteBootentry') {
+ User::assertPermission('ipxe.bootentry.delete');
+ $this->deleteBootEntry();
+ }
+
if ($action === 'savemenu') {
User::assertPermission('ipxe.menu.edit');
$this->saveMenu();
@@ -73,6 +78,7 @@ class Page_ServerSetup extends Page
if (User::hasPermission('ipxe.*')) {
Dashboard::addSubmenu('?do=serversetup&show=menu', Dictionary::translate('submenu_menu', true));
+ Dashboard::addSubmenu('?do=serversetup&show=bootentry', Dictionary::translate('submenu_bootentry', true));
}
if (User::hasPermission('edit.address')) {
Dashboard::addSubmenu('?do=serversetup&show=address', Dictionary::translate('submenu_address', true));
@@ -122,6 +128,10 @@ class Page_ServerSetup extends Page
User::assertPermission('ipxe.menu.view');
$this->showMenuList();
break;
+ case 'bootentry':
+ User::assertPermission('ipxe.bootentry.view');
+ $this->showBootentryList();
+ break;
default:
Util::redirect('?do=serversetup');
break;
@@ -134,6 +144,29 @@ class Page_ServerSetup extends Page
Render::addTemplate('download');
}
+ private function showBootentryList()
+ {
+ $allowEdit = User::hasPermission('ipxe.bootentry.edit');
+ $allowDelete = User::hasPermission('ipxe.bootentry.delete');
+ $allowAdd = 'disabled';
+ if (User::hasPermission('ipxe.bootentry.add')) {
+ $allowAdd = '';
+ }
+
+ $res = Database::simpleQuery("SELECT entryid, hotkey, title FROM serversetup_bootentry");
+ $bootentryTable = [];
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $bootentryTable[] = $row;
+ }
+
+ Render::addTemplate('bootentry-list', array(
+ 'bootentryTable' => $bootentryTable,
+ 'allowAdd' => $allowAdd,
+ 'allowEdit' => $allowEdit,
+ 'allowDelete' => $allowDelete
+ ));
+ }
+
private function showMenuList()
{
$allowedEdit = User::getAllowedLocations('ipxe.menu.edit');
@@ -288,11 +321,22 @@ class Page_ServerSetup extends Page
return true;
}
+ private function deleteBootEntry() {
+ $id = Request::post('deleteid', false, 'string');
+ if ($id === false) {
+ Message::addError('main.parameter-missing', 'deleteid');
+ return;
+ }
+ Database::exec("DELETE FROM serversetup_bootentry WHERE entryid = :entryid", array("entryid" => $id));
+ // TODO: Redirect to &show=bootentry
+ Message::addSuccess('bootentry-deleted');
+ }
+
private function deleteMenu()
{
$id = Request::post('deleteid', false, 'int');
if ($id === false) {
- Message::addError('main.parameter-missing', 'menuid');
+ Message::addError('main.parameter-missing', 'deleteid');
return;
}
if (!$this->hasMenuPermission($id, 'ipxe.menu.delete')) {
@@ -512,6 +556,7 @@ class Page_ServerSetup extends Page
$params['oldid'] = $oldEntryId;
Database::exec('UPDATE serversetup_bootentry SET entryid = :entryid, title = :title, data = :data
WHERE entryid = :oldid AND builtin = 0', $params);
+ // TODO: Redirect to &show=bootentry
Message::addSuccess('boot-entry-updated', $newId);
}
}
diff --git a/modules-available/serversetup-bwlp/permissions/permissions.json b/modules-available/serversetup-bwlp/permissions/permissions.json
index e05b9f6c..5b97e5c2 100644
--- a/modules-available/serversetup-bwlp/permissions/permissions.json
+++ b/modules-available/serversetup-bwlp/permissions/permissions.json
@@ -14,6 +14,12 @@
"ipxe.bootentry.edit": {
"location-aware": false
},
+ "ipxe.bootentry.add": {
+ "location-aware": false
+ },
+ "ipxe.bootentry.delete": {
+ "location-aware": false
+ },
"ipxe.menu.view": {
"location-aware": false
},
diff --git a/modules-available/serversetup-bwlp/templates/bootentry-list.html b/modules-available/serversetup-bwlp/templates/bootentry-list.html
new file mode 100644
index 00000000..f9e881b2
--- /dev/null
+++ b/modules-available/serversetup-bwlp/templates/bootentry-list.html
@@ -0,0 +1,71 @@
+<table class="table">
+ <thead>
+ <tr>
+ <th>{{lang_bootentryTitle}}</th>
+ <th>Hotkey</th>
+ <th class="slx-smallcol">{{lang_edit}}</th>
+ <th class="slx-smallcol">{{lang_delete}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#bootentryTable}}
+ <tr>
+ <td>
+ {{title}}
+ </td>
+ <td>
+ {{hotkey}}
+ </td>
+ <td align="center">
+ {{#allowEdit}}
+ <a href="?do=serversetup&amp;show=editbootentry&amp;id={{entryid}}" class="btn btn-xs btn-default">
+ <span class="glyphicon glyphicon-edit"></span>
+ </a>
+ {{/allowEdit}}
+ </td>
+ <td align="center">
+ {{#allowDelete}}
+ <button type="button" class="btn btn-xs btn-danger" data-toggle="modal" data-target="#deleteModal" onclick="deleteBootentry('{{entryid}}')">
+ <span class="glyphicon glyphicon-trash"></span>
+ </button>
+ {{/allowDelete}}
+ </td>
+ </tr>
+ {{/bootentryTable}}
+ </tbody>
+</table>
+<div class="pull-right">
+ <a href="?do=serversetup&amp;show=editbootentry" class="btn btn-success {{allowAdd}}">
+ <span class="glyphicon glyphicon-plus"></span>
+ {{lang_addBootentry}}
+ </a>
+</div>
+
+<!-- Modals -->
+<form method="post" action="?do=serversetup">
+ <input type="hidden" name="token" value="{{token}}">
+ <div class ="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="myModalLabel">{{lang_delete}}</h4>
+ </div>
+ <div class="modal-body">
+ <p>{{lang_bootentryDeleteConfirm}}</p>
+ </div>
+ <div class="modal-footer">
+ <input type="hidden" id="delete-bootentry-id" name="deleteid" value="">
+ <button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
+ <button type="submit" name="action" value="deleteBootentry" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> {{lang_delete}}</button>
+ </div>
+ </div>
+ </div>
+ </div>
+</form>
+
+<script>
+ function deleteBootentry(entryid) {
+ $("#delete-bootentry-id").val(entryid);
+ }
+</script> \ No newline at end of file