blob: b2dae65e455c3a66afc8f513251ce865c45e1ee8 [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
Matteo Scandoloaa3cc502016-03-09 17:58:51 -080028 // fabric.append('text')
29 // .text('Fabric')
30 // .attr({
31 // 'text-anchor': 'middle',
32 // x: ((hStep + 50) / 2),
33 // y: -10
34 // });
Matteo Scandolodf35ca92016-02-25 09:19:41 -080035
36 isFabricDrawed = true;
37 };
38
39 this.drawBbus = (nodes) => {
40
Matteo Scandoloe223b532016-03-04 08:31:20 -080041 nodes.append('rect')
42 .attr({
43 class: d => d.type,
44 width: 30,
45 height: 30,
46 x: -15,
47 y: -15,
48 opacity: 0
49 })
50 .transition()
51 .duration(duration)
52 .attr({
53 r: 15,
54 opacity: 1
55 });
56
Matteo Scandolodaae6702016-02-26 13:42:50 -080057 nodes
58 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -080059 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -080060 class: d => `${d.type} antenna`,
61 opacity: 0,
62 d: () => TopologyElements.icons.bbu,
Matteo Scandoloe223b532016-03-04 08:31:20 -080063 transform: `translate(-18, -18)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -080064 })
65 .transition()
66 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -080067 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -080068 opacity: 1
69 });
70
71 nodes.append('text')
72 .attr({
73 'text-anchor': 'start',
Matteo Scandoloe223b532016-03-04 08:31:20 -080074 y: 25,
Matteo Scandolod20e18f2016-03-03 11:35:26 -080075 x: 5,
Matteo Scandolodf35ca92016-02-25 09:19:41 -080076 opacity: 0
77 })
78 .text(d => `BBU ${d.name.substr(d.name.length - 1, 1)}`)
79 .transition()
80 .duration(duration * 2)
81 .attr({
82 opacity: 1
83 });
84 };
85
86 this.drawRrus = (nodes) => {
87
88 nodes.append('circle')
89 .attr({
90 class: d => `${d.type}-shadow`,
91 r: 0,
92 opacity: 0
93 })
94 .transition()
95 .duration(duration * 2)
96 // .delay((d, i) => i * (duration / 2))
97 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -080098 r: 40,
Matteo Scandolodf35ca92016-02-25 09:19:41 -080099 opacity: 1
100 });
Matteo Scandolodaae6702016-02-26 13:42:50 -0800101
102 nodes
103 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800104 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -0800105 class: d => `${d.type} antenna`,
106 opacity: 0,
107 d: () => TopologyElements.icons.rru,
Matteo Scandoloe223b532016-03-04 08:31:20 -0800108 transform: `translate(-18, -18)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800109 })
110 .transition()
111 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800112 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800113 opacity: 1
114 });
Matteo Scandolodaae6702016-02-26 13:42:50 -0800115
116 // nodes.append('circle')
117 // .attr({
118 // class: d => d.type,
119 // r: 0,
120 // opacity: 0
121 // })
122 // .transition()
123 // .duration(duration)
124 // // .delay((d, i) => i * (duration / 2))
125 // .attr({
126 // r: 10,
127 // opacity: 1
128 // });
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800129 };
130
131 this.drawFabric = (nodes) => {
132 nodes
133 .append('rect')
134 .attr({
135 width: 30,
136 height: 30,
137 x: -15,
138 y: -15
139 });
140
141 nodes
142 .append('path')
143 .attr({
144 class: d => d.type,
145 opacity: 0,
146 d: () => TopologyElements.icons.switch,
147 transform: `translate(-22, -22), scale(0.4)`
148 })
149 .transition()
150 .duration(duration)
151 // .delay((d, i) => i * (duration / 2))
152 .attr({
153 opacity: 1
154 });
155 };
156
157 this.drawOthers = (nodes) => {
Matteo Scandoloe223b532016-03-04 08:31:20 -0800158 nodes.append('rect')
159 .attr({
160 class: d => d.type,
161 width: 30,
162 height: 30,
163 x: -15,
164 y: -15,
165 opacity: 0
166 })
167 .transition()
168 .duration(duration)
169 .attr({
170 r: 15,
171 opacity: 1
172 });
173
Matteo Scandolodaae6702016-02-26 13:42:50 -0800174 nodes
175 .append('path')
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800176 .attr({
Matteo Scandolodaae6702016-02-26 13:42:50 -0800177 class: d => `${d.type} antenna`,
178 opacity: 0,
179 d: () => TopologyElements.icons.bbu,
Matteo Scandoloe223b532016-03-04 08:31:20 -0800180 transform: `translate(-18, -18)`
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800181 })
182 .transition()
183 .duration(duration)
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800184 .attr({
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800185 opacity: 1
186 });
187
188 nodes.append('text')
189 .attr({
190 'text-anchor': 'start',
Matteo Scandoloe223b532016-03-04 08:31:20 -0800191 y: 25,
192 x: -12,
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800193 opacity: 0
194 })
Matteo Scandolo89667d32016-03-07 13:34:05 -0800195 .text(d => d.name.toUpperCase())
Matteo Scandolodf35ca92016-02-25 09:19:41 -0800196 .transition()
197 .duration(duration * 2)
198 .attr({
199 opacity: 1
200 });
201
202 };
203
204 this.removeElements = (nodes) => {
205 nodes
206 .transition()
207 .duration(duration)
208 .attr({
209 opacity: 0
210 })
211 .remove();
212 };
213});