BackupGridView   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 77
ccs 0
cts 70
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B columns() 0 74 1
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-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\grid;
12
13
use hipanel\grid\ActionColumn;
14
use hipanel\grid\MainColumn;
15
use hipanel\modules\server\grid\ServerColumn;
16
use hipanel\widgets\obj\ObjLinkWidget;
17
use Yii;
18
use yii\helpers\Html;
19
20
class BackupGridView extends \hipanel\grid\BoxedGridView
21
{
22
    public function columns()
23
    {
24
        return array_merge(parent::columns(), [
25
            'id' => [
26
                'class' => MainColumn::class,
27
                'format' => 'html',
28
                'filterOptions' => ['class' => 'narrow-filter'],
29
            ],
30
            'object_id' => [
31
                'filterOptions' => ['class' => 'narrow-filter'],
32
            ],
33
            'backup' => [
34
                'class' => MainColumn::class,
35
                'filterAttribute' => 'backup_like',
36
            ],
37
            'server' => [
38
                'class' => ServerColumn::class,
39
            ],
40
            'account' => [
41
                'class' => AccountColumn::class,
42
            ],
43
            'object' => [
44
                'format' => 'raw',
45
                'attribute' => 'name',
46
                'filterAttribute' => 'name_like',
47
                'filterOptions' => ['class' => 'narrow-filter'],
48
                'value' => function ($model) {
49
                    return  Html::a($model->name, ['@backuping/view', 'id' => $model->object_id], ['class' => 'bold']) . ' ' .
50
                            ObjLinkWidget::widget(['model' => $model->getObj()]);
51
                },
52
            ],
53
            'name' => [
54
                'format' => 'raw',
55
                'attribute' => 'name',
56
                'value' => function ($model) {
57
                    return ObjLinkWidget::widget(['label' => $model->name, 'model' => $model->getObj()]);
58
                },
59
            ],
60
            'size' => [
61
                'format' => 'html',
62
                'filter' => false,
63
                'value' => function ($model) {
64
                    return Yii::$app->formatter->asShortSize($model->size, 2);
65
                },
66
            ],
67
            'time' => [
68
                'filter' => false,
69
                'value' => function ($model) {
70
                    return Yii::$app->formatter->asDatetime($model->time);
71
                },
72
            ],
73
            'actions' => [
74
                'class' => ActionColumn::class,
75
                'template' => '{view} {delete}',
76
            ],
77
            'inner_actions' => [
78
                'class' => ActionColumn::class,
79
                'template' => '{deleteBackup}',
80
                'buttons' => [
81
                    'deleteBackup' => function ($url, $model, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
82
                        return Html::a('<i class="fa fa-trash-o"></i>&nbsp;' . Yii::t('hipanel', 'Delete'), ['/hosting/backup/delete', 'id' => $model->id], [
83
                            'aria-label'   => Yii::t('hipanel', 'Delete'),
84
                            'class' => 'btn btn-danger btn-xs',
85
                            'data' => [
86
                                'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'),
87
                                'method'  => 'POST',
88
                                'data-pjax' => '0',
89
                            ],
90
                        ]);
91
                    },
92
                ],
93
            ],
94
        ]);
95
    }
96
}
97