Skip to content

Commit

Permalink
Account, Db, Hdomain - mass fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire authored and SilverFire - Dima Naumenko committed Aug 20, 2015
1 parent 755c0d9 commit 8c52cf3
Show file tree
Hide file tree
Showing 19 changed files with 170 additions and 77 deletions.
9 changes: 9 additions & 0 deletions src/controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public function actions()
'data' => function ($action) {
return [
'stateData' => $action->controller->getStateData(),
'typeData' => $action->controller->getTypeData(),
];
}
],
'view' => [
'class' => 'hipanel\actions\ViewAction'
],
'create' => [
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account creating task has been added to queue'),
Expand Down Expand Up @@ -58,4 +62,9 @@ public function getStateData()
{
return Ref::getList('state,account');
}

public function getTypeData()
{
return Ref::getList('type,account');
}
}
6 changes: 6 additions & 0 deletions src/controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public function actions()
];
}
],
'view' => [
'class' => 'hipanel\actions\ViewAction'
],
'create' => [
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'DB create task has been created successfully'),
Expand All @@ -44,6 +47,9 @@ public function actions()
'success' => Yii::t('app', 'DB description set successfully'),
'error' => Yii::t('app', 'Failed to set DB description'),
],
'validate-form' => [
'class' => 'hipanel\actions\ValidateFormAction',
],
'delete' => [
'class' => 'hipanel\actions\SmartPerformAction',
'success' => Yii::t('app', 'DB delete task has been created successfully'),
Expand Down
7 changes: 5 additions & 2 deletions src/controllers/HdomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function actions()
],
'view' => [
'class' => 'hipanel\actions\ViewAction',
'findOptions' => ['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true],
'findOptions' => ['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true, 'show_deleted' => true, 'show_aliases' => true],
],
'create' => [
'class' => 'hipanel\actions\SmartCreateAction',
Expand Down Expand Up @@ -56,6 +56,9 @@ public function getStateData()

public function getTypeData()
{
return Ref::getList('type,hdomain');
return [
0 => Yii::t('app', 'Domain'),
1 => Yii::t('app', 'Alias'),
];
}
}
12 changes: 11 additions & 1 deletion src/grid/AccountGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

namespace hipanel\modules\hosting\grid;

use Yii;
use hipanel\grid\ActionColumn;
use hipanel\grid\MainColumn;
use hipanel\grid\RefColumn;
use hipanel\modules\hosting\widgets\account\State;
use hipanel\modules\hosting\widgets\account\Type;
use hipanel\modules\server\grid\ServerColumn;
use hipanel\widgets\ArraySpoiler;

Expand All @@ -30,7 +32,7 @@ static public function defaultColumns()
'value' => function ($model) {
return State::widget(compact('model'));
},
'gtype' => 'state,db',
'gtype' => 'state,account',
],
'server' => [
'class' => ServerColumn::className()
Expand All @@ -49,6 +51,14 @@ static public function defaultColumns()
'class' => ActionColumn::className(),
'template' => '{view} {update} {delete}'
],
'type' => [
'class' => RefColumn::className(),
'format' => 'raw',
'value' => function ($model) {
return Type::widget(compact('model'));
},
'gtype' => 'type,account',
],
];
}
}
13 changes: 13 additions & 0 deletions src/grid/HdomainGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use hipanel\grid\RefColumn;
use hipanel\modules\hosting\widgets\hdomain\State;
use hipanel\modules\server\grid\ServerColumn;
use hipanel\widgets\ArraySpoiler;
use yii\helpers\Html;

