summaryrefslogtreecommitdiffstats
path: root/modules-available/usblockoff/templates
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/usblockoff/templates')
-rw-r--r--modules-available/usblockoff/templates/server-prop-bool.html16
-rw-r--r--modules-available/usblockoff/templates/server-prop-dropdown.html25
-rw-r--r--modules-available/usblockoff/templates/server-prop-generic.html16
-rw-r--r--modules-available/usblockoff/templates/usb-add-generic-rule.html203
-rw-r--r--modules-available/usblockoff/templates/usb-configuration-table.html147
-rw-r--r--modules-available/usblockoff/templates/usb-daemon-config.html26
-rw-r--r--modules-available/usblockoff/templates/usb-device-list.html180
-rw-r--r--modules-available/usblockoff/templates/usb-edit-config.html87
-rw-r--r--modules-available/usblockoff/templates/usb-edit-rule.html170
-rw-r--r--modules-available/usblockoff/templates/usb-rules-config.html122
10 files changed, 992 insertions, 0 deletions
diff --git a/modules-available/usblockoff/templates/server-prop-bool.html b/modules-available/usblockoff/templates/server-prop-bool.html
new file mode 100644
index 00000000..de7c990a
--- /dev/null
+++ b/modules-available/usblockoff/templates/server-prop-bool.html
@@ -0,0 +1,16 @@
+<div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label for="prop-{{property}}">{{title}}</label></div>
+ <div class="col-md-7">
+ <input class="settings-bs-switch" id="prop-{{property}}" type="checkbox" name="prop-{{property}}" value="1"
+ {{#currentvalue}}checked{{/currentvalue}}>
+ </div>
+ <div class="col-md-2">
+ {{#helptext}}
+ <a class="btn btn-default" title="{{helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ {{/helptext}}
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/server-prop-dropdown.html b/modules-available/usblockoff/templates/server-prop-dropdown.html
new file mode 100644
index 00000000..73a55467
--- /dev/null
+++ b/modules-available/usblockoff/templates/server-prop-dropdown.html
@@ -0,0 +1,25 @@
+<div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label for="prop-{{property}}">{{title}}</label></div>
+ <div class="col-md-7 form-inline">
+ <select class="form-control" id="prop-{{property}}" name="prop-{{property}}">
+ {{#select_list}}
+ <option value="{{value}}" {{#active}}selected{{/active}}>{{option}}</option>
+ {{/select_list}}
+ </select>
+ {{#toTextButton}}
+ <button type="button" class="btn btn-default switch-input">
+ <span class="glyphicon glyphicon-pencil"></span>
+ </button>
+ {{/toTextButton}}
+
+ </div>
+ <div class="col-md-2">
+ {{#helptext}}
+ <a class="btn btn-default" title="{{helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ {{/helptext}}
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/server-prop-generic.html b/modules-available/usblockoff/templates/server-prop-generic.html
new file mode 100644
index 00000000..3c06585e
--- /dev/null
+++ b/modules-available/usblockoff/templates/server-prop-generic.html
@@ -0,0 +1,16 @@
+<div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label for="prop-{{property}}">{{title}}</label></div>
+ <div class="col-md-7">
+ <input class="form-control" id="prop-{{property}}" type="{{inputtype}}" name="prop-{{property}}"
+ value="{{currentvalue}}">
+ </div>
+ <div class="col-md-2">
+ {{#helptext}}
+ <a class="btn btn-default" title="{{helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ {{/helptext}}
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/usb-add-generic-rule.html b/modules-available/usblockoff/templates/usb-add-generic-rule.html
new file mode 100644
index 00000000..61e38ebc
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-add-generic-rule.html
@@ -0,0 +1,203 @@
+<form method="post" action="?do=usblockoff" id="addGenericRuleForm">
+ <input type="hidden" name="token" value="{{token}}">
+ <!--<input type="hidden" name="action" value="addGenericRule">-->
+ <input type="hidden" name="action" value="addDevices">
+ <input type="hidden" name="rules" value="" id="rules">
+ <input type="hidden" name="configid" value="{{configid}}" id="configid">
+
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_generalOptions}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ {{#settings}}
+ {{{settingHtml}}}
+ {{/settings}}
+
+ </div>
+ </div>
+ </div>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_modeOptions}}
+ <!--
+ <input class="settings-bs-switch" id="expert_Switch" type="checkbox" name="expert_Switch"
+ data-on-text="Expert" data-off-text="Casual" data-size="small">
+ -->
+ </div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <div id="casualMode">
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label for="casual_selected">{{lang_deviceClasses}}</label></div>
+ <div class="col-md-7">
+ <select class="form-control" id="casual_selected">
+ <option value="08:*:*" selected>{{lang_mass-storage}}</option>
+ <option value="03:*:*">{{lang_hid}}</option>
+ <option value="09:*:*">{{lang_hub}}</option>
+ <option value="07:*:*">{{lang_printer}}</option>
+ <option value="01:*:*">{{lang_audio}}</option>
+ <option value="*:*:*">{{lang_all-devices}}</option>
+ </select>
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_classes-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label for="contains">{{lang_contains}}</label></div>
+ <div class="col-md-7">
+ <input class="settings-bs-switch" id="contains" type="checkbox" value="1" checked
+ data-size="small">
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_contains-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+ <!--
+ <div id="expertMode" style="display: none;">
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label>{{lang_operator}}</label></div>
+ <div class="col-md-7">
+ <select class="form-control" id="expert_selected">
+ <option value="all-of">{{lang_all-of}}</option>
+ <option value="one-of">{{lang_one-of}}</option>
+ <option value="none-of">{{lang_none-of}}</option>
+ <option value="equals" selected>{{lang_equals}}</option>
+ <option value="equals-ordered">{{lang_equals-ordered}}</option>
+ </select>
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_operator-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label>{{lang_deviceClass}}</label></div>
+ <div class="col-md-7">
+ <input class="form-control" type="input" id="input_deviceClass"
+ value="">
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_deviceClass-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label>{{lang_deviceSubClass}}</label></div>
+ <div class="col-md-7">
+ <input class="form-control" type="input" id="input_deviceSubClass"
+ value="">
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_deviceSubClass-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-md-3"><label>{{lang_deviceProtocol}}</label></div>
+ <div class="col-md-7">
+ <input class="form-control" type="input" id="input_deviceProtocol"
+ value="">
+ </div>
+ <div class="col-md-2">
+ <a class="btn btn-default" title="{{lang_deviceProtocol-helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ </div>
+-->
+ </div>
+ </div>
+ </div>
+
+ <div class="pull-right">
+ <a href="?do=usblockoff&show=edit-config&configid={{configid}}" class="btn btn-default">Cancel</a>
+
+ <button id="addButton" class="btn btn-primary" type="submit" onclick="addRule();">
+ <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
+ </button>
+ </div>
+
+</form>
+
+<script type="text/javascript">
+ document.addEventListener("DOMContentLoaded", function() {
+ $('a.btn[title]').tooltip({placement: "auto", html: true});
+
+ var contains = true;
+ var c = $('#contains');
+ c.bootstrapSwitch();
+ c.on('switchChange.bootstrapSwitch', function(event, state) {
+ contains = state;
+ });
+ });
+
+ /*
+ var s = $('#expert_Switch');
+ var mode = "casual";
+ s.bootstrapSwitch();
+ s.parent().parent().addClass('pull-right');
+ s.parent().parent().css("margin", "-5px");
+
+ s.on('switchChange.bootstrapSwitch', function(event, state) {
+ if (state) {
+ // Expert mode.
+ $('#casualMode').hide();
+ $('#expertMode').show();
+ mode = "expert";
+ } else {
+ // Casual mode.
+ $('#expertMode').hide();
+ $('#casualMode').show();
+ mode = "casual";
+ }
+ });
+ */
+
+ function addRule() {
+ var rules = [];
+ var rule = {};
+ rule['target'] = $('#prop-action').val();
+ rule['id'] = 0;
+ var attribute = {};
+ attribute['prop'] = 'with-interface';
+ attribute['value'] = $('#casual_selected option:selected').val();
+ rule['attributes'] = [];
+ rule['attributes'].push(attribute);
+ rules.push(rule);
+ $('#rules').val(JSON.stringify(rules));
+ }
+</script> \ 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
new file mode 100644
index 00000000..dc8254df
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-configuration-table.html
@@ -0,0 +1,147 @@
+<div class="container-fluid">
+ <div class="row">
+ <div class="col-md-12">
+ <div class="page-header">
+ <h1>{{lang_usb-lock-off}}</h1>
+ </div>
+ </div>
+ </div>
+<!--
+ <div class="row">
+ <div class="col-md-12">
+ <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>
+ </tr>
+ </thead>
+ <tbody>
+ {{#config_list}}
+ <tr>
+ <td data-sort-value="{{config_name}}">{{config_name}}</td>
+ <td>TODO: Show Rule information here</td>
+ <td>
+ <a class="btn btn-xs btn-info" href="?do=usblockoff&amp;show=edit-config&amp;configid={{config_id}}">
+ <span class="glyphicon glyphicon-edit"></span>
+ </a>
+ </td>
+ <td>
+ <a class="btn btn-xs btn-danger" onclick="deleteConfig(event, {{config_id}});">
+ <span class="glyphicon glyphicon-trash"></span>
+ </a>
+ </td>
+ </tr>
+ {{/config_list}}
+ </tbody>
+ </table>
+ <div class="buttonbar text-right">
+ <a class="btn btn-success" href="?do=usblockoff&amp;show=edit-config&amp;configid=new-default">
+ <span class="glyphicon glyphicon-plus"></span>
+ {{lang_configuration}}
+ </a>
+ </div>
+ </div>
+ </div> -->
+</div>
+
+
+<ul class="nav nav-tabs">
+ <li class="active"><a data-toggle="tab" href="#configTableMenu">{{lang_editConfig}}</a></li>
+ <li><a data-toggle="tab" href="#assignMenu">{{lang_assingMenu}}</a></li>
+</ul>
+
+<div class="tab-content">
+ <div id="configTableMenu" class="tab-pane fade in active">
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_configurationTable}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <div class="row">
+ <div class="col-md-12">
+ <table id="configurationTable" class="table table-condensed table-hover stupidtable fixedTableLayout">
+ <thead>
+ <tr>
+ <th style="width: 5%" class="tableWrapBreakWord" data-sort="int">ID</th>
+ <th style="width: 35%" class="tableWrapBreakWord" data-sort="string">{{lang_configName}}</th>
+ <th style="width: 40%" class="tableWrapBreakWord">{{lang_description}}</th>
+ <th style="width: 10%" class="tableWrapBreakWord">{{lang_edit}}</th>
+ <th style="width: 10%" class="tableWrapBreakWord">{{lang_delete}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#config_list}}
+ <tr>
+ <td class="tableWrapBreakWord">{{config_id}}</td>
+ <td class="tableWrapBreakWord" data-sort-value="{{config_name}}">{{config_name}}</td>
+ <td class="tableWrapBreakWord">{{config_desc}}</td>
+ <td class="tableWrapBreakWord">
+ <a class="btn btn-xs btn-info" href="?do=usblockoff&amp;show=edit-config&amp;configid={{config_id}}">
+ <span class="glyphicon glyphicon-edit"></span>
+ </a>
+ </td>
+ <td class="tableWrapBreakWord">
+ <a class="btn btn-xs btn-danger" onclick="deleteConfig(event, {{config_id}});">
+ <span class="glyphicon glyphicon-trash"></span>
+ </a>
+ </td>
+ </tr>
+ {{/config_list}}
+ </tbody>
+ </table>
+ <div class="buttonbar text-right">
+ <a class="btn btn-success" href="?do=usblockoff&amp;show=edit-config&amp;configid=new-default">
+ <span class="glyphicon glyphicon-plus"></span>
+ {{lang_configuration}}
+ </a>
+ </div>
+ </div>
+ </div>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ <div id="assignMenu" class="tab-pane fade">
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_configurationTable}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <h3>Work in progress ...</h3>
+ <p>Todo: Implement this.</p>
+ <p>Or not.</p>
+ <p>¯\_(ツ)_/¯</p>
+
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+<script>
+ function deleteConfig(event, id) {
+ event.preventDefault();
+
+ BootstrapDialog.confirm({
+ title: '{{lang_delete}}',
+ message: '{{lang_deleteConfigMessage}}',
+ type: BootstrapDialog.TYPE_DANGER, // <-- Default value is BootstrapDialog.TYPE_PRIMARY
+ closable: false, // <-- Default value is false
+ draggable: false, // <-- Default value is false
+ btnCancelLabel: '{{lang_cancel}}', // <-- Default value is 'Cancel',
+ btnOKLabel: '<span class="glyphicon glyphicon-trash"></span> {{lang_delete}}', // <-- Default value is 'OK',
+ btnOKClass: 'btn-danger', // <-- If you didn't specify it, dialog type will be used,
+ callback: function (result) {
+ if (result) {
+ url = "?do=usblockoff&action=deleteConfig&id=" + id;
+ window.location = url;
+ }
+ }
+ });
+ }
+</script> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/usb-daemon-config.html b/modules-available/usblockoff/templates/usb-daemon-config.html
new file mode 100644
index 00000000..be8c903c
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-daemon-config.html
@@ -0,0 +1,26 @@
+<div class="panel panel-default">
+ <div class="panel-heading">usbugard-daemon.conf</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ {{#list}}
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-3">
+ <label>{{name}}</label>
+ </div>
+ <div class="col-sm-7">
+ <input class="form-control" name="{{name}}" id="{{name}}" value="{{value}}">
+ </div>
+ <div class="col-sm-2">
+ <a class="btn btn-default" title="{{helptext}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
+ </div>
+ </div>
+ {{/list}}
+
+ </div>
+ </div>
+</div> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/usb-device-list.html b/modules-available/usblockoff/templates/usb-device-list.html
new file mode 100644
index 00000000..2c26996b
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-device-list.html
@@ -0,0 +1,180 @@
+<form method="post" action="?do=usblockoff" id="addDevicesForm">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" value="addDevices">
+ <input type="hidden" name="rules" value="" id="rules">
+ <input type="hidden" name="configid" value="{{configid}}" id="configid">
+
+ <div class="input-group" id="search">
+ <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
+ <input type="text" id="myInput" class="form-control" onkeyup="search()" placeholder="Search for .."
+ style="font-size: 16px;"/>
+ <span class="input-group-addon" style="width:0px; padding-left:0px; padding-right:0px; border:none;"></span>
+ <select class="form-control" id="searchFor" style="font-size: 16px;" onchange="search()">
+ <option value="0" select>Name</option>
+ <option value="1">Date / Time</option>
+ <option value="2">User Information</option>
+ <option value="3">USB Information</option>
+ <option value="4">Rules Information</option>
+ </select>
+ </div>
+
+ <div style="max-height: 800px; overflow-x: auto;">
+ <table class="table table-hover" id="myTable">
+ <thead>
+ <tr>
+ <th width="1" style="text-align: center;">Name</th>
+ <th width="1" style="text-align: center;">Time</th>
+ <th width="1">User Info</th>
+ <th width="1">USB Info</th>
+ <th width="1">Rule Info</th>
+ </tr>
+ </thead>
+ {{#list}}
+ <input type="hidden" id="{{uid}}-prop-name" value="{{name}}">
+ <input type="hidden" id="{{uid}}-prop-id" value="{{id}}">
+ <input type="hidden" id="{{uid}}-prop-serial" value="{{serial}}">
+ <input type="hidden" id="{{uid}}-prop-via-port" value="{{via-port}}">
+ <input type="hidden" id="{{uid}}-prop-hash" value="{{hash}}">
+ <input type="hidden" id="{{uid}}-prop-parent-hash" value="{{parent-hash}}">
+ <input type="hidden" id="{{uid}}-prop-with-interface" value="{{with-interface}}">
+
+ <tbody onclick="clickRow(this, {{uid}});" id="{{uid}}">
+ <tr>
+ <td nowrap align="center" style="vertical-align: middle;"><label>{{name}}</label></td>
+ <td nowrap align="center" style="vertical-align: middle;">{{time}}<br>{{date}}</td>
+ <td nowrap><font size="0">User: {{user}}<br>Location: {{location}}<br>Client: {{clientip}}</font></td>
+ <td nowrap><font size="0">id: {{id}}<br>Serial: {{serial}}<br>via-port: {{via-port}}</font></td>
+ <td nowrap><font size="0">hash: {{hash}}<br>parent-hash: {{parent-hash}}<br>with-interface:
+ {{with-interface}}</font></td>
+ </tr>
+ </tbody>
+ {{/list}}
+ </table>
+ </div>
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_ruleOptions}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+ <div id="settingsDIV">
+ {{#settings}}
+ {{{settingHtml}}}
+ {{/settings}}
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="pull-right">
+ <a href="?do=usblockoff&show=edit-config&configid={{configid}}" class="btn btn-default">Cancel</a>
+ <button id="addButton" class="btn btn-primary" type="submit" onclick="addDevices();">
+ <span style="margin-right: 5px;" class="glyphicon glyphicon-floppy-disk"></span>
+ <span id="addButtonText"></span>
+ </button>
+ </div>
+
+</form>
+
+<script type="text/javascript">
+
+ document.addEventListener("DOMContentLoaded", function(event) {
+ $('a.btn[title]').tooltip();
+ $('.settings-bs-switch').bootstrapSwitch({size: 'small'});
+ countSelected();
+ });
+
+ function clickRow(tbody, uid) {
+ $(tbody).toggleClass('selected');
+ countSelected();
+ }
+
+ function countSelected() {
+ var numSelected = $('.selected').length;
+ if (numSelected == 0) {
+ $('#addButton').prop('disabled', true);
+ //$('#addButton').addClass('disabled');
+ } else {
+ $('#addButton').prop('disabled', false);
+ //$('#addButton').removeClass('disabled');
+ }
+ if (numSelected == 1) {
+ $('#addButtonText').text(' ' + numSelected + ' {{lang_device}}');
+ } else {
+ $('#addButtonText').text(' ' + numSelected + ' {{lang_devices}}');
+ }
+ }
+
+ function search() {
+ var searchForIndex = $('#searchFor').val();
+ // Declare variables
+ var input, filter, table, tr, td, i;
+ input = document.getElementById("myInput");
+ filter = input.value.toUpperCase();
+ table = document.getElementById("myTable");
+ tr = table.getElementsByTagName("tr");
+
+ // Loop through all table rows, and hide those who don't match the search query
+ for (i = 0; i < tr.length; i++) {
+ td = tr[i].getElementsByTagName("td")[searchForIndex];
+ if (td) {
+ if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
+ tr[i].style.display = "";
+ } else {
+ tr[i].style.display = "none";
+ }
+ }
+ }
+ }
+
+ function addDevices() {
+ var rules = [];
+ $('.selected').each(function () {
+ var rule = {};
+ rule['target'] = $('#prop-action').val();
+ rule['id'] = 0;
+ rule['attributes'] = [];
+
+ var selected = $(this);
+ $('#settingsDIV .settings-bs-switch').each(function () {
+ if ($(this).is(":checked")) {
+ var attr = {};
+ attr['prop'] = $(this).attr('name').substring(5);
+ attr['value'] = $('#' + $(selected).attr('id') + '-' + $(this).attr('name')).val();
+
+ rule['attributes'].push(attr);
+ }
+ });
+ rules.push(rule);
+ });
+ $('#rules').val(JSON.stringify(rules));
+ }
+</script>
+
+<style type='text/css'>
+ .selected {
+ background-color: rgba(124, 252, 0, 0.152);
+ }
+
+ .selected tr:hover {
+ background-color: rgba(124, 252, 0, 0.252) !important;
+ }
+
+ #myTable {
+ border-collapse: collapse; /* Collapse borders */
+ width: 100%; /* Full-width */
+ border: 1px solid #ddd; /* Add a grey border */
+ }
+
+ #myTable th, #myTable td {
+ padding: 12px; /* Add padding */
+ }
+
+ #myTable tr {
+ /* Add a bottom border to all table rows */
+ border-bottom: 1px solid #ddd;
+ }
+
+ #myTable tr.header, #myTable tr:hover {
+ /* Add a grey background color to the table header and on hover */
+ background-color: #f1f1f1;
+ }
+</style>
diff --git a/modules-available/usblockoff/templates/usb-edit-config.html b/modules-available/usblockoff/templates/usb-edit-config.html
new file mode 100644
index 00000000..1cd24ce7
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-edit-config.html
@@ -0,0 +1,87 @@
+<form method="post" action="?do=usblockoff" id="configForm">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" id="formAction" value="updateConfig">
+ <input type="hidden" name="id" value="{{configid}}" id="configID">
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_general}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ <div class="list-group-item">
+ <div class="row">
+ <div class="col-sm-3">
+ <label for="configName">{{lang_configName}}</label>
+ </div>
+ <div class="col-sm-7">
+ <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}}">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </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>
+ </div>
+ </div>
+
+ <ul class="nav nav-tabs">
+ <li class="active"><a data-toggle="tab" href="#rulesConfigMenu">{{lang_rulesConfig}}</a></li>
+ <li><a data-toggle="tab" href="#deamonConfigMenu">{{lang_daemonConfig}}</a></li>
+ </ul>
+
+ <div class="tab-content">
+ <div id="rulesConfigMenu" class="tab-pane fade in active">
+ <div id="rulesConfigDIV">
+ {{{rulesConfigHtml}}}
+ </div>
+ </div>
+ <div id="deamonConfigMenu" class="tab-pane fade">
+ <div id="daemonConfigDIV">
+ {{{daemonConfigHtml}}
+ </div>
+ </div>
+ </div>
+
+ <div class="pull-right">
+ <a href="?do=usblockoff" class="btn btn-default">Cancel</a>
+ <button type="submit" id="configFormButton" class="btn btn-primary">
+ <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
+ </button>
+ </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-edit-rule.html b/modules-available/usblockoff/templates/usb-edit-rule.html
new file mode 100644
index 00000000..ef5d48d5
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-edit-rule.html
@@ -0,0 +1,170 @@
+<form method="post" action="?do=usblockoff" id="editRuleForm">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" value="editRule">
+ <input type="hidden" name="configid" value="{{configid}}" id="configid">
+ <input type="hidden" name="ruleid" value="{{ruleid}}" id="ruleid">
+ <input type="hidden" name="attributes" value="" id="attributes">
+
+ <div class="panel panel-default">
+ <div class="panel-heading">{{lang_editRule}}</div>
+ <div class="panel-body">
+ <div class="list-group">
+
+ {{#attributes}}
+ {{{attributesHtml}}}
+ {{/attributes}}
+
+ </div>
+ </div>
+ </div>
+
+ <div class="pull-right">
+ <a href="?do=usblockoff&show=edit-config&configid={{configid}}" class="btn btn-default">Cancel</a>
+
+ <button id="addButton" class="btn btn-primary" type="submit">
+ <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
+ </button>
+ </div>
+
+</form>
+
+<script>
+ // JSON with the vendor / product lists.
+ var idArray = {{{usbJson}}};
+
+ // Page loaded event listener.
+ document.addEventListener("DOMContentLoaded", function() {
+ // Init the tooltips.
+ $('a.btn[title]').tooltip({placement: "auto", html: true});
+
+ // Add the click event to the switch input button.
+ $('.switch-input').click(function () {
+ var oldInput = $(this).parent().find(':input').not('button');
+ var value = oldInput.val();
+
+ // Switch case: Either input type=text or select.
+ if (oldInput[0].localName == 'select') {
+ // Replace it with an input type=text field.
+ oldInput.replaceWith($('<input class="form-control" type="text">').attr('name', oldInput.attr('name')).attr('id', oldInput.attr('id')).val(value));
+
+ if (oldInput.attr('id') === 'prop-vid') {
+ // Adds the onchange event for the vendor input field.
+ createVendorOnChange();
+ } else if (oldInput.attr('id') === 'prop-pid') {
+ // Adds the onchange event for the products input field.
+ createProductOnChange();
+ }
+
+ // Change the buttons glyphicon.
+ $(this).parent().find('button span').removeClass('glyphicon-pencil').addClass('glyphicon glyphicon-list-alt');
+ } else if (oldInput[0].localName == 'input') {
+ // Replace it with a select input field.
+ oldInput.replaceWith($('<select class="form-control"><option id="option" selected></option></select>').attr('name', oldInput.attr('name')).attr('id', oldInput.attr('id')));
+ $('#option').val(value).text("unknown");
+
+ if (oldInput.attr('id') === 'prop-vid') {
+ // Initializes (fills) the vendor select dropdown box.
+ fillVendors();
+
+ // Adds the onchange event for the vendor input dropdown.
+ createVendorOnChange();
+ } else if (oldInput.attr('id') === 'prop-pid') {
+ // Initializes (fills) the product select dropdown box.
+ fillProducts();
+
+ // Adds the onchange event for the products input dropdown.
+ createProductOnChange();
+ }
+
+ // Change the buttons glyphicon.
+ $(this).parent().find('button span').removeClass('glyphicon-list-alt').addClass('glyphicon-pencil');
+ }
+ });
+
+ // Create the change event for all props.
+ $('[id^="prop-"]').change(function () {
+ updateAttributes();
+ });
+
+ // Initializes (fills) the dropdown boxes and creates the change events.
+ fillVendors();
+ fillProducts();
+ updateAttributes();
+ createVendorOnChange();
+ createProductOnChange();
+ });
+
+ // Fills the vendor dropdown box with options.
+ function fillVendors() {
+ var vendorid = $('#prop-vid');
+ var value = vendorid.val();
+ vendorid.empty();
+
+ // Fill the select with options.
+ $.each(idArray, function(key, value) {
+ vendorid.append($('<option></option>').val(key).html(value['name']));
+ });
+
+ // If the value exist in the array.
+ if (value in idArray) {
+ // Assign vendor value.
+ vendorid.val(value);
+ }
+ }
+
+ // Creates the onChange event for the vendor dropdown.
+ function createVendorOnChange() {
+ var vendorid = $('#prop-vid');
+ vendorid.change(function() {
+ fillProducts();
+ updateAttributes();
+ });
+ }
+
+ // Fills the product dropdown box with options.
+ function fillProducts() {
+ var vendorid = $('#prop-vid');
+ var productid = $('#prop-pid');
+ var value = productid.val();
+ productid.empty();
+
+ // If the key exists load the option list.
+ if (vendorid.val() in idArray) {
+ $.each(idArray[vendorid.val()]['products'], function(key, value) {
+ productid.append($('<option></option>').val(key).html(value));
+ });
+
+ // IF the value exist in the array.
+ if (value in idArray[vendorid.val()]['products']) {
+ // Assign product value.
+ productid.val(value);
+ }
+ }
+ }
+
+ // Creates the onChange event for the products dropdown.
+ function createProductOnChange() {
+ var productid = $('#prop-pid');
+
+ productid.change(function() {
+ updateAttributes();
+ });
+ }
+
+ // Updates the attributes variable which is send to the page.php on save.
+ function updateAttributes() {
+ var attributes = [];
+
+ // Add all attributes in an array.
+ $.each($('[id^="prop-"]'), function () {
+ var attr = {};
+ attr['prop'] = $(this).attr('id');
+ attr['value'] = $(this).val();
+
+ attributes.push(attr);
+ });
+
+ // Save the array as JSON in the attributes hidden input.
+ $('#attributes').val(JSON.stringify(attributes));
+ }
+</script> \ No newline at end of file
diff --git a/modules-available/usblockoff/templates/usb-rules-config.html b/modules-available/usblockoff/templates/usb-rules-config.html
new file mode 100644
index 00000000..eb6bea59
--- /dev/null
+++ b/modules-available/usblockoff/templates/usb-rules-config.html
@@ -0,0 +1,122 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ {{lang_rules}}
+
+ <div class="pull-right">
+ <span style="color: red;font-weight: bold;opacity: 0.75;">
+ <span class="glyphicon glyphicon-alert" style="margin-right: 5px;"></span>
+ {{lang_firstMatchingRuleCounts}}
+ </span>
+ </div>
+ <div class="clearfix"></div>
+
+ </div>
+
+ <div class="panel-body" id="casualRules">
+ <div class="list-group">
+
+ <input type="hidden" name="rules" value="" id="rules">
+ <table id="rulesTable" class="table table-condensed table-hover fixedTableLayout">
+ <thead>
+ <tr>
+ <th style="width: 10%" data-sort="string"><span class="glyphicon glyphicon-th-list"></span></th>
+ <th style="width: 20%" class="tableWrapBreakWord" width="120">{{lang_action}}</th>
+ <th style="width: 50%" class="tableWrapBreakWord">{{lang_attributes}}</th>
+ <th style="width: 10%" class="tableWrapBreakWord">{{lang_edit}}</th>
+ <th style="width: 10%" class="tableWrapBreakWord">{{lang_delete}}</th>
+ </tr>
+ </thead>
+ <tbody id="tableBody" style="overflow: auto;">
+
+
+ {{#rules}}
+ <tr id="{{id}}">
+ <td class="drag-handler" style="cursor: pointer;text-align: center; vertical-align: middle;">
+ <span class="glyphicon glyphicon-th-list"></span>
+ </td>
+ <td class="tableWrapBreakWord" style="vertical-align: middle; text-align: center;">{{target}}</td>
+ <td class="tableWrapBreakWord">
+ {{#attributes}}
+ {{prop}}: {{value}}<br>
+ {{/attributes}}
+ {{#hasoverload}}
+ <a class="label label-default overload" style="background-color: #337ab7;" title="{{attributes_overload}}">+{{num_overload}}</a>
+ {{/hasoverload}}
+ </td>
+ <td class="tableWrapBreakWord">
+ <a class="btn btn-xs btn-info" href="?do=usblockoff&show=edit-rule&ruleid={{id}}&configid={{configid}}">
+ <span class="glyphicon glyphicon-edit"></span>
+ </a>
+ </td>
+ <td class="tableWrapBreakWord">
+ <a class="btn btn-xs btn-danger" href="?do=usblockoff&action=deleteRule&id={{id}}&configid={{configid}}">
+ <span class="glyphicon glyphicon-trash"></span>
+ </a>
+ </td>
+ </tr>
+ {{/rules}}
+
+ </tbody>
+ </table>
+ <div class="pull-right">
+ <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 {{#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>
+ </div>
+
+ </div>
+</div>
+<script type="text/javascript">
+ var rules = [];
+ var oldIndex = -1;
+ document.addEventListener("DOMContentLoaded", function(event) {
+ $('a.btn[title]').tooltip({placement: "auto", html: true});
+
+ $("#tableBody tr").each(function() {
+ rules.push(Number(this.id));
+ });
+ $('#rules').val(JSON.stringify(rules));
+
+ $('#tableBody').sortable({
+ opacity: 0.8,
+ handle: '.drag-handler',
+ start: function(evt, ui) {
+ oldIndex = ui.item.index();
+ ui.placeholder.css("visibility", "visible");
+ ui.placeholder.css("opacity", "0.152");
+ ui.placeholder.css("background-color", "LawnGreen");
+ },
+ stop: function(evt, ui) {
+ updateTable(ui.item.index());
+ }
+ });
+
+ $('a.overload').tooltip({placement: "auto", html: true});
+ });
+
+
+ // Called after a drag & drop event is finished.
+ function updateTable(new_index) {
+ var old_i = -1;
+ if (oldIndex === -1) {
+ return;
+ } else {
+ old_i = oldIndex;
+ oldIndex = -1;
+ }
+ var rule = rules[old_i];
+ rules.splice(old_i, 1);
+ rules.splice(new_index, 0, rule);
+ $('#rules').val(JSON.stringify(rules));
+ }
+</script> \ No newline at end of file