From 90ce547c2d7a2547bf2ee201378ef17a668cb2e7 Mon Sep 17 00:00:00 2001 From: SilverFire - Dima Naumenko Date: Thu, 30 Jul 2015 15:08:37 +0000 Subject: [PATCH] Db, Hdomain deep coding --- controllers/DbController.php | 6 ++++- controllers/HdomainController.php | 7 ++++++ grid/AccountColumn.php | 42 +++++++++++++++++++++++++++++++ grid/DbGridView.php | 14 +++++++---- grid/HdomainGridView.php | 17 ++++++++++--- views/hdomain/index.php | 20 +++++++++++---- 6 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 grid/AccountColumn.php diff --git a/controllers/DbController.php b/controllers/DbController.php index b02414c1..84c7cba4 100644 --- a/controllers/DbController.php +++ b/controllers/DbController.php @@ -108,7 +108,11 @@ public function actions() } ], ] - ] + ], + 'set-description' => [ + 'class' => 'hipanel\actions\SmartUpdateAction', + 'success' => Yii::t('app', 'Description set successfully'), + ], ]; } } diff --git a/controllers/HdomainController.php b/controllers/HdomainController.php index b46a752a..babd8f0e 100644 --- a/controllers/HdomainController.php +++ b/controllers/HdomainController.php @@ -64,4 +64,11 @@ public function actionIndex() return $this->render('index', compact('searchModel', 'dataProvider')); } + + public function actionView ($id) { + $model = $this->findModel(['id' => $id, 'with_aliases' => true, 'with_vhosts' => true, 'with_request' => true]); + + return $this->render('view', compact('model')); + } + } diff --git a/grid/AccountColumn.php b/grid/AccountColumn.php new file mode 100644 index 00000000..e8981c7f --- /dev/null +++ b/grid/AccountColumn.php @@ -0,0 +1,42 @@ +grid->filterModel)) { + if (!$this->filterInputOptions['id']) { + $this->filterInputOptions['id'] = $this->attribute; + } + if (!$this->filter) { + $this->filter = AccountCombo::widget([ + 'attribute' => $this->attribute, + 'model' => $this->grid->filterModel, + 'formElementSelector' => 'td', + ]); + }; + }; + } +} diff --git a/grid/DbGridView.php b/grid/DbGridView.php index 85c1b660..fa25c838 100644 --- a/grid/DbGridView.php +++ b/grid/DbGridView.php @@ -41,16 +41,20 @@ static public function defaultColumns() 'filter' => false ], 'description' => [ - 'class' => EditableColumn::className(), + 'class' => 'hiqdev\xeditable\grid\XEditableColumn', + 'pluginOptions' => [ + 'url' => 'set-description', + ], 'filter' => true, 'popover' => Yii::t('app', 'Make any notes for your convenience'), - 'action' => ['set-description'], ], - 'password' => [ - 'class' => EditableColumn::className(), + 'password' => [ + 'class' => 'hiqdev\xeditable\grid\XEditableColumn', + 'pluginOptions' => [ + 'url' => 'set-password', + ], 'filter' => true, 'popover' => Yii::t('app', 'Change the DB password'), - 'action' => ['set-password'], 'value' => function () { return Yii::t('app', 'Change password'); } diff --git a/grid/HdomainGridView.php b/grid/HdomainGridView.php index b1fca3a9..8dce7178 100644 --- a/grid/HdomainGridView.php +++ b/grid/HdomainGridView.php @@ -7,7 +7,6 @@ namespace hipanel\modules\hosting\grid; -use hipanel\grid\AccountColumn; use hipanel\grid\ActionColumn; use hipanel\grid\MainColumn; use hipanel\grid\RefColumn; @@ -33,10 +32,20 @@ static public function defaultColumns() ], 'ip' => [ 'filter' => false, + 'format' => 'raw', 'value' => function ($model) { - $html = $model['vhost']['ip']; + $vhost = $model['vhost']; + + $html = $vhost['ip']; + if (isset($vhost['port']) && $vhost['port'] != 80) { + $html .= ':' . $vhost['port']; + } if ($model->isProxied) { - $html .= Html::tag('i', ['class' => 'fa fa-long-arrow-right']) . $model['vhost']['backend']['ip']; + $backend = $model['vhost']['backend']; + $html .= ' ' . Html::tag('i', '', ['class' => 'fa fa-long-arrow-right']) . ' ' . $backend['ip']; + if ($backend['port'] != 80) { + $html .= ':' . $backend['port']; + } } return $html; } @@ -56,7 +65,7 @@ static public function defaultColumns() ], 'actions' => [ 'class' => ActionColumn::className(), - 'template' => '{view} {update} {delete}' + 'template' => '{view} {delete}' ], ]; } diff --git a/views/hdomain/index.php b/views/hdomain/index.php index 67e03819..6cb74451 100644 --- a/views/hdomain/index.php +++ b/views/hdomain/index.php @@ -9,24 +9,33 @@ use hipanel\widgets\ActionBox; use hipanel\widgets\Pjax; use yii\helpers\Html; +use yii\helpers\Url; $this->title = Yii::t('app', 'Domains'); -$this->params['breadcrumbs'][] = $this->title; +$this->breadcrumbs->setItems([ + $this->title, +]); $this->params['subtitle'] = Yii::$app->request->queryParams ? 'filtered list' : 'full list'; Pjax::begin(array_merge(Yii::$app->params['pjax'], ['enablePushState' => true])); -$box = ActionBox::begin(['options' => ['class' => 'box-info']]); + +echo Html::beginForm(); +$box = ActionBox::begin(['bulk' => true, 'options' => ['class' => 'box-info']]); $box->beginActions(); -echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => 'domain']), ['create'], ['class' => 'btn btn-success']) . ' '; +echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => Yii::t('app', 'Domain')]), ['create'], ['class' => 'btn btn-primary']); +echo ' '; $box->endActions(); + +$box->beginBulkActions(); +echo Html::submitButton(Yii::t('app', 'Delete'), ['class' => 'btn btn-danger', 'formmethod' => 'POST', 'formaction' => Url::to('delete')]); +$box->endBulkActions(); $box::end(); echo HdomainGridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ - 'checkbox', 'seller_id', 'client_id', 'account', @@ -34,7 +43,8 @@ 'hdomain', 'ip', 'service', - 'actions' + 'actions', + 'checkbox', ], ]);