Skip to content

Commit

Permalink
Backup module - multiple minor changes and optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Nov 18, 2015
1 parent 7bad7ab commit bcf2025
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
19 changes: 12 additions & 7 deletions src/grid/BackupGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,36 @@ static public function defaultColumns()
'object' => [
'format' => 'raw',
'attribute' => 'name',
'filterAttribute' => 'name_like',
'value' => function($model) {
$labelType = ObjectLabelWidget::widget(compact('model'));
return $labelType
. ' ' .
Html::a($model->name, [sprintf('/hosting/%s/view', $model->object), 'id' => $model->object_id], ['data-pjax' => 0]);
return $labelType . ' ' .
Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]);
}
],
'name' => [
'format' => 'raw',
'attribute' => 'name',
'value' => function($model) {
return Html::a($model->name, [sprintf('/hosting/%s/view', $model->object), 'id' => $model->object_id], ['data-pjax' => 0]);
return Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]);
}
],
'size_gb' => [
'attribute' => 'size_gb',
'size' => [
'filter' => false,
'format' => 'raw',
'value' => function($model) {
return sprintf('%s GB', $model->size_gb);
return Yii::$app->formatter->asSize($model->size, 2);
}
],
'actions' => [
'class' => ActionColumn::className(),
'template' => '{view} {delete}',
],
'time' => [
'value' => function ($model) {
return Yii::$app->formatter->asDatetime($model->time);
}
]
];
}
}
14 changes: 9 additions & 5 deletions src/models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ class Backup extends \hipanel\base\Model
public function rules()
{
return [
[['id', 'service_id', 'object_id', 'server_id', 'account_id', 'client_id', 'ty_id', 'state_id'], 'integer'],
[['id', 'service_id', 'object_id', 'server_id', 'account_id', 'client_id', 'state_id'], 'integer'],
[['time'], 'date'],
[['size'], 'integer'],
[['title', 'db_like', 'size_gb', 'time', 'domain_like', 'service', 'client', 'method', 'server', 'account', 'client', 'classes', 'name', 'ty', 'state', 'object'], 'safe'],
[
[
'title', 'size_gb', 'time', 'service',
'client', 'method', 'server', 'account',
'client', 'object', 'name', 'state', 'type'
],
'safe'
],
[['method_label', 'type_label', 'state_label'], 'safe'],
[['id'], 'integer', 'on' => ['delete']],
];
Expand All @@ -27,9 +34,6 @@ public function attributeLabels()
{
return $this->mergeAttributeLabels([
'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'),
'object_id' => Yii::t('app', 'Backup ID'),
]);
Expand Down
5 changes: 2 additions & 3 deletions src/views/backup/_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
?>

<div class="col-md-6">
<?= $search->field('db_like') ?>
<?= $search->field('domain_like') ?>
<?= $search->field('name_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(), [
<?= $search->field('object')->widget(StaticCombo::classname(), [
'data' => $objectOptions,
'hasId' => true,
'pluginOptions' => [
Expand Down
2 changes: 1 addition & 1 deletion src/views/backup/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'server',
'object',
'time',
'size_gb',
'size',
'actions',
],
]) ?>
Expand Down
2 changes: 1 addition & 1 deletion src/views/backup/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'server',
'object',
'time',
'size_gb'
'size'
],
]) ?>
</div>
Expand Down

0 comments on commit bcf2025

Please sign in to comment.