Merge branch 'master' into zma_to_thread

This commit is contained in:
Isaac Connor 2021-01-17 17:38:34 -05:00
commit cb90c06cde
9 changed files with 56 additions and 33 deletions

View File

@ -122,7 +122,17 @@ sub authentificationHeader {
my $nonceBase64 = encode_base64($nonce, '');
my $currentDate = DateTime->now()->iso8601().'Z';
return '<s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><Username>' . $username . '</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' . digestBase64($nonce, $currentDate, $password) . '</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $nonceBase64 . '</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . $currentDate . '</Created></UsernameToken></Security></s:Header>';
return '
<s:Header>
<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<Username>' . $username . '</Username>
<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">' . digestBase64($nonce, $currentDate, $password) . '</Password>
<Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">' . $nonceBase64 . '</Nonce>
<Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' . $currentDate . '</Created>
</UsernameToken>
</Security>
</s:Header>';
}
sub sendCmd {

View File

@ -65,7 +65,7 @@ sub sendCmd {
my $self = shift;
my $cmd = shift;
my $result = undef;
printMsg($cmd, 'Tx');
$this->printMsg($cmd, 'Tx');
my $req = HTTP::Request->new(GET=>'http://'.$self->{Monitor}->{ControlAddress}.'/'.$cmd);
my $res = $self->{ua}->request($req);

View File

@ -165,8 +165,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
$col_str = 'E.*, M.Name AS Monitor';
$sql = 'SELECT ' .$col_str. ' FROM `Events` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY '.$sort.' '.$order;
//ZM\Debug('Calling the following sql query: ' .$sql);
$storage_areas = ZM\Storage::find();
$StorageById = array();
foreach ( $storage_areas as $S ) {
@ -176,14 +174,18 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
$unfiltered_rows = array();
$event_ids = array();
foreach ( dbFetchAll($sql, NULL, $values) as $row ) {
ZM\Debug('Calling the following sql query: ' .$sql);
$query = dbQuery($sql, $values);
if ( $query ) {
while ( $row = dbFetchNext($query) ) {
$event = new ZM\Event($row);
if ( !$filter->test_post_sql_conditions($event) ) {
$event->remove_from_cache();
if ( !$filter->test_post_sql_conditions($event) ) {
continue;
}
$event_ids[] = $event->Id();
$unfiltered_rows[] = $row;
} # end foreach row
}
ZM\Debug('Have ' . count($unfiltered_rows) . ' events matching base filter.');
@ -218,6 +220,7 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
} # end if search
$sql = 'SELECT ' .$col_str. ' FROM `Events` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE '.$search_filter->sql().' ORDER BY ' .$sort. ' ' .$order;
ZM\Debug('Calling the following sql query: ' .$sql);
$filtered_rows = dbFetchAll($sql);
ZM\Debug('Have ' . count($filtered_rows) . ' events matching search filter.');
} else {

View File

@ -996,9 +996,8 @@ $OLANG = array(
'Help' => '
Parameters in this field are passed on to FFmpeg. Multiple parameters can be separated by ,~~
Examples (do not enter quotes)~~~~
"allowed_media_types=video" Set datatype to request fromcam (audio, video, data)~~~~
"reorder_queue_size=nnn" Set number of packets to buffer for handling of reordered packets~~~~
"loglevel=debug" Set verbosity of FFmpeg (quiet, panic, fatal, error, warning, info, verbose, debug)
"allowed_media_types=video" Set datatype to request from cam (audio, video, data)~~~~
"reorder_queue_size=nnn" Set number of packets to buffer for handling of reordered packets
'
),
'OPTIONS_ENCODER_PARAMETERS' => array(

View File

@ -813,6 +813,16 @@ function manageModalBtns(id) {
});
}
function bindButton(selector, action, data, func) {
var elements = $j(selector);
if ( !elements.length ) {
console.log("Nothing found for " + selector);
return;
}
elements.on(action, data, func);
}
function human_filesize(size, precision = 2) {
var units = Array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
var step = 1024;

View File

@ -43,7 +43,7 @@ var serverId = '<?php echo defined('ZM_SERVER_ID') ? ZM_SERVER_ID : '' ?>';
var canView = {};
var canEdit = {};
<?php
$perms = array("Stream", "Events", "Control", "Monitors", "Groups", "System", "Devices");
$perms = array('Stream', 'Events', 'Control', 'Monitors', 'Groups', 'System', 'Devices');
foreach ( $perms as $perm ) {
?>
canView["<?php echo $perm ?>"] = <?php echo canView($perm)?'true':'false' ?>;
@ -60,7 +60,7 @@ if ( ! empty($refreshParent) ) {
echo 'true';
} else if ( $refreshParent ) {
# This is to tell the parent to refresh to a specific URL
echo "'$refreshParent'";
echo '\''.$refreshParent.'\'';
} else {
echo 'false';
}

View File

@ -1035,14 +1035,14 @@ function initPage() {
});
// Manage the FRAMES Button
document.getElementById("framesBtn").addEventListener("click", function onFramesClick(evt) {
bindButton('#framesBtn', 'click', null, function onFramesClick(evt) {
evt.preventDefault();
window.location.assign('?view=frames&eid='+eventData.Id);
});
// Manage the DELETE button
document.getElementById("deleteBtn").addEventListener("click", function onDeleteClick(evt) {
if ( ! canEdit.Events ) {
bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) {
if ( !canEdit.Events ) {
enoperm();
return;
}
@ -1061,7 +1061,7 @@ function initPage() {
}
$j('#deleteConfirm').modal('show');
});
}
} // end initPage
// Kick everything off
$j(document).ready(initPage);

View File

@ -118,7 +118,7 @@ function requestFrameData( eventId, frameId ) {
function previewEvent(slot) {
eventId = slot.getAttribute('data-event-id');
frameId = slot.getAttribute('data-frame-id');
if ( events[eventId] ) {
if ( events[eventId] && events[eventId]['frames'] && events[eventId]['frames'][frameId] ) {
showEventData(eventId, frameId);
} else {
requestFrameData(eventId, frameId);

View File

@ -40,6 +40,7 @@ function ajaxRequest(params) {
params.data.order = 'desc';
params.data.limit = maxDisplayEvents;
params.data.sort = 'Id';
if ( auth_hash ) params.data.auth = auth_hash;
$j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data)
.done(function(data) {
@ -290,8 +291,8 @@ function getStreamCmdResponse(respObj, respText) {
// Try to reload the image stream.
// If it's an auth error, we should reload the whole page.
console.log("have error");
window.location.reload();
if ( 0 ) {
//window.location.reload();
if ( 1 ) {
var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) {
var oldSrc = streamImg.attr('src');
@ -359,7 +360,7 @@ function streamCmdPlay( action ) {
}
function streamCmdReq(data) {
$j.getJSON(thisUrl + '?view=request&request=stream&connkey='+connKey, data)
$j.getJSON(monitorUrl + '?view=request&request=stream&connkey='+connKey, data)
.done(getStreamCmdResponse)
.fail(getStreamCmdError);
@ -527,7 +528,7 @@ function getStatusCmdResponse(respObj, respText) {
}
function statusCmdQuery() {
$j.getJSON(thisUrl + '?view=request&request=status&entity=monitor&element[]=Status&element[]=FrameRate&id='+monitorId)
$j.getJSON(monitorUrl + '?view=request&request=status&entity=monitor&element[]=Status&element[]=FrameRate&id='+monitorId)
.done(getStatusCmdResponse)
.fail(logAjaxFail);
@ -535,7 +536,7 @@ function statusCmdQuery() {
}
function alarmCmdReq(data) {
$j.getJSON(thisUrl + '?view=request&request=alarm&id='+monitorId, data)
$j.getJSON(monitorUrl + '?view=request&request=alarm&id='+monitorId, data)
.done(getAlarmCmdResponse)
.fail(function(jqxhr, textStatus, error) {
if (textstatus === "timeout") {
@ -598,7 +599,7 @@ function cmdForce() {
}
function controlReq(data) {
$j.getJSON(thisUrl + '?view=request&request=control&id='+monitorId, data)
$j.getJSON(monitorUrl + '?view=request&request=control&id='+monitorId, data)
.done(getControlResponse)
.fail(logAjaxFail);
}
@ -758,7 +759,7 @@ function updatePresetLabels() {
}
function getCtrlPresetModal() {
$j.getJSON(thisUrl + '?request=modal&modal=controlpreset&mid=' + monitorId)
$j.getJSON(monitorUrl + '?request=modal&modal=controlpreset&mid=' + monitorId)
.done(function(data) {
insertModalHtml('ctrlPresetModal', data.html);
updatePresetLabels();
@ -774,7 +775,7 @@ function getCtrlPresetModal() {
}
function getSettingsModal() {
$j.getJSON(thisUrl + '?request=modal&modal=settings&mid=' + monitorId)
$j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId)
.done(function(data) {
insertModalHtml('settingsModal', data.html);
// Manage the Save button
@ -788,7 +789,7 @@ function getSettingsModal() {
function processClicks(event, field, value, row, $element) {
if ( field == 'Delete' ) {
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm')
$j.getJSON(monitorUrl + '?request=modal&modal=delconfirm')
.done(function(data) {
insertModalHtml('deleteConfirm', data.html);
manageDelConfirmModalBtns();
@ -886,7 +887,7 @@ function initPage() {
}
// Manage the BACK button
document.getElementById("backBtn").addEventListener("click", function onBackClick(evt) {
bindButton('#backBtn', 'click', null, function onBackClick(evt) {
evt.preventDefault();
window.history.back();
});
@ -895,13 +896,13 @@ function initPage() {
backBtn.prop('disabled', !document.referrer.length);
// Manage the REFRESH Button
document.getElementById("refreshBtn").addEventListener("click", function onRefreshClick(evt) {
bindButton('#refreshBtn', 'click', null, function onRefreshClick(evt) {
evt.preventDefault();
window.location.reload(true);
});
// Manage the SETTINGS button
document.getElementById("settingsBtn").addEventListener("click", function onSettingsClick(evt) {
bindButton('settingsBtn', 'click', null, function onSettingsClick(evt) {
evt.preventDefault();
$j('#settingsModal').modal('show');
});