convert controlcaps view to bstable
This commit is contained in:
parent
e2fb5ae9ea
commit
0c4fcbbe97
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
if ( !canEdit('Control') ) {
|
||||||
|
ZM\Warning('Need Control permissions to edit control capabilities');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty($_REQUEST['action']) ) {
|
||||||
|
ajaxError('Action Not Provided');
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$action = $_REQUEST['action'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($_REQUEST['cids']) ) {
|
||||||
|
$cids = $_REQUEST['cids'];
|
||||||
|
} else {
|
||||||
|
ajaxError('At least one Control Id must be Provided.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $action == 'delete' ) {
|
||||||
|
foreach( $cids as $cid ) {
|
||||||
|
dbQuery('UPDATE Monitors SET Controllable = 0, ControlId = 0 WHERE ControlId = ?', array($cid));
|
||||||
|
dbQuery('DELETE FROM Controls WHERE Id = ?', array($cid));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ajaxError('Unrecognised action ' .$_REQUEST['action']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ajaxResponse();
|
||||||
|
return;
|
||||||
|
?>
|
|
@ -32,32 +32,45 @@ xhtmlHeaders(__FILE__, translate('ControlCaps'));
|
||||||
<body>
|
<body>
|
||||||
<?php echo getNavBarHTML() ?>
|
<?php echo getNavBarHTML() ?>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<div class="w-100 py-1">
|
|
||||||
<div class="float-left pl-3">
|
<!-- Toolbar button placement and styling handled by bootstrap-tables -->
|
||||||
<button type="button" id="backBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Back') ?>" disabled><i class="fa fa-arrow-left"></i></button>
|
<div id="toolbar">
|
||||||
<button type="button" id="refreshBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Refresh') ?>" ><i class="fa fa-refresh"></i></button>
|
<button id="backBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Back') ?>" disabled><i class="fa fa-arrow-left"></i></button>
|
||||||
</div>
|
<button id="refreshBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Refresh') ?>" ><i class="fa fa-refresh"></i></button>
|
||||||
<div class="w-100 pt-2">
|
<button id="addNewBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('AddNewControl') ?>" data-on-click-this="addNewControl" data-url="?view=controlcap"><i class="fa fa-plus"></i></button>
|
||||||
<h2><?php echo translate('ControlCaps') ?></h2>
|
<button id="editBtn" class="btn btn-normal" data-toggle="tooltip" data-placement="top" title="<?php echo translate('EditControl') ?>" data-on-click-this="editControl" data-url="?view=controlcap&cid=" disabled><i class="fa fa-pencil"></i></button>
|
||||||
</div>
|
<button id="deleteBtn" class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="<?php echo translate('Delete') ?>" disabled><i class="fa fa-trash"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<form name="contentForm" id="contentForm" method="get" action="?" onsubmit="return( confirmDelete( 'Warning, deleting a control will reset all monitors that use it to be uncontrollable.\nAre you sure you wish to delete?' ) );">
|
<table
|
||||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
id="controlTable"
|
||||||
<input type="hidden" name="action" value="delete"/>
|
class="table-sm table-borderless"
|
||||||
<table id="contentTable" class="major">
|
data-search="true"
|
||||||
|
data-cookie="true"
|
||||||
|
data-cookie-id-table="zmControlTable"
|
||||||
|
data-cookie-expire="2y"
|
||||||
|
data-remember-order="true"
|
||||||
|
data-click-to-select="true"
|
||||||
|
data-maintain-meta-data="true"
|
||||||
|
data-mobile-responsive="true"
|
||||||
|
data-buttons-class="btn btn-normal"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-columns="true"
|
||||||
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="colName"><?php echo translate('Name') ?></th>
|
<th data-sortable="false" data-field="toggleCheck" data-checkbox="true"></th>
|
||||||
<th class="colType"><?php echo translate('Type') ?></th>
|
<th class="colId" data-sortable="true" data-field="Id"><?php echo translate('Id') ?></th>
|
||||||
<th class="colProtocol"><?php echo translate('Protocol') ?></th>
|
<th class="colName" data-sortable="true" data-field="Name"><?php echo translate('Name') ?></th>
|
||||||
<th class="colCanMove"><?php echo translate('CanMove') ?></th>
|
<th class="colType" data-sortable="true" data-field="Type"><?php echo translate('Type') ?></th>
|
||||||
<th class="colCanZoom"><?php echo translate('CanZoom') ?></th>
|
<th class="colProtocol" data-sortable="true" data-field="Protocol"><?php echo translate('Protocol') ?></th>
|
||||||
<th class="colCanFocus"><?php echo translate('CanFocus') ?></th>
|
<th class="colCanMove" data-sortable="true" data-field="CanMove"><?php echo translate('CanMove') ?></th>
|
||||||
<th class="colCanIris"><?php echo translate('CanIris') ?></th>
|
<th class="colCanZoom" data-sortable="true" data-field="CanZoom"><?php echo translate('CanZoom') ?></th>
|
||||||
<th class="colCanWhiteBal"><?php echo translate('CanWhiteBal') ?></th>
|
<th class="colCanFocus" data-sortable="true" data-field="CanFocus"><?php echo translate('CanFocus') ?></th>
|
||||||
<th class="colHasPresets"><?php echo translate('HasPresets') ?></th>
|
<th class="colCanIris" data-sortable="true" data-field="CanIris"><?php echo translate('CanIris') ?></th>
|
||||||
<th class="colMark"><?php echo translate('Mark') ?></th>
|
<th class="colCanWhiteBal" data-sortable="true" data-field="CanWhiteBal"><?php echo translate('CanWhiteBal') ?></th>
|
||||||
|
<th class="colHasPresets" data-sortable="true" data-field="HasPresets"><?php echo translate('HasPresets') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -65,7 +78,9 @@ xhtmlHeaders(__FILE__, translate('ControlCaps'));
|
||||||
foreach( $controls as $control ) {
|
foreach( $controls as $control ) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="colName"><?php echo makeLink( '?view=controlcap&cid='.$control['Id'], validHtmlStr($control['Name']), canView( 'Control' ) ) ?></td>
|
<td class="colMark" data-checkbox="true"></td>
|
||||||
|
<td class="colId"><?php echo $control['Id'] ?></td>
|
||||||
|
<td class="colName"><?php echo $control['Name'] ?></td>
|
||||||
<td class="colType"><?php echo $control['Type'] ?></td>
|
<td class="colType"><?php echo $control['Type'] ?></td>
|
||||||
<td class="colProtocol"><?php echo validHtmlStr($control['Protocol']) ?></td>
|
<td class="colProtocol"><?php echo validHtmlStr($control['Protocol']) ?></td>
|
||||||
<td class="colCanMove"><?php echo $control['CanMove']?translate('Yes'):translate('No') ?></td>
|
<td class="colCanMove"><?php echo $control['CanMove']?translate('Yes'):translate('No') ?></td>
|
||||||
|
@ -74,18 +89,12 @@ foreach( $controls as $control ) {
|
||||||
<td class="colCanIris"><?php echo $control['CanIris']?translate('Yes'):translate('No') ?></td>
|
<td class="colCanIris"><?php echo $control['CanIris']?translate('Yes'):translate('No') ?></td>
|
||||||
<td class="colCanWhiteBal"><?php echo $control['CanWhite']?translate('Yes'):translate('No') ?></td>
|
<td class="colCanWhiteBal"><?php echo $control['CanWhite']?translate('Yes'):translate('No') ?></td>
|
||||||
<td class="colHasPresets"><?php echo $control['HasHomePreset']?'H':'' ?><?php echo $control['HasPresets']?$control['NumPresets']:'0' ?></td>
|
<td class="colHasPresets"><?php echo $control['HasHomePreset']?'H':'' ?><?php echo $control['HasPresets']?$control['NumPresets']:'0' ?></td>
|
||||||
<td class="colMark"><input type="checkbox" name="markCids[]" value="<?php echo $control['Id'] ?>" data-on-click-this="configureDeleteButton"<?php if ( !canEdit( 'Control' ) ) {?> disabled="disabled"<?php } ?>/></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div id="contentButtons">
|
|
||||||
<?php echo makeButton('?view=controlcap', 'AddNewControl', canEdit( 'Control' )); ?>
|
|
||||||
<input type="submit" name="deleteBtn" value="<?php echo translate('Delete') ?>" disabled="disabled"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php xhtmlFooter() ?>
|
<?php xhtmlFooter() ?>
|
||||||
|
|
|
@ -1,10 +1,85 @@
|
||||||
|
var table = $j('#controlTable');
|
||||||
|
var addNewBtn = $j('#addNewBtn');
|
||||||
|
var editBtn = $j('#editBtn');
|
||||||
|
var deleteBtn = $j('#deleteBtn');
|
||||||
|
|
||||||
// Manage the Add New Control button
|
// Manage the Add New Control button
|
||||||
function AddNewControl(el) {
|
function AddNewControl(el) {
|
||||||
url = el.getAttribute('data-url');
|
url = el.getAttribute('data-url');
|
||||||
window.location.assign(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Manage the Add New Control button
|
||||||
|
function addNewControl(el) {
|
||||||
|
url = el.getAttribute('data-url');
|
||||||
|
window.location.assign(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manage the Edit Control button
|
||||||
|
function editControl(el) {
|
||||||
|
var selection = getIdSelections();
|
||||||
|
|
||||||
|
url = el.getAttribute('data-url');
|
||||||
|
window.location.assign(url+selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the event id's of the selected rows
|
||||||
|
function getIdSelections() {
|
||||||
|
return $j.map(table.bootstrapTable('getSelections'), function(row) {
|
||||||
|
return row.Id.replace(/(<([^>]+)>)/gi, ''); // strip the html from the element before sending
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Delete Confirmation Modal HTML via Ajax call
|
||||||
|
function getDelConfirmModal(key) {
|
||||||
|
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm&key=' + key)
|
||||||
|
.done(function(data) {
|
||||||
|
if ( $j('#deleteConfirm').length ) {
|
||||||
|
$j('#deleteConfirm').replaceWith(data.html);
|
||||||
|
} else {
|
||||||
|
$j("body").append(data.html);
|
||||||
|
}
|
||||||
|
manageDelConfirmModalBtns();
|
||||||
|
})
|
||||||
|
.fail(logAjaxFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manage the DELETE CONFIRMATION modal button
|
||||||
|
function manageDelConfirmModalBtns() {
|
||||||
|
document.getElementById("delConfirmBtn").addEventListener("click", function onDelConfirmClick(evt) {
|
||||||
|
if ( ! canEditControl ) {
|
||||||
|
enoperm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selections = getIdSelections();
|
||||||
|
|
||||||
|
evt.preventDefault();
|
||||||
|
$j.getJSON(thisUrl + '?request=controlcaps&action=delete&cids[]='+selections.join('&cids[]='))
|
||||||
|
.done( function(data) {
|
||||||
|
$j('#eventTable').bootstrapTable('refresh');
|
||||||
|
window.location.reload(true);
|
||||||
|
})
|
||||||
|
.fail(logAjaxFail);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initPage() {
|
function initPage() {
|
||||||
|
|
||||||
|
// enable or disable buttons based on current selection and user rights
|
||||||
|
table.on('check.bs.table uncheck.bs.table ' +
|
||||||
|
'check-all.bs.table uncheck-all.bs.table',
|
||||||
|
function() {
|
||||||
|
selections = table.bootstrapTable('getSelections');
|
||||||
|
|
||||||
|
addNewBtn.prop('disabled', (selections.length || !canEditControl));
|
||||||
|
editBtn.prop('disabled', !((selections.length == 1) && canEditControl));
|
||||||
|
deleteBtn.prop('disabled', !(selections.length && canEditControl));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Init the bootstrap-table
|
||||||
|
table.bootstrapTable({icons: icons});
|
||||||
|
|
||||||
// Manage the BACK button
|
// Manage the BACK button
|
||||||
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
@ -19,6 +94,25 @@ function initPage() {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Manage the DELETE button
|
||||||
|
document.getElementById("deleteBtn").addEventListener("click", function onDeleteClick(evt) {
|
||||||
|
if ( ! canEditControl ) {
|
||||||
|
enoperm();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
evt.preventDefault();
|
||||||
|
$j('#deleteConfirm').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Load the delete confirmation modal into the DOM
|
||||||
|
getDelConfirmModal('ConfirmDeleteControl');
|
||||||
|
|
||||||
|
// Hide these columns on first run when no cookie is saved
|
||||||
|
if ( !getCookie("zmControlTable.bs.table.columns") ) {
|
||||||
|
table.bootstrapTable('hideColumn', 'Id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$j(document).ready(function() {
|
$j(document).ready(function() {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
var canEditControl = <?php echo canEdit('Control')?'true':'false' ?>;
|
Loading…
Reference in New Issue