~ubuntu-branches/ubuntu/trusty/horizon/trusty-updates

« back to all changes in this revision

Viewing changes to horizon/static/horizon/js/horizon.networktopology.js

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-12-05 14:39:15 UTC
  • mfrom: (1.1.35)
  • Revision ID: package-import@ubuntu.com-20131205143915-40991ba69inywk0u
Tags: 1:2014.1~b1-0ubuntu1
* New upstream release.
* debian/control: open icehouse release.
* debian/static/openstack-dashboard: Refreshed static assets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
      });
115
115
 
116
116
    self.load_network_info();
117
 
    setInterval(function(){
118
 
      self.load_network_info();
119
 
    }, self.reload_duration);
120
117
  },
121
118
  load_network_info:function(){
122
119
    var self = this;
127
124
      function(data) {
128
125
        self.model = data;
129
126
        self.data_convert();
 
127
        setTimeout(function(){
 
128
          self.load_network_info();
 
129
        }, self.reload_duration);
130
130
      }
131
131
    );
132
132
  },
227
227
        this.appendChild(d3.select(self.network_tmpl[self.draw_mode]).node().cloneNode(true));
228
228
        var $this = d3.select(this).select('.network-rect');
229
229
        if (d.url) {
230
 
          var $this = d3.select(this).select('.network-rect');
231
230
          $this
232
231
          .on('mouseover',function(){
233
 
            $this.transition().style('fill',
234
 
              function() { return d3.rgb(self.network_color(d.id)).brighter(0.5)});
 
232
            $this.transition().style('fill', function() {
 
233
              return d3.rgb(self.get_network_color(d.id)).brighter(0.5);
 
234
            });
235
235
          })
236
236
          .on('mouseout',function(){
237
 
            $this.transition().style('fill',
238
 
              function() { return self.network_color(d.id)});
 
237
            $this.transition().style('fill', function() {
 
238
              return self.get_network_color(d.id);
 
239
            });
239
240
          })
240
241
          .on('click',function(){
241
242
            window.location.href = d.url;
248
249
    network
249
250
      .attr('id',function(d) { return 'id_' + d.id; })
250
251
      .attr('transform',function(d,i){ 
251
 
        return 'translate(' + element_properties.network_width * i + ',' + 0 + ')'})
 
252
        return 'translate(' + element_properties.network_width * i + ',' + 0 + ')';
 
253
      })
252
254
      .select('.network-rect')
253
 
      .attr('height', function(d) { return self.network_height})
254
 
      .style('fill', function(d) { return self.network_color(d.id)});
 
255
      .attr('height', function(d) { return self.network_height; })
 
256
      .style('fill', function(d) { return self.get_network_color(d.id); });
255
257
    network
256
258
      .select('.network-name')
257
 
      .attr('x', function(d) { return self.network_height/2 })
 
259
      .attr('x', function(d) { return self.network_height/2; })
258
260
      .text(function(d) { return d.name; });
259
261
    network
260
262
      .select('.network-cidr')
261
 
      .attr('x', function(d) { return self.network_height - self.element_properties.cidr_margin })
 
263
      .attr('x', function(d) {
 
264
        return self.network_height - self.element_properties.cidr_margin;
 
265
      })
262
266
      .text(function(d) {
263
267
        var cidr = $.map(d.subnets,function(n, i){
264
268
          return n.cidr;
362
366
    });
363
367
 
364
368
    port.each(function(d,i){
365
 
      var index_diff = self.network_index(this.parentNode._portdata.parent_network) -
366
 
        self.network_index(d.network_id);
 
369
      var index_diff = self.get_network_index(this.parentNode._portdata.parent_network) -
 
370
        self.get_network_index(d.network_id);
367
371
      this._index_diff = index_diff = (index_diff >= 0)? ++index_diff : index_diff;
368
372
      this._direction = (this._index_diff < 0)? 'right' : 'left';
369
373
      this._index  = this.parentNode._portdata[this._direction] ++;
384
388
      .attr('stroke-width',function(d,i) {
385
389
        return this.parentNode.parentNode._portdata.port_height;
386
390
      })
387
 
      .attr('stroke',function(d,i) {return self.network_color(d.network_id)})
 
391
      .attr('stroke', function(d, i) {
 
392
        return self.get_network_color(d.network_id);
 
393
      })
388
394
      .attr('x1',0).attr('y1',0).attr('y2',0)
389
395
      .attr('x2',function(d,i) {
390
396
        var parent = this.parentNode;
405
411
            return element_properties.port_text_margin.x;
406
412
          }
407
413
        })
408
 
        .attr('y',function(d) { return element_properties.port_text_margin.y })
 
414
        .attr('y',function(d) {
 
415
          return element_properties.port_text_margin.y;
 
416
        })
409
417
        .text(function(d) {
410
418
          var ip_label = [];
411
419
          $.each(d.fixed_ips, function() {
416
424
 
417
425
    port.exit().remove();
418
426
  },
419
 
  network_color: function(network_id) {
420
 
    return this.color(this.network_index(network_id));
 
427
  get_network_color: function(network_id) {
 
428
    return this.color(this.get_network_index(network_id));
421
429
  },
422
 
  network_index: function(network_id) {
 
430
  get_network_index: function(network_id) {
423
431
    return this.network_index[network_id];
424
432
  },
425
433
  select_port: function(device_id){
446
454
  sum_port_length: function(network_id, ports){
447
455
    var self = this;
448
456
    var sum_port_length = 0;
449
 
    var base_index = self.network_index(network_id);
 
457
    var base_index = self.get_network_index(network_id);
450
458
    $.each(ports, function(index, port){
451
 
      sum_port_length += base_index - self.network_index(port.network_id);
 
459
      sum_port_length += base_index - self.get_network_index(port.network_id);
452
460
    });
453
461
    return sum_port_length;
454
462
  },
518
526
      url:d.url,
519
527
      name:d.name,
520
528
      type:d.type,
521
 
      type_capital:d.type.replace(/^\w/, function($0) {return $0.toUpperCase()}),
522
 
      id:d.id,
 
529
      type_capital:d.type.replace(/^\w/, function($0) {
 
530
        return $0.toUpperCase();
 
531
      }),
523
532
      status:d.status,
524
533
      status_class:(d.status == "ACTIVE")? 'active' : 'down'
525
534
    };
557
566
          'left': 0 + 'px'
558
567
        })
559
568
        .css({
560
 
          'left': device_position.position().left
561
 
            - $balloon.outerWidth()
562
 
            - element_properties.balloon_margin.x + 'px'
 
569
          'left': (device_position.position().left - $balloon.outerWidth() -
 
570
                   element_properties.balloon_margin.x + 'px')
563
571
        })
564
572
        .addClass('leftPosition');
565
573
    }
578
586
  delete_balloon:function() {
579
587
    var self = this;
580
588
    if(self.balloon_id) {
581
 
      $('#' + self.balloon_id).remove()
 
589
      $('#' + self.balloon_id).remove();
582
590
      self.balloon_id = null;
583
591
    }
584
592
  },