From 6d37d84ba31911cd0dc741f3e9cb2ccc41435895 Mon Sep 17 00:00:00 2001 From: SilverFire - Dima Naumenko Date: Tue, 19 May 2015 19:15:20 +0300 Subject: [PATCH] DbController - playing with switchAction Models filled in --- controllers/DbController.php | 54 ++++++++++-------------------------- models/Backup.php | 25 +++++++++-------- models/Backuping.php | 30 ++++++++++++-------- models/Crontab.php | 22 ++++++--------- models/Db.php | 2 +- models/Hdomain.php | 21 +++++++------- models/Ip.php | 24 ++++++++-------- models/Mail.php | 24 ++++++++-------- models/Request.php | 24 ++++++++-------- models/Service.php | 23 ++++++++------- 10 files changed, 118 insertions(+), 131 deletions(-) diff --git a/controllers/DbController.php b/controllers/DbController.php index ff04672e..ff74d21f 100644 --- a/controllers/DbController.php +++ b/controllers/DbController.php @@ -52,58 +52,34 @@ function ($model) { ], 'create' => [ 'class' => 'hipanel\actions\SwitchAction', - 'addFlash' => true, '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']); - }] + 'params' => [ + 'model' => function ($action) { + return $action->controller->newModel(['scenario' => 'create']); + } + ], ], 'POST html' => [ - 'perform' => true, + 'save' => true, + 'flash' => true, 'success' => [ 'class' => 'hipanel\actions\RedirectAction', - 'url' => [ - 'view', - function ($action, $model) { - return ['id' => $model->id]; - } - ] - ], - 'error' => [ - 'class' => 'hipanel\actions\RenderAction', - 'url' => [ - 'create', - function ($action, $model) { - return compact('model'); - } - ], - ], - ], - 'POST pjax' => [ - 'perform' => true, - 'success' => [ - 'class' => 'hipanel\actions\RedirectAction', - 'url' => [ - 'view', - function ($model) { - return ['id' => $model->id]; - } - ], - 'pjaxLocationHeader' => true, + 'url' => function ($action, $model) { + return ['view', 'id' => $model->id]; + } ], 'error' => [ - 'class' => 'hipanel\actions\RenderAction', - 'url' => [ - 'create', - function ($model) { - return [$model->model]; + 'class' => 'hipanel\actions\RenderAction', + 'view' => 'create', + 'params' => [ + 'model' => function ($action, $model) { + return $model; } ], - 'pjaxLocationHeader' => true, ], ], ], diff --git a/models/Backup.php b/models/Backup.php index 269e0909..4155bc12 100644 --- a/models/Backup.php +++ b/models/Backup.php @@ -14,22 +14,25 @@ class Backup extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [['id', 'service_id','object_id', 'server_id','account_id', 'client_id', 'ty_id', 'state_id'], 'integer'], + [['time'], 'date'], + [['size', 'size_gb'], 'integer'], + [['service', 'method', 'server', 'account', 'client', 'name', 'ty', 'state'], 'safe'], + [['method_label', 'type_label', 'state_label'], 'safe'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'object_id' => Yii::t('app', 'Object ID'), + 'ty_id' => Yii::t('app', 'Type ID'), + 'ty' => Yii::t('app', 'Type'), + 'size_gb' => Yii::t('app', 'Size in GB'), + 'method_label' => Yii::t('app', 'Method label'), ]); } } diff --git a/models/Backuping.php b/models/Backuping.php index a524f894..f8d8309a 100644 --- a/models/Backuping.php +++ b/models/Backuping.php @@ -14,22 +14,30 @@ class Backuping extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [['id', 'service_id', 'server_id', 'account_id', 'client_id'], 'integer'], + [['skip_lock'], 'boolean'], + [['day','hour', 'path', 'include', 'exclude'], 'safe'], + [['method', 'method_label','server', 'account', 'client', 'name', 'object', 'service'], 'safe'], + [['backup_last' ], 'date'], + [['backup_count', 'total_du', 'total_du_gb',], 'integer'], + [['type', 'type_label', 'state', 'state_label'], 'safe'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'day' => Yii::t('app', 'Date'), + 'hour' => Yii::t('app', 'Time'), + 'skip_lock' => Yii::t('app', 'Skip lock'), + 'backup_last' => Yii::t('app', 'Last backup'), + 'backup_count' => Yii::t('app', 'Count'), + 'total_du' => Yii::t('app', 'Total of backup uses'), + 'total_du_gb' => Yii::t('app', 'Total of backup uses in GB'), + 'method_label' => Yii::t('app', 'Method label'), ]); } } diff --git a/models/Crontab.php b/models/Crontab.php index 75b71676..4b1c00d7 100644 --- a/models/Crontab.php +++ b/models/Crontab.php @@ -14,22 +14,18 @@ class Crontab extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [['id', 'account_id', 'server_id', 'client_id'], 'integer'], + [['crontab', 'account', 'server', 'client'], 'safe'], + [['state', 'state_label'], 'safe'], + [['exists'], 'boolean'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { - return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), - ]); + /** @inheritdoc */ + public function attributeLabels () { + return $this->mergeAttributeLabels([]); } } diff --git a/models/Db.php b/models/Db.php index c46b4c94..4bd5893e 100644 --- a/models/Db.php +++ b/models/Db.php @@ -39,7 +39,7 @@ public function rules () { public function scenarios () { return [ - 'create' => ['server', 'account', 'service_id', 'name', 'password', 'description'], + 'create' => ['client', 'server', 'account', 'service_id', 'name', 'password', 'description'], 'truncate' => ['id'], 'set-description' => ['id', 'description'], 'set-password' => ['id', 'password'], diff --git a/models/Hdomain.php b/models/Hdomain.php index c9799fc3..a552114d 100644 --- a/models/Hdomain.php +++ b/models/Hdomain.php @@ -14,22 +14,21 @@ class Hdomain extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [ + ['id', 'server_id', 'client_id', 'seller_id', 'account_id', 'hdomain_id', 'state_id', 'type_id'], + 'integer' + ], + [['server', 'client', 'seller', 'account', 'hdomain', 'state', 'type', 'ip', 'alias'], 'safe'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'hdomain' => Yii::t('app', 'Domain Name'), ]); } } diff --git a/models/Ip.php b/models/Ip.php index ed995f70..2806d359 100644 --- a/models/Ip.php +++ b/models/Ip.php @@ -14,22 +14,24 @@ class Ip extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + public function rules () { return [ + [['id', 'client_id'], 'integer'], + [['ip','objects_count', 'tags', 'client'], 'safe'], + [['prefix', 'family'], 'safe'], + [['type', 'state', 'state_label'], 'safe'], + [['links', 'expanded_ips', 'ip_normalized'],'safe'], + [['is_single'], 'boolean'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'objects_count' => Yii::t('app', 'Count of objects'), + 'is_single' => Yii::t('app', 'Single'), + 'ip_normalized' => Yii::t('app', 'Normalized IP'), + 'expanded_ips' => Yii::t('app', 'Expanded IPs'), ]); } } diff --git a/models/Mail.php b/models/Mail.php index 51adee5c..a168447f 100644 --- a/models/Mail.php +++ b/models/Mail.php @@ -14,22 +14,24 @@ class Mail extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [['id', 'hdomain_id', 'client_id', 'account_id', 'server_id'], 'integer'], + [['mail', 'nick', 'hdomain', 'client', 'account', 'server', 'domain'], 'safe'], + [['type', 'state', 'state_label'], 'safe'], + [['forwards', 'spam_action', 'autoanswer', 'du_limit'], 'safe'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'hdomain' => Yii::t('app', 'Domain Name'), + 'domain' => Yii::t('app', 'Domain Name'), + 'forwards' => Yii::t('app', 'Forward'), + 'spam_action' => Yii::t('app', 'Spam action'), + 'du_limit' => Yii::t('app', 'Disck usage limit'), ]); } } diff --git a/models/Request.php b/models/Request.php index c52164bd..9e031993 100644 --- a/models/Request.php +++ b/models/Request.php @@ -14,22 +14,24 @@ class Request extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ + [['id', 'object_id', 'service_id', 'client_id', 'account_id', 'server_id'], 'integer'], + [['realm', 'object', 'service', 'client', 'account', 'server'], 'safe'], + [['type', 'type_label', 'state', 'state_label'], 'safe'], + [['tries_left', 'pid', 'time_lag'], 'integer'], + [['object_name'], 'safe'], + [['time'], 'date'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'object_name' => Yii::t('app', 'Object Name'), + 'tries_left' => Yii::t('app', 'Tries left'), + 'time_lag' => Yii::t('app', 'Time lag'), ]); } } diff --git a/models/Service.php b/models/Service.php index f49c0271..a10fafc2 100644 --- a/models/Service.php +++ b/models/Service.php @@ -14,23 +14,22 @@ class Service extends \hipanel\base\Model use \hipanel\base\ModelTrait; - /** - * @inheritdoc - */ - public function rules () - { + /** @inheritdoc */ + public function rules () { return [ - + [['id', 'server_id', 'device_id', 'client_id', 'seller_id', 'soft_id'], 'integer'], + [['name', 'server', 'device', 'client', 'seller', 'soft'], 'safe'], + [['ip', 'bin', 'etc'], 'safe'], + [['soft_type', 'soft_type_label', 'state', 'state_label'], 'safe'], ]; } - /** - * @inheritdoc - */ - public function attributeLabels () - { + /** @inheritdoc */ + public function attributeLabels () { return $this->mergeAttributeLabels([ - 'remoteid' => Yii::t('app', 'Remote ID'), + 'soft_id' => Yii::t('app', 'Soft ID'), + 'soft_type' => Yii::t('app', 'Soft Type'), + 'soft_type_label' => Yii::t('app', 'Soft type label'), ]); } }