Skip to content

Commit

Permalink
Update front end to send disks as list for add pool. rockstor#299
Browse files Browse the repository at this point in the history
  • Loading branch information
schakrava committed Nov 1, 2014
1 parent 286fdd2 commit 8c86d42
Showing 1 changed file with 35 additions and 38 deletions.
73 changes: 35 additions & 38 deletions src/rockstor/storageadmin/static/storageadmin/js/views/add_pool.js
@@ -1,27 +1,27 @@
/*
*
* @licstart The following is the entire license notice for the
* @licstart The following is the entire license notice for the
* JavaScript code in this page.
*
*
* Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
* This file is part of RockStor.
*
*
* RockStor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
*
* RockStor is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* @licend The above is the entire license notice
* for the JavaScript code in this page.
*
*
*/

/*
Expand All @@ -36,7 +36,7 @@ AddPoolView = Backbone.View.extend({
initialize: function() {
this.disks = new DiskCollection();
// dont paginate disk selection table for now
this.disks.pageSize = RockStorGlobals.maxPageSize;
this.disks.pageSize = RockStorGlobals.maxPageSize;

},

Expand All @@ -58,7 +58,7 @@ AddPoolView = Backbone.View.extend({
if (pool_name == "") {
err_msg = 'Please enter pool name';
return false;
}
}
else
if(pool_name.length >127){
err_msg = 'Please enter pool name less than 128 characters';
Expand Down Expand Up @@ -110,23 +110,23 @@ AddPoolView = Backbone.View.extend({
}
return true;
}, raid_err_msg);

this.$("#disks-table").tablesorter({
headers: {
// assign the first column (we start counting zero)
0: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
3: {
// disable it by setting the property sorter to false
sorter: false
headers: {
// assign the first column (we start counting zero)
0: {
// disable it by setting the property sorter to false
sorter: false
},
// assign the third column (we start counting zero)
3: {
// disable it by setting the property sorter to false
sorter: false
}
}
}
});
this.$('#add-pool-form input').tooltip({placement: 'right'});

this.$('#raid_level').tooltip({
html: true,
placement: 'right',
Expand All @@ -147,30 +147,28 @@ AddPoolView = Backbone.View.extend({
disableButton(button);
var pool_name = $('#pool_name').val();
var raid_level = $('#raid_level').val();
var disk_names = '';
var disk_names = [];
var n = $("input:checked.disk").length;
$("input:checked.disk").each(function(i) {
if (i < n-1) {
disk_names += $(this).val() + ',';
} else {
disk_names += $(this).val();
if (i < n) {
disk_names.push($(this).val());
}

});

var jqxhr = $.ajax({
url: "/api/pools",
type: "POST",
dataType: "json",
data: {"disks": disk_names, "raid_level": raid_level,
"pname": pool_name},
});

url: '/api/pools',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({"disks": disk_names, "raid_level": raid_level,
"pname": pool_name}),
});

jqxhr.done(function() {
enableButton(button);

_this.$('#add-pool-form input').tooltip('hide');
app_router.navigate('pools', {trigger: true})
app_router.navigate('pools', {trigger: true})
});

jqxhr.fail(function(xhr, status, error) {
Expand All @@ -191,4 +189,3 @@ AddPoolView = Backbone.View.extend({
app_router.navigate('pools', {trigger: true});
}
});

0 comments on commit 8c86d42

Please sign in to comment.