3 ================================================================================
5 ================================================================================
6 Copyright (C) 2017 AT&T Intellectual Property
7 ================================================================================
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 ================================================================================
24 <title>DCAE Locations</title>
28 href="./lib/leaflet.css"
30 <script src="./lib/d3.v3.min.js"></script>
33 src= "./lib/leaflet.js" >
83 background: rgba(0, 0, 0, 0.8);
88 /* Creates a small triangle extender for the tooltip */
90 box-sizing: border-box;
95 color: rgba(0, 0, 0, 0.8);
101 /* Style northward tooltips differently */
112 font: 14px 'Raleway',Helvetica,sans-serif;
114 background-color: rgba(0,0,0,0.7);
117 pointer-events: none;
122 vertical-align: middle;
123 background: rgba(255,255,255, 0.2);
124 box-shadow: inset 0 0 3px 0px #CECECE;
136 font: 10px sans-serif;
146 font: 10px sans-serif;
151 font-family: verdana,arial,sans-serif;
155 border-color: #666666;
156 border-collapse: collapse;
162 border-color: #666666;
163 background-color: #dedede;
169 border-color: #666666;
170 background-color: #ffffff;
190 border: 3px double gray;
191 box-shadow: 3px 3px black;
197 <div id="map" style="width:75%;height:100%;position:absolute;top:2px;"></div>
198 <div id="cityDetail" style="width:25%;font-family: verdana,arial,sans-serif;
199 font-size:10px;position:absolute;right: 0px">Details for that location</div>
200 <div id="legend"></div>
203 <!--<script type="text/javascript">-->
204 <!--var req = new XMLHttpRequest();-->
206 <!--// Feature detection for CORS-->
207 <!--if ('withCredentials' in req) {-->
208 <!--req.open('GET', 'http://todo_url:8080/dcae-services?vnfLocation=Southfield,MI', true);-->
209 <!--// Just like regular ol' XHR-->
210 <!--req.onreadystatechange = function() {-->
211 <!--if (req.readyState === 4) {-->
212 <!--if (req.status >= 200 && req.status < 400) {-->
213 <!--// JSON.parse(req.responseText) etc.-->
215 <!--// Handle error case-->
223 <script type="text/javascript">
227 var greaterthan75_text = "Existing UEB Prod Instances";
228 var greaterthan75_color = "red";
230 var lessthan50_75_text = "Initial Message Router Prod Instances";
231 var lessthan50_75_color = "yellow";
233 var lessthan50_text = "Existing Atlas Prod Instances";
234 var lessthan50_color = "green";
236 var cityname = d3.select('body').append('cityname')
237 .attr('class', 'tooltip')
238 .style('opacity', 0);
242 //var CSV_URL = "test1.csv";
243 // var CSV_URL = "customer_utilization2.csv";
244 var CSV_URL = "dcae_locations1.csv";
245 var map = L.map('map').setView([39,-99], 4);
247 '<a href="http://mapbox.com">Mapbox</a>';
249 //'http://{s}.tiles.mapbox.com/v3/elijahmeeks.map-azn21pbi/{z}/{x}/{y}.png', {
250 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
251 attribution: '© ' + mapLink + ' Contributors',
255 /* Initialize the SVG layer */
258 /* We simply pick up the SVG from the map object */
259 var svg = d3.select("#map").select("svg"),
262 var dispatcher = d3.dispatch('jsonLoad');
264 // optional dispatcher
265 dispatcher.on('jsonLoad', function(data) {
266 // triggered afer json is loaded (just if you want to do additional stuff here.)
270 d3.csv(CSV_URL, function(data) {
272 /* Add a LatLng object to each item in the dataset */
273 data.forEach(function(d) {
275 d.LatLng = new L.LatLng(d.lat,
281 var feature = g.selectAll("circle")
283 .enter().append("circle")
284 .attr("id", function(d) {return 'circle_'+removeSpecialCharacters(d.id);} )
285 .style("stroke", "black")
286 .style("opacity", .6)
287 .style("fill", function(d) {/*return p.leaf ? "darkred" : "#FFE6E6"*/ if(d!=null) { var perf = d.bandwidth; if (perf>=50000 && perf <=120000) return lessthan50_75_color; else if (perf> 150001) { console.log("&&&&&&&&&&&&&&&&&&&&" + perf); return greaterthan75_color;} else return lessthan50_color; } })
288 //.style("fill", "red")
291 .on("mouseover", function(d){ cityname.transition()
292 .style('opacity', 1.0);
293 cityname.style("visibility", "visible");
296 cityname.html(d.id + "<br/>" + d.popup_note) ;
297 var td_id = "#tdaddr_"+ removeSpecialCharacters(d.id);
298 d3.selectAll(td_id).style('background-color', '#9999ff');
299 //console.log(d3.selectAll(td_id));
301 var target_x = d3.event.target.cx.animVal.value;
302 //console.log("Target_x" + target_x);
303 //console.log(d3.select('#d3MapSVG'));
304 //console.log(this.getCTM() );
305 //console.log(this.getScreenCTM());
306 //cityname.transition().style('left', Number(target_x)+Number(d3.select('#d3MapSVG')[0][0].offsetWidth)+ 'px');
307 cityname.style('left', Number(this.getScreenCTM().e) + 10 + 'px');
308 cityname.style('top', (Number(this.getScreenCTM().f) - 0) + 'px');
309 cityname.style('zIndex', '1');
313 .on("click", function(d) {
314 var city = d.popup_note;
316 // d3.text('../../../portalApi/get_geo_map_api_url', function(error, pref_url) {
317 /* ajax call to return api call url*/
318 var prefix_url="https://todo_url:8080/dcae-services?vnfLocation=";
319 d3.json(prefix_url+city, function(error, d) {
320 console.log(prefix_url+city);
321 d3.selectAll("#cityDetail").text("Total Count: " + d.totalCount + "[" + d.popup_note + "]");
323 out += "Total Count: " + JSON.stringify(d.totalCount, null,4) + " [" + city + "]";
324 out += "<table class='gridtable'>";
325 out += "<tr><th>Service Id</th><th>Service Name</th><th> VNF Type </th> </tr>";
326 d.items.forEach(function(item) {
331 item.typeLink.title +
338 d3.select("#cityDetail").html(out);
344 .on("mouseout", function(d){ if(d.id) { var td_id = "#tdaddr_"+ removeSpecialCharacters(d.id);
345 d3.selectAll(td_id).style('background-color', '#ffffff');
347 //console.log("mouseout");
348 return cityname.style("visibility", "hidden");} );
351 map.on("viewreset", update);
355 feature.attr("transform",
358 map.latLngToLayerPoint(d.LatLng).x +","+
359 map.latLngToLayerPoint(d.LatLng).y +")";
367 var callback = function (error, root) {
368 dispatcher.jsonLoad(root);
373 function csvJSON(csv){
376 //csv1.map(function(csv) {
379 var lines=csv.split("\n");
381 //console.log(lines);
384 //console.log("first line header");
385 //console.log(lines[0]);
386 var headers=lines[0].split(",");
387 //console.log(headers);
388 //console.log(headers[headers.length-1])
389 //headers.splice(headers.length-1);
391 for(var i=1;i<lines.length;i++){
394 var currentline=lines[i].split(",");
395 //console.log(currentline);
397 for(var j=0;j<headers.length;j++){
398 obj[headers[j]] = currentline[j];
402 //console.log(result);
405 //console.log(JSON.stringify(result));
406 //return result; //JavaScript object
407 jsonData = result; //JSON
408 //console.log(jsonData)
410 //refreshTable(null);
414 function isString(o) {
415 return typeof o == "string" || (typeof o == "object" && o.constructor === String);
418 function hyperTrigger(var1, popup_note, bandwidth) {
419 var res = var1.split("*");
422 //parent.hyperTrigger2(res[0],res[1],popup_note, bandwidth);
425 function removeSpecialCharacters(var1) {
426 return var1.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
429 <script src="static/visjs/legend_v2.js"></script>