add actual disk space as a mouseover in nav bar
parent
8da7d845b4
commit
3af795264d
|
@ -320,6 +320,41 @@ class Event {
|
||||||
return( $imageData );
|
return( $imageData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function find_all( $parameters = null, $options = null ) {
|
||||||
|
$filters = array();
|
||||||
|
$sql = 'SELECT * FROM Events ';
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
if ( $parameters ) {
|
||||||
|
$fields = array();
|
||||||
|
$sql .= 'WHERE ';
|
||||||
|
foreach ( $parameters as $field => $value ) {
|
||||||
|
if ( $value == null ) {
|
||||||
|
$fields[] = $field.' IS NULL';
|
||||||
|
} else if ( is_array( $value ) ) {
|
||||||
|
$func = function(){return '?';};
|
||||||
|
$fields[] = $field.' IN ('.implode(',', array_map( $func, $value ) ). ')';
|
||||||
|
$values += $value;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$fields[] = $field.'=?';
|
||||||
|
$values[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql .= implode(' AND ', $fields );
|
||||||
|
}
|
||||||
|
if ( $options and isset($options['order']) ) {
|
||||||
|
$sql .= ' ORDER BY ' . $options['order'];
|
||||||
|
}
|
||||||
|
$result = dbQuery($sql, $values);
|
||||||
|
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Event');
|
||||||
|
foreach ( $results as $row => $obj ) {
|
||||||
|
$filters[] = $obj;
|
||||||
|
}
|
||||||
|
return $filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} # end class
|
} # end class
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -87,7 +87,15 @@ public $defaults = array(
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
dbQuery( 'DELETE FROM Groups WHERE Id = ?', array($this->{'Id'}) );
|
if ( array_key_exists( 'Id', $this ) ) {
|
||||||
|
dbQuery( 'DELETE FROM Groups WHERE Id = ?', array($this->{'Id'}) );
|
||||||
|
if ( isset($_COOKIE['zmGroup']) ) {
|
||||||
|
if ( $this->{'Id'} == $_COOKIE['zmGroup'] ) {
|
||||||
|
unset( $_COOKIE['zmGroup'] );
|
||||||
|
setcookie( 'zmGroup', '', time()-3600*24*2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} # end function delete()
|
} # end function delete()
|
||||||
|
|
||||||
public function set( $data ) {
|
public function set( $data ) {
|
||||||
|
@ -172,5 +180,6 @@ public $defaults = array(
|
||||||
}
|
}
|
||||||
return $groupSql;
|
return $groupSql;
|
||||||
} # end public static function get_group_sql( $group_id )
|
} # end public static function get_group_sql( $group_id )
|
||||||
|
|
||||||
} # end class Group
|
} # end class Group
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Storage {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = disk_total_space( $path );
|
$total = $this->disk_total_space();
|
||||||
if ( ! $total ) {
|
if ( ! $total ) {
|
||||||
Error("disk_total_space returned false for " . $path );
|
Error("disk_total_space returned false for " . $path );
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -85,5 +85,23 @@ class Storage {
|
||||||
$usage = round(($total - $free) / $total * 100);
|
$usage = round(($total - $free) / $total * 100);
|
||||||
return $usage;
|
return $usage;
|
||||||
}
|
}
|
||||||
|
public function disk_total_space() {
|
||||||
|
if ( ! array_key_exists( 'disk_total_space', $this ) ) {
|
||||||
|
$this->{'disk_total_space'} = disk_total_space( $this->Path() );
|
||||||
|
}
|
||||||
|
return $this->{'disk_total_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.
|
||||||
|
if ( ! array_key_exists( 'disk_used_space', $this ) ) {
|
||||||
|
$used = 0;
|
||||||
|
foreach ( Event::find_all( array( 'StorageId'=>$this->Id() ) ) as $Event ) {
|
||||||
|
$used += $Event->DiskSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->{'disk_used_space'} = $used;
|
||||||
|
}
|
||||||
|
return $this->{'disk_used_space'};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -602,10 +602,10 @@ Warning("Addterm");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group edit actions
|
// Group edit actions
|
||||||
|
# Should probably verify that each monitor id is a valid monitor, that we have access to. However at the moment, you have to have System permissions to do this
|
||||||
if ( canEdit( 'Groups' ) ) {
|
if ( canEdit( 'Groups' ) ) {
|
||||||
if ( $action == 'group' ) {
|
if ( $action == 'group' ) {
|
||||||
# Should probably verfy that each monitor id is a valid monitor, that we have access to. HOwever at the moment, you have to have System permissions to do this
|
$monitors = empty( $_POST['newGroup']['MonitorIds'] ) ? '' : implode(',', $_POST['newGroup']['MonitorIds']);
|
||||||
$monitors = empty( $_POST['newGroup']['MonitorIds'] ) ? '' : implode(',', $_POST['newGroup']['MonitorIds'] );
|
|
||||||
if ( !empty($_POST['gid']) ) {
|
if ( !empty($_POST['gid']) ) {
|
||||||
dbQuery( 'UPDATE Groups SET Name=?, ParentId=?, MonitorIds=? WHERE Id=?',
|
dbQuery( 'UPDATE Groups SET Name=?, ParentId=?, MonitorIds=? WHERE Id=?',
|
||||||
array($_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ), $monitors, $_POST['gid']) );
|
array($_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ), $monitors, $_POST['gid']) );
|
||||||
|
@ -614,18 +614,20 @@ Warning("Addterm");
|
||||||
array( $_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ), $monitors ) );
|
array( $_POST['newGroup']['Name'], ( $_POST['newGroup']['ParentId'] == '' ? null : $_POST['newGroup']['ParentId'] ), $monitors ) );
|
||||||
}
|
}
|
||||||
$view = 'none';
|
$view = 'none';
|
||||||
}
|
} else if ( $action == 'delete' ) {
|
||||||
if ( !empty($_REQUEST['gid']) && $action == 'delete' ) {
|
if ( !empty($_REQUEST['gid']) ) {
|
||||||
dbQuery( 'DELETE FROM Groups WHERE Id = ?', array($_REQUEST['gid']) );
|
if ( is_array( $_REQUEST['gid'] ) ) {
|
||||||
if ( isset($_COOKIE['zmGroup']) ) {
|
foreach( $_REQUEST['gid'] as $gid ) {
|
||||||
if ( $_REQUEST['gid'] == $_COOKIE['zmGroup'] ) {
|
$Group = new Group( $gid );
|
||||||
unset( $_COOKIE['zmGroup'] );
|
$Group->delete();
|
||||||
setcookie( 'zmGroup', '', time()-3600*24*2 );
|
}
|
||||||
$refreshParent = true;
|
} else {
|
||||||
|
$Group = new Group( $_REQUEST['gid'] );
|
||||||
|
$Group->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$refreshParent = true;
|
||||||
$refreshParent = true;
|
} # end if action
|
||||||
} // end if can edit groups
|
} // end if can edit groups
|
||||||
|
|
||||||
// System edit actions
|
// System edit actions
|
||||||
|
|
|
@ -165,7 +165,7 @@ function getNavBarHTML() {
|
||||||
$running = daemonCheck();
|
$running = daemonCheck();
|
||||||
$status = $running?translate('Running'):translate('Stopped');
|
$status = $running?translate('Running'):translate('Stopped');
|
||||||
global $user;
|
global $user;
|
||||||
global $bwArray;
|
global $bandwidth_options;
|
||||||
global $view;
|
global $view;
|
||||||
?>
|
?>
|
||||||
<noscript>
|
<noscript>
|
||||||
|
@ -230,7 +230,7 @@ ZoneMinder requires Javascript. Please enable Javascript in your browser for thi
|
||||||
</div> <!-- End .container-fluid -->
|
</div> <!-- End .container-fluid -->
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<?php echo makePopupLink( '?view=bandwidth', 'zmBandwidth', 'bandwidth', $bwArray[$_COOKIE['zmBandwidth']] . ' ' . translate('BandwidthHead'), ($user && $user['MaxBandwidth'] != 'low' ) ) ?>
|
<?php echo makePopupLink( '?view=bandwidth', 'zmBandwidth', 'bandwidth', $bandwidth_options[$_COOKIE['zmBandwidth']] . ' ' . translate('BandwidthHead'), ($user && $user['MaxBandwidth'] != 'low' ) ) ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<?php echo makePopupLink( '?view=version', 'zmVersion', 'version', '<span class="'.$versionClass.'">v'.ZM_VERSION.'</span>', canEdit( 'System' ) ) ?>
|
<?php echo makePopupLink( '?view=version', 'zmVersion', 'version', '<span class="'.$versionClass.'">v'.ZM_VERSION.'</span>', canEdit( 'System' ) ) ?>
|
||||||
|
@ -256,7 +256,7 @@ ZoneMinder requires Javascript. Please enable Javascript in your browser for thi
|
||||||
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 $S->Name() . ': ' . $S->disk_usage_percent().'%'; };
|
$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>'; };
|
||||||
echo implode( ', ', array_map ( $func, $storage_areas ) );
|
echo implode( ', ', array_map ( $func, $storage_areas ) );
|
||||||
echo ' ' . ZM_PATH_MAP .': '. getDiskPercent(ZM_PATH_MAP).'%';
|
echo ' ' . ZM_PATH_MAP .': '. getDiskPercent(ZM_PATH_MAP).'%';
|
||||||
?></li>
|
?></li>
|
||||||
|
|
|
@ -88,11 +88,8 @@ function get_children($Group) {
|
||||||
|
|
||||||
$kids = get_children($newGroup);
|
$kids = get_children($newGroup);
|
||||||
$kids[] = $newGroup->Id();
|
$kids[] = $newGroup->Id();
|
||||||
function get_question_marks() {
|
|
||||||
return '?';
|
|
||||||
}
|
|
||||||
$options = array(''=>'None');
|
$options = array(''=>'None');
|
||||||
foreach ( dbFetchAll( 'SELECT Id,Name from Groups WHERE Id NOT IN ('.implode(',',array_map('get_question_marks', $kids )).') ORDER BY Name', null, $kids ) as $option ) {
|
foreach ( dbFetchAll( 'SELECT Id,Name from Groups WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids )).') ORDER BY Name', null, $kids ) as $option ) {
|
||||||
$options[$option['Id']] = $option['Name'];
|
$options[$option['Id']] = $option['Name'];
|
||||||
}
|
}
|
||||||
echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' ));
|
echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' ));
|
||||||
|
|
|
@ -23,11 +23,10 @@ if ( !canView( 'Groups' ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# This will end up with the group_id of the deepest selection
|
# This will end up with the group_id of the deepest selection
|
||||||
$group_id = 0;
|
$group_id = 0;
|
||||||
$max_depth = 0;
|
$max_depth = 0;
|
||||||
|
|
||||||
|
|
||||||
$Groups = array();
|
$Groups = array();
|
||||||
foreach ( Group::find_all( ) as $Group ) {
|
foreach ( Group::find_all( ) as $Group ) {
|
||||||
$Groups[$Group->Id()] = $Group;
|
$Groups[$Group->Id()] = $Group;
|
||||||
|
@ -42,7 +41,6 @@ foreach ( $Groups as $id=>$Group ) {
|
||||||
if ( $max_depth < $Group->depth() )
|
if ( $max_depth < $Group->depth() )
|
||||||
$max_depth = $Group->depth();
|
$max_depth = $Group->depth();
|
||||||
}
|
}
|
||||||
Warning("Max depth $max_depth");
|
|
||||||
xhtmlHeaders(__FILE__, translate('Groups') );
|
xhtmlHeaders(__FILE__, translate('Groups') );
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
|
@ -75,7 +73,7 @@ function group_line( $Group ) {
|
||||||
$html .= validHtmlStr($Group->Name());
|
$html .= validHtmlStr($Group->Name());
|
||||||
}
|
}
|
||||||
$html .= '</td><td class="colIds">'. monitorIdsToNames( $Group->MonitorIds(), 30 ).'</td>
|
$html .= '</td><td class="colIds">'. monitorIdsToNames( $Group->MonitorIds(), 30 ).'</td>
|
||||||
<td class="colSelect"><input type="checkbox" name="gid" value="'. $Group->Id() .'" onclick="configureButtons(this);"/></td>
|
<td class="colSelect"><input type="checkbox" name="gid[]" value="'. $Group->Id() .'" onclick="configureButtons(this);"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
';
|
';
|
||||||
if ( isset( $children[$Group->Id()] ) ) {
|
if ( isset( $children[$Group->Id()] ) ) {
|
||||||
|
@ -85,8 +83,9 @@ function group_line( $Group ) {
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
foreach ( $children[null] as $Group )
|
if ( isset( $children[null] ) )
|
||||||
echo group_line( $Group );
|
foreach ( $children[null] as $Group )
|
||||||
|
echo group_line( $Group );
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -102,9 +102,9 @@ $monitors = array();
|
||||||
$monitors_dropdown = array( '' => 'All' );
|
$monitors_dropdown = array( '' => 'All' );
|
||||||
$sql = "SELECT * FROM Monitors WHERE Function != 'None'";
|
$sql = "SELECT * FROM Monitors WHERE Function != 'None'";
|
||||||
if ( $groupSql ) { $sql .= ' AND ' . $groupSql; };
|
if ( $groupSql ) { $sql .= ' AND ' . $groupSql; };
|
||||||
if ( $monitor_id ) { $sql .= ' AND Id=?'.$monitor_id; };
|
if ( $monitor_id ) { $sql .= ' AND Id='.$monitor_id; };
|
||||||
|
|
||||||
$sql .= 'ORDER BY Sequence';
|
$sql .= ' ORDER BY Sequence';
|
||||||
foreach( dbFetchAll( $sql ) as $row ) {
|
foreach( dbFetchAll( $sql ) as $row ) {
|
||||||
if ( !visibleMonitor( $row['Id'] ) ) {
|
if ( !visibleMonitor( $row['Id'] ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -114,7 +114,7 @@ if ( ! empty( $user['MonitorIds'] ) ) {
|
||||||
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
|
$frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')';
|
||||||
}
|
}
|
||||||
if ( $monitor_id ) {
|
if ( $monitor_id ) {
|
||||||
$monitorSql .= ' AND Id='.$monitor_id;
|
$monitorsSql .= ' AND Id='.$monitor_id;
|
||||||
$eventsSql .= ' AND M.Id='.$monitor_id;
|
$eventsSql .= ' AND M.Id='.$monitor_id;
|
||||||
$frameSql .= ' AND E.MonitorId='.$monitor_id;
|
$frameSql .= ' AND E.MonitorId='.$monitor_id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue