Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas

This commit is contained in:
Isaac Connor 2018-04-26 22:09:48 -04:00
commit 348468a98d
9 changed files with 44 additions and 31 deletions

View File

@ -160,9 +160,12 @@ sub Sql {
if ( $term->{attr} =~ /^Monitor/ ) { if ( $term->{attr} =~ /^Monitor/ ) {
my ( $temp_attr_name ) = $term->{attr} =~ /^Monitor(.+)$/; my ( $temp_attr_name ) = $term->{attr} =~ /^Monitor(.+)$/;
$self->{Sql} .= 'M.'.$temp_attr_name; $self->{Sql} .= 'M.'.$temp_attr_name;
} elsif ( $term->{attr} =~ /^Server/ ) { } elsif ( $term->{attr} eq 'ServerId' or $term->{attr} eq 'MonitorServerId' ) {
$self->{Sql} .= 'M.'.$term->{attr};
} elsif ( $term->{attr} eq 'StorageServerId' ) {
$self->{Sql} .= 'S.'.$term->{attr}; $self->{Sql} .= 'S.'.$term->{attr};
} elsif ( $term->{attr} eq 'FilterServerId' ) {
$self->{Sql} .= $Config{ZM_SERVER_ID};
# StartTime options # StartTime options
} elsif ( $term->{attr} eq 'DateTime' ) { } elsif ( $term->{attr} eq 'DateTime' ) {
$self->{Sql} .= 'E.StartTime'; $self->{Sql} .= 'E.StartTime';
@ -208,7 +211,7 @@ sub Sql {
foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) { foreach my $temp_value ( split( /["'\s]*?,["'\s]*?/, $stripped_value ) ) {
if ( $term->{attr} =~ /^MonitorName/ ) { if ( $term->{attr} =~ /^MonitorName/ ) {
$value = "'$temp_value'"; $value = "'$temp_value'";
} elsif ( $term->{attr} eq 'ServerId' ) { } elsif ( $term->{attr} =~ /ServerId/) {
Debug("ServerId, temp_value is ($temp_value) ($ZoneMinder::Config::Config{ZM_SERVER_ID})"); Debug("ServerId, temp_value is ($temp_value) ($ZoneMinder::Config::Config{ZM_SERVER_ID})");
if ( $temp_value eq 'ZM_SERVER_ID' ) { if ( $temp_value eq 'ZM_SERVER_ID' ) {
$value = "'$ZoneMinder::Config::Config{ZM_SERVER_ID}'"; $value = "'$ZoneMinder::Config::Config{ZM_SERVER_ID}'";

View File

@ -346,14 +346,13 @@ sub run {
} }
close(CLIENT); close(CLIENT);
} else { } else {
Fatal('Bogus descriptor'); Error('Bogus descriptor');
} }
} elsif ( $nfound < 0 ) { } elsif ( $nfound < 0 ) {
if ( $! == EINTR ) { if ( $! == EINTR ) {
# Dead child, will be reaped # Dead child, will be reaped
#print( "Probable dead child\n" ); #print( "Probable dead child\n" );
# See if it needs to start up again # See if it needs to start up again
restartPending();
} elsif ( $! == EPIPE ) { } elsif ( $! == EPIPE ) {
Error("Can't select: $!"); Error("Can't select: $!");
} else { } else {
@ -361,12 +360,13 @@ sub run {
} }
} else { } else {
#print( "Select timed out\n" ); #print( "Select timed out\n" );
restartPending();
} }
restartPending();
check_for_processes_to_kill(); check_for_processes_to_kill();
} # end while } # end while
dPrint(ZoneMinder::Logger::INFO, 'Server exiting at ' dPrint(ZoneMinder::Logger::INFO, 'Server exiting at '
.strftime( '%y/%m/%d %H:%M:%S', localtime() ) .strftime( '%y/%m/%d %H:%M:%S', localtime() )
."\n" ."\n"
@ -530,7 +530,7 @@ sub check_for_processes_to_kill {
foreach my $command ( %terminating_processes ) { foreach my $command ( %terminating_processes ) {
my $process = $cmd_hash{$command}; my $process = $cmd_hash{$command};
Debug("Have process $command at pid $$process{pid} $$process{term_sent_at}"); Debug("Have process $command at pid $$process{pid} $$process{term_sent_at}");
if ( $$process{term_sent_at} - time > KILL_DELAY ) { if ( $$process{term_sent_at} and ( $$process{term_sent_at} - time > KILL_DELAY ) ) {
dPrint(ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at " dPrint(ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
.strftime('%y/%m/%d %H:%M:%S', localtime()) .strftime('%y/%m/%d %H:%M:%S', localtime())
.' after ' . KILL_DELAY . ' seconds.' .' after ' . KILL_DELAY . ' seconds.'

View File

@ -133,7 +133,7 @@ function dbQuery( $sql, $params=NULL ) {
} }
} else { } else {
if ( defined('ZM_DB_DEBUG') ) { if ( defined('ZM_DB_DEBUG') ) {
Logger::Debug("SQL: $sql values:" . $params?implode(',',$params):'' ); Logger::Debug("SQL: $sql values:" . ($params?implode(',',$params):'') );
} }
$result = $dbConn->query($sql); $result = $dbConn->query($sql);
} }

View File

@ -1025,8 +1025,15 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&amp;') {
$filter['sql'] .= 'M.'.preg_replace('/^Monitor/', '', $terms[$i]['attr']); $filter['sql'] .= 'M.'.preg_replace('/^Monitor/', '', $terms[$i]['attr']);
break; break;
case 'ServerId': case 'ServerId':
case 'MonitorServerId':
$filter['sql'] .= 'M.ServerId'; $filter['sql'] .= 'M.ServerId';
break; break;
case 'StorageServerId':
$filter['sql'] .= 'S.ServerId';
break;
case 'FilterServerId':
$filter['sql'] .= ZM_SERVER_ID;
break;
# Unspecified start or end, so assume start, this is to support legacy filters # Unspecified start or end, so assume start, this is to support legacy filters
case 'DateTime': case 'DateTime':
$filter['sql'] .= 'E.StartTime'; $filter['sql'] .= 'E.StartTime';
@ -1121,6 +1128,9 @@ function parseFilter(&$filter, $saveToSession=false, $querySep='&amp;') {
case 'Notes': case 'Notes':
$value = dbEscape($value); $value = dbEscape($value);
break; break;
case 'MonitorServerId':
case 'FilterServerId':
case 'StorageServerId':
case 'ServerId': case 'ServerId':
if ( $value == 'ZM_SERVER_ID' ) { if ( $value == 'ZM_SERVER_ID' ) {
$value = ZM_SERVER_ID; $value = ZM_SERVER_ID;

View File

@ -130,7 +130,9 @@ $SLANG = array(
'AttrMonitorId' => 'Monitor Id', 'AttrMonitorId' => 'Monitor Id',
'AttrMonitorName' => 'Monitor Name', 'AttrMonitorName' => 'Monitor Name',
'AttrStorageArea' => 'Storage Area', 'AttrStorageArea' => 'Storage Area',
'AttrServer' => 'Server', 'AttrFilterServer' => 'Server Filter is Running On',
'AttrMonitorServer' => 'Server Monitor is Running On',
'AttrStorageServer' => 'Server Hosting Storage',
'AttrStateId' => 'Run State', 'AttrStateId' => 'Run State',
'AttrName' => 'Name', 'AttrName' => 'Name',
'AttrNotes' => 'Notes', 'AttrNotes' => 'Notes',

View File

@ -101,7 +101,10 @@ $attrTypes = array(
'DiskSpace' => translate('AttrDiskSpace'), 'DiskSpace' => translate('AttrDiskSpace'),
'SystemLoad' => translate('AttrSystemLoad'), 'SystemLoad' => translate('AttrSystemLoad'),
'StorageId' => translate('AttrStorageArea'), 'StorageId' => translate('AttrStorageArea'),
'ServerId' => translate('AttrServer'), 'ServerId' => translate('AttrMonitorServer'),
'FilterServerId' => translate('AttrFilterServer'),
'MonitorServerId' => translate('AttrMonitorServer'),
'StorageServerId' => translate('AttrStorageServer'),
'StateId' => translate('AttrStateId'), 'StateId' => translate('AttrStateId'),
); );
@ -268,7 +271,7 @@ for ( $i=0; $i < count($terms); $i++ ) {
<td><?php echo htmlSelect( "filter[Query][terms][$i][op]", $opTypes, $term['op'] ); ?></td> <td><?php echo htmlSelect( "filter[Query][terms][$i][op]", $opTypes, $term['op'] ); ?></td>
<td><?php echo htmlSelect( "filter[Query][terms][$i][val]", $monitors, $term['val'] ); ?></td> <td><?php echo htmlSelect( "filter[Query][terms][$i][val]", $monitors, $term['val'] ); ?></td>
<?php <?php
} elseif ( $term['attr'] == 'ServerId' ) { } elseif ( $term['attr'] == 'ServerId' || $term['attr'] == 'MonitorServerId' || $term['attr'] == 'StorageServerId' || $term['attr'] == 'FilterServerId' ) {
?> ?>
<td><?php echo htmlSelect( "filter[Query][terms][$i][op]", $opTypes, $term['op'] ); ?></td> <td><?php echo htmlSelect( "filter[Query][terms][$i][op]", $opTypes, $term['op'] ); ?></td>
<td><?php echo htmlSelect( "filter[Query][terms][$i][val]", $servers, $term['val'] ); ?></td> <td><?php echo htmlSelect( "filter[Query][terms][$i][val]", $servers, $term['val'] ); ?></td>

View File

@ -142,7 +142,9 @@ function parseRows (rows) {
inputTds.eq(6).find(':input[value="-"]').prop('disabled', false); inputTds.eq(6).find(':input[value="-"]').prop('disabled', false);
} }
if (inputTds.eq(2).children().val() == "Archived") { //Archived types var attr = inputTds.eq(2).children().val();
if ( attr == "Archived") { //Archived types
inputTds.eq(3).html('equal to<input type="hidden" name="filter[Query][terms][' + rowNum + '][op]" value="=">'); inputTds.eq(3).html('equal to<input type="hidden" name="filter[Query][terms][' + rowNum + '][op]" value="=">');
let archiveSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let archiveSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for (let i = 0; i < archiveTypes.length; i++) { for (let i = 0; i < archiveTypes.length; i++) {
@ -151,7 +153,7 @@ function parseRows (rows) {
let archiveVal = inputTds.eq(4).children().val(); let archiveVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(archiveSelect).children().val(archiveVal).chosen({width: "101%"}); inputTds.eq(4).html(archiveSelect).children().val(archiveVal).chosen({width: "101%"});
} else if (inputTds.eq(2).children().val().indexOf('Weekday') >= 0) { //Weekday selection } else if ( attr.indexOf('Weekday') >= 0 ) { //Weekday selection
let weekdaySelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let weekdaySelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for (let i = 0; i < weekdays.length; i++) { for (let i = 0; i < weekdays.length; i++) {
weekdaySelect.append('<option value="' + i + '">' + weekdays[i] + '</option>'); weekdaySelect.append('<option value="' + i + '">' + weekdays[i] + '</option>');
@ -159,7 +161,7 @@ function parseRows (rows) {
let weekdayVal = inputTds.eq(4).children().val(); let weekdayVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(weekdaySelect).children().val(weekdayVal).chosen({width: "101%"}); inputTds.eq(4).html(weekdaySelect).children().val(weekdayVal).chosen({width: "101%"});
} else if (inputTds.eq(2).children().val() == 'StateId') { //Run state } else if ( attr == 'StateId' ) { //Run state
let stateSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let stateSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for (let key in states) { for (let key in states) {
stateSelect.append('<option value="' + key + '">' + states[key] + '</option>'); stateSelect.append('<option value="' + key + '">' + states[key] + '</option>');
@ -167,8 +169,7 @@ function parseRows (rows) {
let stateVal = inputTds.eq(4).children().val(); let stateVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(stateSelect).children().val(stateVal).chosen({width: "101%"}); inputTds.eq(4).html(stateSelect).children().val(stateVal).chosen({width: "101%"});
} else if ( attr == 'ServerId' || attr == 'MonitorServerId' || attr == 'StorageServerId' || attr == 'FilterServerId' ) { //Select Server
} else if (inputTds.eq(2).children().val() == 'ServerId') { //Select Server
let serverSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let serverSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for (let key in servers) { for (let key in servers) {
serverSelect.append('<option value="' + key + '">' + servers[key] + '</option>'); serverSelect.append('<option value="' + key + '">' + servers[key] + '</option>');
@ -176,21 +177,15 @@ function parseRows (rows) {
let serverVal = inputTds.eq(4).children().val(); let serverVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(serverSelect).children().val(serverVal).chosen({width: "101%"}); inputTds.eq(4).html(serverSelect).children().val(serverVal).chosen({width: "101%"});
} else if (inputTds.eq(2).children().val() == 'StorageId') { //Choose by storagearea } else if ( attr == 'StorageId' ) { //Choose by storagearea
let storageSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let storageSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for ( key in storageareas ) { for ( key in storageareas ) {
console.log(key + ' ' + storageareas[key]);
storageSelect.append('<option value="' + key + '">' + storageareas[key] + '</option>'); storageSelect.append('<option value="' + key + '">' + storageareas[key] + '</option>');
} }
/*
for (let i=0; i < storageareas.length; i++) {
storageSelect.append('<option value="' + i + '">' + storageareas[i] + '</option>');
}
*/
let storageVal = inputTds.eq(4).children().val(); let storageVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(storageSelect).children().val(storageVal).chosen({width: "101%"}); inputTds.eq(4).html(storageSelect).children().val(storageVal).chosen({width: "101%"});
} else if (inputTds.eq(2).children().val() == 'MonitorName') { //Monitor names } else if ( attr == 'MonitorName' ) { //Monitor names
let monitorSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]'); let monitorSelect = $j('<select></select>').attr('name', queryPrefix + rowNum + '][val]').attr('id', queryPrefix + rowNum + '][val]');
for (let key in monitors) { for (let key in monitors) {
monitorSelect.append('<option value="' + key + '">' + monitors[key] + '</option>'); monitorSelect.append('<option value="' + key + '">' + monitors[key] + '</option>');
@ -208,15 +203,15 @@ console.log(key + ' ' + storageareas[key]);
let textVal = inputTds.eq(4).children().val(); let textVal = inputTds.eq(4).children().val();
inputTds.eq(4).html(textInput).children().val(textVal); inputTds.eq(4).html(textInput).children().val(textVal);
} }
if (inputTds.eq(2).children().val().endsWith('DateTime')) { //Start/End DateTime if ( attr.endsWith('DateTime') ) { //Start/End DateTime
inputTds.eq(4).children().datetimepicker({timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false}); inputTds.eq(4).children().datetimepicker({timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false});
} else if (inputTds.eq(2).children().val().endsWith('Date')) { //Start/End Date } else if ( attr.endsWith('Date') ) { //Start/End Date
inputTds.eq(4).children().datepicker({dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false}); inputTds.eq(4).children().datepicker({dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false});
} else if (inputTds.eq(2).children().val().endsWith('Time')) { //Start/End Time } else if ( attr.endsWith('Time')) { //Start/End Time
inputTds.eq(4).children().timepicker({timeFormat: "HH:mm:ss", constrainInput: false}); inputTds.eq(4).children().timepicker({timeFormat: "HH:mm:ss", constrainInput: false});
} }
let attr = inputTds.find("[name$='attr\\]']") // Set attr list id and name attr = inputTds.find("[name$='attr\\]']") // Set attr list id and name
let term = attr.attr('name').split(/[[\]]{1,2}/); let term = attr.attr('name').split(/[[\]]{1,2}/);
term.length--; term.length--;
term.shift(); term.shift();

View File

@ -234,7 +234,7 @@ foreach( array_map( 'basename', glob('skins/'.$current_skin.'/css/*',GLOB_ONLYDI
<td class="colMemory <td class="colMemory
<?php if ( $row['FreeMem']/$row['TotalMem'] < .1 ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeMem']) . ' / ' . human_filesize($row['TotalMem']), $canEdit ) ?></td> <?php if ( $row['FreeMem']/$row['TotalMem'] < .1 ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeMem']) . ' / ' . human_filesize($row['TotalMem']), $canEdit ) ?></td>
<td class="colSwap <td class="colSwap
<?php if ( $row['FreeSwap']/$row['TotalSwap'] < .1 ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeSwap']) . ' / ' . human_filesize($row['TotalSwap']) , $canEdit ) ?></td> <?php if ( (!$row['TotalSwap']) or ($row['FreeSwap']/$row['TotalSwap'] < .1) ) { echo 'danger'; } ?>"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', human_filesize($row['FreeSwap']) . ' / ' . human_filesize($row['TotalSwap']) , $canEdit ) ?></td>
<td class="colStats"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmstats'] ? 'yes' : 'no', $canEdit ) ?></td> <td class="colStats"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmstats'] ? 'yes' : 'no', $canEdit ) ?></td>
<td class="colAudit"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmaudit'] ? 'yes' : 'no', $canEdit ) ?></td> <td class="colAudit"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmaudit'] ? 'yes' : 'no', $canEdit ) ?></td>
<td class="colTrigger"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmtrigger'] ? 'yes' : 'no', $canEdit ) ?></td> <td class="colTrigger"><?php echo makePopupLink( '?view=server&amp;id='.$row['Id'], 'zmServer', 'server', $row['zmtrigger'] ? 'yes' : 'no', $canEdit ) ?></td>