diff --git a/src/controllers/AccountController.php b/src/controllers/AccountController.php
index e0fbc89d..bf75fa1a 100644
--- a/src/controllers/AccountController.php
+++ b/src/controllers/AccountController.php
@@ -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'),
@@ -58,4 +62,9 @@ public function getStateData()
{
return Ref::getList('state,account');
}
+
+ public function getTypeData()
+ {
+ return Ref::getList('type,account');
+ }
}
diff --git a/src/controllers/DbController.php b/src/controllers/DbController.php
index 8111c491..ab3bea10 100644
--- a/src/controllers/DbController.php
+++ b/src/controllers/DbController.php
@@ -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'),
@@ -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'),
diff --git a/src/controllers/HdomainController.php b/src/controllers/HdomainController.php
index d55ea41b..9aed7713 100644
--- a/src/controllers/HdomainController.php
+++ b/src/controllers/HdomainController.php
@@ -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',
@@ -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'),
+ ];
}
}
diff --git a/src/grid/AccountGridView.php b/src/grid/AccountGridView.php
index 18de63c4..5d0128b8 100644
--- a/src/grid/AccountGridView.php
+++ b/src/grid/AccountGridView.php
@@ -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;
@@ -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()
@@ -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',
+ ],
];
}
}
diff --git a/src/grid/HdomainGridView.php b/src/grid/HdomainGridView.php
index 82cfd0bc..99758ad5 100644
--- a/src/grid/HdomainGridView.php
+++ b/src/grid/HdomainGridView.php
@@ -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
@@ -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}'
diff --git a/src/models/Account.php b/src/models/Account.php
index 0e085248..44c725b3 100644
--- a/src/models/Account.php
+++ b/src/models/Account.php
@@ -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()
diff --git a/src/models/Hdomain.php b/src/models/Hdomain.php
index ca85ef64..81fb1400 100644
--- a/src/models/Hdomain.php
+++ b/src/models/Hdomain.php
@@ -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()
{
@@ -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'),
]);
}
diff --git a/src/models/HdomainSearch.php b/src/models/HdomainSearch.php
index 7e5d6cf7..2aa4a1a0 100644
--- a/src/models/HdomainSearch.php
+++ b/src/models/HdomainSearch.php
@@ -37,6 +37,7 @@ public function searchAttributes()
'with_request',
'with_vhosts',
'with_dns',
+ 'show_aliases_only',
]);
}
}
diff --git a/src/views/account/_search.php b/src/views/account/_search.php
index c5c3d0e5..635a8b40 100644
--- a/src/views/account/_search.php
+++ b/src/views/account/_search.php
@@ -25,6 +25,15 @@
= $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,
+ ]
+ ],
+ ]) ?>
diff --git a/src/views/account/index.php b/src/views/account/index.php
index e192ed52..7a4ccda1 100644
--- a/src/views/account/index.php
+++ b/src/views/account/index.php
@@ -36,7 +36,7 @@
= $box->renderSearchButton() ?>
= $box->renderSorter([
'attributes' => [
- 'login', 'client', 'server', 'state', 'type'
+ 'login', 'client', 'seller', 'server', 'state', 'type'
],
]) ?>
= $box->renderPerPage() ?>
@@ -45,7 +45,7 @@
beginBulkActions() ?>
= $box->renderDeleteButton() ?>
endBulkActions() ?>
- = $box->renderSearchForm(['stateData' => $stateData]) ?>
+ = $box->renderSearchForm(['stateData' => $stateData, 'typeData' => $typeData]) ?>
end() ?>
beginBulkForm() ?>
@@ -59,6 +59,7 @@
'seller',
'server',
'state',
+ 'type',
'actions',
],
]) ?>
diff --git a/src/views/account/view.php b/src/views/account/view.php
index 92327543..cb1545ae 100644
--- a/src/views/account/view.php
+++ b/src/views/account/view.php
@@ -148,4 +148,4 @@
-
\ No newline at end of file
+
diff --git a/src/views/db/_form.php b/src/views/db/_form.php
index 77300b63..9e85ec28 100644
--- a/src/views/db/_form.php
+++ b/src/views/db/_form.php
@@ -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']),
]) ?>
@@ -52,4 +52,4 @@
= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-default']) ?>
= Html::button(Yii::t('app', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?>
-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' => [
diff --git a/src/views/db/create.php b/src/views/db/create.php
index 9b99920a..a15b5c91 100644
--- a/src/views/db/create.php
+++ b/src/views/db/create.php
@@ -9,5 +9,5 @@
?>
- = $this->render('_form', compact('models')) ?>
+ = $this->render('_form', compact('models', 'model')) ?>
diff --git a/src/views/db/index.php b/src/views/db/index.php
index 7af757a7..76b8ca4f 100644
--- a/src/views/db/index.php
+++ b/src/views/db/index.php
@@ -16,7 +16,7 @@
= $box->renderSearchButton(); ?>
= $box->renderSorter([
'attributes' => [
- 'client', 'account', 'server', 'name', 'description', 'state'
+ 'client', 'seller', 'account', 'server', 'name', 'description', 'state'
],
]) ?>
= $box->renderPerPage() ?>
diff --git a/src/views/hdomain/_form.php b/src/views/hdomain/_form.php
index 4fd87bd8..9131473d 100644
--- a/src/views/hdomain/_form.php
+++ b/src/views/hdomain/_form.php
@@ -18,66 +18,78 @@
use yii\helpers\Url;
use yii\web\JsExpression;
-$this->registerJs(<<<'JS'
- $('#dynamic-form').on('change', '.proxy_enable', function () {
- var $checkbox = $(this);
- var $scope = $(this).closest('.form-instance');
- var $proxied = $scope.find(".frontend_ip, .backend_ip");
- var $not_proxied = $scope.find(".not-proxied-ip");
-
- if ($checkbox.prop('checked')) {
- $proxied.removeClass('hidden');
- $not_proxied.addClass('hidden');
- $scope.find('input[data-field=account]').trigger('change');
- } else {
- $proxied.addClass('hidden').find('input').select2('enable', false);
- $not_proxied.removeClass('hidden');
- $scope.find('input[data-field=account]').trigger('change');
- }
- });
-JS
-);
+ if (Yii::$app->user->can('support')) {
+ $this->registerJs(<<<'JS'
+ $('#dynamic-form').find('input[data-field=path]').on('updatePath', function (e, update) {
+ var $group = $(this).closest('.form-group');
+ var $input = $group.find('input');
+
+ var s_path = $input.val().split('/');
+ if (s_path.length < 2 || s_path[1] != 'home') {
+ s_path = ['', 'home', ''];
+ }
-$this->registerJs(<<<'JS'
-/*
-TODO: after ABAC - for admin
- $('.hdomain-create').find('.field-hdomain-path').on('updatePath', function (e, update) {
- var $path = $(this);
- var s_path = $path.val().split('/');
- if (s_path.length < 2 || s_path[1] != 'home') {
- s_path = ['', 'home', ''];
- }
+ // 0 - /
+ // 1 - home
+ // 2 - user
+ // 3 - domain
- // 0 - /
- // 1 - home
- // 2 - user
- // 3 - domain
+ if (update.account) {
+ if (s_path.length > 1) {
+ s_path[2] = update.account;
+ if (!s_path[3]) s_path[3] = '';
+ }
+ }
- if (update.account) {
- if (s_path.length > 1) {
- s_path[2] = update.account;
- if (!s_path[3]) s_path[3] = '';
+ if (update.domain) {
+ s_path[s_path.length - 1] = update.domain.replace(/\//g, ''); /// удаляем слеши, чтобы не собрать паровоз из пути
}
- } else if (update.domain) {
- s_path[s_path.length - 1] = update.domain.replace(/\\//g, ''); /// удаляем слеши, чтобы не собрать паровоз из пути
- } else if (update.clear) {
- s_path = [];
- }
- $path.val(s_path.join('/'));
- });
-*/
+ if (update.clear) {
+ s_path = [];
+ }
- $('#dynamic-form').find('input[data-field=path]').on('updatePath', function (e, update) {
- var $group = $(this).closest('.form-group');
- var $input = $group.find('input');
- var $span = $group.find('span');
+ $input.val(s_path.join('/'));
+ });
+JS
+ );
+ } else {
+ $this->registerJs(<<<'JS'
+ $('#dynamic-form').find('input[data-field=path]').on('updatePath', function (e, update) {
+ var $group = $(this).closest('.form-group');
+ var $input = $group.find('input');
+ var $span = $group.find('span');
+
+ if (update.account) $span.text('/home/' + update.account + '/');
+ if (update.domain !== undefined) $input.val(update.domain);
+ if (update.clear) $span.val('');
+ });
+JS
+ );
+ }
- if (update.account) $span.text('/home/' + update.account + '/');
- if (update.domain !== undefined) $input.val(update.domain);
- if (update.clear) $span.val('');
+ $this->registerJs(<<<'JS'
+ $('#dynamic-form').on('change', '.proxy_enable', function () {
+ var $checkbox = $(this);
+ var $scope = $(this).closest('.form-instance');
+ var $proxied = $scope.find(".frontend_ip, .backend_ip");
+ var $not_proxied = $scope.find(".not-proxied-ip");
+
+ if ($checkbox.prop('checked')) {
+ $proxied.removeClass('hidden');
+ $not_proxied.addClass('hidden');
+ $scope.find('input[data-field=account]').trigger('change');
+ } else {
+ $proxied.addClass('hidden').find('input').select2('enable', false);
+ $not_proxied.removeClass('hidden');
+ $scope.find('input[data-field=account]').trigger('change');
+ }
});
+JS
+ );
+
+$this->registerJs(<<<'JS'
$('#dynamic-form').on('keyup keypress blur change', 'input[data-field=domain]', function () {
var $scope = $(this).closest('.form-instance');
$scope.find("input[data-field=path]").trigger('updatePath', {domain: $(this).val()});
@@ -91,7 +103,7 @@
'validateOnBlur' => true,
'enableAjaxValidation' => true,
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->isNewRecord ? $model->scenario : 'update']),
-]) ?>
+]); ?>
$model) { ?>
@@ -116,7 +128,7 @@ function (event) {
var $form = event.element.closest('.form-instance');
var data;
if (event.added) {
- data = {account: event.added.text};
+ data = {account: event.added.text, domain: $form.find('input[data-field="domain"]').val()};
} else {
data = {clear: true};
}
@@ -128,18 +140,17 @@ function (event) {
],
]);
print $form->field($model, "[$i]domain")->input('text', ['data-field' => 'domain']);
- print $form->field($model, "[$i]path", [
- 'inputOptions' => [
- 'data-field' => 'path'
- ],
- 'template' => '{label}
+ $fieldOptions = ['inputOptions' => ['data-field' => 'path']];
+ if (!Yii::$app->user->can('support')) {
+ $fieldOptions['template'] = '{label}
/home/
{input}
{hint}
{error}
-
',
- ]);
+
';
+ }
+ print $form->field($model, "[$i]path", $fieldOptions);
print $form->field($model, "[$i]with_www")->checkbox();
print $form->field($model, "[$i]proxy_enable")->checkbox([
@@ -206,4 +217,4 @@ function (event) {
= Html::button(Yii::t('app', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?>
registerJs("$('#hdomain-proxy_enable').trigger('change');");
\ No newline at end of file
+//$this->registerJs("$('#hdomain-proxy_enable').trigger('change');");
diff --git a/src/views/hdomain/_search.php b/src/views/hdomain/_search.php
index a2889e02..dcd89e4a 100644
--- a/src/views/hdomain/_search.php
+++ b/src/views/hdomain/_search.php
@@ -20,7 +20,7 @@
]
],
]) ?>
- = $search->field('type')->widget(StaticCombo::classname(), [
+ = $search->field('show_aliases_only')->widget(StaticCombo::classname(), [
'data' => $typeData,
'hasId' => true,
'pluginOptions' => [
@@ -28,7 +28,7 @@
'multiple' => false,
]
],
- ]) ?>
+ ])->label(Yii::t('app', 'Type')); ?>
@@ -36,4 +36,4 @@
= $search->field('seller_id')->widget(SellerCombo::classname(), ['formElementSelector' => '.form-group']) ?>
= $search->field('server')->widget(ServerCombo::className(), ['formElementSelector' => '.form-group']) ?>
-
\ No newline at end of file
+
diff --git a/src/views/hdomain/view.php b/src/views/hdomain/view.php
index 86332737..16b0758a 100644
--- a/src/views/hdomain/view.php
+++ b/src/views/hdomain/view.php
@@ -82,6 +82,8 @@
'service',
'ip',
'state',
+ 'dns_on',
+ 'aliases',
],
]);
$box->endBody();
@@ -90,4 +92,4 @@
-
\ No newline at end of file
+
diff --git a/src/widgets/account/Type.php b/src/widgets/account/Type.php
new file mode 100644
index 00000000..a0436ebf
--- /dev/null
+++ b/src/widgets/account/Type.php
@@ -0,0 +1,21 @@
+model->type;
+ if ($type=='user') $class = 'info';
+ else $type = 'warning';
+
+ $this->zclass = $class;
+ $this->label = Re::l($this->model->type_label);
+ parent::run();
+ }
+}