Skip to content

Commit

Permalink
Service - added filter, view
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Nov 20, 2015
1 parent e0b5cfe commit b177286
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 19 deletions.
6 changes: 5 additions & 1 deletion src/controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ public function actions()
$action = $event->sender;
$dataProvider = $action->getDataProvider();
$dataProvider->query->joinWith('ips');
}
},

],
'view' => [
'class' => 'hipanel\actions\ViewAction',
]
];
}
}
2 changes: 2 additions & 0 deletions src/grid/ServiceGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use hipanel\modules\server\grid\ServerColumn;
use hipanel\widgets\ArraySpoiler;
use kartik\helpers\Html;
use Yii;

class ServiceGridView extends \hipanel\grid\BoxedGridView
{
Expand All @@ -34,6 +35,7 @@ static public function defaultColumns()
],
'ip' => [
'format' => 'raw',
'label' => Yii::t('hipanel/hosting', 'IP'),
'value' => function ($model) {
return ArraySpoiler::widget(['data' => $model->ips]);
},
Expand Down
5 changes: 4 additions & 1 deletion src/messages/ru/hosting.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
'This will immediately terminate all sessions of the user!' => 'Это немедленно прервет все сеансы пользователя!',
'Enter new restrictions' => 'Введите новые ограничения',
'Enter a new password' => 'Введите новый пароль',

/**
* Service
*/
'Soft' => 'ПО',
];
3 changes: 3 additions & 0 deletions src/models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function attributeLabels () {
return $this->mergeAttributeLabels([
'soft_type' => Yii::t('app', 'Soft Type'),
'soft_type_label' => Yii::t('app', 'Soft type label'),
'bin' => Yii::t('hipanel/hosting', 'bin'),
'etc' => Yii::t('hipanel/hosting', 'etc'),
'soft' => Yii::t('hipanel/hosting', 'Soft'),
]);
}

Expand Down
44 changes: 44 additions & 0 deletions src/views/service/_search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

use hipanel\modules\client\widgets\combo\ClientCombo;
use hipanel\modules\client\widgets\combo\SellerCombo;
use hipanel\modules\server\widgets\combo\ServerCombo;
use hiqdev\combo\StaticCombo;
use yii\web\View;

/**
* @var $this View
*/

?>

<div class="col-md-6">
<?= $search->field('name_like') ?>
<?= $search->field('server')->widget(ServerCombo::className(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('state')->widget(StaticCombo::classname(), [
'data' => $stateData,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => false,
]
],
]) ?>

</div>

<div class="col-md-6">
<?= $search->field('client_id')->widget(ClientCombo::classname(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('seller_id')->widget(SellerCombo::classname(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('soft')->widget(StaticCombo::classname(), [
'data' => $softData,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => false,
]
],
]) ?>
</div>


60 changes: 45 additions & 15 deletions src/views/service/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,54 @@
*/

use hipanel\modules\hosting\grid\ServiceGridView;
use hipanel\widgets\ActionBox;
use hipanel\widgets\Pjax;

$this->title = Yii::t('hipanel/hosting', 'Services');
$this->params['breadcrumbs'][] = $this->title;
$this->params['subtitle'] = array_filter(Yii::$app->request->get($model->formName(), [])) ? 'filtered list' : 'full list';

?>

<?= serviceGridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $model,
'columns' => [
'seller_id',
'client_id',
'service',
'ip',
'bin',
'etc',
'soft',
'state',
],
]) ?>
<?php Pjax::begin(array_merge(Yii::$app->params['pjax'], ['enablePushState' => true])); ?>

<?php $box = ActionBox::begin(['model' => $model, 'dataProvider' => $dataProvider]) ?>
<?php $box->beginActions() ?>
<?= $box->renderCreateButton(Yii::t('app', 'Create service')) ?>
<?= $box->renderSearchButton() ?>
<?= $box->renderSorter([
'attributes' => [
'client',
'seller',
'name',
'soft',
],
]) ?>
<?= $box->renderPerPage() ?>
<?php $box->endActions() ?>
<?php $box->beginBulkActions() ?>
<?= $box->renderDeleteButton() ?>
<?php $box->endBulkActions() ?>
<?= $box->renderSearchForm(['stateData' => $stateData, 'typeData' => $typeData]) ?>
<?php $box->end(); ?>

<?php $box->beginBulkForm() ?>
<?= ServiceGridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $model,
'columns' => [
'checkbox',
'seller_id',
'client_id',
'service',
'ip',
'bin',
'etc',
'soft',
'state',
'actions',
],
]) ?>
<?php $box->endBulkForm() ?>
<?php Pjax::end();


4 changes: 2 additions & 2 deletions src/views/service/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use hipanel\widgets\Pjax;
use yii\helpers\Html;

$this->title = Html::encode($model->domain);
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Domains'), 'url' => ['index']];
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('hipanel/hosting', 'Services'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

?>
Expand Down

0 comments on commit b177286

Please sign in to comment.