blob: c3f95ec3fb5a02160d21f783021e30f370a8a3ac [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 Baker4b0cedd2014-04-22 21:01:21 -070026 <input type="text" name="new-slice-name" id="new-slice-name">
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>
Scott Baker4b0cedd2014-04-22 21:01:21 -070046 <input type="text" name="number-of-slivers" id="number-of-slivers">
Scott Bakeredf2f672014-04-22 10:17:37 -070047 </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){
Scott Baker03e3fff2014-04-23 16:51:15 -0700129 sliceInfo = "Slice Name: "+rows[row]['sliceName']+"\nNumber of Slivers: "+rows[row]['numOfSlivers']+"\nService Level: "+rows[row]['sliceServiceClass']+"\nImage: "+rows[row]['preferredImage']+"\n";
Scott Bakeredf2f672014-04-22 10:17:37 -0700130 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(),
Scott Baker4b0cedd2014-04-22 21:01:21 -0700284 dataSet: $("#adv-dataset-dropdown").val(),
Scott Bakeredf2f672014-04-22 10:17:37 -0700285 actionToDo: "update",
286 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
287 state: "inactive"
288 },
289 type: 'POST',
290 complete: function () {
291 //oTable.fnReloadAjax();
292 location.reload();
293 }
294 });
295
296 });
297 oTable = $('#advTenantSiteTableData').dataTable({
298 "bJQueryUI": true,
299 "bFilter": false,
300 "bInfo": false,
301 "bLengthChange": false,
302 "bPaginate": false,
303 "aaData": siteNames,
304 "bStateSave": true,
305 "aoColumns": [{
306 "sTitle": "Site Name",
307 sClass: "siteName"
308 }, {
309 "sTitle": "Allocated",
310 sClass: "alignCenter allocated"
311 }, {
312 "sTitle": "Edit",
313 sClass: "alignCenter"
314 }]
315 });
316 editSliverAdv();
317 $('#advTenantSliceDropDown').on('change', function () {
318 var selectedValue = $("#advTenantSliceDropDown").val();
319 //alert(selectedValue);
320 checkForBasicAdvView(selectedValue, data);
321 //editSliverAdv();
322 });
323 }
324
325 function checkForBasicAdvView(value, data) {
326 var rows = data['userSliceInfo']['rows'];
327 for (row in rows) {
328 if (rows[row]['sliceName'] == value) {
329 if (rows[row]['numOfSites'] > 1) {
330 advShowSliceData(data,value);
331 downloadSliceInfo(data,value);
332 $("#tenantSliceDataWrapper").css("display","none");
333 $("#advancedTenantSliceDataWrapper").css("display","block");
334 $("#advTenantSiteTable").css("display","block");
335 $("#tenantSiteTable").css("display","none");
336 $("#sliver-btn").css("display","none");
337 $("#save-btn").css("display","block");
338 break;
339 } else if(rows[row]['numOfSites'] <= 1){
340 showSliceData(data,value);
341 downloadSliceInfo(data,value);
342 //editSliverAdv();
343 $("#tenantSliceDataWrapper").css("display","block");
344 $("#advancedTenantSliceDataWrapper").css("display","none");
345 $("#advTenantSiteTable").css("display","none");
346 $("#tenantSiteTable").css("display","block");
347 $("#sliver-btn").css("display","block");
348 $("#save-btn").css("display","none");
349 break;
350 }break;
Scott Baker537d8232014-04-08 23:40:56 -0700351 }
352 }
353 }
Scott Baker537d8232014-04-08 23:40:56 -0700354
355 function UserSliceTable(data) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700356 //Add check for #dynamicusersliceinfo_filter label-> input having focus here
357 var rows = data['userSliceInfo']['rows'];
358 $("<div></div>").attr('id', 'tenantSliceDataWrapper').appendTo('#tabs-5');
359 $("<div></div>").attr('id', 'advancedTenantSliceDataWrapper').appendTo('#tabs-5');
360 var sliceData = '';
361 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>';
362 var advSliceData = '';
363 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>';
364 $('#tenantSliceDataWrapper').append(sliceData).css("display", "none");
365 $('#advancedTenantSliceDataWrapper').append(advSliceData);
366 $("#advancedTenantSliceDataWrapper").css("display", "none");
367 $("<select></select>").attr('id', 'tenantSliceDropDown').appendTo('#slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700368 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700369 $("#tenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700370 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700371 $("<select></select>").attr('id', 'advTenantSliceDropDown').appendTo('#adv-slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700372 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700373 $("#advTenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700374 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700375 $("<div></div>").attr('id', 'tenantSiteTable').appendTo('#tabs-5').css("display","none");
376 $("<div></div>").attr('id', 'advTenantSiteTable').appendTo('#tabs-5').css("display", "none");
377 $('<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");
378 $('<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");
379 $('<div class="btn btn-high btn-info" id="download-details">Download Slice Details</div>').appendTo("#tabs-5");
380 $('<div class="btn btn-success" id="sliver-btn"><i class="icon-plus-sign icon-white"></i>&nbsp;Add/Remove Slivers</div>').appendTo("#tabs-5");
381 $('<div class="btn btn-high btn-info" id="save-btn">Save</div>').appendTo("#tabs-5").css("display", "none");
Scott Baker4b0cedd2014-04-22 21:01:21 -0700382 $("#advanced-tenant").unbind().click(function () {
383 var value = $("#tenantSliceDropDown").val();
Scott Bakeredf2f672014-04-22 10:17:37 -0700384 advShowSliceData(data,value);
385 $("#tenantSliceDataWrapper").css("display","none");
386 $("#advancedTenantSliceDataWrapper").css("display","block");
387 $("#advTenantSiteTable").css("display","block");
388 $("#tenantSiteTable").css("display","none");
389 $("#sliver-btn").toggle();
390 $("#save-btn").toggle();
Scott Baker6253dfc2014-04-14 09:29:30 -0700391
Scott Baker537d8232014-04-08 23:40:56 -0700392 });
393 $("#sliver-btn").click(function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700394 $("#numOfSlivers").empty();
395 $("#basic-tooltip").css("display", "none");
Scott Baker537d8232014-04-08 23:40:56 -0700396 $("#dialog-form").dialog({
397 autoOpen: false,
398 height: 200,
Scott Baker4b0cedd2014-04-22 21:01:21 -0700399 width: 400,
Scott Baker537d8232014-04-08 23:40:56 -0700400 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700401 dialogClass: "tenantDialog",
Scott Baker537d8232014-04-08 23:40:56 -0700402 buttons: {
Scott Bakeredf2f672014-04-22 10:17:37 -0700403 "Add": function () {
404 $.ajax({
405 url: '/tenantaddorremsliver/',
406 dataType: 'json',
407 data: {
408 count: parseInt($("#numOfSlivers").val()),
409 slice: $("#tenantSliceDropDown").val(),
410 actionToDo: "add",
411 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
412 state: "inactive"
413 },
414 type: 'POST',
415 beforeSend: function () {
416 if (!$("#numOfSlivers").val()) {
417 $("#basic-tooltip").css("display", "block");
418 return false;
419 } else {
420 return true;
421 }
422 },
423 complete: function () {
424 location.reload();
425 }
426 });
427 },
428 Remove: function () {
429 $.ajax({
430 url: '/tenantaddorremsliver/',
431 dataType: 'json',
432 data: {
433 count: parseInt($("#numOfSlivers").val()),
434 slice: $("#tenantSliceDropDown").val(),
435 actionToDo: "rem",
436 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
437 state: "inactive"
438 },
439 type: 'POST',
440 beforeSend: function () {
441 if (!$("#numOfSlivers").val()) {
442 $("#basic-tooltip").css("display", "block");
443 return false;
444 } else {
445 return true;
446 }
447 },
448 complete: function () {
449 location.reload();
450 }
451 });
Scott Baker537d8232014-04-08 23:40:56 -0700452 }
453 }
454 });
455 $("#dialog-form").dialog("open");
456 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700457 $("#create-slice-btn").unbind().click(function () {
Scott Baker537d8232014-04-08 23:40:56 -0700458 var serviceLevelData = data['sliceServiceClass']['rows'];
459 var imageData = data['image']['rows'];
Scott Bakeredf2f672014-04-22 10:17:37 -0700460 var dataSet = data['mountDataSets']['rows'];
461 var networkData = data['network']['rows'];
462 $("#new-service-class").empty();
463 $("#new-image").empty();
464 $("#mount-data-sets").empty();
465 $("#new-network").empty();
Scott Baker537d8232014-04-08 23:40:56 -0700466 for (row in serviceLevelData) {
467 $("#new-service-class").append("<option>" + serviceLevelData[row]['serviceClass'] + "</option>");
468 }
469 for (row in imageData) {
470 $("#new-image").append("<option>" + imageData[row]['Image'] + "</option>");
471 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700472 for (row in dataSet) {
473 $("#mount-data-sets").append("<option>" + dataSet[row]['DataSet'] + "</option>");
474 }
475 for (row in networkData) {
476 $("#new-network").append("<option>" + networkData[row]['Network'] + "</option>");
477 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700478 var nameOfSlice = $("#new-slice-name").val();
Scott Baker537d8232014-04-08 23:40:56 -0700479 var nameOfServiceClass = $("#new-service-class").val();
480 var nameOfImage = $("#new-image").val();
481 $("#create-slice-form").dialog({
Scott Baker6253dfc2014-04-14 09:29:30 -0700482 autoOpen: false,
Scott Bakeredf2f672014-04-22 10:17:37 -0700483 height: 400,
484 width: 400,
Scott Baker6253dfc2014-04-14 09:29:30 -0700485 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700486 dialogClass: "tenantDialog",
Scott Baker6253dfc2014-04-14 09:29:30 -0700487 buttons: {
488 "Submit": function () {
489 $.ajax({
490 url: '/createnewslice/',
491 dataType: 'json',
492 data: {
493 sliceName: $("#new-slice-name").val(),
494 serviceClass: nameOfServiceClass,
Scott Bakeredf2f672014-04-22 10:17:37 -0700495 imageName: $("#new-image").val(),
496 network: $("#new-network").val(),
497 mountDataSets: $("#mount-data-sets").val(),
Scott Baker6253dfc2014-04-14 09:29:30 -0700498 actionToDo: "add",
499 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
500 state: "inactive"
501 },
Scott Bakeredf2f672014-04-22 10:17:37 -0700502 async: false,
Scott Baker6253dfc2014-04-14 09:29:30 -0700503 type: 'POST',
504 beforeSend: function () {
505 if (!$("#new-slice-name").val()) {
506 $("#tooltip").css("display", "block");
507 return false;
508 } else {
509 return true;
510 }
511 },
512 success: function (response) {},
513 complete: function () {
514 location.reload();
515 }
516 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700517 $.ajax({
518 url: '/tenantaddorremsliver/',
519 dataType: 'json',
520 data: {
521 count: parseInt($("#number-of-slivers").val()),
522 slice: $("#new-slice-name").val(),
523 actionToDo: "add",
524 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
525 state: "inactive"
526 },
527 async: false,
528 type: 'POST',
529 complete: function () {
530 location.reload();
531 }
532 });
533
Scott Baker6253dfc2014-04-14 09:29:30 -0700534 },
535 Cancel: function () {
536 $(this).dialog("close");
Scott Baker537d8232014-04-08 23:40:56 -0700537 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700538 }
539 });
540 $("#create-slice-form").dialog("open");
Scott Baker537d8232014-04-08 23:40:56 -0700541 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700542 $("#delete-slice-btn").unbind().click(function () {
543 var rows = data['userSliceInfo']['rows'];
544 $("#delete-slice").empty();
545 for (row in rows) {
546 $("#delete-slice").append("<option>" + rows[row]['sliceName'] + "</option>");
547 }
548 $("#delete-slice-form").dialog({
549 autoOpen: false,
550 height: 200,
551 width: 350,
552 modal: true,
553 dialogClass: "tenantDialog",
554 buttons: {
555 "Delete": function () {
556 $.ajax({
557 url: '/tenantdeleteslice/',
558 dataType: 'json',
559 data: {
560 sliceName: $("#delete-slice").val(),
561 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
562 state: "inactive"
563 },
564 type: 'POST',
565 success: function (response) {},
566 complete: function () {
567 location.reload();
568 }
569 });
570 },
571 Cancel: function () {
572 $(this).dialog("close");
573 }
574 }
575 });
576 $("#delete-slice-form").dialog("open");
577 });
Scott Baker537d8232014-04-08 23:40:56 -0700578 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700579
580
581 function initTenant() {
582 jQuery.ajax({
583 url: '/tenantview',
584 dataType: 'json',
585 success: function (data) {
586 UserSliceTable(data);
587 var value = $("#tenantSliceDropDown").val();
588 checkForBasicAdvView(value, data);
589 $("#tooltip").css("display", "none");
590 $("#basic-tooltip").css("display", "none");
591 $("#adv-tooltip").css("display", "none");
592 },
593 complete: function () {}
594 });
Scott Baker537d8232014-04-08 23:40:56 -0700595 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700596
Scott Baker537d8232014-04-08 23:40:56 -0700597 initTenant();
598});
599</script>
600
601</html>