Skip to content

Commit

Permalink
Server view - charts are hidden, when no data is available
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Feb 29, 2016
1 parent 1e1d52e commit 6ad898c
Showing 1 changed file with 51 additions and 48 deletions.
99 changes: 51 additions & 48 deletions src/views/server/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
use hipanel\modules\server\assets\OsSelectionAsset;
use hipanel\modules\server\grid\ServerGridView;
use hipanel\modules\server\models\Server;
use hipanel\modules\server\widgets\ChartOptions;
use hipanel\widgets\Box;
use hipanel\widgets\Pjax;
use hipanel\widgets\ClientSellerLink;
use yii\bootstrap\Html;
use yii\web\JsExpression;

/**
* @var $model Server
Expand All @@ -20,6 +19,8 @@
$this->title,
]);

list($chartsLabels, $chartsData) = $model->groupUsesForCharts();

Pjax::begin();

?>
Expand Down Expand Up @@ -179,60 +180,62 @@
</div>
</div>
<div class="col-md-5">
<div class="row">
<div class="col-md-12">
<?php
$box = Box::begin(['renderBody' => false]);
$box->beginHeader();
echo $box->renderTitle(Yii::t('hipanel/server', 'Traffic consumption'));
$box->beginTools();
echo \hipanel\modules\server\widgets\ChartOptions::widget([
'id' => 'traffic-consumption',
<?php if (isset($chartsData['server_traf'])) { ?>
<div class="row">
<div class="col-md-12">
<?php
$box = Box::begin(['renderBody' => false]);
$box->beginHeader();
echo $box->renderTitle(Yii::t('hipanel/server', 'Traffic consumption'));
$box->beginTools();
echo ChartOptions::widget([
'id' => 'traffic-consumption',
'form' => [
'action' => 'draw-chart'
],
'hiddenInputs' => [
'id' => ['value' => $model->id],
'type' => ['value' => 'traffic']
]
]);
$box->endTools();
$box->endHeader();
$box->beginBody();
echo $this->render('_traffic_consumption', ['labels' => $chartsLabels, 'data' => $chartsData]);
$box->endBody();
$box->end();
?>
</div>
<?php } ?>
</div>
<?php if (isset($chartsData['server_traf95'])) { ?>
<div class="row">
<div class="col-md-12">
<?php
$box = Box::begin(['renderBody' => false]);
$box->beginHeader();
echo $box->renderTitle(Yii::t('hipanel/server', 'Bandwidth consumption'));
$box->beginTools();
echo ChartOptions::widget([
'id' => 'bandwidth-consumption',
'form' => [
'action' => 'draw-chart'
],
'hiddenInputs' => [
'id' => ['value' => $model->id],
'type' => ['value' => 'traffic']
'type' => ['value' => 'bandwidth']
]
]);
$box->endTools();
$box->endHeader();
$box->beginBody();
list($labels, $data) = $model->groupUsesForCharts();
echo $this->render('_traffic_consumption', ['labels' => $labels, 'data' => $data]);
$box->endBody();
$box->end();
?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
$box = Box::begin(['renderBody' => false]);
$box->beginHeader();
echo $box->renderTitle(Yii::t('hipanel/server', 'Bandwidth consumption'));
$box->beginTools();
echo \hipanel\modules\server\widgets\ChartOptions::widget([
'id' => 'bandwidth-consumption',
'form' => [
'action' => 'draw-chart'
],
'hiddenInputs' => [
'id' => ['value' => $model->id],
'type' => ['value' => 'bandwidth']
]
]);
$box->endTools();
$box->endHeader();
$box->beginBody();
list($labels, $data) = $model->groupUsesForCharts();
echo $this->render('_bandwidth_consumption', ['labels' => $labels, 'data' => $data]);
$box->endBody();
$box->end();
?>
$box->endTools();
$box->endHeader();
$box->beginBody();
echo $this->render('_bandwidth_consumption', ['labels' => $chartsLabels, 'data' => $chartsData]);
$box->endBody();
$box->end();
?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>

Expand Down

0 comments on commit 6ad898c

Please sign in to comment.