move States loading code into state view where it belongs. Move runnign check into specific places where it is needed. These changes reduce events list load time by about 4 seconds for me.

This commit is contained in:
Isaac Connor 2016-10-20 13:16:50 -04:00
parent cb88b984c7
commit 67e14bd12f
5 changed files with 18 additions and 16 deletions

View File

@ -137,15 +137,15 @@ if ( ZM_OPT_USE_AUTH ) {
require_once( 'includes/lang.php' ); require_once( 'includes/lang.php' );
require_once( 'includes/functions.php' ); require_once( 'includes/functions.php' );
$running = daemonCheck(); #$running = daemonCheck();
$states = dbFetchAll( 'SELECT * FROM States' ); #$states = dbFetchAll( 'SELECT * FROM States' );
foreach ( $states as $state ) { #foreach ( $states as $state ) {
if ( $state['IsActive'] == 1 ) { #if ( $state['IsActive'] == 1 ) {
$run_state = $state['Name']; #$run_state = $state['Name'];
break; #break;
} #}
} #}
$status = $running?translate('Running'):translate('Stopped'); #$status = $running?translate('Running'):translate('Stopped');
#$run_state = dbFetchOne('SELECT Name FROM States WHERE IsActive = 1', 'Name' ); #$run_state = dbFetchOne('SELECT Name FROM States WHERE IsActive = 1', 'Name' );
# Add Cross domain access headers # Add Cross domain access headers

View File

@ -186,7 +186,7 @@ function getNavBarHTML() {
global $CLANG; global $CLANG;
global $VLANG; global $VLANG;
global $status; global $status;
global $running; $running = daemonCheck();
global $user; global $user;
global $bwArray; global $bwArray;
?> ?>

View File

@ -1,2 +1,2 @@
var running = <?php echo $running?'true':'false' ?>; var running = <?php echo daemonCheck()?'true':'false' ?>;
var applying = <?php echo !empty($_REQUEST['apply'])?'true':'false' ?>; var applying = <?php echo !empty($_REQUEST['apply'])?'true':'false' ?>;

View File

@ -40,14 +40,16 @@ if ( !canEdit( 'System' ) ) {
<label for="runState" class="col-sm-3 control-label">Change State</label> <label for="runState" class="col-sm-3 control-label">Change State</label>
<div class="col-sm-9"> <div class="col-sm-9">
<select id="runState" name="runState" class="form-control"> <select id="runState" name="runState" class="form-control">
<?php if ( $running ) { ?> <?php if ( daemonCheck() ) { ?>
<option value="stop" selected="selected"><?php echo translate('Stop') ?></option> <option value="stop" selected="selected"><?php echo translate('Stop') ?></option>
<option value="restart"><?php echo translate('Restart') ?></option> <option value="restart"><?php echo translate('Restart') ?></option>
<?php } else { ?> <?php } else { ?>
<option value="start" selected="selected"><?php echo translate('Start') ?></option> <option value="start" selected="selected"><?php echo translate('Start') ?></option>
<?php } <?php }
?> ?>
<?php foreach ( $states as $state ) { ?> <?php
$states = dbFetchAll( 'SELECT * FROM States' );
foreach ( $states as $state ) { ?>
<option value="<?php echo $state['Name'] ?>"><?php echo $state['Name'] ?></option> <option value="<?php echo $state['Name'] ?>"><?php echo $state['Name'] ?></option>
<?php } ?> <?php } ?>
</select> </select>

View File

@ -70,7 +70,7 @@ if ( empty($_REQUEST['path']) ) {
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg'; $path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
} }
} else { } else {
$errorText = "No image path"; $errorText = 'No image path';
} }
if ( ! file_exists( $path ) ) { if ( ! file_exists( $path ) ) {