Skip to content

Commit

Permalink
DbController - playing with switchAction
Browse files Browse the repository at this point in the history
Models filled in
  • Loading branch information
SilverFire committed May 19, 2015
1 parent c5ba741 commit 6d37d84
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 131 deletions.
54 changes: 15 additions & 39 deletions controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
],
],
Expand Down
25 changes: 14 additions & 11 deletions models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
30 changes: 19 additions & 11 deletions models/Backuping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
22 changes: 9 additions & 13 deletions models/Crontab.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
}
}
2 changes: 1 addition & 1 deletion models/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
21 changes: 10 additions & 11 deletions models/Hdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
24 changes: 13 additions & 11 deletions models/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
24 changes: 13 additions & 11 deletions models/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
24 changes: 13 additions & 11 deletions models/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}
23 changes: 11 additions & 12 deletions models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
]);
}
}

0 comments on commit 6d37d84

Please sign in to comment.