blob: 6fedd6c123fcc84e959c2826af2c8e3f290fc65c [file] [log] [blame]
Scott Baker537d8232014-04-08 23:40:56 -07001<!doctype html>
Scott Baker537d8232014-04-08 23:40:56 -07002<script type="text/javascript" src="http://www.google.com/jsapi"></script>
Scott Baker537d8232014-04-08 23:40:56 -07003<div id="dialog-form" title="Add/Remove Slivers" style="display: none;">
4 <form>
5 <fieldset>
6 <label for="numberOfSlivers">Number of Slivers</label>
7 <input type="text" name="numberOfSlivers" id="numOfSlivers" class="text ui-widget-content ui-corner-all">
Scott Bakeredf2f672014-04-22 10:17:37 -07008 <div id=basic-tooltip>Please enter number of slivers</div>
Scott Baker537d8232014-04-08 23:40:56 -07009 </fieldset>
10 </form>
11</div>
12<div id="adv-dialog-form" title="Add/Remove Slivers" style="display: none;">
13 <form>
14 <fieldset>
15 <label for="numberOfSlivers">Number of Slivers</label>
16 <input type="text" name="numberOfSlivers" id="advNumOfSlivers" class="text ui-widget-content ui-corner-all">
Scott Bakeredf2f672014-04-22 10:17:37 -070017 <div id=adv-tooltip>Please enter number of slivers</div>
Scott Baker537d8232014-04-08 23:40:56 -070018 </fieldset>
19 </form>
20</div>
21<div id="create-slice-form" title="Create New Slice" style="display: none;">
22 <form>
23 <fieldset>
24 <div class="create-slice-row">
25 <label for="new-slice-name">Name</label>
Scott Bakeredf2f672014-04-22 10:17:37 -070026 <input type="text" name="new-slice-name" id="new-slice-name" class="text tenant-create-slice">
Scott Baker537d8232014-04-08 23:40:56 -070027 </div>
28 <div class="create-slice-row">
29 <label for="new-service-class">Service Class</label>
Scott Bakeredf2f672014-04-22 10:17:37 -070030 <select id="new-service-class" class="tenant-create-slice"></select>
Scott Baker537d8232014-04-08 23:40:56 -070031 </div>
32 <div class="create-slice-row">
33 <label for="new-image">Image</label>
Scott Bakeredf2f672014-04-22 10:17:37 -070034 <select id="new-image" class="tenant-create-slice"></select>
Scott Baker537d8232014-04-08 23:40:56 -070035 </div>
Scott Bakeredf2f672014-04-22 10:17:37 -070036 <div class="create-slice-row">
37 <label for="new-network">Network</label>
38 <select id="new-network" class="tenant-create-slice"></select>
39 </div>
40 <div class="create-slice-row">
41 <label for="mount-data-sets">Data Sets</label>
42 <select id="mount-data-sets" class="tenant-create-slice"></select>
43 </div>
44 <div class="create-slice-row">
45 <label for="number-of-slivers">Number Of Slivers</label>
46 <input type="text" name="number-of-slivers" id="number-of-slivers" class="text tenant-create-slice">
47 </div>
Scott Baker537d8232014-04-08 23:40:56 -070048 <div id=tooltip>Slice Name cannot be empty</div>
49 </fieldset>
50 </form>
51</div>
Scott Bakeredf2f672014-04-22 10:17:37 -070052<div id="delete-slice-form" title="Delete a Slice" style="display: none;">
53 <form>
54 <fieldset>
55 <div class="create-slice-row">
56 <label for="delete-slice">Choose a Slice</label>
57 <select id="delete-slice"></select>
58 </div>
59 </fieldset>
60 </form>
61</div>
Scott Baker537d8232014-04-08 23:40:56 -070062<script type="text/javascript">
Scott Bakeredf2f672014-04-22 10:17:37 -070063 google.load('visualization', '1', {
64 'packages': ['controls', 'table', 'corechart', 'geochart']
65 });
66 </script>
67 <script>
68 $(document).ready(function () {
69 function showSliceData(data,value) {
70 var imageData = data['image']['rows'];
71 var networkData = data['network']['rows'];
72 $("#service-level-value").empty();
73 $("#slice-image-value").empty();
74 $("#tenantSiteTable").empty();
75 $('#tenantSiteTable').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="tenantSiteTableData"></table>');
76 $("#tenantSliceDropDown").val(value);
77 var rows = data['userSliceInfo']['rows'];
78 var siteNames = [];
79 var sliverCount;
80 for (row in rows) {
81 if (rows[row]['sliceName'] == value) {
82 sliceImageData = rows[row]['preferredImage'];
83 $("#slice-image-value").html(sliceImageData);
84 serviceLevelData = rows[row]['sliceServiceClass'];
85 $("#service-level-value").html(serviceLevelData);
86 var innerRows = rows[row]['sliceSite'];
87 for (innerRow in innerRows) {
88 sliverCount = innerRows[innerRow];
89 siteNames.push([innerRow, sliverCount]);
90 }
91 }
92 }
93 oTable = $('#tenantSiteTableData').dataTable({
94 "bJQueryUI": true,
95 "bFilter": false,
96 "bInfo": false,
97 "bLengthChange": false,
98 "aaData": siteNames,
99 "bStateSave": true,
100 "aoColumns": [{
101 "sTitle": "Site Name"
102 }, {
103 "sTitle": "Allocated",
104 sClass: "alignCenter"
105 }
106 //{ "sTitle": "Allocated" , sClass: "alignCenter"},
107 //{ "sTitle": "Desired" , sClass: "alignCenter"},
108 ]
109 });
110 $('#tenantSliceDropDown').on('change', function () {
111 var value = $("#tenantSliceDropDown").val();
112 //alert(value);
113 checkForBasicAdvView(value, data);
114 });
115 }
116
117 function downloadSliceInfo(data,value){
118 $("#download-details").unbind().click(function(){
119 function download(filename, text) {
120 var sliceDetails = document.createElement('a');
121 sliceDetails.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
122 sliceDetails.setAttribute('download', filename);
123 sliceDetails.click();
124 }
125 var rows = data['userSliceInfo']['rows'];
126 var sliceInfo;
127 for (row in rows){
128 if(rows[row]['sliceName']==value){
129 sliceInfo = "Slice Name: "+rows[row]['sliceName']+"\nNumber of Slivers: "+rows[row]['numOfSlivers']+"\nService Level: "+rows[row]['sliceServiceClass']+"\nImage: "+rows[row]['sliceImage']+"\n";
130 for (instanceNodePairs in rows[row]['instanceNodePair']){
131 sliceInfo += instanceNodePairs+"@"+rows[row]['instanceNodePair'][instanceNodePairs]+"\n";
132 }
133 }
134 }
135 download('slice.txt', sliceInfo);
136 });
137 }
138 function editSliverAdv() {
139 $(".edit-view").click(function () {
140 var allocatedSlivers = parseInt($(this).parent().siblings(".allocated").html());
141 var td = $(this).parent().siblings(".allocated");
142 var pos = oTable.fnGetPosition(td[0]);
143 $("#adv-tooltip").css("display", "none");
144 $("#numOfSlivers").empty();
145 $("#adv-dialog-form").dialog({
146 autoOpen: false,
147 height: 200,
148 width: 350,
149 modal: true,
150 dialogClass: "tenantDialog",
151 buttons: {
152 "Add": function () {
153 allocatedSlivers += parseInt($("#advNumOfSlivers").val());
154 //if (!(parseInt($("#numOfSlivers").val()))) {
155 $("#adv-tooltip").css("display", "block");
156 //} else {
157 $(this).dialog("close");
158 td.html(allocatedSlivers);
159 //}
160 },
161 "Remove": function () {
162 allocatedSlivers -= parseInt($("#advNumOfSlivers").val());
163 // if (!(parseInt($("#numOfSlivers").val()))) {
164 $("#adv-tooltip").css("display", "block");
165 // } else {
166 $(this).dialog("close");
167 td.html(allocatedSlivers);
168 // }
169 }
170 }
171 });
172 $("#adv-dialog-form").dialog("open");
173 });
174 }
175
176 function advShowSliceData(data,value) {
177 var serviceLevelData = data['sliceServiceClass']['rows'];
178 var imageData = data['image']['rows'];
179 var networkData = data['network']['rows'];
180 var siteRows = data['sites']['rows'];
181 var dataSet = data['mountDataSets']['rows'];
182 $("#adv-service-level-value").empty();
183 $("#adv-slice-image-value").empty();
184 $("#adv-slice-data-set-value").empty();
185 $("#adv-slice-network-value").empty();
186 $("#advTenantSliceDropDown").val(value);
187 $("<select></select>").attr('id', 'adv-service-level-dropdown').appendTo('#adv-service-level-value');
188 $("<select></select>").attr('id', 'adv-image-dropdown').appendTo('#adv-slice-image-value');
189 $("<select></select>").attr('id', 'adv-network-dropdown').appendTo('#adv-slice-network-value');
190 $("<select></select>").attr('id', 'adv-dataset-dropdown').appendTo('#adv-slice-data-set-value');
191 $('#advTenantSiteTable').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="advTenantSiteTableData"></table>');
192 var rows = data['userSliceInfo']['rows'];
193 var siteNames = [];
194 var sliverCount;
195 var tableData = {};
196 for (row in serviceLevelData) {
197 $("#adv-service-level-dropdown").append("<option>" + serviceLevelData[row]['serviceClass'] + "</option>");
198 }
199 for (row in imageData) {
200 $("#adv-image-dropdown").append("<option>" + imageData[row]['Image'] + "</option>");
201 }
202 for (row in networkData) {
203 $("#adv-network-dropdown").append("<option>" + networkData[row]['Network'] + "</option>");
204 }
205 for (row in dataSet) {
206 $("#adv-dataset-dropdown").append("<option>" + dataSet[row]['DataSet'] + "</option>");
207 }
208
209 for (row in rows) {
210 if (rows[row]['sliceName'] == value) {
211 var innerRows = rows[row]['sliceSite'];
212 $("#adv-service-level-dropdown").val(rows[row]['sliceServiceClass']);
213 $("#adv-image-dropdown").val(rows[row]['preferredImage']);
214 $("#adv-dataset-dropdown").val(rows[row]['sliceDataSet']);
215 $("#adv-network-dropdown").val(rows[row]['sliceNetwork']);
216 for (innerRow in innerRows) {
217 tableData[innerRow] = innerRows[innerRow];
218 }
219 }
220 }
221 for (row in siteRows) {
222 var entry = siteRows[row]['siteName'];
223 if (!(entry in tableData)) {
224 tableData[siteRows[row]['siteName']] = 0;
225 }
226 }
227 for (row in tableData) {
228 siteNames.push([row, tableData[row], '<a href="#" class="edit-view">Edit</a>']);
229 }
230 $("#save-btn").unbind().click(function () {
231 var newTableData = {};
232 var newSite = $(".siteName");
233 var newAllocated = $(".allocated");
234 for (i = 1; i < newSite.length; i++) {
235 newTableData[$($(".siteName")[i]).text()] = parseInt($($(".allocated")[i]).text());
236 }
237 for (newRow in newTableData) {
238 if (newTableData[newRow] > tableData[newRow]) {
239 $.ajax({
240 url: '/tenantaddorremsliver/',
241 dataType: 'json',
242 data: {
243 siteName: newRow,
244 count: newTableData[newRow] - tableData[newRow],
245 slice: $("#advTenantSliceDropDown").val(),
246 actionToDo: "add",
247 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
248 state: "inactive"
249 },
250 type: 'POST',
251 complete: function () {
252 //oTable.fnReloadAjax();
253 location.reload();
254 }
255 });
256 } else if (newTableData[newRow] < tableData[newRow]) {
257 $.ajax({
258 url: '/tenantaddorremsliver/',
259 dataType: 'json',
260 data: {
261 siteName: newRow,
262 count: tableData[newRow] - newTableData[newRow],
263 slice: $("#advTenantSliceDropDown").val(),
264 actionToDo: "rem",
265 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
266 state: "inactive"
267 },
268 type: 'POST',
269 complete: function () {
270 // oTable.fnReloadAjax();
271 location.reload();
272 }
273 });
274 }
275 }
276 $.ajax({
277 url: '/updateslice/',
278 dataType: 'json',
279 data: {
280 sliceName: $("#advTenantSliceDropDown").val(),
281 serviceClass: $("#adv-service-level-dropdown").val(),
282 imageName: $("#adv-image-dropdown").val(),
283 network: $("#adv-network-dropdown").val(),
284 actionToDo: "update",
285 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
286 state: "inactive"
287 },
288 type: 'POST',
289 complete: function () {
290 //oTable.fnReloadAjax();
291 location.reload();
292 }
293 });
294
295 });
296 oTable = $('#advTenantSiteTableData').dataTable({
297 "bJQueryUI": true,
298 "bFilter": false,
299 "bInfo": false,
300 "bLengthChange": false,
301 "bPaginate": false,
302 "aaData": siteNames,
303 "bStateSave": true,
304 "aoColumns": [{
305 "sTitle": "Site Name",
306 sClass: "siteName"
307 }, {
308 "sTitle": "Allocated",
309 sClass: "alignCenter allocated"
310 }, {
311 "sTitle": "Edit",
312 sClass: "alignCenter"
313 }]
314 });
315 editSliverAdv();
316 $('#advTenantSliceDropDown').on('change', function () {
317 var selectedValue = $("#advTenantSliceDropDown").val();
318 //alert(selectedValue);
319 checkForBasicAdvView(selectedValue, data);
320 //editSliverAdv();
321 });
322 }
323
324 function checkForBasicAdvView(value, data) {
325 var rows = data['userSliceInfo']['rows'];
326 for (row in rows) {
327 if (rows[row]['sliceName'] == value) {
328 if (rows[row]['numOfSites'] > 1) {
329 advShowSliceData(data,value);
330 downloadSliceInfo(data,value);
331 $("#tenantSliceDataWrapper").css("display","none");
332 $("#advancedTenantSliceDataWrapper").css("display","block");
333 $("#advTenantSiteTable").css("display","block");
334 $("#tenantSiteTable").css("display","none");
335 $("#sliver-btn").css("display","none");
336 $("#save-btn").css("display","block");
337 break;
338 } else if(rows[row]['numOfSites'] <= 1){
339 showSliceData(data,value);
340 downloadSliceInfo(data,value);
341 //editSliverAdv();
342 $("#tenantSliceDataWrapper").css("display","block");
343 $("#advancedTenantSliceDataWrapper").css("display","none");
344 $("#advTenantSiteTable").css("display","none");
345 $("#tenantSiteTable").css("display","block");
346 $("#sliver-btn").css("display","block");
347 $("#save-btn").css("display","none");
348 break;
349 }break;
Scott Baker537d8232014-04-08 23:40:56 -0700350 }
351 }
352 }
Scott Baker537d8232014-04-08 23:40:56 -0700353
354 function UserSliceTable(data) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700355 //Add check for #dynamicusersliceinfo_filter label-> input having focus here
356 var rows = data['userSliceInfo']['rows'];
357 $("<div></div>").attr('id', 'tenantSliceDataWrapper').appendTo('#tabs-5');
358 $("<div></div>").attr('id', 'advancedTenantSliceDataWrapper').appendTo('#tabs-5');
359 var sliceData = '';
360 sliceData += '<div class="tenant-row"><span class="summary-attr"><b>Slice Name:</b> <span id="slice-name-value"> </span> </span><br></div><div class="tenant-row"><span class="summary-attr"><b>Service Level:</b> <span id="service-level-value"> </span> </span><br></div><div class="tenant-row"><span class="summary-attr"><b>Image:</b> <span id="slice-image-value"> </span> </span><br></div><div class="btn btn-high btn-info" id="advanced-tenant">Go to Advanced View</div>';
361 var advSliceData = '';
362 advSliceData += '<div class="adv-tenant-row"><span class="summary-attr"><b>Slice Name:</b> <span id="adv-slice-name-value"> </span> </span><br><br></div><div class="tenant-row"><span class="summary-attr"><b>Service Level:</b> <span id="adv-service-level-value"> </span> <span class="help-inline">Changes are potentially disruptive to existing slivers</span> </span><br></div><div class="tenant-row"><span class="summary-attr"><b>Image:</b> <span id="adv-slice-image-value"> </span><span class="help-inline">Changes are potentially disruptive to existing slivers</span> </span><br></div><div class="tenant-row"><span class="summary-attr"><b>Network:</b> <span id="adv-slice-network-value"> </span> <span class="help-inline">Changes are potentially disruptive to existing slivers</span></span></div><div class="tenant-row"><span class="summary-attr"><b>Data Sets:</b> <span id="adv-slice-data-set-value"> </span> </span></div>';
363 $('#tenantSliceDataWrapper').append(sliceData).css("display", "none");
364 $('#advancedTenantSliceDataWrapper').append(advSliceData);
365 $("#advancedTenantSliceDataWrapper").css("display", "none");
366 $("<select></select>").attr('id', 'tenantSliceDropDown').appendTo('#slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700367 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700368 $("#tenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700369 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700370 $("<select></select>").attr('id', 'advTenantSliceDropDown').appendTo('#adv-slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700371 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700372 $("#advTenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700373 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700374 $("<div></div>").attr('id', 'tenantSiteTable').appendTo('#tabs-5').css("display","none");
375 $("<div></div>").attr('id', 'advTenantSiteTable').appendTo('#tabs-5').css("display", "none");
376 $('<div class="btn btn-success" id="create-slice-btn"><i class="icon-plus-sign icon-white"></i>&nbsp;Create New Slice</div>').appendTo("#tabs-5");
377 $('<div class="btn btn-success" id="delete-slice-btn"><i class="icon-plus-sign icon-white"></i>&nbsp;Delete a Slice</div>').appendTo("#tabs-5");
378 $('<div class="btn btn-high btn-info" id="download-details">Download Slice Details</div>').appendTo("#tabs-5");
379 $('<div class="btn btn-success" id="sliver-btn"><i class="icon-plus-sign icon-white"></i>&nbsp;Add/Remove Slivers</div>').appendTo("#tabs-5");
380 $('<div class="btn btn-high btn-info" id="save-btn">Save</div>').appendTo("#tabs-5").css("display", "none");
381 $("#advanced-tenant").click(function () {
382 var value = $("#advTenantSliceDropDown").val();
383 advShowSliceData(data,value);
384 $("#tenantSliceDataWrapper").css("display","none");
385 $("#advancedTenantSliceDataWrapper").css("display","block");
386 $("#advTenantSiteTable").css("display","block");
387 $("#tenantSiteTable").css("display","none");
388 $("#sliver-btn").toggle();
389 $("#save-btn").toggle();
Scott Baker6253dfc2014-04-14 09:29:30 -0700390
Scott Bakeredf2f672014-04-22 10:17:37 -0700391 //$("#advTenantSliceDropDown").val(selectedValue);
392 //advShowSliceData(data);
393 //editSliverAdv();
Scott Baker537d8232014-04-08 23:40:56 -0700394 });
395 $("#sliver-btn").click(function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700396 $("#numOfSlivers").empty();
397 $("#basic-tooltip").css("display", "none");
Scott Baker537d8232014-04-08 23:40:56 -0700398 $("#dialog-form").dialog({
399 autoOpen: false,
400 height: 200,
401 width: 350,
402 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700403 dialogClass: "tenantDialog",
Scott Baker537d8232014-04-08 23:40:56 -0700404 buttons: {
Scott Bakeredf2f672014-04-22 10:17:37 -0700405 "Add": function () {
406 $.ajax({
407 url: '/tenantaddorremsliver/',
408 dataType: 'json',
409 data: {
410 count: parseInt($("#numOfSlivers").val()),
411 slice: $("#tenantSliceDropDown").val(),
412 actionToDo: "add",
413 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
414 state: "inactive"
415 },
416 type: 'POST',
417 beforeSend: function () {
418 if (!$("#numOfSlivers").val()) {
419 $("#basic-tooltip").css("display", "block");
420 return false;
421 } else {
422 return true;
423 }
424 },
425 complete: function () {
426 location.reload();
427 }
428 });
429 },
430 Remove: function () {
431 $.ajax({
432 url: '/tenantaddorremsliver/',
433 dataType: 'json',
434 data: {
435 count: parseInt($("#numOfSlivers").val()),
436 slice: $("#tenantSliceDropDown").val(),
437 actionToDo: "rem",
438 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
439 state: "inactive"
440 },
441 type: 'POST',
442 beforeSend: function () {
443 if (!$("#numOfSlivers").val()) {
444 $("#basic-tooltip").css("display", "block");
445 return false;
446 } else {
447 return true;
448 }
449 },
450 complete: function () {
451 location.reload();
452 }
453 });
Scott Baker537d8232014-04-08 23:40:56 -0700454 }
455 }
456 });
457 $("#dialog-form").dialog("open");
458 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700459 $("#create-slice-btn").unbind().click(function () {
Scott Baker537d8232014-04-08 23:40:56 -0700460 var serviceLevelData = data['sliceServiceClass']['rows'];
461 var imageData = data['image']['rows'];
Scott Bakeredf2f672014-04-22 10:17:37 -0700462 var dataSet = data['mountDataSets']['rows'];
463 var networkData = data['network']['rows'];
464 $("#new-service-class").empty();
465 $("#new-image").empty();
466 $("#mount-data-sets").empty();
467 $("#new-network").empty();
Scott Baker537d8232014-04-08 23:40:56 -0700468 for (row in serviceLevelData) {
469 $("#new-service-class").append("<option>" + serviceLevelData[row]['serviceClass'] + "</option>");
470 }
471 for (row in imageData) {
472 $("#new-image").append("<option>" + imageData[row]['Image'] + "</option>");
473 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700474 for (row in dataSet) {
475 $("#mount-data-sets").append("<option>" + dataSet[row]['DataSet'] + "</option>");
476 }
477 for (row in networkData) {
478 $("#new-network").append("<option>" + networkData[row]['Network'] + "</option>");
479 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700480 var nameOfSlice = $("#new-slice-name").val();
Scott Baker537d8232014-04-08 23:40:56 -0700481 var nameOfServiceClass = $("#new-service-class").val();
482 var nameOfImage = $("#new-image").val();
483 $("#create-slice-form").dialog({
Scott Baker6253dfc2014-04-14 09:29:30 -0700484 autoOpen: false,
Scott Bakeredf2f672014-04-22 10:17:37 -0700485 height: 400,
486 width: 400,
Scott Baker6253dfc2014-04-14 09:29:30 -0700487 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700488 dialogClass: "tenantDialog",
Scott Baker6253dfc2014-04-14 09:29:30 -0700489 buttons: {
490 "Submit": function () {
491 $.ajax({
492 url: '/createnewslice/',
493 dataType: 'json',
494 data: {
495 sliceName: $("#new-slice-name").val(),
496 serviceClass: nameOfServiceClass,
Scott Bakeredf2f672014-04-22 10:17:37 -0700497 imageName: $("#new-image").val(),
498 network: $("#new-network").val(),
499 mountDataSets: $("#mount-data-sets").val(),
Scott Baker6253dfc2014-04-14 09:29:30 -0700500 actionToDo: "add",
501 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
502 state: "inactive"
503 },
Scott Bakeredf2f672014-04-22 10:17:37 -0700504 async: false,
Scott Baker6253dfc2014-04-14 09:29:30 -0700505 type: 'POST',
506 beforeSend: function () {
507 if (!$("#new-slice-name").val()) {
508 $("#tooltip").css("display", "block");
509 return false;
510 } else {
511 return true;
512 }
513 },
514 success: function (response) {},
515 complete: function () {
516 location.reload();
517 }
518 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700519 $.ajax({
520 url: '/tenantaddorremsliver/',
521 dataType: 'json',
522 data: {
523 count: parseInt($("#number-of-slivers").val()),
524 slice: $("#new-slice-name").val(),
525 actionToDo: "add",
526 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
527 state: "inactive"
528 },
529 async: false,
530 type: 'POST',
531 complete: function () {
532 location.reload();
533 }
534 });
535
Scott Baker6253dfc2014-04-14 09:29:30 -0700536 },
537 Cancel: function () {
538 $(this).dialog("close");
Scott Baker537d8232014-04-08 23:40:56 -0700539 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700540 }
541 });
542 $("#create-slice-form").dialog("open");
Scott Baker537d8232014-04-08 23:40:56 -0700543 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700544 $("#delete-slice-btn").unbind().click(function () {
545 var rows = data['userSliceInfo']['rows'];
546 $("#delete-slice").empty();
547 for (row in rows) {
548 $("#delete-slice").append("<option>" + rows[row]['sliceName'] + "</option>");
549 }
550 $("#delete-slice-form").dialog({
551 autoOpen: false,
552 height: 200,
553 width: 350,
554 modal: true,
555 dialogClass: "tenantDialog",
556 buttons: {
557 "Delete": function () {
558 $.ajax({
559 url: '/tenantdeleteslice/',
560 dataType: 'json',
561 data: {
562 sliceName: $("#delete-slice").val(),
563 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
564 state: "inactive"
565 },
566 type: 'POST',
567 success: function (response) {},
568 complete: function () {
569 location.reload();
570 }
571 });
572 },
573 Cancel: function () {
574 $(this).dialog("close");
575 }
576 }
577 });
578 $("#delete-slice-form").dialog("open");
579 });
Scott Baker537d8232014-04-08 23:40:56 -0700580 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700581
582
583 function initTenant() {
584 jQuery.ajax({
585 url: '/tenantview',
586 dataType: 'json',
587 success: function (data) {
588 UserSliceTable(data);
589 var value = $("#tenantSliceDropDown").val();
590 checkForBasicAdvView(value, data);
591 $("#tooltip").css("display", "none");
592 $("#basic-tooltip").css("display", "none");
593 $("#adv-tooltip").css("display", "none");
594 },
595 complete: function () {}
596 });
Scott Baker537d8232014-04-08 23:40:56 -0700597 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700598
Scott Baker537d8232014-04-08 23:40:56 -0700599 initTenant();
600});
601</script>
602
603</html>