blob: 95a166330769ee744b506ef6f8fb463b77c141d4 [file] [log] [blame]
Matteo Scandolodf35ca92016-02-25 09:19:41 -08001'use strict';
2
3angular.module('xos.mcordTopology')
4.service('NodeDrawer', function(TopologyElements){
5
6 const duration = 500;
7
8 let isFabricDrawed = false;
9
10 this.drawFabricBox = (svg, hStep, vStep) => {
11
12 if(isFabricDrawed){
13 return;
14 }
15
16 let fabric = svg.append('g')
17 .attr({
18 transform: `translate(${hStep - 25}, ${vStep - 25})`
19 });
20
21 fabric.append('rect')
22 .attr({
23 width: hStep + 50,
24 height: vStep + 50,
25 class: 'fabric-container'
26 });
27
28 fabric.append('text')
29 .text('Fabric')
30 .attr({
31 'text-anchor': 'middle',
32 x: ((hStep + 50) / 2),
33 y: -10
34 });
35
36 isFabricDrawed = true;
37 };
38
39 this.drawBbus = (nodes) => {
40
Matteo Scandolodaae6702016-02-26 13:42:50 -080041 // nodes.append('circle')
42 // .attr({
43 // class: d => d.type,
44 // r: 0,
45 // opacity: 0
46 // })
47 // .transition()
48 // .duration(duration)
49 // // .delay((d, i) => i * (duration / 2))
50 // .attr({
51 // r: 15,
52 // opacity: 1
53 // });
54 nodes
55 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -080056 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -080057 class: d => `${d.type} antenna`,
58 opacity: 0,
59 d: () => TopologyElements.icons.bbu,
Matteo Scandolod20e18f2016-03-03 11:35:26 -080060 transform: `translate(-22, -22)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -080061 })
62 .transition()
63 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -080064 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -080065 opacity: 1
66 });
67
68 nodes.append('text')
69 .attr({
70 'text-anchor': 'start',
Matteo Scandolod20e18f2016-03-03 11:35:26 -080071 y: 23,
72 x: 5,
Matteo Scandolodf35ca92016-02-25 09:19:41 -080073 opacity: 0
74 })
75 .text(d => `BBU ${d.name.substr(d.name.length - 1, 1)}`)
76 .transition()
77 .duration(duration * 2)
78 .attr({
79 opacity: 1
80 });
81 };
82
83 this.drawRrus = (nodes) => {
84
85 nodes.append('circle')
86 .attr({
87 class: d => `${d.type}-shadow`,
88 r: 0,
89 opacity: 0
90 })
91 .transition()
92 .duration(duration * 2)
93 // .delay((d, i) => i * (duration / 2))
94 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -080095 r: 40,
Matteo Scandolodf35ca92016-02-25 09:19:41 -080096 opacity: 1
97 });
Matteo Scandolodaae6702016-02-26 13:42:50 -080098
99 nodes
100 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800101 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -0800102 class: d => `${d.type} antenna`,
103 opacity: 0,
104 d: () => TopologyElements.icons.rru,
105 transform: `translate(-22, -22), scale(0.4)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800106 })
107 .transition()
108 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800109 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800110 opacity: 1
111 });
Matteo Scandolodaae6702016-02-26 13:42:50 -0800112
113 // nodes.append('circle')
114 // .attr({
115 // class: d => d.type,
116 // r: 0,
117 // opacity: 0
118 // })
119 // .transition()
120 // .duration(duration)
121 // // .delay((d, i) => i * (duration / 2))
122 // .attr({
123 // r: 10,
124 // opacity: 1
125 // });
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800126 };
127
128 this.drawFabric = (nodes) => {
129 nodes
130 .append('rect')
131 .attr({
132 width: 30,
133 height: 30,
134 x: -15,
135 y: -15
136 });
137
138 nodes
139 .append('path')
140 .attr({
141 class: d => d.type,
142 opacity: 0,
143 d: () => TopologyElements.icons.switch,
144 transform: `translate(-22, -22), scale(0.4)`
145 })
146 .transition()
147 .duration(duration)
148 // .delay((d, i) => i * (duration / 2))
149 .attr({
150 opacity: 1
151 });
152 };
153
154 this.drawOthers = (nodes) => {
Matteo Scandolodaae6702016-02-26 13:42:50 -0800155 // nodes.append('circle')
156 // .attr({
157 // class: d => d.type,
158 // r: 0,
159 // opacity: 0
160 // })
161 // .transition()
162 // .duration(duration)
163 // // .delay((d, i) => i * (duration / 2))
164 // .attr({
165 // r: 15,
166 // opacity: 1
167 // });
168 nodes
169 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800170 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -0800171 class: d => `${d.type} antenna`,
172 opacity: 0,
173 d: () => TopologyElements.icons.bbu,
Matteo Scandolod20e18f2016-03-03 11:35:26 -0800174 transform: `translate(-22, -22)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800175 })
176 .transition()
177 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800178 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800179 opacity: 1
180 });
181
182 nodes.append('text')
183 .attr({
184 'text-anchor': 'start',
Matteo Scandolod20e18f2016-03-03 11:35:26 -0800185 y: 23,
186 x: -15,
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800187 opacity: 0
188 })
189 .text(d => d.type)
190 .transition()
191 .duration(duration * 2)
192 .attr({
193 opacity: 1
194 });
195
196 };
197
198 this.removeElements = (nodes) => {
199 nodes
200 .transition()
201 .duration(duration)
202 .attr({
203 opacity: 0
204 })
205 .remove();
206 };
207});