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\RefColumn; |
15
|
|
|
use hipanel\grid\XEditableColumn; |
16
|
|
|
use hipanel\modules\hosting\menus\PrefixActionsMenu; |
17
|
|
|
use hipanel\modules\hosting\models\AddressSearch; |
18
|
|
|
use hipanel\modules\hosting\models\Prefix; |
19
|
|
|
use hiqdev\yii2\menus\grid\MenuColumn; |
20
|
|
|
use Yii; |
21
|
|
|
use yii\helpers\Html; |
22
|
|
|
|
23
|
|
|
class PrefixGridView extends BoxedGridView |
24
|
|
|
{ |
25
|
|
|
public function columns() |
26
|
|
|
{ |
27
|
|
|
return array_merge(parent::columns(), [ |
28
|
|
|
'ip' => [ |
29
|
|
|
'format' => 'html', |
30
|
|
|
'value' => static function (Prefix $prefix) { |
31
|
|
|
return Html::a($prefix->ip, ['@prefix/view', 'id' => $prefix->id], ['class' => 'text-bold']); |
|
|
|
|
32
|
|
|
}, |
33
|
|
|
], |
34
|
|
|
'type' => [ |
35
|
|
|
'class' => RefColumn::class, |
36
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
37
|
|
|
'format' => 'raw', |
38
|
|
|
'gtype' => 'type,ip_prefix', |
39
|
|
|
], |
40
|
|
|
'vrf' => [ |
41
|
|
|
'class' => RefColumn::class, |
42
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
43
|
|
|
'format' => 'raw', |
44
|
|
|
'gtype' => 'type,ip_vrf', |
45
|
|
|
], |
46
|
|
|
'role' => [ |
47
|
|
|
'class' => RefColumn::class, |
48
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
49
|
|
|
'format' => 'raw', |
50
|
|
|
'gtype' => 'type,ip_prefix_role', |
51
|
|
|
], |
52
|
|
|
'site' => [ |
53
|
|
|
'class' => RefColumn::class, |
54
|
|
|
'i18nDictionary' => 'hipanel.hosting.ipam', |
55
|
|
|
'format' => 'raw', |
56
|
|
|
'gtype' => 'type,location', |
57
|
|
|
], |
58
|
|
|
'family' => [ |
59
|
|
|
'class' => FamilyColumn::class, |
60
|
|
|
], |
61
|
|
|
'utilization' => [ |
62
|
|
|
'class' => UtilizationColumn::class, |
63
|
|
|
], |
64
|
|
|
'note' => [ |
65
|
|
|
'class' => XEditableColumn::class, |
66
|
|
|
'pluginOptions' => [ |
67
|
|
|
'url' => '@prefix/set-note', |
68
|
|
|
], |
69
|
|
|
'filter' => true, |
70
|
|
|
'popover' => Yii::t('hipanel', 'Make any notes for your convenience'), |
71
|
|
|
], |
72
|
|
|
'aggregate' => [ |
73
|
|
|
'attribute' => 'aggregate', |
74
|
|
|
'format' => 'html', |
75
|
|
|
'value' => static function ($prefix): string { |
76
|
|
|
return $prefix->aggregate ? |
77
|
|
|
Html::a($prefix->aggregate, ['@aggregate/view', 'id' => $prefix->aggregate_id]) : |
78
|
|
|
''; |
79
|
|
|
}, |
80
|
|
|
], |
81
|
|
|
'ip_count' => [ |
82
|
|
|
'attribute' => 'ip_count', |
83
|
|
|
'label' => Yii::t('hipanel.hosting.ipam', 'IP Addresses'), |
84
|
|
|
'format' => 'html', |
85
|
|
|
'value' => static function ($prefix): string { |
86
|
|
|
return $prefix->ip_count > 0 ? |
87
|
|
|
Html::a('IP Addresses (' . $prefix->ip_count . ')', [ |
88
|
|
|
'@address/index', (new AddressSearch)->formName() => ['ip_cnts' => $prefix->ip], |
89
|
|
|
], ['class' => 'btn btn-success btn-flat btn-sm']) : |
90
|
|
|
$prefix->ip_count; |
91
|
|
|
}, |
92
|
|
|
], |
93
|
|
|
'actions' => [ |
94
|
|
|
'class' => MenuColumn::class, |
95
|
|
|
'contentOptions' => ['style' => 'width: 1%; white-space:nowrap;'], |
96
|
|
|
'menuClass' => PrefixActionsMenu::class, |
97
|
|
|
], |
98
|
|
|
]); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.