|
282 | 282 |
|
283 | 283 | }); |
284 | 284 |
|
285 | | - $.ajax({ |
286 | | - url: createURL("updateResourceLimit&resourceType=0&max=" + todb(args.data.vmLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
287 | | - dataType: "json", |
288 | | - async: false, |
289 | | - success: function(json) { |
290 | | - accountObj["vmLimit"] = args.data.vmLimit; |
291 | | - } |
292 | | - }); |
293 | | - |
294 | | - $.ajax({ |
295 | | - url: createURL("updateResourceLimit&resourceType=1&max=" + todb(args.data.ipLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
296 | | - dataType: "json", |
297 | | - async: false, |
298 | | - success: function(json) { |
299 | | - accountObj["ipLimit"] = args.data.ipLimit; |
300 | | - } |
301 | | - }); |
| 285 | + if(args.data.vmLimit != null) { |
| 286 | + $.ajax({ |
| 287 | + url: createURL("updateResourceLimit&resourceType=0&max=" + todb(args.data.vmLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 288 | + dataType: "json", |
| 289 | + async: false, |
| 290 | + success: function(json) { |
| 291 | + accountObj["vmLimit"] = args.data.vmLimit; |
| 292 | + } |
| 293 | + }); |
| 294 | + } |
302 | 295 |
|
303 | | - $.ajax({ |
304 | | - url: createURL("updateResourceLimit&resourceType=2&max=" + todb(args.data.volumeLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
305 | | - dataType: "json", |
306 | | - async: false, |
307 | | - success: function(json) { |
308 | | - accountObj["volumeLimit"] = args.data.volumeLimit; |
309 | | - } |
310 | | - }); |
| 296 | + if(args.data.ipLimit != null) { |
| 297 | + $.ajax({ |
| 298 | + url: createURL("updateResourceLimit&resourceType=1&max=" + todb(args.data.ipLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 299 | + dataType: "json", |
| 300 | + async: false, |
| 301 | + success: function(json) { |
| 302 | + accountObj["ipLimit"] = args.data.ipLimit; |
| 303 | + } |
| 304 | + }); |
| 305 | + } |
311 | 306 |
|
312 | | - $.ajax({ |
313 | | - url: createURL("updateResourceLimit&resourceType=3&max=" + todb(args.data.snapshotLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
314 | | - dataType: "json", |
315 | | - async: false, |
316 | | - success: function(json) { |
317 | | - accountObj["snapshotLimit"] = args.data.snapshotLimit; |
318 | | - } |
319 | | - }); |
| 307 | + if(args.data.volumeLimit != null) { |
| 308 | + $.ajax({ |
| 309 | + url: createURL("updateResourceLimit&resourceType=2&max=" + todb(args.data.volumeLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 310 | + dataType: "json", |
| 311 | + async: false, |
| 312 | + success: function(json) { |
| 313 | + accountObj["volumeLimit"] = args.data.volumeLimit; |
| 314 | + } |
| 315 | + }); |
| 316 | + } |
320 | 317 |
|
321 | | - $.ajax({ |
322 | | - url: createURL("updateResourceLimit&resourceType=4&max=" + todb(args.data.templateLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
323 | | - dataType: "json", |
324 | | - async: false, |
325 | | - success: function(json) { |
326 | | - accountObj["templateLimit"] = args.data.templateLimit; |
327 | | - } |
328 | | - }); |
329 | | - |
330 | | - $.ajax({ |
331 | | - url: createURL("updateResourceLimit&resourceType=7&max=" + todb(args.data.vpcLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
332 | | - dataType: "json", |
333 | | - async: false, |
334 | | - success: function(json) { |
335 | | - accountObj["vpcLimit"] = args.data.vpcLimit; |
336 | | - } |
337 | | - }); |
| 318 | + if(args.data.snapshotLimit != null) { |
| 319 | + $.ajax({ |
| 320 | + url: createURL("updateResourceLimit&resourceType=3&max=" + todb(args.data.snapshotLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 321 | + dataType: "json", |
| 322 | + async: false, |
| 323 | + success: function(json) { |
| 324 | + accountObj["snapshotLimit"] = args.data.snapshotLimit; |
| 325 | + } |
| 326 | + }); |
| 327 | + } |
| 328 | + |
| 329 | + if(args.data.templateLimit != null) { |
| 330 | + $.ajax({ |
| 331 | + url: createURL("updateResourceLimit&resourceType=4&max=" + todb(args.data.templateLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 332 | + dataType: "json", |
| 333 | + async: false, |
| 334 | + success: function(json) { |
| 335 | + accountObj["templateLimit"] = args.data.templateLimit; |
| 336 | + } |
| 337 | + }); |
| 338 | + } |
| 339 | + |
| 340 | + if(args.data.vpcLimit != null) { |
| 341 | + $.ajax({ |
| 342 | + url: createURL("updateResourceLimit&resourceType=7&max=" + todb(args.data.vpcLimit) + "&account=" + accountObj.name + "&domainid=" + accountObj.domainid), |
| 343 | + dataType: "json", |
| 344 | + async: false, |
| 345 | + success: function(json) { |
| 346 | + accountObj["vpcLimit"] = args.data.vpcLimit; |
| 347 | + } |
| 348 | + }); |
| 349 | + } |
338 | 350 |
|
339 | 351 | if(errorMsg == "") |
340 | 352 | args.response.success({data: accountObj}); |
|
546 | 558 | }, |
547 | 559 | vmLimit: { |
548 | 560 | label: 'label.instance.limits', |
549 | | - isEditable: true |
| 561 | + isEditable: function(context) { |
| 562 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 563 | + return true; |
| 564 | + else |
| 565 | + return false; |
| 566 | + } |
550 | 567 | }, |
551 | 568 | ipLimit: { |
552 | 569 | label: 'label.ip.limits', |
553 | | - isEditable: true |
| 570 | + isEditable: function(context) { |
| 571 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 572 | + return true; |
| 573 | + else |
| 574 | + return false; |
| 575 | + } |
554 | 576 | }, |
555 | 577 | volumeLimit: { |
556 | 578 | label: 'label.volume.limits', |
557 | | - isEditable: true |
| 579 | + isEditable: function(context) { |
| 580 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 581 | + return true; |
| 582 | + else |
| 583 | + return false; |
| 584 | + } |
558 | 585 | }, |
559 | 586 | snapshotLimit: { |
560 | 587 | label: 'label.snapshot.limits', |
561 | | - isEditable: true |
| 588 | + isEditable: function(context) { |
| 589 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 590 | + return true; |
| 591 | + else |
| 592 | + return false; |
| 593 | + } |
562 | 594 | }, |
563 | 595 | templateLimit: { |
564 | 596 | label: 'label.template.limits', |
565 | | - isEditable: true |
| 597 | + isEditable: function(context) { |
| 598 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 599 | + return true; |
| 600 | + else |
| 601 | + return false; |
| 602 | + } |
566 | 603 | }, |
567 | 604 | vpcLimit: { |
568 | 605 | label: 'VPC limits', |
569 | | - isEditable: true |
| 606 | + isEditable: function(context) { |
| 607 | + if (context.accounts[0].accounttype == roleTypeUser || context.accounts[0].accounttype == roleTypeDomainAdmin) //updateResourceLimits is only allowed on account whose type is user or domain-admin |
| 608 | + return true; |
| 609 | + else |
| 610 | + return false; |
| 611 | + } |
570 | 612 | }, |
571 | 613 |
|
572 | 614 | vmtotal: { label: 'label.total.of.vm' }, |
|
1091 | 1133 | if (jsonObj.state == 'Destroyed') return []; |
1092 | 1134 |
|
1093 | 1135 | if(isAdmin()) { |
1094 | | - if(!(jsonObj.domain == "ROOT" && jsonObj.name == "admin" && jsonObj.accounttype == 1)) { //if not system-generated default admin account |
1095 | | - //allowedActions.push("edit"); |
1096 | | - if (jsonObj.accounttype == roleTypeUser || jsonObj.accounttype == roleTypeDomainAdmin) { |
1097 | | - //allowedActions.push("updateResourceLimits"); |
1098 | | - allowedActions.push("edit"); |
1099 | | - } |
| 1136 | + allowedActions.push("edit"); //updating networkdomain is allowed on any account, including system-generated default admin account |
| 1137 | + if(!(jsonObj.domain == "ROOT" && jsonObj.name == "admin" && jsonObj.accounttype == 1)) { //if not system-generated default admin account |
1100 | 1138 | if(jsonObj.state == "enabled") { |
1101 | 1139 | allowedActions.push("disable"); |
1102 | 1140 | allowedActions.push("lock"); |
|
0 commit comments