Skip to content

Commit

Permalink
Minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Feb 26, 2016
1 parent 6b271a9 commit 1e1d52e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
21 changes: 13 additions & 8 deletions src/controllers/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
use hipanel\models\Ref;
use hipanel\modules\finance\models\Tariff;
use hipanel\modules\server\helpers\ServerHelper;
use hipanel\modules\server\models\ConsumptionForm;
use hipanel\modules\server\models\Osimage;
use hipanel\modules\server\models\Server;
use hipanel\modules\server\models\ServerSearch;
use hipanel\modules\server\models\ServerUseSearch;
use Yii;
use yii\base\Event;
use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper;
use yii\web\NotFoundHttpException;

class ServerController extends CrudController
Expand All @@ -52,7 +51,7 @@ public function actions()
]
],
'view' => [
'class' => ViewAction::class,
'class' => ViewAction::class,
'on beforePerform' => function (Event $event) {
/** @var \hipanel\actions\SearchAction $action */
$action = $event->sender;
Expand All @@ -67,7 +66,7 @@ public function actions()
->andWhere(['with_uses' => 1])
->select(['*']);
},
'data' => function ($action) {
'data' => function ($action) {
/**
* @var $controller $this
* @var $model Server
Expand Down Expand Up @@ -105,7 +104,14 @@ public function actions()

$blockReasons = $controller->getBlockReasons();

return compact(['model', 'osimages', 'osimageslivecd', 'grouped_osimages', 'panels', 'blockReasons']);
return compact([
'model',
'osimages',
'osimageslivecd',
'grouped_osimages',
'panels',
'blockReasons'
]);
},
],
'requests-state' => [
Expand Down Expand Up @@ -268,8 +274,6 @@ public function actionDrawChart()
$dataProvider = $searchModel->search([]);
$dataProvider->pagination = false;
$dataProvider->query->options = ['scenario' => 'get-uses'];
$dataProvider->query->index = 'servers';
$dataProvider->query->type = 'server';
$dataProvider->query->andWhere($post);
$models = $dataProvider->getModels();

Expand Down Expand Up @@ -326,7 +330,8 @@ protected function getPanelTypes()

protected function getStates()
{
return Ref::getList('state,device');
$states = Ref::getList('state,device');
return $states;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/models/ServerUse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ class ServerUse extends RUse
{
use \hipanel\base\ModelTrait;

public function formName()
{
return 'ServerUse';
}

public static function index()
{
return 'servers';
}

public static function type()
{
return 'server';
}

private function getTrafficTypes()
{
return ['server_traf_in', 'server_traf_max', 'server_traf'];
Expand Down
15 changes: 0 additions & 15 deletions src/models/ServerUseSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,4 @@
class ServerUseSearch extends ServerUse
{
use \hipanel\base\SearchModelTrait;

public function formName()
{
return 'ServerUse';
}

public static function index()
{
return 'Servers';
}

public static function type()
{
return 'Server';
}
}

0 comments on commit 1e1d52e

Please sign in to comment.