blob: e0a844fc49add5d67dc6c020fc55b85671a36209 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
kmcpeakeb172d5f2015-12-10 11:30:43 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.faultmanagement.alarms.gui;
17
18import java.util.Map;
19import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
20import org.onosproject.net.DeviceId;
21import org.onosproject.ui.UiTopoOverlay;
22import org.onosproject.ui.topo.ButtonId;
23import org.onosproject.ui.topo.PropertyPanel;
24import org.onosproject.ui.topo.TopoConstants.CoreButtons;
25import static org.onosproject.ui.topo.TopoConstants.Properties.*;
26
27/**
28 * Our topology overlay.
29 */
30public class AlarmTopovOverlay extends UiTopoOverlay {
31
32 // NOTE: this must match the ID defined in alarmTopov.js
33 private static final String OVERLAY_ID = "alarmsTopo-overlay";
34
35 private static final ButtonId ALARM1_BUTTON = new ButtonId("alarm1button");
kmcpeakeb172d5f2015-12-10 11:30:43 +000036
37 public AlarmTopovOverlay() {
38 super(OVERLAY_ID);
39 }
40
41 @Override
42 public void modifySummary(PropertyPanel pp) {
43 pp.title("Alarms Overview");
44 // We could just remove some properties here but lets keep it uncluttered, unless
45 // there is feedback other properties are essential.
46 pp.removeAllProps();
47 Map<Alarm.SeverityLevel, Long> countsForAll = AlarmServiceUtil.lookUpAlarmCounts();
48 addAlarmCountsProperties(pp, countsForAll);
49
50 }
51
52 @Override
53 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
54 pp.title("Alarm Details");
55 pp.removeProps(LATITUDE, LONGITUDE, PORTS, FLOWS, TUNNELS, SERIAL_NUMBER, PROTOCOL);
56
57 Map<Alarm.SeverityLevel, Long> countsForDevice = AlarmServiceUtil.lookUpAlarmCounts(deviceId);
58 addAlarmCountsProperties(pp, countsForDevice);
59
Andrea Campanellac2417672017-02-02 11:29:59 -080060 pp.addButton(ALARM1_BUTTON);
kmcpeakeb172d5f2015-12-10 11:30:43 +000061
62 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
Jian Li79f67322016-01-06 18:22:37 -080063 .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
64 .removeButtons(CoreButtons.SHOW_METER_VIEW);
kmcpeakeb172d5f2015-12-10 11:30:43 +000065 }
66
67 private void addAlarmCountsProperties(PropertyPanel pp, Map<Alarm.SeverityLevel, Long> countsForDevice) {
68
69 // TODO we could show these as color-coded squares with a count inside, to save space on the screen.
70
71 long cr = countsForDevice.getOrDefault(Alarm.SeverityLevel.CRITICAL, 0L);
72 long ma = countsForDevice.getOrDefault(Alarm.SeverityLevel.MAJOR, 0L);
73 long mi = countsForDevice.getOrDefault(Alarm.SeverityLevel.MINOR, 0L);
74 long wa = countsForDevice.getOrDefault(Alarm.SeverityLevel.WARNING, 0L);
75 long in = countsForDevice.getOrDefault(Alarm.SeverityLevel.INDETERMINATE, 0L);
76 long cl = countsForDevice.getOrDefault(Alarm.SeverityLevel.CLEARED, 0L);
77
78 // Unfortunately the PropertyPanel does not righ justify numbers even when using longs,
79 // but that not in scope of fault management work
80 pp.addProp("Critical", cr);
81 pp.addProp("Major", ma);
82 pp.addProp("Minor", mi);
83 pp.addProp("Warning", wa);
84 pp.addProp("Indeter.", in);
85 pp.addProp("Cleared", cl);
86 pp.addSeparator();
87 pp.addProp("Total", cr + ma + mi + wa + in + cl);
88
89 }
90
91}