blob: 7fc87db7969bea7a8683f75a02fedbd85a08485c [file] [log] [blame]
kmcpeakeb172d5f2015-12-10 11:30:43 +00001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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)
65 .removeButtons(CoreButtons.SHOW_GROUP_VIEW);
66 }
67
68 private void addAlarmCountsProperties(PropertyPanel pp, Map<Alarm.SeverityLevel, Long> countsForDevice) {
69
70 // TODO we could show these as color-coded squares with a count inside, to save space on the screen.
71
72 long cr = countsForDevice.getOrDefault(Alarm.SeverityLevel.CRITICAL, 0L);
73 long ma = countsForDevice.getOrDefault(Alarm.SeverityLevel.MAJOR, 0L);
74 long mi = countsForDevice.getOrDefault(Alarm.SeverityLevel.MINOR, 0L);
75 long wa = countsForDevice.getOrDefault(Alarm.SeverityLevel.WARNING, 0L);
76 long in = countsForDevice.getOrDefault(Alarm.SeverityLevel.INDETERMINATE, 0L);
77 long cl = countsForDevice.getOrDefault(Alarm.SeverityLevel.CLEARED, 0L);
78
79 // Unfortunately the PropertyPanel does not righ justify numbers even when using longs,
80 // but that not in scope of fault management work
81 pp.addProp("Critical", cr);
82 pp.addProp("Major", ma);
83 pp.addProp("Minor", mi);
84 pp.addProp("Warning", wa);
85 pp.addProp("Indeter.", in);
86 pp.addProp("Cleared", cl);
87 pp.addSeparator();
88 pp.addProp("Total", cr + ma + mi + wa + in + cl);
89
90 }
91
92}