Merge branch 'master' into storageareas

pull/1857/head
Isaac Connor 2016-11-11 22:40:00 -05:00
commit 3b7723ee8f
4 changed files with 39 additions and 6 deletions

View File

@ -1207,7 +1207,7 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {
} // end foreach remaining term
} // end no StorageArea found yet
$filter['sql'] .= getDiskPercent( $StorageArea );
$filter['sql'] .= getDiskPercent( $StorageArea->Path() );
break;
case 'DiskBlocks':
// Need to specify a storage area, so need to look through other terms looking for a storage area, else we default to ZM_EVENTS_PATH
@ -1410,10 +1410,18 @@ function getLoad() {
return( $load[0] );
}
function getDiskPercent( $StorageArea = NULL ) {
if ( ! $StorageArea ) $StorageArea = new Storage();
return $StorageArea->disk_usage_percent();
function getDiskPercent($path = ZM_DIR_EVENTS) {
$total = disk_total_space($path);
if ( ! $total ) {
Error("disk_total_space returned false for " . $path );
return 0;
}
$free = disk_free_space($path);
if ( ! $free ) {
Error("disk_free_space returned false for " . $path );
}
$space = round(($total - $free) / $total * 100);
return( $space );
}
function getDiskBlocks() {

View File

@ -269,6 +269,7 @@ if ( canView( 'Stream' ) && $cycleCount > 1 ) {
$func = function($S){ return $S->Name() . ': ' . $S->disk_usage_percent().'%'; };
echo implode( ', ', array_map ( $func, $storage_areas ) );
echo ' ' . ZM_PATH_MAP .': '. getDiskPercent(ZM_PATH_MAP).'%';
?></li>
</ul>
</div> <!-- End .footer -->

View File

@ -183,7 +183,7 @@ foreach ( $tabs as $name=>$value )
?>
</ul>
<div class="clear"></div>
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<form name="contentForm" id="contentForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="return validateForm( this )">
<input type="hidden" name="view" value="<?php echo $view ?>"/>
<input type="hidden" name="tab" value="<?php echo $tab ?>"/>
<input type="hidden" name="action" value="controlcap"/>

View File

@ -0,0 +1,24 @@
function validateForm( form ) {
var errors = new Array();
// If "Can Move" is enabled, then the end user must also select at least one of the other check boxes (excluding Can Move Diagonally)
if ( form.elements['newControl[CanMove]'].checked ) {
if ( !form.elements['newControl[CanMoveCon]'].checked || !form.elements['newControl[CanMoveRel]'].checked || !form.elements['newControl[CanMoveAbs]'].checked || !form.elements['newControl[CanMoveMap]'].checked ) {
errors[errors.length] = "In addition to \"Can Move\", you also must select at least one of: \"Can Move Mapped\", \"Can Move Absolute\", \"Can Move Relative\", or \"Can Move Continuous\"";
}
} else {
// Now lets check for the opposite condition. If any of the boxes below Can Move are checked, but Can Move is not checked then signal an error
if ( form.elements['newControl[CanMoveCon]'].checked || form.elements['newControl[CanMoveRel]'].checked || form.elements['newControl[CanMoveAbs]'].checked || form.elements['newControl[CanMoveMap]'].checked || form.elements['newControl[CanMoveDiag]'].checked ) {
errors[errors.length] = "\"Can Move\" must also be selected if any one of the movement types are sleceted";
}
}
if ( errors.length ) {
alert( errors.join( "\n" ) );
return( false );
}
return( true );
}