<?php
$baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/gridview';
$cssFile=$baseScriptUrl.'/styles.css';
Yii::app()->getClientScript()->registerCssFile($cssFile);
$cs=Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('bbq');
$cs->registerScriptFile($baseScriptUrl.'/jquery.yiigridview.js');
$id = "resumo-grid";
$options = "{'ajaxUpdate':['resumo-grid'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items','selectableRows':1}";
//jQuery('#resumo-grid').yiiGridView();
$cs->registerScript('#'.$id,"jQuery('#$id').yiiGridView($options);");

$this->breadcrumbs=array(
	'Runtime'=>array('thundercache'),"Informações"
);
?>
<h1>Requisições do ThunderCache</h1>
<?php echo CHtml::Link ( "<img src='".Yii::app()->request->baseUrl."/images/ajax-loader.png' alt='Recarregar' />",
			'#',
			array('class'=>'click-thundersnarf', 'style'=>'float:right;'));
				?>
<div class="grid-view" id="resumo-grid">
	<br>
	<div title="<?php echo Yii::app()->request->requestUri;?>" style="display: none;" class="keys">
		<span>20100514</span>
	</div>
	<table class="items">
		<thead>
			<tr>
				<th id="resumo-grid_c0">
					Time
				</th>
				<th id="resumo-grid_c1">
					%CPU
				</th>
				<th id="resumo-grid_c2">
					%MEM
				</th>
				<th id="resumo-grid_c3">
					RSS
				</th>
				<th id="resumo-grid_c4">
					VSZ
				</th>
				<th id="resumo-grid_c5">
					IP
				</th>
				<th id="resumo-grid_c6">
					URL
				</th>
			</tr>
		</thead>
		<tbody>
			<?php
			$class_tr = "even";
			if(count($modelFreeBSD)>0){
                                foreach($modelFreeBSD as $key=>$valor){
					if($class_tr=="even") $class_tr="odd";
					else $class_tr="even";
					?>
				<tr class="<?php echo $class_tr;?>">
					<td><?php echo $valor["time"];?></td>
					<td><?php echo $valor["cpu"];?></td>
					<td><?php echo $valor["mem"];?></td>
					<td><?php echo $valor["rss"];?></td>
					<td><?php echo $valor["vsz"];?></td>
					<td><?php echo $valor["ip"];?></td>
					<td><?php echo $valor["url"];?></td>
				</tr>
					<?php
				}
			}
			?>
		</tbody>
	</table>
	<b>Time:</b> Tempo de CPU acumulado, sistema + usuário  <br/>
	<b>%CPU:</b> Porcentagem de uso de CPU <br/>
	<b>%MEM:</b> Percentagem de uso de Memória <br/>
	<b>RSS:</b> Memória RAM Alocada <br/>
	<b>VSZ:</b> Tamanho Virtual em Kbytes<br/>
	<div class="pager"/>
	<br>
	<div title="<?php echo Yii::app()->request->requestUri;?>" style="display: none;" class="keys">
		<span>20100514</span>
	</div>
	<table class="items">
		<thead>
			<tr>
				<th id="resumo-grid_c0">
					id
				</th>
				<th id="resumo-grid_c1">
					status
				</th>
				<th id="resumo-grid_c2">
					connects
				</th>
				<th id="resumo-grid_c3">
					totalread
				</th>
				<th id="resumo-grid_c4">
					totaltrans
				</th>
				<th id="resumo-grid_c5">
					cache_type
				</th>
				<th id="resumo-grid_c6">
					cache_response
				</th>
				<th id="resumo-grid_c6">
					domain
				</th>
				<th id="resumo-grid_c6">
					file
				</th>
			</tr>
		</thead>
		<tbody>
			<?php
			$class_tr = "even";
			if(count($modelThunderCache)>0){
                                foreach($modelThunderCache as $key=>$valor){
					if($class_tr=="even") $class_tr="odd";
					else $class_tr="even";
					?>
				<tr class="<?php echo $class_tr;?>">
					<td><?php echo $valor["id"];?></td>
					<td><?php echo $valor["status"];?></td>
					<td><?php echo $valor["connects"];?></td>
					<td><?php echo $valor["totalread"];?></td>
					<td><?php echo $valor["totaltrans"];?></td>
					<td><?php echo $valor["cache_type"];?></td>
					<td><?php echo $valor["cache_response"];?></td>
					<td><?php echo $valor["domain"];?></td>
					<td><?php echo $valor["file"];?></td>
				</tr>
					<?php
				}
			}
			?>
		</tbody>
	</table>
	<div class="pager"/>
</div>
<?php Yii::app()->clientScript->registerScript('initreloadruntime',<<<EOD
    $('.click-thundersnarf').bind('click', function() {
        $.fn.yiiGridView.update('resumo-grid');
    });
EOD
,CClientScript::POS_READY); ?>