Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
f620781f7e
|
@ -145,26 +145,33 @@ class Storage {
|
||||||
}
|
}
|
||||||
return $this->{'disk_total_space'};
|
return $this->{'disk_total_space'};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disk_used_space() {
|
public function disk_used_space() {
|
||||||
# This isn't a function like this in php, so we have to add up the space used in each event.
|
# This isn't a function like this in php, so we have to add up the space used in each event.
|
||||||
if ( (! array_key_exists( 'DiskSpace', $this )) or (!$this->{'DiskSpace'}) ) {
|
if ( (! array_key_exists('disk_used_space', $this)) or (!$this->{'disk_used_space'}) ) {
|
||||||
$used = 0;
|
|
||||||
if ( $this->{'Type'} == 's3fs' ) {
|
if ( $this->{'Type'} == 's3fs' ) {
|
||||||
|
$this->{'disk_used_space'} = $this->disk_event_space();
|
||||||
|
} else {
|
||||||
|
$path = $this->Path();
|
||||||
|
$this->{'disk_used_space'} = disk_total_space($path) - disk_free_space($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->{'disk_used_space'};
|
||||||
|
} // end function disk_used_space
|
||||||
|
|
||||||
|
public function event_disk_space() {
|
||||||
|
# This isn't a function like this in php, so we have to add up the space used in each event.
|
||||||
|
if ( (! array_key_exists('DiskSpace', $this)) or (!$this->{'DiskSpace'}) ) {
|
||||||
$used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) );
|
$used = dbFetchOne('SELECT SUM(DiskSpace) AS DiskSpace FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL', 'DiskSpace', array($this->Id()) );
|
||||||
|
|
||||||
foreach ( Event::find_all( array('StorageId'=>$this->Id(), 'DiskSpace'=>null) ) as $Event ) {
|
foreach ( Event::find_all( array('StorageId'=>$this->Id(), 'DiskSpace'=>null) ) as $Event ) {
|
||||||
$Event->Storage( $this ); // Prevent further db hit
|
$Event->Storage( $this ); // Prevent further db hit
|
||||||
$used += $Event->DiskSpace();
|
$used += $Event->DiskSpace();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$path = $this->Path();
|
|
||||||
$used = disk_total_space( $path ) - disk_free_space( $path );;
|
|
||||||
}
|
|
||||||
$this->{'DiskSpace'} = $used;
|
$this->{'DiskSpace'} = $used;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->{'DiskSpace'};
|
return $this->{'DiskSpace'};
|
||||||
}
|
} // end function event_disk_space
|
||||||
public function Server() {
|
public function Server() {
|
||||||
if ( ! array_key_exists('Server',$this) ) {
|
if ( ! array_key_exists('Server',$this) ) {
|
||||||
$this->{'Server'}= new Server( $this->{'ServerId'} );
|
$this->{'Server'}= new Server( $this->{'ServerId'} );
|
||||||
|
|
|
@ -341,11 +341,11 @@ fieldset > legend {
|
||||||
/*
|
/*
|
||||||
* Behavior classes
|
* Behavior classes
|
||||||
*/
|
*/
|
||||||
.alarm, .errorText {
|
.alarm, .errorText, .error {
|
||||||
color: #ff3f34;
|
color: #ff3f34;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert, .warnText {
|
.alert, .warnText, .warning {
|
||||||
color: #ffa801;
|
color: #ffa801;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,17 @@ if ($reload == 'reload') ob_start();
|
||||||
if ( ! isset($storage_paths[ZM_DIR_EVENTS]) ) {
|
if ( ! isset($storage_paths[ZM_DIR_EVENTS]) ) {
|
||||||
array_push( $storage_areas, new Storage() );
|
array_push( $storage_areas, new Storage() );
|
||||||
}
|
}
|
||||||
$func = function($S){ return '<span title="'.human_filesize($S->disk_used_space()) . ' of ' . human_filesize($S->disk_total_space()).'">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
$func = function($S){
|
||||||
|
$class = '';
|
||||||
|
if ( $S->disk_usage_percent() > 98 ) {
|
||||||
|
$class = "error";
|
||||||
|
} else if ( $S->disk_usage_percent() > 90 ) {
|
||||||
|
$class = "warning";
|
||||||
|
}
|
||||||
|
$title = human_filesize($S->disk_used_space()) . ' of ' . human_filesize($S->disk_total_space()).
|
||||||
|
( ( $S->disk_used_space() != $S->event_disk_space() ) ? ' ' .human_filesize($S->event_disk_space()) . ' used by events' : '' );
|
||||||
|
|
||||||
|
return '<span class="'.$class.'" title="'.$title.'">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
||||||
#$func = function($S){ return '<span title="">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
#$func = function($S){ return '<span title="">'.$S->Name() . ': ' . $S->disk_usage_percent().'%' . '</span>'; };
|
||||||
if ( count($storage_areas) >= 4 )
|
if ( count($storage_areas) >= 4 )
|
||||||
$storage_areas = Storage::find_all( array('ServerId'=>null) );
|
$storage_areas = Storage::find_all( array('ServerId'=>null) );
|
||||||
|
|
|
@ -149,11 +149,13 @@ while( $event = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||||
$monitor = $displayMonitors[$monitor_i];
|
$monitor = $displayMonitors[$monitor_i];
|
||||||
$Monitor = new Monitor($monitor);
|
$Monitor = new Monitor($monitor);
|
||||||
|
|
||||||
|
$montagereview_link = "?view=montagereview&live=0&MonitorId=". $monitor['Id'] . '&minTime='.$minTime.'&maxTime='.$maxTime;
|
||||||
?>
|
?>
|
||||||
<tr id="<?php echo 'monitor_id-'.$monitor['Id'] ?>" title="<?php echo $monitor['Id'] ?>">
|
<tr id="<?php echo 'monitor_id-'.$monitor['Id'] ?>" title="<?php echo $monitor['Id'] ?>">
|
||||||
<td class="colId"><a href="?view=watch&mid=<?php echo $monitor['Id']?>"><?php echo $monitor['Id'] ?></a></td>
|
<td class="colId"><a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Id'] ?></a></td>
|
||||||
<td class="colName">
|
<td class="colName">
|
||||||
<a href="?view=watch&mid=<?php echo $monitor['Id']?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
<a href="<?php echo $montagereview_link ?>"><?php echo $monitor['Name'] ?></a><br/><div class="small text-nowrap text-muted">
|
||||||
<?php echo implode('<br/>',
|
<?php echo implode('<br/>',
|
||||||
array_map(function($group_id){
|
array_map(function($group_id){
|
||||||
$Group = new Group($group_id);
|
$Group = new Group($group_id);
|
||||||
|
|
Loading…
Reference in New Issue