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\BoxedGridView; |
14
|
|
|
use hipanel\grid\DataColumn; |
15
|
|
|
use hipanel\grid\RefColumn; |
16
|
|
|
use hipanel\grid\XEditableColumn; |
17
|
|
|
use hipanel\modules\hosting\menus\PrefixActionsMenu; |
18
|
|
|
use hipanel\modules\hosting\models\Prefix; |
19
|
|
|
use hiqdev\yii2\menus\grid\MenuColumn; |
20
|
|
|
use Yii; |
21
|
|
|
use yii\helpers\Html; |
22
|
|
|
use yii\helpers\IpHelper; |
23
|
|
|
|
24
|
|
|
class PrefixGridView extends BoxedGridView |
25
|
|
|
{ |
26
|
|
|
public function columns() |
27
|
|
|
{ |
28
|
|
|
return array_merge(parent::columns(), [ |
29
|
|
|
'ip' => [ |
30
|
|
|
'format' => 'html', |
31
|
|
View Code Duplication |
'value' => static function (Prefix $prefix) { |
|
|
|
|
32
|
|
|
return Html::a($prefix->ip, ['@prefix/view', 'id' => $prefix->id], ['class' => 'text-bold']); |
|
|
|
|
33
|
|
|
}, |
34
|
|
|
], |
35
|
|
|
'type' => [ |
36
|
|
|
'class' => RefColumn::class, |
37
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
38
|
|
|
'format' => 'raw', |
39
|
|
|
'gtype' => 'type,ip_prefix', |
40
|
|
|
], |
41
|
|
|
'vrf' => [ |
42
|
|
|
'class' => RefColumn::class, |
43
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
44
|
|
|
'format' => 'raw', |
45
|
|
|
'gtype' => 'type,ip_vrf', |
46
|
|
|
], |
47
|
|
|
'role' => [ |
48
|
|
|
'class' => RefColumn::class, |
49
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
50
|
|
|
'format' => 'raw', |
51
|
|
|
'gtype' => 'type,ip_prefix_role', |
52
|
|
|
], |
53
|
|
|
'site' => [ |
54
|
|
|
'class' => RefColumn::class, |
55
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
56
|
|
|
'format' => 'raw', |
57
|
|
|
'gtype' => 'type,location', |
58
|
|
|
], |
59
|
|
|
'family' => [ |
60
|
|
|
'class' => FamilyColumn::class, |
61
|
|
|
], |
62
|
|
|
'utilization' => [ |
63
|
|
|
'class' => UtilizationColumn::class, |
64
|
|
|
], |
65
|
|
|
'note' => [ |
66
|
|
|
'class' => XEditableColumn::class, |
67
|
|
|
'pluginOptions' => [ |
68
|
|
|
'url' => 'set-note', |
69
|
|
|
], |
70
|
|
|
'filter' => true, |
71
|
|
|
'popover' => Yii::t('hipanel', 'Make any notes for your convenience'), |
72
|
|
|
], |
73
|
|
|
'actions' => [ |
74
|
|
|
'class' => MenuColumn::class, |
75
|
|
|
'contentOptions' => ['style' => 'width: 1%; white-space:nowrap;'], |
76
|
|
|
'menuClass' => PrefixActionsMenu::class, |
77
|
|
|
], |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.