|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Hosting Plugin for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
|
6
|
|
|
* @package hipanel-module-hosting |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @see http://hiqdev.com/hipanel-module-hosting |
|
13
|
|
|
* @license http://hiqdev.com/hipanel-module-hosting/license |
|
14
|
|
|
* @copyright Copyright (c) 2015 HiQDev |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace hipanel\modules\hosting\grid; |
|
18
|
|
|
|
|
19
|
|
|
use hipanel\grid\MainColumn; |
|
20
|
|
|
use hipanel\helpers\Url; |
|
21
|
|
|
use hipanel\modules\hosting\widgets\backup\ObjectLabelWidget; |
|
22
|
|
|
use hipanel\modules\server\grid\ServerColumn; |
|
23
|
|
|
use hiqdev\xeditable\widgets\XEditable; |
|
24
|
|
|
use Yii; |
|
25
|
|
|
use yii\helpers\Html; |
|
26
|
|
|
|
|
27
|
|
|
class BackupingGridView extends \hipanel\grid\BoxedGridView |
|
28
|
|
|
{ |
|
29
|
|
|
public $typeOptions; |
|
30
|
|
|
|
|
31
|
|
|
public function getTypeOptions() |
|
32
|
|
|
{ |
|
33
|
|
|
$result = []; |
|
34
|
|
|
foreach ($this->typeOptions as $key => $value) { |
|
35
|
|
|
$result[$key] = Yii::t('hipanel:hosting:backuping:periodicity', $value); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
return $result; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function columns() |
|
42
|
|
|
{ |
|
43
|
|
|
$typeOptions = $this->getTypeOptions(); |
|
44
|
|
|
|
|
45
|
|
|
return array_merge(parent::columns(), [ |
|
46
|
|
|
'name' => [ |
|
47
|
|
|
'class' => MainColumn::class, |
|
48
|
|
|
'filterAttribute' => 'name_like', |
|
49
|
|
|
'format' => 'html', |
|
50
|
|
|
'value' => function ($model) { |
|
51
|
|
|
return Html::a($model->name, ['@' . $model->object . '/view', 'id' => $model->id], ['class' => 'bold']); |
|
52
|
|
|
}, |
|
53
|
|
|
], |
|
54
|
|
|
'main' => [ |
|
55
|
|
|
'attribute' => 'name', |
|
56
|
|
|
'filterAttribute' => 'name_like', |
|
57
|
|
|
'format' => 'raw', |
|
58
|
|
|
'value' => function ($model) { |
|
59
|
|
|
return Html::a($model->name, ['@backuping/view', 'id' => $model->id], ['class' => 'bold']) . ' ' . |
|
60
|
|
|
Html::a(ObjectLabelWidget::widget(compact('model')), ['@' . $model->object . '/view', 'id' => $model->id]); |
|
61
|
|
|
}, |
|
62
|
|
|
], |
|
63
|
|
|
'account' => [ |
|
64
|
|
|
'attribute' => 'account_id', |
|
65
|
|
|
'class' => AccountColumn::class, |
|
66
|
|
|
], |
|
67
|
|
|
'server' => [ |
|
68
|
|
|
'attribute' => 'server_id', |
|
69
|
|
|
'class' => ServerColumn::class, |
|
70
|
|
|
], |
|
71
|
|
|
'object' => [ |
|
72
|
|
|
'filter' => false, |
|
73
|
|
|
'format' => 'raw', |
|
74
|
|
|
'value' => function ($model) { |
|
75
|
|
|
return ObjectLabelWidget::widget(compact('model')); |
|
76
|
|
|
}, |
|
77
|
|
|
], |
|
78
|
|
|
'backup_count' => [ |
|
79
|
|
|
'filter' => false, |
|
80
|
|
|
], |
|
81
|
|
|
'type' => [ |
|
82
|
|
|
'attribute' => 'type', |
|
83
|
|
|
'format' => 'raw', |
|
84
|
|
|
'filter' => false, |
|
85
|
|
|
'enableSorting' => false, |
|
86
|
|
|
'value' => function ($model) use ($typeOptions) { |
|
87
|
|
|
return XEditable::widget([ |
|
88
|
|
|
'model' => $model, |
|
89
|
|
|
'attribute' => 'type', |
|
90
|
|
|
'pluginOptions' => [ |
|
91
|
|
|
'type' => 'select', |
|
92
|
|
|
'source' => $typeOptions, |
|
93
|
|
|
'url' => Url::to('update'), |
|
94
|
|
|
], |
|
95
|
|
|
]); |
|
96
|
|
|
}, |
|
97
|
|
|
], |
|
98
|
|
|
'state_label' => [ |
|
99
|
|
|
'filter' => false, |
|
100
|
|
|
'enableSorting' => false, |
|
101
|
|
|
], |
|
102
|
|
|
'backup_last' => [ |
|
103
|
|
|
'filter' => false, |
|
104
|
|
|
'format' => 'raw', |
|
105
|
|
|
'value' => function ($model) { |
|
106
|
|
|
return Html::tag('nobr', Yii::$app->formatter->asDate($model->backup_last)) . ' ' . |
|
107
|
|
|
Html::tag('nobr', Yii::$app->formatter->asTime($model->backup_last)); |
|
108
|
|
|
}, |
|
109
|
|
|
], |
|
110
|
|
|
'total_du' => [ |
|
111
|
|
|
'filter' => false, |
|
112
|
|
|
'format' => 'html', |
|
113
|
|
|
'value' => function ($model) { |
|
114
|
|
|
return Yii::$app->formatter->asShortSize($model->total_du, 2); |
|
115
|
|
|
}, |
|
116
|
|
|
], |
|
117
|
|
|
]); |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|