|
277 | 277 | }).click(); |
278 | 278 | }; |
279 | 279 |
|
280 | | - var filterPodList = function(zoneId) { |
281 | | - var podcallback = function(data) { |
282 | | - var podSelect = $step.find('.select-deployment .podid'); |
283 | | - podSelect.find('option').remove().end(); |
284 | | - $(data).each(function() { |
285 | | - podSelect.append( |
286 | | - $('<option>') |
287 | | - .attr({ |
288 | | - value: this.id, |
289 | | - 'wizard-field': 'pod', |
290 | | - 'parentId': this.parentId |
291 | | - }) |
292 | | - .html(this.description) |
293 | | - .data('json-obj', this) |
294 | | - ); |
295 | | - }); |
296 | | - }; |
297 | | - args.fetchPodList(podcallback, zoneId); |
298 | | - }; |
299 | | - |
300 | | - var filterClusterList = function(podId, zoneId) { |
301 | | - var clustercallback = function(data) { |
302 | | - var clusterSelect = $step.find('.select-deployment .clusterid'); |
303 | | - clusterSelect.find('option').remove().end(); |
304 | | - $(data).each(function() { |
305 | | - clusterSelect.append( |
306 | | - $('<option>') |
307 | | - .attr({ |
308 | | - value: this.id, |
309 | | - 'wizard-field': 'cluster', |
310 | | - 'parentId': this.parentId |
311 | | - }) |
312 | | - .html(this.description) |
313 | | - .data('json-obj', this) |
314 | | - ); |
315 | | - }); |
316 | | - }; |
317 | | - args.fetchClusterList(clustercallback, podId, zoneId); |
318 | | - }; |
319 | | - |
320 | | - var filterHostList = function(clusterId, podId, zoneId) { |
321 | | - var hostcallback = function(data) { |
322 | | - var hostSelect = $step.find('.select-deployment .hostid'); |
323 | | - hostSelect.find('option').remove().end(); |
324 | | - $(data).each(function() { |
325 | | - hostSelect.append( |
326 | | - $('<option>') |
327 | | - .attr({ |
328 | | - value: this.id, |
329 | | - 'wizard-field': 'host', |
330 | | - 'parentId': this.parentId |
331 | | - }) |
332 | | - .html(this.description) |
333 | | - .data('json-obj', this) |
334 | | - ); |
335 | | - }); |
336 | | - }; |
337 | | - args.fetchHostList(hostcallback, clusterId, podId, zoneId); |
338 | | - }; |
339 | | - |
340 | | - var $zoneSelect = $step.find('.select-deployment .zoneid'); |
341 | | - $zoneSelect.unbind('change'); |
342 | | - $zoneSelect.change(function() { |
343 | | - zoneId = $zoneSelect.val(); |
344 | | - if (zoneId != null) { |
345 | | - filterPodList(zoneId); |
346 | | - filterClusterList(-1, zoneId); |
347 | | - filterHostList(-1, -1, zoneId); |
348 | | - } |
349 | | - }); |
350 | | - |
351 | | - var $podSelect = $step.find('.select-deployment .podid'); |
352 | | - $podSelect.unbind('change'); |
353 | | - $podSelect.change(function() { |
354 | | - podId = $podSelect.val(); |
355 | | - if (podId != null) { |
356 | | - filterClusterList(podId, -1); |
357 | | - filterHostList(-1, podId, -1); |
358 | | - } |
359 | | - }); |
| 280 | + if (isAdmin()) { |
| 281 | + $step.find('.select-deployment .podid').parent().show(); |
| 282 | + $step.find('.select-deployment .clusterid').parent().show(); |
| 283 | + $step.find('.select-deployment .hostid').parent().show(); |
| 284 | + |
| 285 | + |
| 286 | + var updateFieldOptions = function(fieldClass, wizardField) { |
| 287 | + return function(data) { |
| 288 | + var fieldSelect = $step.find('.select-deployment .' + fieldClass); |
| 289 | + fieldSelect.find('option').remove().end(); |
| 290 | + $(data).each(function() { |
| 291 | + fieldSelect.append( |
| 292 | + $('<option>') |
| 293 | + .attr({ |
| 294 | + value: this.id, |
| 295 | + 'wizard-field': wizardField, |
| 296 | + 'parentId': this.parentId |
| 297 | + }) |
| 298 | + .html(this.description) |
| 299 | + .data('json-obj', this) |
| 300 | + ); |
| 301 | + }); |
| 302 | + } |
| 303 | + }; |
| 304 | + |
| 305 | + var $zoneSelect = $step.find('.select-deployment .zoneid'); |
| 306 | + $zoneSelect.unbind('change'); |
| 307 | + $zoneSelect.change(function() { |
| 308 | + zoneId = $zoneSelect.val(); |
| 309 | + if (zoneId != null && isAdmin()) { |
| 310 | + args.fetchPodList(updateFieldOptions('podid', 'pod'), zoneId); |
| 311 | + args.fetchClusterList(updateFieldOptions('clusterid', 'cluster'), -1, zoneId); |
| 312 | + args.fetchHostList(updateFieldOptions('hostid', 'host'), -1, -1, zoneId); |
| 313 | + } |
| 314 | + }); |
| 315 | + |
| 316 | + var $podSelect = $step.find('.select-deployment .podid'); |
| 317 | + $podSelect.unbind('change'); |
| 318 | + $podSelect.change(function() { |
| 319 | + podId = $podSelect.val(); |
| 320 | + if (podId != null) { |
| 321 | + args.fetchClusterList(updateFieldOptions('clusterid', 'cluster'), podId, -1); |
| 322 | + args.fetchHostList(updateFieldOptions('hostid', 'host'), -1, podId, -1); |
| 323 | + } |
| 324 | + }); |
360 | 325 |
|
361 | | - var $clusterSelect = $step.find('.select-deployment .clusterid'); |
362 | | - $clusterSelect.unbind('change'); |
363 | | - $clusterSelect.change(function() { |
364 | | - clusterId = $clusterSelect.val(); |
365 | | - if (clusterId != null) { |
366 | | - filterHostList(clusterId, -1, -1); |
367 | | - } |
368 | | - }); |
| 326 | + var $clusterSelect = $step.find('.select-deployment .clusterid'); |
| 327 | + $clusterSelect.unbind('change'); |
| 328 | + $clusterSelect.change(function() { |
| 329 | + clusterId = $clusterSelect.val(); |
| 330 | + if (clusterId != null) { |
| 331 | + args.fetchHostList(updateFieldOptions('hostid', 'host'), clusterId, -1, -1); |
| 332 | + } |
| 333 | + }); |
| 334 | + } else { |
| 335 | + $step.find('.select-deployment .podid').parent().hide(); |
| 336 | + $step.find('.select-deployment .clusterid').parent().hide(); |
| 337 | + $step.find('.select-deployment .hostid').parent().hide(); |
| 338 | + } |
369 | 339 |
|
370 | 340 | return { |
371 | 341 | response: { |
|
0 commit comments