class HdomainGridView extends \hipanel\grid\BoxedGridView
Expand Down Expand Up @@ -64,6 +65,18 @@ static public function defaultColumns()
},
'gtype' => 'state,hdomain',
],
'dns_on' => [
'format' => 'raw',
'value' => function ($model) {
return $model->dns_on ? \Yii::t('app', 'Enabled') : \Yii::t('app', 'Disabled');
}
],
'aliases' => [
'format' => 'raw',
'value' => function ($model) {
return ArraySpoiler::widget(['data' => $model->getAttribute('aliases')]);
}
],
'actions' => [
'class' => ActionColumn::className(),
'template' => '{view} {delete}'
Expand Down
2 changes: 1 addition & 1 deletion src/models/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function isOperable()

public function getSshFtpIpsList()
{
return implode(', ', $this->sshftp_ips);
return implode(', ', empty($this->sshftp_ips) ? ['0.0.0.0/0'] : $this->sshftp_ips);
}

public function getKnownTypes()
Expand Down
7 changes: 7 additions & 0 deletions src/models/Hdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class Hdomain extends \hipanel\base\Model
*/
public $vhost;

/**
* @var array Stores array of aliases of hdomain
*/
public $aliases;


/** @inheritdoc */
public function rules()
{
Expand Down Expand Up @@ -87,6 +93,7 @@ public function attributeLabels()
'with_www' => Yii::t('app', 'Create www alias'),
'proxy_enable' => Yii::t('app', 'Enable proxy (NEED MANUAL)'),
'backuping_type' => Yii::t('app', 'Backup periodicity'),
'dns_on' => Yii::t('app', 'DNS'),
]);
}

Expand Down
1 change: 1 addition & 0 deletions src/models/HdomainSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function searchAttributes()
'with_request',
'with_vhosts',
'with_dns',
'show_aliases_only',
]);
}
}
9 changes: 9 additions & 0 deletions src/views/account/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
<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('type')->widget(StaticCombo::classname(), [
'data' => $typeData,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => false,
]
],
]) ?>
</div>


5 changes: 3 additions & 2 deletions src/views/account/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<?= $box->renderSearchButton() ?>
<?= $box->renderSorter([
'attributes' => [
'login', 'client', 'server', 'state', 'type'
'login', 'client', 'seller', 'server', 'state', 'type'
],
]) ?>
<?= $box->renderPerPage() ?>
Expand All @@ -45,7 +45,7 @@
<?php $box->beginBulkActions() ?>
<?= $box->renderDeleteButton() ?>
<?php $box->endBulkActions() ?>
<?= $box->renderSearchForm(['stateData' => $stateData]) ?>
<?= $box->renderSearchForm(['stateData' => $stateData, 'typeData' => $typeData]) ?>
<?php $box->end() ?>

<?php $box->beginBulkForm() ?>
Expand All @@ -59,6 +59,7 @@
'seller',
'server',
'state',
'type',
'actions',
],
]) ?>
Expand Down
2 changes: 1 addition & 1 deletion src/views/account/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@
</div>
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions src/views/db/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'enableClientValidation' => true,
'validateOnBlur' => true,
'enableAjaxValidation' => true,
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->isNewRecord ? reset($models)->scenario : 'update']),
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->isNewRecord ? $model->scenario : 'update']),
]) ?>

<div class="container-items"><!-- widgetContainer -->
Expand Down Expand Up @@ -52,4 +52,4 @@
<?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-default']) ?>
&nbsp;
<?= Html::button(Yii::t('app', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?>
<?php ActiveForm::end();
<?php ActiveForm::end();
2 changes: 1 addition & 1 deletion src/views/db/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<?= $search->field('client_id')->widget(ClientCombo::classname(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('seller_id')->widget(SellerCombo::classname(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('state')->widget(StaticCombo::classname(), [
'data' => $state_data,
'data' => $stateData,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
Expand Down
2 changes: 1 addition & 1 deletion src/views/db/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
?>

<div class="db-create">
<?= $this->render('_form', compact('models')) ?>
<?= $this->render('_form', compact('models', 'model')) ?>
</div>
2 changes: 1 addition & 1 deletion src/views/db/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<?= $box->renderSearchButton(); ?>
<?= $box->renderSorter([
'attributes' => [
'client', 'account', 'server', 'name', 'description', 'state'
'client', 'seller', 'account', 'server', 'name', 'description', 'state'
],
]) ?>
<?= $box->renderPerPage() ?>
Expand Down
Loading

0 comments on commit 8c52cf3

Please sign in to comment.