Skip to content

Commit

Permalink
Server RRD view page re-designed
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Mar 25, 2016
1 parent 8dd0661 commit c9a958f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 64 deletions.
1 change: 1 addition & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Plugin extends \hiqdev\pluginmanager\Plugin
'aliases' => [
"@server" => "/server/server",
"@rrd" => "/server/rrd",
"@switch-graph" => "/server/switch-graph",
],
'menus' => [
'hipanel\modules\server\SidebarMenu',
Expand Down
58 changes: 25 additions & 33 deletions src/views/rrd/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,40 @@
/**
* @var \hipanel\widgets\AdvancedSearch $search
*/
use yii\helpers\Html;

?>
<?= $search->field('id')->hiddenInput()->label(false) ?>

<div class="col-md-12">
<?= $search->field('graph')->widget(\yii\bootstrap\ToggleButtonGroup::class, [
'type' => 'radio',
'items' => array_merge(['' => Yii::t('hipanel/server/rrd', 'Index')], array_combine((array) $model->graphs, (array) $model->graphs)),
'labelOptions' => [
'class' => 'btn btn-default'
],
'options' => [
'style' => 'display: block'
]
]) ?>
</div>

<div class="col-md-6">
<?= $search->field('period')->widget(\yii\bootstrap\ToggleButtonGroup::class, [
'type' => 'radio',
'items' => ['1' => '1 min/px', '5' => '5 min/px', '60' => '1 hour/px', '720' => '12 hours/px'],
'labelOptions' => [
'class' => 'btn btn-default',
],
'options' => [
'style' => 'display: block'
]
]) ?>
</div>
<div class="col-md-2">
<?= $search->field('width') ?>
</div>
<div class="col-md-2">
<?= $search->field('shift') ?>
</div>
<div class="col-md-2">
<?= $search->field('graph')->dropDownList(
array_merge(['' => Yii::t('hipanel/server/rrd', 'Index')],
array_combine((array)$model->graphs, (array)$model->graphs)),
['class' => 'form-control input-sm']
) ?>
</div>
<div class="col-md-2">
<?= $search->field('period')->dropDownList(
[
'1' => Yii::t('hipanel/server', '1 min/px'),
'5' => Yii::t('hipanel/server', '5 min/px'),
'60' => Yii::t('hipanel/server', '60 min/px'),
'720' => Yii::t('hipanel/server', '720 min/px'),
],
['class' => 'form-control input-sm']
) ?>
</div>
<div class="col-md-2">
<?= $search->field('width')->textInput(['placeholder' => '1081', 'class' => 'form-control input-sm']) ?>
</div>
<div class="col-md-2">
<?= $search->field('shift')->textInput(['placeholder' => '0', 'class' => 'form-control input-sm']) ?>
</div>

<?php
$widgetId = $search->getDivId();

$this->registerJs(<<<JS
$('#form-$widgetId').on('change', 'input[type="radio"]', function (event) {
$('#form-$widgetId').on('change', 'select', function (event) {
$(this).submit();
});
JS
Expand Down
65 changes: 36 additions & 29 deletions src/views/rrd/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,50 @@

Pjax::begin(array_merge(Yii::$app->params['pjax'], ['enablePushState' => true]));

$box = ActionBox::begin(['model' => $searchModel, 'dataProvider' => $dataProvider, 'bulk' => false]);
$box = ActionBox::begin([
'model' => $searchModel,
'dataProvider' => $dataProvider,
'bulk' => false,
]);
echo $box->renderSearchForm(['model' => $model], [
'id' => 'rrd-form',
'options' => [
'displayNone' => false,
],
'action' => ['@rrd/view', 'id' => $model->id]
'action' => ['@rrd/view', 'id' => $model->id],
'submitButtonWrapperOptions' => [
'class' => 'col-md-2 md-pt-20'
],
]);
$box->end();
echo GridView::widget([
'showHeader' => false,
'options' => [
'class' => 'table-responsive'
],
'tableOptions' => [
'class' => 'table',
],
'summary' => false,
'dataProvider' => new \yii\data\ArrayDataProvider([
'allModels' => $model->images,
'pagination' => false,
'sort' => false,
]),
'columns' => [
[
'format' => 'raw',
'value' => function ($model, $key, $index, $widget) {
$html = Html::tag('img', '', ['src' => 'data:image/png;base64,' . $model->base64]);

echo GridView::widget([
'showHeader' => false,
'options' => [
'class' => 'table-responsive'
],
'tableOptions' => [
'class' => 'table',
],
'summary' => false,
'dataProvider' => new \yii\data\ArrayDataProvider([
'allModels' => $model->images,
'pagination' => false,
'sort' => false,
]),
'columns' => [
[
'format' => 'raw',
'value' => function ($model, $key, $index, $widget) {
$html = Html::tag('img', '', ['src' => 'data:image/png;base64,' . $model->base64]);
if ($model->graph) {
$html = Html::a($html, Url::current(['graph' => $model->graph]));
}

if ($model->graph) {
$html = Html::a($html, Url::current(['graph' => $model->graph]));
return Html::tag('div', $html, ['class' => 'text-center']);
}

return Html::tag('div', $html, ['class' => 'text-center']);
}
]
]
]
]);
]);
$box->end();

Pjax::end();
4 changes: 2 additions & 2 deletions src/views/server/view.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use hipanel\grid\XEditableColumn;
use hipanel\helpers\Url;
use hipanel\modules\server\assets\OsSelectionAsset;
use hipanel\modules\server\grid\ServerGridView;
Expand Down Expand Up @@ -51,7 +50,8 @@
</li>
<?php } ?>
<li>
<?= Html::a('<i class="fa fa-area-chart"></i>' . Yii::t('hipanel/server', 'Resources usage charts'), ['@rrd/view', 'id' => $model->id]); ?>
<?= Html::a('<i class="fa fa-area-chart"></i>' . Yii::t('hipanel/server', 'Resources usage graphs'), ['@rrd/view', 'id' => $model->id]); ?>
<?= Html::a('<i class="fa fa-area-chart"></i>' . Yii::t('hipanel/server', 'Switch graphs'), ['@switch-graph/view', 'id' => $model->id]); ?>
</li>
<?php if (Yii::$app->user->can('support') && Yii::$app->user->id != $model->client_id) { ?>
<li>
Expand Down

0 comments on commit c9a958f

Please sign in to comment.