Revision ee314631

View differences:

src/sunstone/public/app/tabs/vms-tab/panels/storage.js
66 66
      snapshots = [this.element.SNAPSHOTS];
67 67
    }
68 68

  
69
    var snapshotsSize = {};
70
    var monitoringSnapshots = [];
71
    if ($.isArray(that.element.MONITORING.SNAPSHOT_SIZE))
72
      monitoringSnapshots = that.element.MONITORING.SNAPSHOT_SIZE;
73
    else if (!$.isEmptyObject(that.element.MONITORING.SNAPSHOT_SIZE))
74
      monitoringSnapshots = [that.element.MONITORING.SNAPSHOT_SIZE];
75

  
76
    $.each(monitoringSnapshots, function(index, monitoringSnap){
77
      if(snapshotsSize[monitoringSnap.DISK_ID] == undefined){
78
        snapshotsSize[monitoringSnap.DISK_ID] = {};
79
      }
80

  
81
      snapshotsSize[monitoringSnap.DISK_ID][monitoringSnap.ID] = monitoringSnap.SIZE;
82
    })
83

  
69 84
    var snapshotsHtml = {};
70 85

  
71 86
    $.each(snapshots, function(){
......
76 91
        diskSnapshots = [diskSnapshots];
77 92
      }
78 93

  
94
      var indexedSize = snapshotsSize[diskId];
95

  
96
      if(indexedSize == undefined){
97
        indexedSize = {};
98
      }
99

  
79 100
      var treeRoot = {
80 101
        htmlStr : '',
81 102
        subTree : []
......
94 115

  
95 116
      $.each(noParent, function(){
96 117
        treeRoot.subTree.push(
97
          _makeTree(that, indexedSnapshots[this], indexedSnapshots)
118
          _makeTree(that, indexedSnapshots[this], indexedSnapshots, indexedSize)
98 119
        );
99 120
      });
100 121

  
......
188 209
        }
189 210

  
190 211
        var sizeStr = "";
191
        if (disk.SIZE) {
192
          sizeStr += Humanize.sizeFromMB(disk.SIZE);
212
        if (disksSize[disk.DISK_ID]) {
213
          sizeStr += Humanize.sizeFromMB(disksSize[disk.DISK_ID]);
193 214
        } else {
194 215
          sizeStr += '-';
195 216
        }
217

  
196 218
        sizeStr += '/';
197
        if (disksSize[disk.DISK_ID]) {
198
          sizeStr += Humanize.sizeFromMB(disksSize[disk.DISK_ID]);
219
        if (disk.SIZE) {
220
          sizeStr += Humanize.sizeFromMB(disk.SIZE);
199 221
        } else {
200 222
          sizeStr += '-';
201 223
        }
......
461 483
    });
462 484
  }
463 485

  
464
  function _makeTree(that, snapshot, indexedSnapshots){
486
  function _makeTree(that, snapshot, indexedSnapshots, indexedSize){
465 487
    var SPACE = '    ';
466 488

  
467 489
    var subTree = [];
......
469 491
    if (snapshot.CHILDREN){
470 492
      $.each(snapshot.CHILDREN.split(","), function(){
471 493
        subTree.push(
472
          _makeTree(that, indexedSnapshots[this], indexedSnapshots)
494
          _makeTree(that, indexedSnapshots[this], indexedSnapshots, indexedSize)
473 495
        );
474 496
      });
475 497
    }
......
485 507
                Locale.tr("Active")+'"/>' + SPACE;
486 508
    }
487 509

  
488
    html += Humanize.prettyTime(snapshot.DATE) + SPACE +
489
            Humanize.sizeFromMB(snapshot.SIZE) + SPACE +
510
    var sizeStr = "";
511
    if (indexedSize[snapshot.ID]) {
512
      sizeStr += Humanize.sizeFromMB(indexedSize[snapshot.ID]);
513
    } else {
514
      sizeStr += '-';
515
    }
516

  
517
    sizeStr += '/';
518
    if (snapshot.SIZE) {
519
      sizeStr += Humanize.sizeFromMB(snapshot.SIZE);
520
    } else {
521
      sizeStr += '-';
522
    }
523

  
524
    html += Humanize.prettyTime(snapshot.DATE) + SPACE + sizeStr + SPACE +
490 525
            (snapshot.NAME ? snapshot.NAME + SPACE : '');
491 526

  
492 527
    html += '</div>';

Also available in: Unified diff