blob: 07d1e9c93678d04bd7bccc84ddd88f1404fd4c24 [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">
Scott Baker9d9650d2014-05-23 11:50:54 -070037 <label for="new-network">Network Ports</label>
Scott Baker168b7412014-05-16 14:25:41 -070038 <input type="text" name="new-network" id="new-network">
Scott Bakeredf2f672014-04-22 10:17:37 -070039 </div>
40 <div class="create-slice-row">
Scott Baker168b7412014-05-16 14:25:41 -070041 <label for="private-vol">Include Private Vol</label>
42 <input type="checkbox" name="checkbox" id="private-vol" value="value">
43 </div>
44 <div class="create-slice-row">
Scott Bakeredf2f672014-04-22 10:17:37 -070045 <label for="mount-data-sets">Data Sets</label>
46 <select id="mount-data-sets" class="tenant-create-slice"></select>
47 </div>
48 <div class="create-slice-row">
49 <label for="number-of-slivers">Number Of Slivers</label>
Scott Baker4b0cedd2014-04-22 21:01:21 -070050 <input type="text" name="number-of-slivers" id="number-of-slivers">
Scott Bakeredf2f672014-04-22 10:17:37 -070051 </div>
Scott Baker537d8232014-04-08 23:40:56 -070052 <div id=tooltip>Slice Name cannot be empty</div>
53 </fieldset>
54 </form>
55</div>
Scott Bakeredf2f672014-04-22 10:17:37 -070056<div id="delete-slice-form" title="Delete a Slice" style="display: none;">
57 <form>
58 <fieldset>
59 <div class="create-slice-row">
60 <label for="delete-slice">Choose a Slice</label>
61 <select id="delete-slice"></select>
62 </div>
63 </fieldset>
64 </form>
65</div>
Scott Baker537d8232014-04-08 23:40:56 -070066<script type="text/javascript">
Scott Bakeredf2f672014-04-22 10:17:37 -070067 google.load('visualization', '1', {
68 'packages': ['controls', 'table', 'corechart', 'geochart']
69 });
70 </script>
71 <script>
72 $(document).ready(function () {
Scott Baker168b7412014-05-16 14:25:41 -070073 function showSliceData(rows,imageData,serviceLevelData,siteRows,dataSet,value) {
Scott Bakeredf2f672014-04-22 10:17:37 -070074 $("#service-level-value").empty();
75 $("#slice-image-value").empty();
76 $("#tenantSiteTable").empty();
77 $('#tenantSiteTable').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="tenantSiteTableData"></table>');
78 $("#tenantSliceDropDown").val(value);
Scott Bakeredf2f672014-04-22 10:17:37 -070079 var siteNames = [];
80 var sliverCount;
81 for (row in rows) {
82 if (rows[row]['sliceName'] == value) {
83 sliceImageData = rows[row]['preferredImage'];
84 $("#slice-image-value").html(sliceImageData);
Scott Baker168b7412014-05-16 14:25:41 -070085 serviceLevelDataBasic = rows[row]['sliceServiceClass'];
86 $("#service-level-value").html(serviceLevelDataBasic);
Scott Bakeredf2f672014-04-22 10:17:37 -070087 var innerRows = rows[row]['sliceSite'];
88 for (innerRow in innerRows) {
89 sliverCount = innerRows[innerRow];
90 siteNames.push([innerRow, sliverCount]);
91 }
92 }
93 }
94 oTable = $('#tenantSiteTableData').dataTable({
95 "bJQueryUI": true,
96 "bFilter": false,
97 "bInfo": false,
98 "bLengthChange": false,
99 "aaData": siteNames,
100 "bStateSave": true,
101 "aoColumns": [{
102 "sTitle": "Site Name"
103 }, {
104 "sTitle": "Allocated",
105 sClass: "alignCenter"
106 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700107 ]
108 });
109 $('#tenantSliceDropDown').on('change', function () {
110 var value = $("#tenantSliceDropDown").val();
111 //alert(value);
Scott Baker168b7412014-05-16 14:25:41 -0700112 checkForBasicAdvView(value,rows,imageData,serviceLevelData,siteRows,dataSet);
Scott Bakeredf2f672014-04-22 10:17:37 -0700113 });
114 }
115
Scott Baker168b7412014-05-16 14:25:41 -0700116 function downloadSliceInfo(rows,imageData,serviceLevelData,siteRows,dataSet,value){
Scott Bakeredf2f672014-04-22 10:17:37 -0700117 $("#download-details").unbind().click(function(){
118 function download(filename, text) {
119 var sliceDetails = document.createElement('a');
120 sliceDetails.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
121 sliceDetails.setAttribute('download', filename);
122 sliceDetails.click();
123 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700124 var sliceInfo;
125 for (row in rows){
126 if(rows[row]['sliceName']==value){
Scott Baker03e3fff2014-04-23 16:51:15 -0700127 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 -0700128 for (instanceNodePairs in rows[row]['instanceNodePair']){
129 sliceInfo += instanceNodePairs+"@"+rows[row]['instanceNodePair'][instanceNodePairs]+"\n";
130 }
131 }
132 }
133 download('slice.txt', sliceInfo);
134 });
135 }
136 function editSliverAdv() {
137 $(".edit-view").click(function () {
138 var allocatedSlivers = parseInt($(this).parent().siblings(".allocated").html());
139 var td = $(this).parent().siblings(".allocated");
140 var pos = oTable.fnGetPosition(td[0]);
Scott Baker168b7412014-05-16 14:25:41 -0700141 $("#numOfSlivers").val("");;
142 $("#advNumOfSlivers").val("");;
Scott Bakeredf2f672014-04-22 10:17:37 -0700143 $("#adv-tooltip").css("display", "none");
Scott Bakeredf2f672014-04-22 10:17:37 -0700144 $("#adv-dialog-form").dialog({
145 autoOpen: false,
146 height: 200,
147 width: 350,
148 modal: true,
149 dialogClass: "tenantDialog",
150 buttons: {
151 "Add": function () {
152 allocatedSlivers += parseInt($("#advNumOfSlivers").val());
Scott Bakeredf2f672014-04-22 10:17:37 -0700153 $("#adv-tooltip").css("display", "block");
Scott Bakeredf2f672014-04-22 10:17:37 -0700154 $(this).dialog("close");
155 td.html(allocatedSlivers);
Scott Bakeredf2f672014-04-22 10:17:37 -0700156 },
157 "Remove": function () {
158 allocatedSlivers -= parseInt($("#advNumOfSlivers").val());
Scott Bakeredf2f672014-04-22 10:17:37 -0700159 $("#adv-tooltip").css("display", "block");
Scott Bakeredf2f672014-04-22 10:17:37 -0700160 $(this).dialog("close");
161 td.html(allocatedSlivers);
Scott Bakeredf2f672014-04-22 10:17:37 -0700162 }
163 }
164 });
165 $("#adv-dialog-form").dialog("open");
166 });
167 }
168
Scott Baker168b7412014-05-16 14:25:41 -0700169 function advShowSliceData(rows,imageData,serviceLevelData,siteRows,dataSet,value) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700170 $("#adv-service-level-value").empty();
171 $("#adv-slice-image-value").empty();
172 $("#adv-slice-data-set-value").empty();
Scott Bakeredf2f672014-04-22 10:17:37 -0700173 $("#advTenantSliceDropDown").val(value);
174 $("<select></select>").attr('id', 'adv-service-level-dropdown').appendTo('#adv-service-level-value');
175 $("<select></select>").attr('id', 'adv-image-dropdown').appendTo('#adv-slice-image-value');
Scott Bakeredf2f672014-04-22 10:17:37 -0700176 $("<select></select>").attr('id', 'adv-dataset-dropdown').appendTo('#adv-slice-data-set-value');
177 $('#advTenantSiteTable').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="advTenantSiteTableData"></table>');
Scott Bakeredf2f672014-04-22 10:17:37 -0700178 var siteNames = [];
179 var sliverCount;
180 var tableData = {};
181 for (row in serviceLevelData) {
182 $("#adv-service-level-dropdown").append("<option>" + serviceLevelData[row]['serviceClass'] + "</option>");
183 }
184 for (row in imageData) {
185 $("#adv-image-dropdown").append("<option>" + imageData[row]['Image'] + "</option>");
186 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700187 for (row in dataSet) {
188 $("#adv-dataset-dropdown").append("<option>" + dataSet[row]['DataSet'] + "</option>");
189 }
190
191 for (row in rows) {
192 if (rows[row]['sliceName'] == value) {
193 var innerRows = rows[row]['sliceSite'];
194 $("#adv-service-level-dropdown").val(rows[row]['sliceServiceClass']);
195 $("#adv-image-dropdown").val(rows[row]['preferredImage']);
196 $("#adv-dataset-dropdown").val(rows[row]['sliceDataSet']);
Scott Bakeredf2f672014-04-22 10:17:37 -0700197 for (innerRow in innerRows) {
198 tableData[innerRow] = innerRows[innerRow];
199 }
200 }
201 }
202 for (row in siteRows) {
203 var entry = siteRows[row]['siteName'];
204 if (!(entry in tableData)) {
205 tableData[siteRows[row]['siteName']] = 0;
206 }
207 }
208 for (row in tableData) {
209 siteNames.push([row, tableData[row], '<a href="#" class="edit-view">Edit</a>']);
210 }
211 $("#save-btn").unbind().click(function () {
212 var newTableData = {};
213 var newSite = $(".siteName");
214 var newAllocated = $(".allocated");
215 for (i = 1; i < newSite.length; i++) {
216 newTableData[$($(".siteName")[i]).text()] = parseInt($($(".allocated")[i]).text());
217 }
218 for (newRow in newTableData) {
219 if (newTableData[newRow] > tableData[newRow]) {
220 $.ajax({
221 url: '/tenantaddorremsliver/',
222 dataType: 'json',
223 data: {
224 siteName: newRow,
225 count: newTableData[newRow] - tableData[newRow],
226 slice: $("#advTenantSliceDropDown").val(),
227 actionToDo: "add",
228 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
229 state: "inactive"
230 },
231 type: 'POST',
232 complete: function () {
Scott Baker168b7412014-05-16 14:25:41 -0700233 //location.reload();
234
Scott Bakeredf2f672014-04-22 10:17:37 -0700235 }
236 });
237 } else if (newTableData[newRow] < tableData[newRow]) {
238 $.ajax({
239 url: '/tenantaddorremsliver/',
240 dataType: 'json',
241 data: {
242 siteName: newRow,
243 count: tableData[newRow] - newTableData[newRow],
244 slice: $("#advTenantSliceDropDown").val(),
245 actionToDo: "rem",
246 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
247 state: "inactive"
248 },
249 type: 'POST',
250 complete: function () {
Scott Baker168b7412014-05-16 14:25:41 -0700251 //location.reload();
Scott Bakeredf2f672014-04-22 10:17:37 -0700252 }
253 });
254 }
255 }
256 $.ajax({
257 url: '/updateslice/',
258 dataType: 'json',
259 data: {
260 sliceName: $("#advTenantSliceDropDown").val(),
261 serviceClass: $("#adv-service-level-dropdown").val(),
262 imageName: $("#adv-image-dropdown").val(),
Scott Baker4b0cedd2014-04-22 21:01:21 -0700263 dataSet: $("#adv-dataset-dropdown").val(),
Scott Baker9d9650d2014-05-23 11:50:54 -0700264 networkPorts: $("#adv-network-value").val(),
265 privateVolume: $("#private-vol-checkbox").is(":checked"),
Scott Bakeredf2f672014-04-22 10:17:37 -0700266 actionToDo: "update",
267 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
268 state: "inactive"
269 },
270 type: 'POST',
271 complete: function () {
Scott Baker168b7412014-05-16 14:25:41 -0700272 $("#tabs-5").empty();
273 initTenant(); //location.reload();
Scott Bakeredf2f672014-04-22 10:17:37 -0700274 }
275 });
276
277 });
278 oTable = $('#advTenantSiteTableData').dataTable({
279 "bJQueryUI": true,
280 "bFilter": false,
281 "bInfo": false,
282 "bLengthChange": false,
283 "bPaginate": false,
284 "aaData": siteNames,
285 "bStateSave": true,
286 "aoColumns": [{
287 "sTitle": "Site Name",
288 sClass: "siteName"
289 }, {
290 "sTitle": "Allocated",
291 sClass: "alignCenter allocated"
292 }, {
293 "sTitle": "Edit",
294 sClass: "alignCenter"
295 }]
296 });
297 editSliverAdv();
298 $('#advTenantSliceDropDown').on('change', function () {
Scott Baker168b7412014-05-16 14:25:41 -0700299 var selectedValue = $("#advTenantSliceDropDown").val();
300 checkForBasicAdvView(selectedValue, rows,imageData,serviceLevelData,siteRows,dataSet);
Scott Bakeredf2f672014-04-22 10:17:37 -0700301 });
302 }
303
Scott Baker168b7412014-05-16 14:25:41 -0700304 function checkForBasicAdvView(value, rows,imageData,serviceLevelData,siteRows,dataSet) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700305 for (row in rows) {
306 if (rows[row]['sliceName'] == value) {
307 if (rows[row]['numOfSites'] > 1) {
Scott Baker168b7412014-05-16 14:25:41 -0700308 advShowSliceData(rows,imageData,serviceLevelData,siteRows,dataSet,value);
309 downloadSliceInfo(rows,imageData,serviceLevelData,siteRows,dataSet,value);
Scott Bakeredf2f672014-04-22 10:17:37 -0700310 $("#tenantSliceDataWrapper").css("display","none");
311 $("#advancedTenantSliceDataWrapper").css("display","block");
312 $("#advTenantSiteTable").css("display","block");
313 $("#tenantSiteTable").css("display","none");
314 $("#sliver-btn").css("display","none");
315 $("#save-btn").css("display","block");
316 break;
317 } else if(rows[row]['numOfSites'] <= 1){
Scott Baker168b7412014-05-16 14:25:41 -0700318 showSliceData(rows,imageData,serviceLevelData,siteRows,dataSet,value);
319 downloadSliceInfo(rows,imageData,serviceLevelData,siteRows,dataSet,value);
Scott Bakeredf2f672014-04-22 10:17:37 -0700320 $("#tenantSliceDataWrapper").css("display","block");
321 $("#advancedTenantSliceDataWrapper").css("display","none");
322 $("#advTenantSiteTable").css("display","none");
323 $("#tenantSiteTable").css("display","block");
324 $("#sliver-btn").css("display","block");
325 $("#save-btn").css("display","none");
326 break;
327 }break;
Scott Baker537d8232014-04-08 23:40:56 -0700328 }
329 }
330 }
Scott Baker537d8232014-04-08 23:40:56 -0700331
Scott Baker168b7412014-05-16 14:25:41 -0700332 function UserSliceTable(rows,imageData,serviceLevelData,siteRows,dataSet) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700333 //Add check for #dynamicusersliceinfo_filter label-> input having focus here
Scott Bakeredf2f672014-04-22 10:17:37 -0700334 $("<div></div>").attr('id', 'tenantSliceDataWrapper').appendTo('#tabs-5');
335 $("<div></div>").attr('id', 'advancedTenantSliceDataWrapper').appendTo('#tabs-5');
336 var sliceData = '';
Scott Baker168b7412014-05-16 14:25:41 -0700337 sliceData += '<div class="tenant-row public-key-warning"><span class="summary-attr">You have not uploaded your Public Key. <a href="http://{{ request.get_host}}/admin/core/user/{{user.id}}">Click here</a> to upload it now.</span></div><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>';
Scott Bakeredf2f672014-04-22 10:17:37 -0700338 var advSliceData = '';
Scott Baker168b7412014-05-16 14:25:41 -0700339 advSliceData += '<div class="tenant-row public-key-warning"><span class="summary-attr">You have not uploaded your Public Key. <a href="http://{{ request.get_host}}/admin/core/user/{{user.id}}">Click here</a> to upload it now.</span></div><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> <input type="text" name="adv-network-value" id="adv-network-value"> <span class="help-inline">List of port ranges(if any) e.g. 1021-1026,1029</span><br></div><div class="tenant-row"><span class="summary-attr"><b>Data Sets:</b> <span id="adv-slice-data-set-value"> </span> <input type="checkbox" name="checkbox" id="private-vol-checkbox" value="value"><span class="help-inline">Include Private Volume</span></span></div>';
Scott Bakeredf2f672014-04-22 10:17:37 -0700340 $('#tenantSliceDataWrapper').append(sliceData).css("display", "none");
341 $('#advancedTenantSliceDataWrapper').append(advSliceData);
342 $("#advancedTenantSliceDataWrapper").css("display", "none");
343 $("<select></select>").attr('id', 'tenantSliceDropDown').appendTo('#slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700344 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700345 $("#tenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700346 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700347 $("<select></select>").attr('id', 'advTenantSliceDropDown').appendTo('#adv-slice-name-value');
Scott Baker537d8232014-04-08 23:40:56 -0700348 for (row in rows) {
Scott Bakeredf2f672014-04-22 10:17:37 -0700349 $("#advTenantSliceDropDown").append("<option>" + rows[row]['sliceName'] + "</option>");
Scott Baker537d8232014-04-08 23:40:56 -0700350 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700351 $("<div></div>").attr('id', 'tenantSiteTable').appendTo('#tabs-5').css("display","none");
352 $("<div></div>").attr('id', 'advTenantSiteTable').appendTo('#tabs-5').css("display", "none");
353 $('<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");
354 $('<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");
355 $('<div class="btn btn-high btn-info" id="download-details">Download Slice Details</div>').appendTo("#tabs-5");
356 $('<div class="btn btn-success" id="sliver-btn"><i class="icon-plus-sign icon-white"></i>&nbsp;Add/Remove Slivers</div>').appendTo("#tabs-5");
357 $('<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 -0700358 $("#advanced-tenant").unbind().click(function () {
359 var value = $("#tenantSliceDropDown").val();
Scott Baker168b7412014-05-16 14:25:41 -0700360 advShowSliceData(rows,imageData,serviceLevelData,siteRows,dataSet,value);
Scott Bakeredf2f672014-04-22 10:17:37 -0700361 $("#tenantSliceDataWrapper").css("display","none");
362 $("#advancedTenantSliceDataWrapper").css("display","block");
363 $("#advTenantSiteTable").css("display","block");
364 $("#tenantSiteTable").css("display","none");
365 $("#sliver-btn").toggle();
366 $("#save-btn").toggle();
Scott Baker6253dfc2014-04-14 09:29:30 -0700367
Scott Baker537d8232014-04-08 23:40:56 -0700368 });
369 $("#sliver-btn").click(function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700370 $("#basic-tooltip").css("display", "none");
Scott Baker537d8232014-04-08 23:40:56 -0700371 $("#dialog-form").dialog({
372 autoOpen: false,
373 height: 200,
Scott Baker4b0cedd2014-04-22 21:01:21 -0700374 width: 400,
Scott Baker537d8232014-04-08 23:40:56 -0700375 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700376 dialogClass: "tenantDialog",
Scott Baker537d8232014-04-08 23:40:56 -0700377 buttons: {
Scott Bakeredf2f672014-04-22 10:17:37 -0700378 "Add": function () {
379 $.ajax({
380 url: '/tenantaddorremsliver/',
381 dataType: 'json',
382 data: {
383 count: parseInt($("#numOfSlivers").val()),
384 slice: $("#tenantSliceDropDown").val(),
385 actionToDo: "add",
386 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
387 state: "inactive"
388 },
389 type: 'POST',
390 beforeSend: function () {
391 if (!$("#numOfSlivers").val()) {
392 $("#basic-tooltip").css("display", "block");
393 return false;
394 } else {
395 return true;
396 }
397 },
Scott Baker168b7412014-05-16 14:25:41 -0700398 success: function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700399 location.reload();
Scott Baker168b7412014-05-16 14:25:41 -0700400$("#dialog-form").dialog("close");
Scott Bakeredf2f672014-04-22 10:17:37 -0700401 }
402 });
403 },
404 Remove: function () {
405 $.ajax({
406 url: '/tenantaddorremsliver/',
407 dataType: 'json',
408 data: {
409 count: parseInt($("#numOfSlivers").val()),
410 slice: $("#tenantSliceDropDown").val(),
411 actionToDo: "rem",
412 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
413 state: "inactive"
414 },
415 type: 'POST',
416 beforeSend: function () {
417 if (!$("#numOfSlivers").val()) {
418 $("#basic-tooltip").css("display", "block");
419 return false;
420 } else {
421 return true;
422 }
423 },
Scott Baker168b7412014-05-16 14:25:41 -0700424 success: function () {
425$("#dialog-form").dialog("close");
426location.reload();
427
Scott Bakeredf2f672014-04-22 10:17:37 -0700428 }
429 });
Scott Baker537d8232014-04-08 23:40:56 -0700430 }
431 }
432 });
433 $("#dialog-form").dialog("open");
434 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700435 $("#create-slice-btn").unbind().click(function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700436 $("#new-service-class").empty();
437 $("#new-image").empty();
438 $("#mount-data-sets").empty();
439 $("#new-network").empty();
Scott Baker537d8232014-04-08 23:40:56 -0700440 for (row in serviceLevelData) {
441 $("#new-service-class").append("<option>" + serviceLevelData[row]['serviceClass'] + "</option>");
442 }
443 for (row in imageData) {
444 $("#new-image").append("<option>" + imageData[row]['Image'] + "</option>");
445 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700446 for (row in dataSet) {
447 $("#mount-data-sets").append("<option>" + dataSet[row]['DataSet'] + "</option>");
448 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700449 var nameOfSlice = $("#new-slice-name").val();
Scott Baker537d8232014-04-08 23:40:56 -0700450 var nameOfServiceClass = $("#new-service-class").val();
451 var nameOfImage = $("#new-image").val();
452 $("#create-slice-form").dialog({
Scott Baker6253dfc2014-04-14 09:29:30 -0700453 autoOpen: false,
Scott Bakeredf2f672014-04-22 10:17:37 -0700454 height: 400,
455 width: 400,
Scott Baker6253dfc2014-04-14 09:29:30 -0700456 modal: true,
Scott Bakeredf2f672014-04-22 10:17:37 -0700457 dialogClass: "tenantDialog",
Scott Baker6253dfc2014-04-14 09:29:30 -0700458 buttons: {
459 "Submit": function () {
460 $.ajax({
461 url: '/createnewslice/',
462 dataType: 'json',
463 data: {
464 sliceName: $("#new-slice-name").val(),
465 serviceClass: nameOfServiceClass,
Scott Bakeredf2f672014-04-22 10:17:37 -0700466 imageName: $("#new-image").val(),
Scott Baker9d9650d2014-05-23 11:50:54 -0700467 network: $("#new-network").val(),
468 privateVolume: $("#private-vol").is(":checked"),
Scott Bakeredf2f672014-04-22 10:17:37 -0700469 mountDataSets: $("#mount-data-sets").val(),
Scott Baker6253dfc2014-04-14 09:29:30 -0700470 actionToDo: "add",
471 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
472 state: "inactive"
473 },
Scott Bakeredf2f672014-04-22 10:17:37 -0700474 async: false,
Scott Baker6253dfc2014-04-14 09:29:30 -0700475 type: 'POST',
476 beforeSend: function () {
477 if (!$("#new-slice-name").val()) {
478 $("#tooltip").css("display", "block");
479 return false;
480 } else {
481 return true;
482 }
483 },
484 success: function (response) {},
485 complete: function () {
486 location.reload();
487 }
488 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700489 $.ajax({
490 url: '/tenantaddorremsliver/',
491 dataType: 'json',
492 data: {
493 count: parseInt($("#number-of-slivers").val()),
494 slice: $("#new-slice-name").val(),
495 actionToDo: "add",
496 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
497 state: "inactive"
498 },
499 async: false,
500 type: 'POST',
501 complete: function () {
502 location.reload();
503 }
504 });
505
Scott Baker6253dfc2014-04-14 09:29:30 -0700506 },
507 Cancel: function () {
508 $(this).dialog("close");
Scott Baker537d8232014-04-08 23:40:56 -0700509 }
Scott Baker6253dfc2014-04-14 09:29:30 -0700510 }
511 });
512 $("#create-slice-form").dialog("open");
Scott Baker537d8232014-04-08 23:40:56 -0700513 });
Scott Bakeredf2f672014-04-22 10:17:37 -0700514 $("#delete-slice-btn").unbind().click(function () {
Scott Bakeredf2f672014-04-22 10:17:37 -0700515 $("#delete-slice").empty();
516 for (row in rows) {
517 $("#delete-slice").append("<option>" + rows[row]['sliceName'] + "</option>");
518 }
519 $("#delete-slice-form").dialog({
520 autoOpen: false,
521 height: 200,
522 width: 350,
523 modal: true,
524 dialogClass: "tenantDialog",
525 buttons: {
526 "Delete": function () {
527 $.ajax({
528 url: '/tenantdeleteslice/',
529 dataType: 'json',
530 data: {
531 sliceName: $("#delete-slice").val(),
532 csrfmiddlewaretoken: "{{ csrf_token }}", // < here
533 state: "inactive"
534 },
535 type: 'POST',
536 success: function (response) {},
537 complete: function () {
538 location.reload();
539 }
540 });
541 },
542 Cancel: function () {
543 $(this).dialog("close");
544 }
545 }
546 });
547 $("#delete-slice-form").dialog("open");
548 });
Scott Baker537d8232014-04-08 23:40:56 -0700549 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700550
551
552 function initTenant() {
553 jQuery.ajax({
554 url: '/tenantview',
555 dataType: 'json',
556 success: function (data) {
Scott Baker168b7412014-05-16 14:25:41 -0700557 var rows = data['userSliceInfo']['rows'];
558 var imageData = data['image']['rows'];
559 //var networkData = data['network']['rows'];
560 var serviceLevelData = data['sliceServiceClass']['rows'];
561 var siteRows = data['sites']['rows'];
562 var dataSet = data['mountDataSets']['rows'];
563 UserSliceTable(rows,imageData,serviceLevelData,siteRows,dataSet);
564 if(!(data['publicKey'])){
565 $(".public-key-warning").css("display","block");
566 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700567 var value = $("#tenantSliceDropDown").val();
Scott Baker168b7412014-05-16 14:25:41 -0700568 checkForBasicAdvView(value,rows,imageData,serviceLevelData,siteRows,dataSet);
Scott Bakeredf2f672014-04-22 10:17:37 -0700569 $("#tooltip").css("display", "none");
570 $("#basic-tooltip").css("display", "none");
571 $("#adv-tooltip").css("display", "none");
572 },
573 complete: function () {}
574 });
Scott Baker537d8232014-04-08 23:40:56 -0700575 }
Scott Bakeredf2f672014-04-22 10:17:37 -0700576
Scott Baker537d8232014-04-08 23:40:56 -0700577 initTenant();
578});
579</script>
580
581</html>