Skip to content

Commit

Permalink
Some function to NS
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Dec 11, 2015
1 parent 66c6406 commit 705d681
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
55 changes: 35 additions & 20 deletions src/controllers/DomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use hipanel\actions\Action;
use hipanel\actions\IndexAction;
use hipanel\actions\ProxyAction;
use hipanel\actions\RedirectAction;
use hipanel\actions\RenderAction;
use hipanel\actions\RenderJsonAction;
Expand Down Expand Up @@ -138,17 +139,31 @@ public function actions()
'success' => [
'class' => RedirectAction::class,
'url' => function ($action) {
return $action->redirect($this->redirect(Yii::$app->request->referrer));
return $action->controller->redirect(Yii::$app->request->referrer);
}
],
],
],
'bulk-set-nss' => [
'class' => SmartUpdateAction::class,
'scenario' => 'set-nss',
'view' => '_bulkSetNs',
'success' => Yii::t('app', 'Nameservers changed'),
'POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => 'index'
'class' => ProxyAction::class,
'return' => function ($action) {
return ['fuck' => 'yeah'];
}
],
],
'on beforeFetch' => function (Event $event) {
/** @var \hipanel\actions\SearchAction $action */
$action = $event->sender;
$dataProvider = $action->getDataProvider();
$dataProvider->query->andWhere(['with_nsips' => 1]);
},
'on beforeSave' => function (Event $event) {
/** @var \hipanel\actions\Action $action */
$action = $event->sender;
Expand Down Expand Up @@ -395,23 +410,23 @@ public function actionDomainPushModal($id)
'hasPincode' => $hasPincode,
]);
}

public function actionBulkSetNs()
{
$model = new Domain();
$model->scenario = 'set-nss';
$collection = new Collection();
$collection->setModel($model);
$collection->load();
$searchModel = new DomainSearch();
$models = $searchModel
->search([$searchModel->formName() => [
'id_in' => ArrayHelper::map($collection->models, 'id', 'id'),
'with_nsips' => true,
]])->getModels();

return $this->renderAjax('_bulkSetNs', ['models' => $models]);
}
//
// public function actionBulkSetNs()
// {
// $model = new Domain();
// $model->scenario = 'set-nss';
// $collection = new Collection();
// $collection->setModel($model);
// $collection->load();
// $searchModel = new DomainSearch();
// $models = $searchModel
// ->search([$searchModel->formName() => [
// 'id_in' => ArrayHelper::map($collection->models, 'id', 'id'),
// 'with_nsips' => true,
// ]])->getModels();
//
// return $this->renderAjax('_bulkSetNs', ['models' => $models]);
// }

public function actionBulkSetNote()
{
Expand Down
1 change: 1 addition & 0 deletions src/views/domain/_bulkSetNs.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<?= NsWidget::widget([
'model' => $models,
'attribute' => 'nsips',
'actionUrl' => 'bulk-set-nss',
]); ?>
<br>
<div class="panel panel-default">
Expand Down
4 changes: 2 additions & 2 deletions src/views/domain/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
<?= AjaxModal::widget([
'bulkPage' => true,
'header'=> Html::tag('h4', Yii::t('app', 'Set NS'), ['class' => 'modal-title']),
'scenario' => 'bulk-set-ns',
'actionUrl' => ['bulk-set-ns'],
'scenario' => 'bulk-set-nss',
'actionUrl' => ['bulk-set-nss'],
'size' => Modal::SIZE_LARGE,
'toggleButton' => ['label' => Yii::t('app', 'Set NS'), 'class' => 'btn btn-default',],
]) ?>
Expand Down

0 comments on commit 705d681

Please sign in to comment.