Merge branch 'master' of github.com:ZoneMinder/zoneminder
This commit is contained in:
commit
0bcf7cc3c5
|
@ -51,13 +51,19 @@ jobs:
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
- name: Clean install dependencies and build
|
||||||
|
run: |
|
||||||
|
git submodule init
|
||||||
|
git submodule update --init --recursive
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl-
|
||||||
|
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
# and modify them (or add more) to build your code if your project
|
# and modify them (or add more) to build your code if your project
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !canEdit( 'Devices' ) ) return;
|
||||||
|
|
||||||
|
if ( !empty($_REQUEST['did']) ) {
|
||||||
|
$newDevice = dbFetchOne( 'SELECT * FROM Devices WHERE Id = ?', NULL, array($_REQUEST['did']) );
|
||||||
|
} else {
|
||||||
|
$newDevice = array(
|
||||||
|
"Id" => "",
|
||||||
|
"Name" => "New Device",
|
||||||
|
"KeyString" => ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="modal fade" id="deviceModal" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="staticBackdropLabel"><?php echo translate('Device')." - ".validHtmlStr($newDevice['Name']) ?></h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form id="deviceModalForm" name="contentForm" method="get" action="?view=device&action=device">
|
||||||
|
<?php
|
||||||
|
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
|
||||||
|
echo getCSRFinputHTML();
|
||||||
|
?>
|
||||||
|
<input type="hidden" name="view" value="device"/>
|
||||||
|
<input type="hidden" name="action" value="device"/>
|
||||||
|
<input type="hidden" name="did" value="<?php echo $newDevice['Id'] ?>"/>
|
||||||
|
<table class="table-sm table-borderless" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row" class="text-right pr-2"><?php echo translate('Name') ?></th>
|
||||||
|
<td><input type="text" name="newDevice[Name]" value="<?php echo validHtmlStr($newDevice['Name']) ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row" class="text-right pr-2"><?php echo translate('KeyString') ?></th>
|
||||||
|
<td><input type="text" name="newDevice[KeyString]" value="<?php echo validHtmlStr($newDevice['KeyString']) ?>"/></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="submit" id="deviceSaveBtn" class="btn btn-primary"><?php echo translate('Save') ?></button>
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -28,15 +28,17 @@ if ( $action == 'device' ) {
|
||||||
if ( !empty($_REQUEST['command']) ) {
|
if ( !empty($_REQUEST['command']) ) {
|
||||||
setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']);
|
setDeviceStatusX10($_REQUEST['key'], $_REQUEST['command']);
|
||||||
} else if ( isset($_REQUEST['newDevice']) ) {
|
} else if ( isset($_REQUEST['newDevice']) ) {
|
||||||
if ( isset($_REQUEST['did']) ) {
|
if ( isset($_REQUEST['did']) && $_REQUEST['did'] ) {
|
||||||
|
ZM\Warning('did value is: '.$_REQUEST['did']);
|
||||||
|
ZM\Warning('newDevice array value is: '.print_r($_REQUEST['newDevice'],true));
|
||||||
dbQuery('UPDATE Devices SET Name=?, KeyString=? WHERE Id=?',
|
dbQuery('UPDATE Devices SET Name=?, KeyString=? WHERE Id=?',
|
||||||
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'], $_REQUEST['did']) );
|
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString'], $_REQUEST['did']) );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
dbQuery('INSERT INTO Devices SET Name=?, KeyString=?',
|
dbQuery('INSERT INTO Devices SET Name=?, KeyString=?',
|
||||||
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString']) );
|
array($_REQUEST['newDevice']['Name'], $_REQUEST['newDevice']['KeyString']) );
|
||||||
}
|
}
|
||||||
$refreshParent = true;
|
$redirect = '?view=devices';
|
||||||
$view = 'none';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ZM\Error('Unknown action in device');
|
ZM\Error('Unknown action in device');
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
<?php
|
|
||||||
//
|
|
||||||
// ZoneMinder web device detail view file, $Date$, $Revision$
|
|
||||||
// Copyright (C) 2001-2008 Philip Coombes
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
//
|
|
||||||
|
|
||||||
if ( !canEdit( 'Devices' ) )
|
|
||||||
{
|
|
||||||
$view = "error";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( !empty($_REQUEST['did']) ) {
|
|
||||||
$newDevice = dbFetchOne( 'SELECT * FROM Devices WHERE Id = ?', NULL, array($_REQUEST['did']) );
|
|
||||||
} else {
|
|
||||||
$newDevice = array(
|
|
||||||
"Id" => "",
|
|
||||||
"Name" => "New Device",
|
|
||||||
"KeyString" => ""
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
xhtmlHeaders( __FILE__, translate('Device')." - ".$newDevice['Name'] );
|
|
||||||
?>
|
|
||||||
<body>
|
|
||||||
<div id="page">
|
|
||||||
<div id="header">
|
|
||||||
<h2><?php echo translate('Device')." - ".validHtmlStr($newDevice['Name']) ?></h2>
|
|
||||||
</div>
|
|
||||||
<div id="content">
|
|
||||||
<form name="contentForm" method="get" action="?">
|
|
||||||
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
|
||||||
<input type="hidden" name="action" value="device"/>
|
|
||||||
<input type="hidden" name="did" value="<?php echo $newDevice['Id'] ?>"/>
|
|
||||||
<table id="contentTable" class="major" cellspacing="0">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php echo translate('Name') ?></th>
|
|
||||||
<td><input type="text" name="newDevice[Name]" value="<?php echo validHtmlStr($newDevice['Name']) ?>"/></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th scope="row"><?php echo translate('KeyString') ?></th>
|
|
||||||
<td><input type="text" name="newDevice[KeyString]" value="<?php echo validHtmlStr($newDevice['KeyString']) ?>"/></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div id="contentButtons">
|
|
||||||
<input type="submit" value="<?php echo translate('Save') ?>"<?php if ( !canEdit( 'Devices' ) ) { ?> disabled="disabled"<?php } ?>/><input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -35,10 +35,17 @@ foreach( dbFetchAll( $sql ) as $row )
|
||||||
xhtmlHeaders(__FILE__, translate('Devices') );
|
xhtmlHeaders(__FILE__, translate('Devices') );
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
|
<?php echo getNavBarHTML(); ?>
|
||||||
<div id="page">
|
<div id="page">
|
||||||
<div id="header">
|
<div class="w-100 py-1">
|
||||||
|
<div class="float-left pl-3">
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="w-100 pt-2">
|
||||||
<h2><?php echo translate('Devices') ?></h2>
|
<h2><?php echo translate('Devices') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<form name="contentForm" method="get" action="?">
|
<form name="contentForm" method="get" action="?">
|
||||||
<input type="hidden" name="view" value="none"/>
|
<input type="hidden" name="view" value="none"/>
|
||||||
|
@ -48,23 +55,20 @@ xhtmlHeaders(__FILE__, translate('Devices') );
|
||||||
<table id="contentTable" class="major" cellspacing="0">
|
<table id="contentTable" class="major" cellspacing="0">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach( $devices as $device )
|
foreach( $devices as $device ) {
|
||||||
{
|
|
||||||
if ( $device['Status'] == 'ON' )
|
if ( $device['Status'] == 'ON' ) {
|
||||||
{
|
|
||||||
$fclass = "infoText";
|
$fclass = "infoText";
|
||||||
}
|
} else if ( $device['Status'] == 'OFF' ) {
|
||||||
elseif ( $device['Status'] == 'OFF' )
|
|
||||||
{
|
|
||||||
$fclass = "warnText";
|
$fclass = "warnText";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$fclass = "errorText";
|
$fclass = "errorText";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$str_opt = 'class="deviceCol" data-did="'.$device['Id'].'"';
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo makePopupLink( '?view=device&did='.$device['Id'], 'zmDevice', 'device', '<span class="'.$fclass.'">'.validHtmlStr($device['Name']).' ('.validHtmlStr($device['KeyString']).')</span>', canEdit( 'Devices' ) ) ?></td>
|
<td><?php echo makeLink( '#', '<span class="'.$fclass.'">'.validHtmlStr($device['Name']).' ('.validHtmlStr($device['KeyString']).')</span>', canEdit( 'Devices' ), $str_opt ) ?></td>
|
||||||
<td><input type="button" value="<?php echo translate('On') ?>"<?php echo ($device['Status'] != 'ON')?' class="set"':'' ?> onclick="switchDeviceOn( this, '<?php echo validHtmlStr($device['KeyString']) ?>' )"<?php echo canEdit( 'Devices' )?"":' disabled="disabled"' ?>/></td>
|
<td><input type="button" value="<?php echo translate('On') ?>"<?php echo ($device['Status'] != 'ON')?' class="set"':'' ?> onclick="switchDeviceOn( this, '<?php echo validHtmlStr($device['KeyString']) ?>' )"<?php echo canEdit( 'Devices' )?"":' disabled="disabled"' ?>/></td>
|
||||||
<td><input type="button" value="<?php echo translate('Off') ?>"<?php echo ($device['Status'] != 'OFF')?' class="set"':'' ?> onclick="switchDeviceOff( this, '<?php echo validHtmlStr($device['KeyString']) ?>' )"<?php echo canEdit( 'Devices' )?"":' disabled="disabled"' ?>/></td>
|
<td><input type="button" value="<?php echo translate('Off') ?>"<?php echo ($device['Status'] != 'OFF')?' class="set"':'' ?> onclick="switchDeviceOff( this, '<?php echo validHtmlStr($device['KeyString']) ?>' )"<?php echo canEdit( 'Devices' )?"":' disabled="disabled"' ?>/></td>
|
||||||
<td><input type="checkbox" name="markDids[]" value="<?php echo $device['Id'] ?>" onclick="configureButtons( this, 'markDids' );"<?php if ( !canEdit( 'Devices' ) ) {?> disabled="disabled"<?php } ?>/></td>
|
<td><input type="checkbox" name="markDids[]" value="<?php echo $device['Id'] ?>" onclick="configureButtons( this, 'markDids' );"<?php if ( !canEdit( 'Devices' ) ) {?> disabled="disabled"<?php } ?>/></td>
|
||||||
|
@ -75,12 +79,10 @@ foreach( $devices as $device )
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div id="contentButtons">
|
<div id="contentButtons">
|
||||||
<?php echo makePopupButton('?view=device&did=0', 'zmDevice', 'device', translate('New'), canEdit( 'Devices' )); ?>
|
<button type="button" id="newDeviceBtn" value="<?php echo translate('New') ?>" disabled="disabled"><?php echo translate('New') ?></button>
|
||||||
<input type="button" name="deleteBtn" value="<?php echo translate('Delete') ?>" data-on-click-this="deleteDevice" disabled="disabled"/>
|
<input type="button" class="btn-danger" name="deleteBtn" value="<?php echo translate('Delete') ?>" data-on-click-this="deleteDevice" disabled="disabled"/>
|
||||||
<input type="button" value="<?php echo translate('Cancel') ?>" data-on-click="closeWindow"/>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
<?php xhtmlFooter() ?>
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
var newDeviceBtn = $j('#newDeviceBtn');
|
||||||
|
|
||||||
function switchDeviceOn( element, key ) {
|
function switchDeviceOn( element, key ) {
|
||||||
var form = element.form;
|
var form = element.form;
|
||||||
form.view.value = currentView;
|
form.view.value = currentView;
|
||||||
|
@ -37,4 +39,56 @@ function configureButtons( element, name ) {
|
||||||
form.deleteBtn.disabled = !checked;
|
form.deleteBtn.disabled = !checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.focus();
|
// Load the Device Modal HTML via Ajax call
|
||||||
|
function getDeviceModal(did) {
|
||||||
|
$j.getJSON(thisUrl + '?request=modal&modal=device&did=' + did)
|
||||||
|
.done(function(data) {
|
||||||
|
if ( $j('#deviceModal').length ) {
|
||||||
|
$j('#deviceModal').replaceWith(data.html);
|
||||||
|
} else {
|
||||||
|
$j("body").append(data.html);
|
||||||
|
}
|
||||||
|
$j('#deviceModal').modal('show');
|
||||||
|
// Manage the Save button
|
||||||
|
$j('#deviceSaveBtn').click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
$j('#deviceModalForm').submit();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.fail(logAjaxFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableDeviceModal() {
|
||||||
|
$j(".deviceCol").click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
var did = $j(this).data('did');
|
||||||
|
getDeviceModal(did);
|
||||||
|
});
|
||||||
|
newDeviceBtn.click(function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
getDeviceModal(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initPage() {
|
||||||
|
if ( canEditDevice ) enableDeviceModal();
|
||||||
|
|
||||||
|
newDeviceBtn.prop('disabled', !canEditDevice);
|
||||||
|
|
||||||
|
// Manage the BACK button
|
||||||
|
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
window.history.back();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Disable the back button if there is nothing to go back to
|
||||||
|
$j('#backBtn').prop('disabled', !document.referrer.length);
|
||||||
|
|
||||||
|
// Manage the REFRESH Button
|
||||||
|
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
window.location.reload(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$j(document).ready(initPage);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
var canEditDevice = <?php echo canEdit('Devices') ? 'true' : 'false' ?>;
|
Loading…
Reference in New Issue