Skip to content

Commit

Permalink
Db, Hdomain deep coding
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Jul 30, 2015
1 parent 8456939 commit 90ce547
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 15 deletions.
6 changes: 5 additions & 1 deletion controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ public function actions()
}
],
]
]
],
'set-description' => [
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'Description set successfully'),
],
];
}
}
7 changes: 7 additions & 0 deletions controllers/HdomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

}
42 changes: 42 additions & 0 deletions grid/AccountColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\grid;

use hipanel\grid\DataColumn;
use hipanel\modules\hosting\widgets\combo\AccountCombo;
use hipanel\widgets\Select2;
use yii\helpers\Url;
use yii\helpers\Html;

use yii\web\JsExpression;

class AccountColumn extends DataColumn
{
public $attribute = 'account_id';

public $nameAttribute = 'account';

public $format = 'html';

public function init () {
parent::init();

if (!empty($this->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',
]);
};
};
}
}
14 changes: 9 additions & 5 deletions grid/DbGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
17 changes: 13 additions & 4 deletions grid/HdomainGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -56,7 +65,7 @@ static public function defaultColumns()
],
'actions' => [
'class' => ActionColumn::className(),
'template' => '{view} {update} {delete}'
'template' => '{view} {delete}'
],
];
}
Expand Down
20 changes: 15 additions & 5 deletions views/hdomain/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,42 @@
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']) . '&nbsp;';
echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => Yii::t('app', 'Domain')]), ['create'], ['class' => 'btn btn-primary']);
echo '&nbsp;';
$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',
'server',
'hdomain',
'ip',
'service',
'actions'
'actions',
'checkbox',
],
]);

Expand Down

0 comments on commit 90ce547

Please sign in to comment.