diff options
author | Jannik Schönartz | 2018-03-20 19:44:15 +0100 |
---|---|---|
committer | Jannik Schönartz | 2018-03-20 19:44:15 +0100 |
commit | 5c0d2e3a40310291924e8225a1ffb01b35eb1e6d (patch) | |
tree | 952f924f439036e88d390ec33c338b1dadeb847c /modules-available | |
parent | [usb-lock-off] Added the edit rule function. Saveing is not finished. (diff) | |
parent | [usb-lock-off] now you can add a description which is shown on the front page... (diff) | |
download | slx-admin-5c0d2e3a40310291924e8225a1ffb01b35eb1e6d.tar.gz slx-admin-5c0d2e3a40310291924e8225a1ffb01b35eb1e6d.tar.xz slx-admin-5c0d2e3a40310291924e8225a1ffb01b35eb1e6d.zip |
Merge branch 'usb-lock-off' into usb-lock-off
Diffstat (limited to 'modules-available')
12 files changed, 135 insertions, 48 deletions
diff --git a/modules-available/usblockoff/install.inc.php b/modules-available/usblockoff/install.inc.php index cf260c61..47a07573 100644 --- a/modules-available/usblockoff/install.inc.php +++ b/modules-available/usblockoff/install.inc.php @@ -16,7 +16,7 @@ $t2 = $res[] = tableCreate('usblockoff_hw_prop', ' PRIMARY KEY (`hwid`, `serial`, `prop`) '); -$res[] = tableCreate('usb_configs', ' +$t4 = $res[] = tableCreate('usb_configs', ' `configid` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `configname` VARCHAR(200) NOT NULL, `rulesconfig` VARCHAR(512), @@ -60,6 +60,11 @@ if ($t1 === UPDATE_DONE || $t2 === UPDATE_DONE) { $res[] = UPDATE_DONE; } +if ($t4 === UPDATE_NOOP) { + Database::exec("ALTER TABLE `usb_configs` + ADD `configdesc` VARCHAR(200)"); +} + if (in_array(UPDATE_DONE, $res)) { finalResponse(UPDATE_DONE, 'Table created successfully'); diff --git a/modules-available/usblockoff/lang/de/messages.json b/modules-available/usblockoff/lang/de/messages.json index fa78c288..ae926304 100644 --- a/modules-available/usblockoff/lang/de/messages.json +++ b/modules-available/usblockoff/lang/de/messages.json @@ -2,5 +2,5 @@ "config-deleted": "Konfiguration erfolgreich gelöscht.", "config-saved": "Konfiguration erfolgreich gespeichert.", "rule-deleted": "Regel erfolgreich gelöscht.", - "invalid-rule-id": "Ungültige regel ID." + "invalid-rule-id": "Ungültige Regel ID." }
\ No newline at end of file diff --git a/modules-available/usblockoff/lang/de/rule.json b/modules-available/usblockoff/lang/de/rule.json index 0af86c37..394c44fe 100644 --- a/modules-available/usblockoff/lang/de/rule.json +++ b/modules-available/usblockoff/lang/de/rule.json @@ -9,7 +9,7 @@ "hash": "Hashwert", "hash_helptext": "Hashwert des USB-Geräts. Von USBGuard mittels sodium oder gcrypt berechnet.", "parent-hash": "Parent-Hashwert", - "parent-hash_helptext": "Hashwert des Client an dem das USB-Gerät angeschlossen wurde.", + "parent-hash_helptext": "Hashwert des Clients an dem das USB-Gerät angeschlossen wurde.", "via-port": "Erlaubte Ports", "via-port_helptext": "USB-Port(s), an welche das USB-Gerät angeschlossen werden kann.", "with-interface": "Interfaces", diff --git a/modules-available/usblockoff/lang/de/template-tags.json b/modules-available/usblockoff/lang/de/template-tags.json index 16466922..4e623e3a 100644 --- a/modules-available/usblockoff/lang/de/template-tags.json +++ b/modules-available/usblockoff/lang/de/template-tags.json @@ -4,20 +4,20 @@ "lang_devices": "USB Geräte", "lang_general": "Allgemein", "lang_config": "Konfiguration", - "lang_config_helptext": "Erstelle eine neue Konfiguration oder wähle eine aus, um sie zu Laden und Bearbeiten zu können", + "lang_config_helptext": "Erstelle eine neue Konfiguration oder wähle eine aus, um sie laden und bearbeiten zu können.", "lang_configName": "Konfigurationsname", "lang_configName_helptext": "Name der Konfiguration", - "lang_deleteConfig": "Konfiguration Löschen", - "lang_deleteConfig_helptext": "Löscht die Konfiguration aus der Datenbank", + "lang_deleteConfig": "Konfiguration löschen", + "lang_deleteConfig_helptext": "Löscht die Konfiguration.", "lang_createNewConfig": "<Neue Konfiguration erstellen>", - "lang_deleteConfigMessage": "Sind sie sicher, dass sie die Konfiguration Löschen wollen?", + "lang_deleteConfigMessage": "Sind Sie sicher, dass Sie die Konfiguration löschen wollen?", "lang_genericRule": "Generische Regel", "lang_generalOptions": "Allgemeine Optionen", "lang_modeOptions": "Modus Optionen", "lang_deviceClasses": "Geräteklassen", "lang_classes-helptext": "", "lang_contains": "Beinhält Interface", - "lang_contains-helptext": "Erlaubt das Gerät selbst wenn es noch zusätzliche Interfaces hat", + "lang_contains-helptext": "Erlaubt das Gerät selbst wenn es noch zusätzliche Interfaces hat.", "lang_mass-storage": "Massenspeichergeräte", "lang_hid": "Eingabegeräte", "lang_hub": "USB Hubs", @@ -38,8 +38,8 @@ "lang_none-of": "Keins von", "lang_equals": "Gleicht", "lang_equals-ordered": "Gleicht geordnet", - "lang_saveAsNewConfig": "Als neue Konfiguration Speichern", - "lang_saveAsNewConfig-helptext": "Erstellt eine neue Konfiguration anstatt die alte zu Überschreiben.", + "lang_saveAsNewConfig": "Als neue Konfiguration speichern", + "lang_saveAsNewConfig-helptext": "Erstellt eine neue Konfiguration statt die alte zu Überschreiben.", "lang_add-generic-rule": "Generische Regel hinzufügen", "lang_device-list": "Geräte Liste", "lang_rulesConfig": "Regel Konfiguration", @@ -47,5 +47,13 @@ "lang_assignMenu": "Zuweisungsmenü", "lang_serverName": "Servername", "lang_configuration": "Konfiguration", - "lang_usb-lock-off": "USB Lock-Off" + "lang_usb-lock-off": "USB Lock-Off", + "lang_disabledButtons_helptext": "Sie müssen zuerst die Konfiguration speichern, um Regeln hinzufügen zu können.", + "lang_firstMatchingRuleCounts": "Die erste zutreffende Regel (von Oben nach Unten) wird angewendet.", + "lang_description": "Beschreibung", + "lang_configurationTable": "Konfigurationstabelle", + "lang_editConfig": "Konfiguration bearbeiten", + "lang_configDesc_helptext": "Beschreibung der Konfiguration.", + "lang_attributes": "Attribute", + "lang_action": "Aktion" } diff --git a/modules-available/usblockoff/lang/en/messages.json b/modules-available/usblockoff/lang/en/messages.json index 500e5e7e..6873e284 100644 --- a/modules-available/usblockoff/lang/en/messages.json +++ b/modules-available/usblockoff/lang/en/messages.json @@ -1,6 +1,6 @@ { - "config-deleted": "Config successfully deleted.", - "config-saved": "Config successfully saved.", + "config-deleted": "Configuration successfully deleted.", + "config-saved": "Configuration successfully saved.", "rule-deleted": "Rule successfully deleted.", "invalid-rule-id": "Invalid rule ID." }
\ No newline at end of file diff --git a/modules-available/usblockoff/lang/en/rule.json b/modules-available/usblockoff/lang/en/rule.json index d2e7b8ca..46c8bf08 100644 --- a/modules-available/usblockoff/lang/en/rule.json +++ b/modules-available/usblockoff/lang/en/rule.json @@ -9,11 +9,11 @@ "hash": "Hash value", "hash_helptext": "Hash value of the USB-device. Calculated via USBGuard through sodium or gcrypt.", "parent-hash": "Parent-hash value", - "parent-hash_helptext": "Hash value of the Client the USB-device was connected.", + "parent-hash_helptext": "Hash value of the Client the USB-device was connected to.", "via-port": "Via port", "via-port_helptext": "Accepted USB-port(s) for the USB-device.", "with-interface": "Interfaces", "with-interface_helptext": "Interfaces of the USB-device.", - "interface-policy": "interface-policy", + "interface-policy": "interface policy", "interface-policy_helptext": "Per-interface authorisation." } diff --git a/modules-available/usblockoff/lang/en/template-tags.json b/modules-available/usblockoff/lang/en/template-tags.json index bfa52caf..1ddb6334 100644 --- a/modules-available/usblockoff/lang/en/template-tags.json +++ b/modules-available/usblockoff/lang/en/template-tags.json @@ -1,23 +1,23 @@ { "lang_howToRuleLang": "Usage of the Rule Language.", - "lang_device": "usb device", - "lang_devices": "usb devices", + "lang_device": "USB device", + "lang_devices": "USB devices", "lang_general": "General", "lang_config": "Configuration", "lang_config_helptext": "Create a new configuration or choose one to load and edit it", "lang_configName": "Configuration name", "lang_configName_helptext": "The name of the configuration", "lang_deleteConfig": "Delete configuration", - "lang_deleteConfig_helptext": "Delets the configuration", - "lang_createNewConfig": "<create new configuration>", + "lang_deleteConfig_helptext": "Delets the configuration.", + "lang_createNewConfig": "<Create new configuration>", "lang_deleteConfigMessage": "Are you sure you want to delete the configuration?", - "lang_genericRule": "generic rule", + "lang_genericRule": "Generic rule", "lang_generalOptions": "General options", "lang_modeOptions": "Mode options", "lang_deviceClasses": "Device classes", "lang_classes-helptext": "", "lang_contains": "Contains interface", - "lang_contains-helptext": "If true the device is allowed if it contains the interface among others", + "lang_contains-helptext": "If true the device is allowed even if it contains additional interfaces.", "lang_mass-storage": "Mass storage devices", "lang_hid": "Human interface devices", "lang_hub": "USB Hubs", @@ -38,14 +38,22 @@ "lang_none-of": "None of", "lang_equals": "Equals", "lang_equals-ordered": "Equals ordered", - "lang_saveAsNewConfig": "Save as new config", - "lang_saveAsNewConfig-helptext": "If true a new config is created instead of overriding the old one", + "lang_saveAsNewConfig": "Save as new configuration", + "lang_saveAsNewConfig-helptext": "If true a new configuration is created instead of overriding the old one", "lang_add-generic-rule": "Add generic rule", "lang_device-list": "Device list", - "lang_rulesConfig": "Rules config", - "lang_daemonConfig": "Daemon config", + "lang_rulesConfig": "Rules configuration", + "lang_daemonConfig": "Daemon configuration", "lang_assignMenu": "Assign menu", "lang_serverName": "Server name", "lang_configuration": "Configuration", - "lang_usb-lock-off": "USB lock off" + "lang_usb-lock-off": "USB lock off", + "lang_disabledButtons_helptext": "You must first save the configuration to add rules.", + "lang_firstMatchingRuleCounts": "First matching rule (from top to bottom) will be applied.", + "lang_description": "Description", + "lang_configurationTable": "Configuration Table", + "lang_editConfig": "Edit Configuration", + "lang_configDesc_helptext": "Description of the configuration.", + "lang_attributes": "Attributes", + "lang_action": "Action" } diff --git a/modules-available/usblockoff/page.inc.php b/modules-available/usblockoff/page.inc.php index d5334838..40e0ff78 100644 --- a/modules-available/usblockoff/page.inc.php +++ b/modules-available/usblockoff/page.inc.php @@ -39,7 +39,7 @@ class Page_usblockoff extends Page $this->loadConfigChooser(); } else if ($show === "edit-config") { $configid = Request::get("configid", ""); - $configName = Database::queryFirst("SELECT configname FROM `usb_configs` WHERE configid=:id", array( + $dbquery = Database::queryFirst("SELECT configname, configdesc FROM `usb_configs` WHERE configid=:id", array( 'id' => $configid )); @@ -48,7 +48,8 @@ class Page_usblockoff extends Page Render::addTemplate('usb-edit-config', array( 'configid' => $configid, - 'configName' => $configName['configname'], + 'configName' => $dbquery['configname'], + 'configDesc' => $dbquery['configdesc'], 'rulesConfigHtml' => $rulesConfigHtml, 'daemonConfigHtml' => $daemonConfigHtml )); @@ -361,11 +362,12 @@ class Page_usblockoff extends Page protected function loadConfigChooser() { - $dbquery = Database::simpleQuery("SELECT configid, configname FROM `usb_configs`"); + $dbquery = Database::simpleQuery("SELECT configid, configname, configdesc FROM `usb_configs`"); $configs = array(); while ($dbentry = $dbquery->fetch(PDO::FETCH_ASSOC)) { $config['config_id'] = $dbentry['configid']; $config['config_name'] = $dbentry['configname']; + $config['config_desc'] = $dbentry['configdesc']; $configs[] = $config; } Render::addTemplate('usb-configuration-table', array('config_list' => array_values($configs))); @@ -415,6 +417,7 @@ class Page_usblockoff extends Page $id = Request::post('id', 0, 'int'); $configname = Request::post('configName', '', 'string'); + $configdesc = Request::post('configDesc', '', 'string'); $dbquery = Database::queryFirst("SELECT * FROM `usb_configs` WHERE configid=:id", array('id' => $id)); // Load daemon.conf from db else load default @@ -442,16 +445,18 @@ class Page_usblockoff extends Page // INSERT IN DB if ($id == '0' || $result['saveAsNewConfig']) { - $dbquery = Database::exec("INSERT INTO `usb_configs` (configname, rulesconfig, daemonconfig) VALUES (:configname, :rulesconfig, :daemonconfig)", + $dbquery = Database::exec("INSERT INTO `usb_configs` (configname, rulesconfig, daemonconfig, configdesc) VALUES (:configname, :rulesconfig, :daemonconfig, :configdesc)", array('configname' => $configname, 'rulesconfig' => json_encode($result['rules']), - 'daemonconfig' => implode($newDaemonConf))); + 'daemonconfig' => implode($newDaemonConf), + 'configdesc' => $configdesc)); } else { - $dbquery = Database::exec("UPDATE `usb_configs` SET configname=:configname, rulesconfig=:rulesconfig, daemonconfig=:daemonconfig WHERE configid=:configid", + $dbquery = Database::exec("UPDATE `usb_configs` SET configname=:configname, rulesconfig=:rulesconfig, daemonconfig=:daemonconfig, configdesc=:configdesc WHERE configid=:configid", array('configid' => $id, 'configname' => $configname, 'rulesconfig' => json_encode($result['rules']), - 'daemonconfig' => implode($newDaemonConf))); + 'daemonconfig' => implode($newDaemonConf), + 'configdesc' => $configdesc)); } Message::addSuccess('config-saved'); } @@ -501,9 +506,17 @@ class Page_usblockoff extends Page $rulesArray[] = $rule; } } + + if ($configid == "new-default") { + $newConfig = true; + } else { + $newConfig = false; + } + return Render::parse('usb-rules-config', array( 'rules' => (array)$rulesArray, - 'configid' => $configid + 'configid' => $configid, + 'newConfig' => $newConfig )); } diff --git a/modules-available/usblockoff/style.css b/modules-available/usblockoff/style.css new file mode 100644 index 00000000..b54b2d88 --- /dev/null +++ b/modules-available/usblockoff/style.css @@ -0,0 +1,13 @@ +#configurationTable { + table-layout: fixed; + width: 100%; +} + +#configurationTable th, #configurationTable td { + word-wrap: break-word +} + +.missingInput { + border-color: rgba(255, 0, 0, 0.8); + box-shadow: 0 1px 1px rgba(255, 0, 0, 0.075) inset, 0 0 8px rgba(255, 0, 0, 0.6); +}
\ No newline at end of file diff --git a/modules-available/usblockoff/templates/usb-configuration-table.html b/modules-available/usblockoff/templates/usb-configuration-table.html index 3ceebce5..35eede5a 100644 --- a/modules-available/usblockoff/templates/usb-configuration-table.html +++ b/modules-available/usblockoff/templates/usb-configuration-table.html @@ -65,17 +65,19 @@ <table id="configurationTable" class="table table-condensed table-hover stupidtable"> <thead> <tr> - <th data-sort="string">{{lang_serverName}}</th> - <th>{{lang_ruleInfoTODO}}</th> - <th>{{lang_edit}}</th> - <th>{{lang_delete}}</th> + <th style="width: 5%" data-sort="int">ID</th> + <th style="width: 35%" data-sort="string">{{lang_configName}}</th> + <th style="width: 40%">{{lang_description}}</th> + <th style="width: 10%">{{lang_edit}}</th> + <th style="width: 10%">{{lang_delete}}</th> </tr> </thead> <tbody> {{#config_list}} <tr> + <td>{{config_id}}</td> <td data-sort-value="{{config_name}}">{{config_name}}</td> - <td>TODO: Show Rule information here</td> + <td>{{config_desc}}</td> <td> <a class="btn btn-xs btn-info" href="?do=usblockoff&show=edit-config&configid={{config_id}}"> <span class="glyphicon glyphicon-edit"></span> diff --git a/modules-available/usblockoff/templates/usb-edit-config.html b/modules-available/usblockoff/templates/usb-edit-config.html index 694101d4..1cd24ce7 100644 --- a/modules-available/usblockoff/templates/usb-edit-config.html +++ b/modules-available/usblockoff/templates/usb-edit-config.html @@ -14,7 +14,7 @@ <label for="configName">{{lang_configName}}</label> </div> <div class="col-sm-7"> - <input required class="form-control" name="configName" id="configName" maxlength="50" value="{{configName}}"> + <input type="text" class="form-control" name="configName" id="configName" value="{{configName}}"> </div> <div class="col-sm-2"> <a class="btn btn-default" title="{{lang_configName_helptext}}"> @@ -22,6 +22,20 @@ </a> </div> </div> + <br> + <div class="row"> + <div class="col-sm-3"> + <label for="configDesc">{{lang_description}}</label> + </div> + <div class="col-sm-7"> + <input class="form-control" name="configDesc" id="configDesc" value="{{configDesc}}"> + </div> + <div class="col-sm-2"> + <a class="btn btn-default" title="{{lang_configDesc_helptext}}"> + <span class="glyphicon glyphicon-question-sign"></span> + </a> + </div> + </div> </div> </div> @@ -54,3 +68,20 @@ </div> </form> + + + +<script type="application/javascript"> + document.addEventListener("DOMContentLoaded", function () { + $('form').submit(function () { + var input = $("#configName"); + var name = $.trim(input.val()); + if (!name) { + input.addClass("missingInput"); + return false; + } + }); + }); +</script> + + diff --git a/modules-available/usblockoff/templates/usb-rules-config.html b/modules-available/usblockoff/templates/usb-rules-config.html index 15c7a2f7..8cb63d88 100644 --- a/modules-available/usblockoff/templates/usb-rules-config.html +++ b/modules-available/usblockoff/templates/usb-rules-config.html @@ -1,5 +1,10 @@ <div class="panel panel-default"> - <div class="panel-heading">rules.conf</div> + <div class="panel-heading"> + rules.conf + <a class="btn btn-default" title="{{lang_firstMatchingRuleCounts}}"> + <span class="glyphicon glyphicon-question-sign"></span> + </a> + </div> <div class="panel-body" id="casualRules"> <div class="list-group"> @@ -9,7 +14,7 @@ <thead> <tr> <th data-sort="string" width="20"><span class="glyphicon glyphicon-th-list"></span></th> - <th width="120">{{lang_target}}</th> + <th width="120">{{lang_action}}</th> <th>{{lang_attributes}}</th> <th>{{lang_edit}}</th> <th>{{lang_delete}}</th> @@ -48,14 +53,16 @@ </tbody> </table> <div class="pull-right"> - <a class="btn btn-success" href="?do=usblockoff&show=add-generic-rule&configid={{configid}}" - style="margin-right: 3px; float: right;"> - <span style="margin-right: 5px;" class="glyphicon glyphicon-plus"></span> + <a class="btn btn-success {{#newConfig}}disabled{{/newConfig}}" + {{^newConfig}}href="?do=usblockoff&show=add-generic-rule&configid={{configid}}"{{/newConfig}} + {{#newConfig}}title="{{lang_disabledButtons_helptext}}" style="pointer-events: auto;"{{/newConfig}}> + <span class="glyphicon glyphicon-plus"></span> <span>{{lang_genericRule}}</span> </a> - <a class="btn btn-success" href="?do=usblockoff&show=add-devices&configid={{configid}}" - style="margin-right: 3px;float: right;"> - <span style="margin-right: 5px;" class="glyphicon glyphicon-plus"></span> + <a class="btn btn-success {{#newConfig}}disabled{{/newConfig}}" + {{^newConfig}}href="?do=usblockoff&show=add-devices&configid={{configid}}"{{/newConfig}} + {{#newConfig}}title="{{lang_disabledButtons_helptext}}" style="pointer-events: auto;"{{/newConfig}}> + <span class="glyphicon glyphicon-plus"></span> <span>{{lang_devices}}</span> </a> </div> |