Skip to content

Commit 2012b29

Browse files
raviks789nilmerg
authored andcommitted
Indicate the number of affected children by a particular parent
1 parent 134e45d commit 2012b29

File tree

8 files changed

+47
-8
lines changed

8 files changed

+47
-8
lines changed

Diff for: library/Icingadb/Common/Icons.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Icons
1010

1111
const HOST_DOWN = 'sitemap';
1212

13+
const UNREACHABLE = 'sitemap';
14+
1315
const IN_DOWNTIME = 'plug';
1416

1517
const IS_ACKNOWLEDGED = 'check';

Diff for: library/Icingadb/Model/Host.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* @property ?string $zone_id
5757
* @property string $command_endpoint_name
5858
* @property ?string $command_endpoint_id
59+
* @property ?int $affected_children
5960
*/
6061
class Host extends Model
6162
{
@@ -111,7 +112,8 @@ public function getColumns()
111112
'zone_name',
112113
'zone_id',
113114
'command_endpoint_name',
114-
'command_endpoint_id'
115+
'command_endpoint_id',
116+
'affected_children'
115117
];
116118
}
117119

@@ -155,7 +157,8 @@ public function getColumnDefinitions()
155157
'zone_name' => t('Zone Name'),
156158
'zone_id' => t('Zone Id'),
157159
'command_endpoint_name' => t('Endpoint Name'),
158-
'command_endpoint_id' => t('Endpoint Id')
160+
'command_endpoint_id' => t('Endpoint Id'),
161+
'affected_children' => t('Affected Children'),
159162
];
160163
}
161164

Diff for: library/Icingadb/Model/HostState.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public function getColumnDefinitions()
5353
'last_update' => t('Host Last Update'),
5454
'last_state_change' => t('Host Last State Change'),
5555
'next_check' => t('Host Next Check'),
56-
'next_update' => t('Host Next Update')
56+
'next_update' => t('Host Next Update'),
57+
'affects_children' => t('Host Affects Children'),
5758
];
5859
}
5960

Diff for: library/Icingadb/Model/Service.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* @property ?string $zone_id
5252
* @property string $command_endpoint_name
5353
* @property ?string $command_endpoint_id
54+
* @property ?int $affected_children
5455
*/
5556
class Service extends Model
5657
{
@@ -103,7 +104,8 @@ public function getColumns()
103104
'zone_name',
104105
'zone_id',
105106
'command_endpoint_name',
106-
'command_endpoint_id'
107+
'command_endpoint_id',
108+
'affected_children'
107109
];
108110
}
109111

@@ -144,7 +146,8 @@ public function getColumnDefinitions()
144146
'zone_name' => t('Zone Name'),
145147
'zone_id' => t('Zone Id'),
146148
'command_endpoint_name' => t('Endpoint Name'),
147-
'command_endpoint_id' => t('Endpoint Id')
149+
'command_endpoint_id' => t('Endpoint Id'),
150+
'affected_children' => t('Affected Children')
148151
];
149152
}
150153

Diff for: library/Icingadb/Model/ServiceState.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public function getColumnDefinitions()
5555
'last_update' => t('Service Last Update'),
5656
'last_state_change' => t('Service Last State Change'),
5757
'next_check' => t('Service Next Check'),
58-
'next_update' => t('Service Next Update')
58+
'next_update' => t('Service Next Update'),
59+
'affects_children' => t('Service Affects Children'),
5960
];
6061
}
6162

Diff for: library/Icingadb/Model/State.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* @property DateTime $last_state_change The time when the node last got a status change
4949
* @property DateTime $next_check The time when the node will execute the next check
5050
* @property DateTime $next_update The time when the next check of the node is expected to end
51+
* @property bool $affects_children Whether any of the children is affected if there is a problem
5152
*/
5253
abstract class State extends Model
5354
{
@@ -98,7 +99,8 @@ public function getColumns()
9899
'last_update',
99100
'last_state_change',
100101
'next_check',
101-
'next_update'
102+
'next_update',
103+
'affects_children'
102104
];
103105
}
104106

@@ -111,7 +113,8 @@ public function createBehaviors(Behaviors $behaviors)
111113
'is_flapping',
112114
'is_overdue',
113115
'is_acknowledged',
114-
'in_downtime'
116+
'in_downtime',
117+
'affects_children'
115118
]));
116119

117120
$behaviors->add(new MillisecondTimestamp([

Diff for: library/Icingadb/Widget/ItemList/StateListItem.php

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use ipl\Html\HtmlElement;
1414
use ipl\Web\Common\BaseListItem;
1515
use ipl\Web\Widget\EmptyState;
16+
use ipl\Web\Widget\StateBadge;
1617
use ipl\Web\Widget\TimeSince;
1718
use ipl\Html\BaseHtmlElement;
1819
use ipl\Html\Html;
@@ -93,6 +94,23 @@ protected function assembleTitle(BaseHtmlElement $title): void
9394
$this->createSubject(),
9495
Html::tag('span', ['class' => 'state-text'], $this->state->getStateTextTranslated())
9596
));
97+
98+
if ($this->state->affects_children) {
99+
$total = $this->item->affected_children;
100+
101+
if ((int) $total > 1000) {
102+
$total = '1000+';
103+
}
104+
105+
$icon = new Icon(Icons::UNREACHABLE);
106+
107+
$title->addHtml((new StateBadge([$icon, Text::create($total)], ''))
108+
->addAttributes([
109+
'class' => 'affected-objects',
110+
'title' => sprintf(t('Up to %s affected objects'), $total)
111+
])
112+
);
113+
}
96114
}
97115

98116
protected function assembleVisual(BaseHtmlElement $visual): void

Diff for: public/css/common.less

+8
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,11 @@ div.show-more {
403403
form[name="form_confirm_removal"] {
404404
text-align: center;
405405
}
406+
407+
.affected-objects {
408+
display: inline-flex;
409+
align-items: baseline;
410+
background-color: @state-critical;
411+
color: @text-color-inverted;
412+
padding: 0 0.25em;
413+
}

0 commit comments

Comments
 (0)