Skip to content

Commit

Permalink
DB, Accounts, Hdomains - controllers, views, models updated to actual…
Browse files Browse the repository at this point in the history
…y agreed style

Minor fixes
  • Loading branch information
SilverFire committed Aug 2, 2015
1 parent cf4ac41 commit 143db74
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 549 deletions.
121 changes: 15 additions & 106 deletions src/controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,118 +15,27 @@ public function actions()
{
return [
'create' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'Account create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating account'),
'scenario' => 'create-user',
'GET html | GET pjax' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action) {
return $action->controller->newModel(['scenario' => 'create-user']);
},
],
],
'POST html | POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action, $model) {
return $model;
},
'type' => 'user'
],
],
],
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account creating task has been added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to create account')
],
'create-ftponly' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'Account create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating account'),
'GET html | GET pjax' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action) {
return $action->controller->newModel(['scenario' => 'create-ftponly']);
}
],
],
'POST html | POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action, $model) {
return $model;
}
],
],
],
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account creating task has been added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to create account')
],
'set-password' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'Password changing task has been successfully added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to change password'),
'POST html' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
]
],
'POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\ProxyAction',
'action' => 'view',
'params' => function ($action, $model) {
return ['id' => $model->id];
},
]
],
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'Password changed'),
'error' => Yii::t('app', 'Failed to change password'),
],
'set-allowed-ips' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'Allowed IPs changing task has been successfully added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to change allowed IPs'),
'POST html' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
]
],
'POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\ProxyAction',
'action' => 'view',
'params' => function ($action, $model) {
return ['id' => $model->id];
},
]
],
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'Allowed IPs changing task has been successfully added to queue'),
'error' => Yii::t('app', 'An error occurred when trying to change allowed IPs'),
],
'validate-form' => [
'class' => 'hipanel\actions\ValidateFormAction',
],
];
}
Expand Down
105 changes: 16 additions & 89 deletions src/controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,110 +8,37 @@
namespace hipanel\modules\hosting\controllers;

use hipanel\base\CrudController;
use yii\filters\VerbFilter;
use Yii;

class DbController extends CrudController
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'create' => ['get', 'post']
]
]
];
}

public function actions()
{
return [
'delete' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'DB delete task has been created successfully'),
'error' => Yii::t('app', 'Error while deleting DB'),
'POST' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => ['index'],
],
'error' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
]
],
],
'create' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'DB create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating DB'),
'GET html | GET pjax' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action) {
return $action->controller->newModel(['scenario' => 'create']);
}
],
],
'POST html' => [
'save' => true,
'flash' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action, $model) {
return $model;
}
],
],
],
'create' => [
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'DB create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating DB'),
],
'set-password' => [
'class' => 'hipanel\actions\SwitchAction',
'set-password' => [
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'DB password change task has been created successfully'),
'error' => Yii::t('app', 'Error while DB password changing'),
'POST' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\ProxyAction',
'action' => 'view',
'params' => function ($action, $model) {
return ['id' => $model->id];
},
]
],
],
'truncate' => [
'class' => 'hipanel\actions\SwitchAction',
'truncate' => [
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'DB truncate task has been created successfully'),
'error' => Yii::t('app', 'Error while truncating DB'),
'POST' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\ProxyAction',
'action' => 'view',
'params' => function ($action, $model) {
return ['id' => $model->id];
}
],
]
],
'set-description' => [
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'Description set successfully'),
'class' => 'hipanel\actions\SmartUpdateAction',
'success' => Yii::t('app', 'DB description set successfully'),
'error' => Yii::t('app', 'Failed to set DB description'),
],
'delete' => [
'class' => 'hipanel\actions\SmartDeleteAction',
'success' => Yii::t('app', 'DB delete task has been created successfully'),
'error' => Yii::t('app', 'Error while deleting DB'),
],
];
}
Expand Down
71 changes: 18 additions & 53 deletions src/controllers/HdomainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,33 @@

namespace hipanel\modules\hosting\controllers;

use hipanel\helpers\ArrayHelper;
use Yii;

class HdomainController extends \hipanel\base\CrudController
{
public function actions()
{
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
'findOptions' => ['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true]
],
'view' => [
'class' => 'hipanel\actions\ViewAction',
'findOptions' => [
'with_aliases' => true,
'with_vhosts' => true,
'with_request' => true
]
],
'create' => [
'class' => 'hipanel\actions\SwitchAction',
'success' => Yii::t('app', 'Account create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating account'),
'GET html | GET pjax' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action) {
return $action->controller->newModel(['scenario' => 'create']);
},
],
],
'POST html | POST pjax' => [
'save' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => function ($action, $model) {
return ['view', 'id' => $model->id];
}
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => [
'model' => function ($action, $model) {
return $model;
},
'type' => 'user'
],
],
],
'class' => 'hipanel\actions\SmartCreateAction',
'success' => Yii::t('app', 'Account create task has been created successfully'),
'error' => Yii::t('app', 'Error while creating account'),
],
'validate-form' => [
'class' => 'hipanel\actions\ValidateFormAction',
],
];
}

/**
* @return string
*/
public function actionIndex()
{
$searchModel = static::searchModel();
$params = Yii::$app->request->queryParams;
$params[$searchModel->formName()] = ArrayHelper::merge($params[$searchModel->formName()],
['with_aliases' => true, 'with_vhosts' => true, 'with_request' => true]);
$dataProvider = $searchModel->search($params);

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'));
}

}
Loading

0 comments on commit 143db74

Please sign in to comment.