Skip to content

Commit

Permalink
Initial Backup section
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Nov 11, 2015
1 parent 8eb6cfb commit 1303e48
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/SidebarMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public function items()
'url' => ['/hosting/hdomain/index'],
'icon' => 'fa-globe',
'visible' => function () { return (bool)Yii::getAlias('@domain', false); },
],
'Backups' => [
'label' => Yii::t('app', 'Backups'),
'url' => ['/hosting/backup/index'],
// 'icon' => 'fa-globe',
'visible' => function () { return (bool)Yii::getAlias('@domain', false); },
]
],
],
Expand Down
27 changes: 22 additions & 5 deletions src/controllers/BackupController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\controllers;

use Yii;

class BackupController extends \hipanel\base\CrudController
{
public function actions()
{
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
'data' => function ($action) {
return [
'objectOptions' => $action->controller->getObjectOptions(),
];
},
],
];
}

public function getObjectOptions()
{
return [
'hdomain' => Yii::t('app', 'Domain'),
'db' => Yii::t('app', 'Data bases'),
];
}
}
16 changes: 9 additions & 7 deletions src/grid/BackupGridView.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\grid;

use hipanel\grid\MainColumn;
use hipanel\modules\server\grid\ServerColumn;

class BackupGridView extends \hipanel\grid\BoxedGridView
{
static public function defaultColumns()
{
return [
'backup' => [
'class' => MainColumn::className(),
'filterAttribute' => 'backup_like',
'class' => MainColumn::className(),
'filterAttribute' => 'backup_like',
],
'server' => [
'class' => ServerColumn::className(),
],
'account' => [
'class' => AccountColumn::className()
],
];
}
Expand Down
29 changes: 13 additions & 16 deletions src/models/Backup.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/**
* @link http://hiqdev.com/hipanel-module-hosting
* @license http://hiqdev.com/hipanel-module-hosting/license
* @copyright Copyright (c) 2015 HiQDev
*/

namespace hipanel\modules\hosting\models;

Expand All @@ -15,23 +10,25 @@ class Backup extends \hipanel\base\Model
use \hipanel\base\ModelTrait;

/** @inheritdoc */
public function rules () {
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'],
[['id', 'service_id', 'object_id', 'server_id', 'account_id', 'client_id', 'ty_id', 'state_id'], 'integer'],
[['time'], 'date'],
[['size', 'size_gb'], 'integer'],
[['title', 'db_like', 'domain_like', 'service', 'method', 'server', 'account', 'client', 'classes', 'name', 'ty', 'state', 'object'], 'safe'],
[['method_label', 'type_label', 'state_label'], 'safe'],
];
}

/** @inheritdoc */
public function attributeLabels () {
public function attributeLabels()
{
return $this->mergeAttributeLabels([
'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'),
'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'),
]);
}
}
29 changes: 29 additions & 0 deletions src/views/backup/_search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use hipanel\modules\client\widgets\combo\ClientCombo;

use hipanel\modules\hosting\widgets\combo\AccountCombo;
use hipanel\modules\server\widgets\combo\ServerCombo;
use hiqdev\combo\StaticCombo;

?>

<div class="col-md-6">
<?= $search->field('db_like') ?>
<?= $search->field('domain_like') ?>
<?= $search->field('account')->widget(AccountCombo::className()) ?>
</div>

<div class="col-md-6">
<?= $search->field('server')->widget(ServerCombo::className(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('client_id')->widget(ClientCombo::classname(), ['formElementSelector' => '.form-group']) ?>
<?= $search->field('classes')->widget(StaticCombo::classname(), [
'data' => $objectOptions,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => false,
],
],
]) ?>
</div>
50 changes: 42 additions & 8 deletions src/views/backup/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,55 @@
* @copyright Copyright (c) 2015 HiQDev
*/

use hipanel\helpers\Url;
use hipanel\modules\hosting\grid\BackupGridView;
use hipanel\widgets\ActionBox;
use hipanel\widgets\Pjax;

$this->title = Yii::t('app', 'Backups');
$this->params['breadcrumbs'][] = $this->title;
$this->params['subtitle'] = array_filter(Yii::$app->request->get($model->formName(), [])) ? 'filtered list' : 'full list';
$this->title = Yii::t('app', 'Backups');
$this->params['breadcrumbs'][] = $this->title;
$this->params['subtitle'] = array_filter(Yii::$app->request->get($model->formName(), [])) ? 'filtered list' : 'full list';

?>
<?php Pjax::begin(array_merge(Yii::$app->params['pjax'], ['enablePushState' => true])) ?>
<?php $box = ActionBox::begin(['model' => $model, 'dataProvider' => $dataProvider]) ?>
<?php $box->beginActions() ?>

<?= backupGridView::widget([
<?= $box->renderSearchButton() ?>
<?= $box->renderSorter([
'attributes' => [
'client',
'account',
'server',
'object',
'id',
// 'time',
// 'disk',
],
]) ?>
<?= $box->renderPerPage() ?>
<?php $box->endActions() ?>
<?php $box->renderBulkActions([
'items' => [
$box->renderDeleteButton(Yii::t('app', 'Delete'))
],
]) ?>
<?= $box->renderSearchForm(compact('objectOptions')) ?>
<?php $box->end() ?>
<?php $box->beginBulkForm() ?>
<?= BackupGridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $model,
'columns' => [
'filterModel' => $model,
'columns' => [
'checkbox',
'seller',
'client',
'backup'
'account',
'server',
'object',
'name',
'object_id',
'size_gb'
],
]) ?>
<?php $box->endBulkForm() ?>
<?php Pjax::end() ?>

0 comments on commit 1303e48

Please sign in to comment.