blob: 3e1e1a68c50568a9a5252fcb4485f9cc7750c916 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
Sean Condon91481822019-01-01 13:56:14 +00002 * Copyright 2019-present Open Networking Foundation
Sean Condonf4f54a12018-10-10 23:25:46 +01003 *
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 */
Sean Condon0c577f62018-11-18 22:40:05 +000016import {
17 Component,
18 OnDestroy,
Sean Condon021f0fa2018-12-06 23:31:11 -080019 OnInit, SimpleChange,
Sean Condon0c577f62018-11-18 22:40:05 +000020 ViewChild
21} from '@angular/core';
Sean Condon55c30532018-10-29 12:26:57 +000022import * as d3 from 'd3';
Sean Condonf4f54a12018-10-10 23:25:46 +010023import {
Sean Condon91481822019-01-01 13:56:14 +000024 FnService, IconService,
Sean Condon0c577f62018-11-18 22:40:05 +000025 KeysService,
Sean Condon91481822019-01-01 13:56:14 +000026 KeysToken, LionService,
Sean Condon0c577f62018-11-18 22:40:05 +000027 LogService,
28 PrefsService,
29 SvgUtilService,
30 WebSocketService,
Sean Condon0c577f62018-11-18 22:40:05 +000031 ZoomService
Sean Condonf4f54a12018-10-10 23:25:46 +010032} from 'gui2-fw-lib';
Sean Condon0c577f62018-11-18 22:40:05 +000033import {InstanceComponent} from '../panel/instance/instance.component';
34import {SummaryComponent} from '../panel/summary/summary.component';
35import {DetailsComponent} from '../panel/details/details.component';
36import {BackgroundSvgComponent} from '../layer/backgroundsvg/backgroundsvg.component';
37import {ForceSvgComponent} from '../layer/forcesvg/forcesvg.component';
38import {TopologyService} from '../topology.service';
Sean Condon91481822019-01-01 13:56:14 +000039import {
40 HostLabelToggle,
41 LabelToggle,
42 UiElement
43} from '../layer/forcesvg/models';
Sean Condon50855cf2018-12-23 15:37:42 +000044import {ToolbarComponent} from '../panel/toolbar/toolbar.component';
45import {TrafficService} from '../traffic.service';
Sean Condon91481822019-01-01 13:56:14 +000046import {ZoomableDirective} from '../layer/zoomable.directive';
Sean Condonf4f54a12018-10-10 23:25:46 +010047
48/**
49 * ONOS GUI Topology View
50 *
51 * This Topology View component is the top level component in a hierarchy that
52 * comprises the whole Topology View
53 *
54 * There are three main parts (panels, graphical and breadcrumbs)
55 * The panel hierarchy
56 * |-- Instances Panel (shows ONOS instances)
57 * |-- Summary Panel (summary of ONOS)
58 * |-- Toolbar Panel (the toolbar)
59 * |-- Details Panel (when a node is selected in the Force graphical view (see below))
60 *
61 * The graphical hierarchy contains
62 * Topology (this)
63 * |-- No Devices Connected (only of there are no nodes to show)
64 * |-- Zoom Layer (everything beneath this can be zoomed and panned)
65 * |-- Background (container for any backgrounds - can be toggled on and off)
66 * |-- Map
67 * |-- Forces (all of the nodes and links laid out by a d3.force simulation)
68 *
69 * The breadcrumbs
70 * |-- Breadcrumb (in region view a way of navigating back up through regions)
71 */
72@Component({
73 selector: 'onos-topology',
74 templateUrl: './topology.component.html',
75 styleUrls: ['./topology.component.css']
76})
Sean Condonaa4366d2018-11-02 14:29:01 +000077export class TopologyComponent implements OnInit, OnDestroy {
78 // These are references to the components inserted in the template
Sean Condonf4f54a12018-10-10 23:25:46 +010079 @ViewChild(InstanceComponent) instance: InstanceComponent;
80 @ViewChild(SummaryComponent) summary: SummaryComponent;
81 @ViewChild(DetailsComponent) details: DetailsComponent;
Sean Condon50855cf2018-12-23 15:37:42 +000082 @ViewChild(ToolbarComponent) toolbar: ToolbarComponent;
Sean Condonaa4366d2018-11-02 14:29:01 +000083 @ViewChild(BackgroundSvgComponent) background: BackgroundSvgComponent;
84 @ViewChild(ForceSvgComponent) force: ForceSvgComponent;
Sean Condon91481822019-01-01 13:56:14 +000085 @ViewChild(ZoomableDirective) zoomDirective: ZoomableDirective;
Sean Condonf4f54a12018-10-10 23:25:46 +010086
87 flashMsg: string = '';
88 prefsState = {};
Sean Condonf4f54a12018-10-10 23:25:46 +010089 hostLabelIdx: number = 1;
Sean Condon50855cf2018-12-23 15:37:42 +000090 showBackground: boolean = false;
Sean Condon91481822019-01-01 13:56:14 +000091 lionFn; // Function
Sean Condon55c30532018-10-29 12:26:57 +000092
Sean Condonf4f54a12018-10-10 23:25:46 +010093 constructor(
94 protected log: LogService,
95 protected fs: FnService,
96 protected ks: KeysService,
97 protected sus: SvgUtilService,
98 protected ps: PrefsService,
Sean Condon55c30532018-10-29 12:26:57 +000099 protected wss: WebSocketService,
Sean Condonaa4366d2018-11-02 14:29:01 +0000100 protected zs: ZoomService,
101 protected ts: TopologyService,
Sean Condon91481822019-01-01 13:56:14 +0000102 protected trs: TrafficService,
103 protected is: IconService,
104 private lion: LionService,
Sean Condonf4f54a12018-10-10 23:25:46 +0100105 ) {
Sean Condon91481822019-01-01 13:56:14 +0000106 if (this.lion.ubercache.length === 0) {
107 this.lionFn = this.dummyLion;
108 this.lion.loadCbs.set('topo-toolbar', () => this.doLion());
109 } else {
110 this.doLion();
111 }
Sean Condonf4f54a12018-10-10 23:25:46 +0100112
Sean Condon91481822019-01-01 13:56:14 +0000113 this.is.loadIconDef('bird');
114 this.is.loadIconDef('active');
115 this.is.loadIconDef('uiAttached');
116 this.is.loadIconDef('m_switch');
117 this.is.loadIconDef('m_roadm');
118 this.is.loadIconDef('m_router');
119 this.is.loadIconDef('m_uiAttached');
120 this.is.loadIconDef('m_endstation');
121 this.is.loadIconDef('m_ports');
122 this.is.loadIconDef('m_summary');
123 this.is.loadIconDef('m_details');
124 this.is.loadIconDef('m_map');
125 this.is.loadIconDef('m_cycleLabels');
126 this.is.loadIconDef('m_resetZoom');
127 this.is.loadIconDef('m_eqMaster');
128 this.is.loadIconDef('m_unknown');
129 this.is.loadIconDef('m_allTraffic');
130 this.is.loadIconDef('deviceTable');
131 this.is.loadIconDef('flowTable');
132 this.is.loadIconDef('portTable');
133 this.is.loadIconDef('groupTable');
134 this.is.loadIconDef('meterTable');
135 this.is.loadIconDef('triangleUp');
Sean Condonf4f54a12018-10-10 23:25:46 +0100136 this.log.debug('Topology component constructed');
137 }
138
Sean Condon91481822019-01-01 13:56:14 +0000139 /**
140 * Static functions must come before member variables
141 * @param index
142 */
Sean Condon021f0fa2018-12-06 23:31:11 -0800143 private static deviceLabelFlashMessage(index: number): string {
144 switch (index) {
Sean Condon91481822019-01-01 13:56:14 +0000145 case 0: return 'fl_device_labels_hide';
146 case 1: return 'fl_device_labels_show_friendly';
147 case 2: return 'fl_device_labels_show_id';
Sean Condon021f0fa2018-12-06 23:31:11 -0800148 }
149 }
150
151 private static hostLabelFlashMessage(index: number): string {
152 switch (index) {
Sean Condon91481822019-01-01 13:56:14 +0000153 case 0: return 'fl_host_labels_hide';
154 case 1: return 'fl_host_labels_show_friendly';
155 case 2: return 'fl_host_labels_show_ip';
156 case 3: return 'fl_host_labels_show_mac';
Sean Condon021f0fa2018-12-06 23:31:11 -0800157 }
158 }
159
Sean Condon91481822019-01-01 13:56:14 +0000160 /**
161 * Pass the list of Key Commands to the KeyService, and initialize the Topology
162 * Service - which communicates with through the WebSocket to the ONOS server
163 * to get the nodes and links.
164 */
Sean Condonf4f54a12018-10-10 23:25:46 +0100165 ngOnInit() {
166 this.bindCommands();
Sean Condonaa4366d2018-11-02 14:29:01 +0000167 // The components from the template are handed over to TopologyService here
168 // so that WebSocket responses can be passed back in to them
169 // The handling of the WebSocket call is delegated out to the Topology
170 // Service just to compartmentalize things a bit
171 this.ts.init(this.instance, this.background, this.force);
Sean Condonf4f54a12018-10-10 23:25:46 +0100172 this.log.debug('Topology component initialized');
173 }
174
Sean Condon91481822019-01-01 13:56:14 +0000175 /**
176 * When this component is being stopped, disconnect the TopologyService from
177 * the WebSocket
178 */
Sean Condonaa4366d2018-11-02 14:29:01 +0000179 ngOnDestroy() {
180 this.ts.destroy();
181 this.log.debug('Topology component destroyed');
182 }
183
Sean Condon91481822019-01-01 13:56:14 +0000184 /**
185 * When ever a toolbar button is clicked, an event is sent up from toolbar
186 * component which is caught and passed on to here.
187 * @param name The name of the button that was clicked
188 */
189 toolbarButtonClicked(name: string) {
190 switch (name) {
191 case 'instance-tog':
192 this.toggleInstancePanel();
193 break;
194 case 'summary-tog':
195 this.toggleSummary();
196 break;
197 case 'details-tog':
198 this.toggleDetails();
199 break;
200 case 'hosts-tog':
201 this.toggleHosts();
202 break;
203 case 'offline-tog':
204 this.toggleOfflineDevices();
205 break;
206 case 'ports-tog':
207 this.togglePorts();
208 break;
209 case 'bkgrnd-tog':
210 this.toggleBackground();
211 break;
212 case 'cycleLabels-btn':
213 this.cycleDeviceLabels();
214 break;
215 case 'cycleHostLabel-btn':
216 this.cycleHostLabels();
217 break;
218 case 'resetZoom-btn':
219 this.resetZoom();
220 break;
221 case 'eqMaster-btn':
222 this.equalizeMasters();
223 break;
224 case 'cancel-traffic':
225 this.cancelTraffic();
226 break;
227 case 'all-traffic':
228 this.monitorAllTraffic();
229 break;
230 default:
231 this.log.warn('Unhandled Toolbar action', name);
232 }
233 }
234
235 /**
236 * The list of key strokes that will be active in the Topology View.
237 *
238 * This action map is passed to the KeyService through the bindCommands()
239 * when this component is being initialized
240 */
Sean Condonf4f54a12018-10-10 23:25:46 +0100241 actionMap() {
242 return {
Sean Condon50855cf2018-12-23 15:37:42 +0000243 A: [() => {this.monitorAllTraffic(); }, 'Monitor all traffic'],
Sean Condonf4f54a12018-10-10 23:25:46 +0100244 L: [() => {this.cycleDeviceLabels(); }, 'Cycle device labels'],
245 B: [(token) => {this.toggleBackground(token); }, 'Toggle background'],
246 D: [(token) => {this.toggleDetails(token); }, 'Toggle details panel'],
247 I: [(token) => {this.toggleInstancePanel(token); }, 'Toggle ONOS Instance Panel'],
248 O: [() => {this.toggleSummary(); }, 'Toggle the Summary Panel'],
249 R: [() => {this.resetZoom(); }, 'Reset pan / zoom'],
250 P: [(token) => {this.togglePorts(token); }, 'Toggle Port Highlighting'],
251 E: [() => {this.equalizeMasters(); }, 'Equalize mastership roles'],
252 X: [() => {this.resetNodeLocation(); }, 'Reset Node Location'],
253 U: [() => {this.unpinNode(); }, 'Unpin node (mouse over)'],
254 H: [() => {this.toggleHosts(); }, 'Toggle host visibility'],
255 M: [() => {this.toggleOfflineDevices(); }, 'Toggle offline visibility'],
256 dot: [() => {this.toggleToolbar(); }, 'Toggle Toolbar'],
Sean Condon50855cf2018-12-23 15:37:42 +0000257 0: [() => {this.cancelTraffic(); }, 'Cancel traffic monitoring'],
Sean Condonf4f54a12018-10-10 23:25:46 +0100258 'shift-L': [() => {this.cycleHostLabels(); }, 'Cycle host labels'],
259
260 // -- instance color palette debug
Sean Condon55c30532018-10-29 12:26:57 +0000261 9: () => {
262 this.sus.cat7().testCard(d3.select('svg#topo2'));
Sean Condonf4f54a12018-10-10 23:25:46 +0100263 },
264
265 esc: this.handleEscape,
266
267 // TODO update after adding in Background Service
268 // topology overlay selections
269 // F1: function () { t2tbs.fnKey(0); },
270 // F2: function () { t2tbs.fnKey(1); },
271 // F3: function () { t2tbs.fnKey(2); },
272 // F4: function () { t2tbs.fnKey(3); },
273 // F5: function () { t2tbs.fnKey(4); },
274 //
275 // _keyListener: t2tbs.keyListener.bind(t2tbs),
276
277 _helpFormat: [
278 ['I', 'O', 'D', 'H', 'M', 'P', 'dash', 'B'],
279 ['X', 'Z', 'N', 'L', 'shift-L', 'U', 'R', 'E', 'dot'],
280 [], // this column reserved for overlay actions
281 ],
282 };
283 }
284
285
286 bindCommands(additional?: any) {
287
288 const am = this.actionMap();
289 const add = this.fs.isO(additional);
290
Sean Condonf4f54a12018-10-10 23:25:46 +0100291 this.ks.keyBindings(am);
292
293 this.ks.gestureNotes([
294 ['click', 'Select the item and show details'],
295 ['shift-click', 'Toggle selection state'],
296 ['drag', 'Reposition (and pin) device / host'],
297 ['cmd-scroll', 'Zoom in / out'],
298 ['cmd-drag', 'Pan'],
299 ]);
300 }
301
302 handleEscape() {
303
304 if (false) {
305 // TODO: Cancel show mastership
306 // TODO: Cancel Active overlay
307 // TODO: Reinstate with components
308 } else {
309 this.log.debug('Handling escape');
310 // } else if (t2rs.deselectAllNodes()) {
311 // // else if we have node selections, deselect them all
312 // // (work already done)
313 // } else if (t2rs.deselectLink()) {
314 // // else if we have a link selection, deselect it
315 // // (work already done)
316 // } else if (t2is.isVisible()) {
317 // // If the instance panel is visible, close it
318 // t2is.toggle();
319 // } else if (t2sp.isVisible()) {
320 // // If the summary panel is visible, close it
321 // t2sp.toggle();
322 }
323 }
324
325
326
327 updatePrefsState(what, b) {
328 this.prefsState[what] = b ? 1 : 0;
329 this.ps.setPrefs('topo2_prefs', this.prefsState);
330 }
331
Sean Condonf4f54a12018-10-10 23:25:46 +0100332 protected cycleDeviceLabels() {
Sean Condon021f0fa2018-12-06 23:31:11 -0800333 const old: LabelToggle = this.force.deviceLabelToggle;
334 const next = LabelToggle.next(old);
335 this.force.ngOnChanges({'deviceLabelToggle':
336 new SimpleChange(old, next, false)});
Sean Condon91481822019-01-01 13:56:14 +0000337 this.flashMsg = this.lionFn(TopologyComponent.deviceLabelFlashMessage(next));
Sean Condon021f0fa2018-12-06 23:31:11 -0800338 this.log.debug('Cycling device labels', old, next);
Sean Condonf4f54a12018-10-10 23:25:46 +0100339 }
340
341 protected cycleHostLabels() {
Sean Condon021f0fa2018-12-06 23:31:11 -0800342 const old: HostLabelToggle = this.force.hostLabelToggle;
343 const next = HostLabelToggle.next(old);
344 this.force.ngOnChanges({'hostLabelToggle':
345 new SimpleChange(old, next, false)});
Sean Condon91481822019-01-01 13:56:14 +0000346 this.flashMsg = this.lionFn(TopologyComponent.hostLabelFlashMessage(next));
Sean Condon021f0fa2018-12-06 23:31:11 -0800347 this.log.debug('Cycling host labels', old, next);
Sean Condonf4f54a12018-10-10 23:25:46 +0100348 }
349
Sean Condon91481822019-01-01 13:56:14 +0000350 protected toggleBackground(token?: KeysToken) {
Sean Condon50855cf2018-12-23 15:37:42 +0000351 this.showBackground = !this.showBackground;
Sean Condon91481822019-01-01 13:56:14 +0000352 this.flashMsg = this.lionFn(this.showBackground ? 'show' : 'hide') +
353 ' ' + this.lionFn('fl_background_map');
354 this.toolbar.backgroundVisible = this.showBackground;
Sean Condonf4f54a12018-10-10 23:25:46 +0100355 this.log.debug('Toggling background', token);
Sean Condonf4f54a12018-10-10 23:25:46 +0100356 }
357
Sean Condon91481822019-01-01 13:56:14 +0000358 protected toggleDetails(token?: KeysToken) {
Sean Condon0c577f62018-11-18 22:40:05 +0000359 if (this.details.selectedNode) {
Sean Condon91481822019-01-01 13:56:14 +0000360 const on: boolean = this.details.togglePanel(() => {
Sean Condon0c577f62018-11-18 22:40:05 +0000361 });
Sean Condon91481822019-01-01 13:56:14 +0000362 this.flashMsg = this.lionFn(on ? 'show' : 'hide') +
363 ' ' + this.lionFn('fl_panel_details');
364 this.toolbar.detailsVisible = on;
365
Sean Condon0c577f62018-11-18 22:40:05 +0000366 this.log.debug('Toggling details', token);
367 }
Sean Condonf4f54a12018-10-10 23:25:46 +0100368 }
369
Sean Condon91481822019-01-01 13:56:14 +0000370 protected toggleInstancePanel(token?: KeysToken) {
371 const on: boolean = this.instance.togglePanel(() => {});
372 this.flashMsg = this.lionFn(on ? 'show' : 'hide') +
373 ' ' + this.lionFn('fl_panel_instances');
374 this.toolbar.instancesVisible = on;
375 this.log.debug('Toggling instances', token, on);
Sean Condonf4f54a12018-10-10 23:25:46 +0100376 }
377
378 protected toggleSummary() {
Sean Condon91481822019-01-01 13:56:14 +0000379 const on: boolean = this.summary.togglePanel(() => {});
380 this.flashMsg = this.lionFn(on ? 'show' : 'hide') +
381 ' ' + this.lionFn('fl_panel_summary');
382 this.toolbar.summaryVisible = on;
Sean Condonf4f54a12018-10-10 23:25:46 +0100383 }
384
385 protected resetZoom() {
Sean Condon91481822019-01-01 13:56:14 +0000386 this.zoomDirective.resetZoom();
387 this.flashMsg = this.lionFn('fl_pan_zoom_reset');
Sean Condonf4f54a12018-10-10 23:25:46 +0100388 }
389
Sean Condon91481822019-01-01 13:56:14 +0000390 protected togglePorts(token?: KeysToken) {
391 const old: boolean = this.force.highlightPorts;
392 const current: boolean = !this.force.highlightPorts;
393 this.force.ngOnChanges({'highlightPorts': new SimpleChange(old, current, false)});
394 this.flashMsg = this.lionFn(current ? 'enable' : 'disable') +
395 ' ' + this.lionFn('fl_port_highlighting');
396 this.toolbar.portsVisible = current;
397 this.log.debug(current ? 'Enable' : 'Disable', 'port highlighting');
Sean Condonf4f54a12018-10-10 23:25:46 +0100398 }
399
400 protected equalizeMasters() {
401 this.wss.sendEvent('equalizeMasters', null);
Sean Condon91481822019-01-01 13:56:14 +0000402 this.flashMsg = this.lionFn('fl_eq_masters');
Sean Condonf4f54a12018-10-10 23:25:46 +0100403 this.log.debug('equalizing masters');
Sean Condonf4f54a12018-10-10 23:25:46 +0100404 }
405
406 protected resetNodeLocation() {
Sean Condon91481822019-01-01 13:56:14 +0000407 // TODO: Implement reset locations
408 this.flashMsg = this.lionFn('fl_reset_node_locations');
Sean Condonf4f54a12018-10-10 23:25:46 +0100409 this.log.debug('resetting node location');
Sean Condonf4f54a12018-10-10 23:25:46 +0100410 }
411
412 protected unpinNode() {
Sean Condon91481822019-01-01 13:56:14 +0000413 // TODO: Implement this
Sean Condonf4f54a12018-10-10 23:25:46 +0100414 this.log.debug('unpinning node');
Sean Condonf4f54a12018-10-10 23:25:46 +0100415 }
416
417 protected toggleToolbar() {
418 this.log.debug('toggling toolbar');
Sean Condon50855cf2018-12-23 15:37:42 +0000419 this.toolbar.on = !this.toolbar.on;
Sean Condonf4f54a12018-10-10 23:25:46 +0100420 }
421
Sean Condonf4f54a12018-10-10 23:25:46 +0100422 protected toggleHosts() {
Sean Condon021f0fa2018-12-06 23:31:11 -0800423 const old: boolean = this.force.showHosts;
424 const current = !this.force.showHosts;
425 this.force.ngOnChanges({'showHosts': new SimpleChange(old, current, false)});
Sean Condon91481822019-01-01 13:56:14 +0000426 this.flashMsg = this.lionFn('hosts') + ' ' +
427 this.lionFn(this.force.showHosts ? 'visible' : 'hidden');
428 this.toolbar.hostsVisible = current;
Sean Condon021f0fa2018-12-06 23:31:11 -0800429 this.log.debug('toggling hosts: ', this.force.showHosts ? 'Show' : 'Hide');
Sean Condonf4f54a12018-10-10 23:25:46 +0100430 }
431
432 protected toggleOfflineDevices() {
Sean Condon91481822019-01-01 13:56:14 +0000433 // TODO: Implement toggle offline visibility
434 const on: boolean = true;
435 this.flashMsg = this.lionFn(on ? 'show' : 'hide') +
436 ' ' + this.lionFn('fl_offline_devices');
Sean Condonf4f54a12018-10-10 23:25:46 +0100437 this.log.debug('toggling offline devices');
Sean Condonf4f54a12018-10-10 23:25:46 +0100438 }
439
Sean Condon91481822019-01-01 13:56:14 +0000440 /**
441 * Check to see if this is needed anymore
442 * @param what
443 */
Sean Condonf4f54a12018-10-10 23:25:46 +0100444 protected notValid(what) {
445 this.log.warn('topo.js getActionEntry(): Not a valid ' + what);
446 }
447
Sean Condon91481822019-01-01 13:56:14 +0000448 /**
449 * Check to see if this is needed anymore
450 * @param what
451 */
Sean Condonf4f54a12018-10-10 23:25:46 +0100452 getActionEntry(key) {
453 let entry;
454
455 if (!key) {
456 this.notValid('key');
457 return null;
458 }
459
460 entry = this.actionMap()[key];
461
462 if (!entry) {
463 this.notValid('actionMap (' + key + ') entry');
464 return null;
465 }
466 return this.fs.isA(entry) || [entry, ''];
467 }
468
Sean Condon91481822019-01-01 13:56:14 +0000469 /**
470 * An event handler that updates the details panel as items are
471 * selected in the forcesvg layer
472 * @param nodeOrLink the item to display details of
473 */
474 nodeSelected(nodeOrLink: UiElement) {
475 this.details.ngOnChanges({'selectedNode':
476 new SimpleChange(undefined, nodeOrLink, true)});
477 this.details.on = Boolean(nodeOrLink);
Sean Condon0c577f62018-11-18 22:40:05 +0000478 }
479
Sean Condon50855cf2018-12-23 15:37:42 +0000480 /**
481 * Enable traffic monitoring
482 */
483 monitorAllTraffic() {
Sean Condon91481822019-01-01 13:56:14 +0000484 // TODO: Implement support for toggling between bits, packets and octets
485 this.flashMsg = this.lionFn('tr_fl_pstats_bits');
Sean Condon50855cf2018-12-23 15:37:42 +0000486 this.trs.init(this.force);
487 }
488
489 /**
490 * Cancel traffic monitoring
491 */
492 cancelTraffic() {
Sean Condon91481822019-01-01 13:56:14 +0000493 this.flashMsg = this.lionFn('fl_monitoring_canceled');
Sean Condon50855cf2018-12-23 15:37:42 +0000494 this.trs.destroy();
495 }
Sean Condon91481822019-01-01 13:56:14 +0000496
497 /**
498 * Read the LION bundle for Toolbar and set up the lionFn
499 */
500 doLion() {
501 this.lionFn = this.lion.bundle('core.view.Topo');
502 }
503
504 /**
505 * A dummy implementation of the lionFn until the response is received and the LION
506 * bundle is received from the WebSocket
507 */
508 dummyLion(key: string): string {
509 return '%' + key + '%';
510 }
Sean Condonf4f54a12018-10-10 23:25:46 +0100511}