|
99 | 99 | var domainObj; |
100 | 100 |
|
101 | 101 | var data = { |
102 | | - id: args.context.domains[0].id, |
103 | | - networkdomain: args.data.networkdomain |
| 102 | + id: args.context.domains[0].id |
104 | 103 | }; |
105 | 104 |
|
106 | | - if (args.data.name != null) { |
| 105 | + if (args.data.name != null) { //args.data.name == undefined means name field is not editable (when log in as normal user or domain admin) |
107 | 106 | $.extend(data, { |
108 | 107 | name: args.data.name |
109 | 108 | }); |
110 | 109 | } |
111 | | - |
112 | | - $.ajax({ |
113 | | - url: createURL("updateDomain"), |
114 | | - async: false, |
115 | | - data: data, |
116 | | - success: function(json) { |
117 | | - domainObj = json.updatedomainresponse.domain; |
118 | | - } |
119 | | - }); |
| 110 | + |
| 111 | + if (args.data.networkdomain != null) { //args.data.networkdomain == undefined means networkdomain field is not editable (when log in as normal user or domain admin) |
| 112 | + $.extend(data, { |
| 113 | + networkdomain: args.data.networkdomain |
| 114 | + }); |
| 115 | + } |
| 116 | + |
| 117 | + if('name' in data || 'networkdomain' in data) { |
| 118 | + $.ajax({ |
| 119 | + url: createURL("updateDomain"), |
| 120 | + async: false, |
| 121 | + data: data, |
| 122 | + success: function(json) { |
| 123 | + domainObj = json.updatedomainresponse.domain; |
| 124 | + } |
| 125 | + }); |
| 126 | + } |
120 | 127 |
|
121 | 128 | if (args.data.vmLimit != null) { |
122 | 129 | $.ajax({ |
|
328 | 335 | fields: [{ |
329 | 336 | name: { |
330 | 337 | label: 'label.name', |
331 | | - isEditable: function(context) { |
332 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to change domain name |
| 338 | + isEditable: function(args) { |
| 339 | + if (isAdmin() && args.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to change domain name |
333 | 340 | return true; |
334 | 341 | else |
335 | 342 | return false; |
|
346 | 353 |
|
347 | 354 | networkdomain: { |
348 | 355 | label: 'label.network.domain', |
349 | | - isEditable: true |
| 356 | + isEditable: function(args) { |
| 357 | + if (isAdmin()) |
| 358 | + return true; |
| 359 | + else |
| 360 | + return false; |
| 361 | + } |
350 | 362 | }, |
351 | 363 | vmLimit: { |
352 | 364 | label: 'label.instance.limits', |
353 | | - isEditable: function(context) { |
354 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
355 | | - return true; |
356 | | - else |
| 365 | + isEditable: function(args) { |
| 366 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
357 | 367 | return false; |
| 368 | + else |
| 369 | + return true; |
358 | 370 | } |
359 | 371 | }, |
360 | 372 | ipLimit: { |
361 | 373 | label: 'label.ip.limits', |
362 | | - isEditable: function(context) { |
363 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
364 | | - return true; |
365 | | - else |
| 374 | + isEditable: function(args) { |
| 375 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
366 | 376 | return false; |
| 377 | + else |
| 378 | + return true; |
367 | 379 | } |
368 | 380 | }, |
369 | 381 | volumeLimit: { |
370 | 382 | label: 'label.volume.limits', |
371 | | - isEditable: function(context) { |
372 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
373 | | - return true; |
374 | | - else |
| 383 | + isEditable: function(args) { |
| 384 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
375 | 385 | return false; |
| 386 | + else |
| 387 | + return true; |
376 | 388 | } |
377 | 389 | }, |
378 | 390 | snapshotLimit: { |
379 | 391 | label: 'label.snapshot.limits', |
380 | | - isEditable: function(context) { |
381 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
382 | | - return true; |
383 | | - else |
| 392 | + isEditable: function(args) { |
| 393 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
384 | 394 | return false; |
| 395 | + else |
| 396 | + return true; |
385 | 397 | } |
386 | 398 | }, |
387 | 399 | templateLimit: { |
388 | 400 | label: 'label.template.limits', |
389 | | - isEditable: function(context) { |
390 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
391 | | - return true; |
392 | | - else |
| 401 | + isEditable: function(args) { |
| 402 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
393 | 403 | return false; |
| 404 | + else |
| 405 | + return true; |
394 | 406 | } |
395 | 407 | }, |
396 | 408 | vpcLimit: { |
397 | 409 | label: 'VPC limits', |
398 | | - isEditable: function(context) { |
399 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
400 | | - return true; |
401 | | - else |
| 410 | + isEditable: function(args) { |
| 411 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
402 | 412 | return false; |
| 413 | + else |
| 414 | + return true; |
403 | 415 | } |
404 | 416 | }, |
405 | 417 | cpuLimit: { |
406 | 418 | label: 'label.cpu.limits', |
407 | | - isEditable: function(context) { |
408 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
409 | | - return true; |
410 | | - else |
| 419 | + isEditable: function(args) { |
| 420 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
411 | 421 | return false; |
| 422 | + else |
| 423 | + return true; |
412 | 424 | } |
413 | 425 | }, |
414 | 426 | memoryLimit: { |
415 | 427 | label: 'label.memory.limits', |
416 | | - isEditable: function(context) { |
417 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
418 | | - return true; |
419 | | - else |
| 428 | + isEditable: function(args) { |
| 429 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
420 | 430 | return false; |
| 431 | + else |
| 432 | + return true; |
421 | 433 | } |
422 | 434 | }, |
423 | 435 | primaryStorageLimit: { |
424 | 436 | label: 'label.primary.storage.limits', |
425 | | - isEditable: function(context) { |
426 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
427 | | - return true; |
428 | | - else |
| 437 | + isEditable: function(args) { |
| 438 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
429 | 439 | return false; |
| 440 | + else |
| 441 | + return true; |
430 | 442 | } |
431 | 443 | }, |
432 | 444 | secondaryStorageLimit: { |
433 | 445 | label: 'label.secondary.storage.limits', |
434 | | - isEditable: function(context) { |
435 | | - if (context.domains[0].level != 0) //ROOT domain (whose level is 0) is not allowed to updateResourceLimits |
436 | | - return true; |
437 | | - else |
| 446 | + isEditable: function(args) { |
| 447 | + if (args.domains[0].id == g_domainid) //disallow to update the field on the domain you log in as |
438 | 448 | return false; |
| 449 | + else |
| 450 | + return true; |
439 | 451 | } |
440 | 452 | }, |
441 | 453 | accountTotal: { |
|
620 | 632 | if (jsonObj.level != 0) { //ROOT domain (whose level is 0) is not allowed to delete |
621 | 633 | allowedActions.push("delete"); |
622 | 634 | } |
| 635 | + } else if (isDomainAdmin()) { |
| 636 | + if (args.context.domains[0].id != g_domainid) { |
| 637 | + allowedActions.push("edit"); //merge updateResourceLimit into edit |
| 638 | + } |
623 | 639 | } |
624 | 640 | allowedActions.push("updateResourceCount"); |
625 | 641 | return allowedActions; |
|
0 commit comments