Permalink
Browse files

Handle cases to auto add new group from 1 to 11 disks

While I'm here fix it to add the group in the first row, if empty.
  • Loading branch information...
1 parent 5645a90 commit 5b00ea3281d7044491aa6b6d4b74fd4fe1ecbd40 @william-gr william-gr committed Jun 5, 2013
Showing with 28 additions and 11 deletions.
  1. +28 −11 gui/freeadmin/static/lib/js/freeadmin/VolumeManager.js
@@ -208,8 +208,13 @@ define([
this.dapSize.innerHTML = this.size;
this.update();
on(this.dapRow, "click", function() {
+ var can_delete = true;
+ if(me.manager._layout[0].disks.length == 0) {
+ me.manager._layout[0].remove();
+ can_delete = false;
+ }
me.manager.addVdev({
- can_delete: true,
+ can_delete: can_delete,
initialDisks: me.disks
});
});
@@ -645,13 +650,7 @@ define([
}, this.dapDelete);
if(this.can_delete === true) {
- on(this.dapDelete, "click", function() {
- while(true) {
- if(me.disks.length == 0) break;
- me.disks[0].remove();
- }
- me.destroyRecursive();
- });
+ on(this.dapDelete, "click", this.remove);
} else {
this.dapDelete.set('disabled', true);
@@ -678,16 +677,26 @@ define([
}
if(this.initialDisks.length > 0) {
- for(var i=0,len=this.initialDisks.length;i<len;i++) {
- this.initialDisks[0].addToRow(this, 0, i);
+
+ if(this.initialDisks.length == 4 || this.initialDisks.length == 8) {
+ for(var i=0,len=this.initialDisks.length;i<len;i++) {
+ this.initialDisks[0].addToRow(this, Math.floor(i / (len / 2)), i % (len / 2));
+ }
+ this.rows = 2;
+ } else if(this.initialDisks.length < 12) {
+
+ for(var i=0,len=this.initialDisks.length;i<len;i++) {
+ this.initialDisks[0].addToRow(this, 0, i);
+ }
}
this.manager._disksCheck(me);
this.manager.updateCapacity();
this.colorActive();
this.manager.updateSwitch();
}
- domStyle.set(this.resize.domNode.parentNode, "width", this.disks.length * PER_NODE_WIDTH + "px");
+ domStyle.set(this.resize.domNode.parentNode, "width", (EMPTY_WIDTH + (this.disks.length / this.rows) * PER_NODE_WIDTH) + "px");
+ domStyle.set(this.resize.domNode.parentNode, "height", (HEADER_HEIGHT + this.rows * PER_NODE_HEIGHT) + "px");
this._dragTooltip = Tooltip({
connectId: [this.resize.domNode],
@@ -710,6 +719,14 @@ define([
me._dragTooltip.open(me.resize.domNode);
}, 100);
+ },
+ remove: function() {
+ while(this.disks.length != 0) {
+ this.disks[0].remove();
+ }
+ var iof = this.manager._layout.indexOf(this);
+ delete this.manager._layout[iof];
+ this.destroyRecursive();
}
});

0 comments on commit 5b00ea3

Please sign in to comment.