blob: 509403027cf125e391af55ae60eab66e30f76b11 [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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");
36 private static final ButtonId ALARM2_BUTTON = new ButtonId("alarm2button");
37
38 public AlarmTopovOverlay() {
39 super(OVERLAY_ID);
40 }
41
42 @Override
43 public void modifySummary(PropertyPanel pp) {
44 pp.title("Alarms Overview");
45 // We could just remove some properties here but lets keep it uncluttered, unless
46 // there is feedback other properties are essential.
47 pp.removeAllProps();
48 Map<Alarm.SeverityLevel, Long> countsForAll = AlarmServiceUtil.lookUpAlarmCounts();
49 addAlarmCountsProperties(pp, countsForAll);
50
51 }
52
53 @Override
54 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
55 pp.title("Alarm Details");
56 pp.removeProps(LATITUDE, LONGITUDE, PORTS, FLOWS, TUNNELS, SERIAL_NUMBER, PROTOCOL);
57
58 Map<Alarm.SeverityLevel, Long> countsForDevice = AlarmServiceUtil.lookUpAlarmCounts(deviceId);
59 addAlarmCountsProperties(pp, countsForDevice);
60
61 pp.addButton(ALARM1_BUTTON)
62 .addButton(ALARM2_BUTTON);
63
64 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
Jian Li79f67322016-01-06 18:22:37 -080065 .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
66 .removeButtons(CoreButtons.SHOW_METER_VIEW);
kmcpeakeb172d5f2015-12-10 11:30:43 +000067 }
68
69 private void addAlarmCountsProperties(PropertyPanel pp, Map<Alarm.SeverityLevel, Long> countsForDevice) {
70
71 // TODO we could show these as color-coded squares with a count inside, to save space on the screen.
72
73 long cr = countsForDevice.getOrDefault(Alarm.SeverityLevel.CRITICAL, 0L);
74 long ma = countsForDevice.getOrDefault(Alarm.SeverityLevel.MAJOR, 0L);
75 long mi = countsForDevice.getOrDefault(Alarm.SeverityLevel.MINOR, 0L);
76 long wa = countsForDevice.getOrDefault(Alarm.SeverityLevel.WARNING, 0L);
77 long in = countsForDevice.getOrDefault(Alarm.SeverityLevel.INDETERMINATE, 0L);
78 long cl = countsForDevice.getOrDefault(Alarm.SeverityLevel.CLEARED, 0L);
79
80 // Unfortunately the PropertyPanel does not righ justify numbers even when using longs,
81 // but that not in scope of fault management work
82 pp.addProp("Critical", cr);
83 pp.addProp("Major", ma);
84 pp.addProp("Minor", mi);
85 pp.addProp("Warning", wa);
86 pp.addProp("Indeter.", in);
87 pp.addProp("Cleared", cl);
88 pp.addSeparator();
89 pp.addProp("Total", cr + ma + mi + wa + in + cl);
90
91 }
92
93}