+ }
+ for (row in tableData) {
+ siteNames.push([row, tableData[row], '<a href="#" class="edit-view">Edit</a>']);
+ }
+ $("#save-btn").unbind().click(function () {
+ var newTableData = {};
+ var newSite = $(".siteName");
+ var newAllocated = $(".allocated");
+ for (i = 1; i < newSite.length; i++) {
+ newTableData[$($(".siteName")[i]).text()] = parseInt($($(".allocated")[i]).text());
+ }
+ for (newRow in newTableData) {
+ if (newTableData[newRow] > tableData[newRow]) {
+ $.ajax({
+ url: '/tenantaddorremsliver/',
+ dataType: 'json',
+ data: {
+ siteName: newRow,
+ count: newTableData[newRow] - tableData[newRow],
+ slice: $("#advTenantSliceDropDown").val(),
+ actionToDo: "add",
+ csrfmiddlewaretoken: "{{ csrf_token }}", // < here
+ state: "inactive"
+ },
+ type: 'POST',
+ complete: function () {
+ //oTable.fnReloadAjax();
+ location.reload();
+ }
+ });
+ } else if (newTableData[newRow] < tableData[newRow]) {
+ $.ajax({
+ url: '/tenantaddorremsliver/',
+ dataType: 'json',
+ data: {
+ siteName: newRow,
+ count: tableData[newRow] - newTableData[newRow],
+ slice: $("#advTenantSliceDropDown").val(),
+ actionToDo: "rem",
+ csrfmiddlewaretoken: "{{ csrf_token }}", // < here
+ state: "inactive"
+ },
+ type: 'POST',
+ complete: function () {
+ // oTable.fnReloadAjax();
+ location.reload();
+ }
+ });
+ }
+ }
+ $.ajax({
+ url: '/updateslice/',
+ dataType: 'json',
+ data: {
+ sliceName: $("#advTenantSliceDropDown").val(),
+ serviceClass: $("#adv-service-level-dropdown").val(),
+ imageName: $("#adv-image-dropdown").val(),
+ network: $("#adv-network-dropdown").val(),
+ actionToDo: "update",
+ csrfmiddlewaretoken: "{{ csrf_token }}", // < here
+ state: "inactive"
+ },
+ type: 'POST',
+ complete: function () {
+ //oTable.fnReloadAjax();
+ location.reload();
+ }
+ });
+
+ });
+ oTable = $('#advTenantSiteTableData').dataTable({
+ "bJQueryUI": true,
+ "bFilter": false,
+ "bInfo": false,
+ "bLengthChange": false,
+ "bPaginate": false,
+ "aaData": siteNames,
+ "bStateSave": true,
+ "aoColumns": [{
+ "sTitle": "Site Name",
+ sClass: "siteName"
+ }, {
+ "sTitle": "Allocated",
+ sClass: "alignCenter allocated"
+ }, {
+ "sTitle": "Edit",
+ sClass: "alignCenter"
+ }]
+ });
+ editSliverAdv();