RIFT-15726 - optimize download size -> lodash usage in UI
[osm/UI.git] / skyquake / plugins / composer / src / src / libraries / graph / HighlightRecordServicePaths.js
1 /**
2 * Created by onvelocity on 2/23/16.
3 */
4
5 'use strict';
6
7 import _isArray from 'lodash/isArray'
8 import d3 from 'd3'
9
10 /**
11 * Add CSS classes to Rendered Service Paths (Record Service Path in code) so they hightlight.
12 */
13 export default class HighlightRecordServicePaths {
14
15 static removeHighlighting() {
16 Array.from(document.querySelectorAll(`svg .forwarding-graph-paths`)).forEach(d => {
17 d3.select(d).classed('-is-highlighting', false);
18 });
19 Array.from(document.querySelectorAll('.rsp-path')).forEach(d => {
20 d3.select(d).classed('-is-highlighted', false);
21 });
22 }
23
24 static highlightPaths(rsp) {
25 HighlightRecordServicePaths.removeHighlighting();
26 Array.from(document.querySelectorAll(`svg .forwarding-graph-paths`)).forEach(d => {
27 d3.select(d).classed('-is-highlighting', true);
28 });
29 const list = _isArray(rsp) ? rsp : [rsp];
30 list.forEach(rsp => {
31 Array.from(document.querySelectorAll(`[data-id="${rsp.id}"]`)).forEach(d => {
32 d.parentNode.appendChild(d);
33 d3.select(d).classed('-is-highlighted', true);
34 });
35 });
36 }
37
38 }