From b17728643c9c2494acb738a6fd58c47d07b02d00 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Fri, 20 Nov 2015 14:38:19 +0200 Subject: [PATCH] Service - added filter, view --- src/controllers/ServiceController.php | 6 ++- src/grid/ServiceGridView.php | 2 + src/messages/ru/hosting.php | 5 ++- src/models/Service.php | 3 ++ src/views/service/_search.php | 44 ++++++++++++++++++++ src/views/service/index.php | 60 ++++++++++++++++++++------- src/views/service/view.php | 4 +- 7 files changed, 105 insertions(+), 19 deletions(-) create mode 100644 src/views/service/_search.php diff --git a/src/controllers/ServiceController.php b/src/controllers/ServiceController.php index fba21bfb..283f87f6 100644 --- a/src/controllers/ServiceController.php +++ b/src/controllers/ServiceController.php @@ -21,8 +21,12 @@ public function actions() $action = $event->sender; $dataProvider = $action->getDataProvider(); $dataProvider->query->joinWith('ips'); - } + }, + ], + 'view' => [ + 'class' => 'hipanel\actions\ViewAction', + ] ]; } } diff --git a/src/grid/ServiceGridView.php b/src/grid/ServiceGridView.php index 2f9d42ca..167fe71a 100644 --- a/src/grid/ServiceGridView.php +++ b/src/grid/ServiceGridView.php @@ -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 { @@ -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]); }, diff --git a/src/messages/ru/hosting.php b/src/messages/ru/hosting.php index f15cd909..5c273a4d 100644 --- a/src/messages/ru/hosting.php +++ b/src/messages/ru/hosting.php @@ -24,5 +24,8 @@ 'This will immediately terminate all sessions of the user!' => 'Это немедленно прервет все сеансы пользователя!', 'Enter new restrictions' => 'Введите новые ограничения', 'Enter a new password' => 'Введите новый пароль', - +/** + * Service + */ + 'Soft' => 'ПО', ]; \ No newline at end of file diff --git a/src/models/Service.php b/src/models/Service.php index 64d5c7c0..fe8a0fff 100644 --- a/src/models/Service.php +++ b/src/models/Service.php @@ -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'), ]); } diff --git a/src/views/service/_search.php b/src/views/service/_search.php new file mode 100644 index 00000000..85dad7c2 --- /dev/null +++ b/src/views/service/_search.php @@ -0,0 +1,44 @@ + + +
+ field('name_like') ?> + field('server')->widget(ServerCombo::className(), ['formElementSelector' => '.form-group']) ?> + field('state')->widget(StaticCombo::classname(), [ + 'data' => $stateData, + 'hasId' => true, + 'pluginOptions' => [ + 'select2Options' => [ + 'multiple' => false, + ] + ], + ]) ?> + +
+ +
+ field('client_id')->widget(ClientCombo::classname(), ['formElementSelector' => '.form-group']) ?> + field('seller_id')->widget(SellerCombo::classname(), ['formElementSelector' => '.form-group']) ?> + field('soft')->widget(StaticCombo::classname(), [ + 'data' => $softData, + 'hasId' => true, + 'pluginOptions' => [ + 'select2Options' => [ + 'multiple' => false, + ] + ], + ]) ?> +
+ + diff --git a/src/views/service/index.php b/src/views/service/index.php index a2e627d2..89d63e9b 100644 --- a/src/views/service/index.php +++ b/src/views/service/index.php @@ -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'; - ?> - $dataProvider, - 'filterModel' => $model, - 'columns' => [ - 'seller_id', - 'client_id', - 'service', - 'ip', - 'bin', - 'etc', - 'soft', - 'state', - ], -]) ?> +params['pjax'], ['enablePushState' => true])); ?> + + $model, 'dataProvider' => $dataProvider]) ?> + beginActions() ?> + renderCreateButton(Yii::t('app', 'Create service')) ?> + renderSearchButton() ?> + renderSorter([ + 'attributes' => [ + 'client', + 'seller', + 'name', + 'soft', + ], + ]) ?> + renderPerPage() ?> + endActions() ?> + beginBulkActions() ?> + renderDeleteButton() ?> + endBulkActions() ?> + renderSearchForm(['stateData' => $stateData, 'typeData' => $typeData]) ?> +end(); ?> + +beginBulkForm() ?> + $dataProvider, + 'filterModel' => $model, + 'columns' => [ + 'checkbox', + 'seller_id', + 'client_id', + 'service', + 'ip', + 'bin', + 'etc', + 'soft', + 'state', + 'actions', + ], + ]) ?> +endBulkForm() ?> +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; ?>