|
3995 | 3995 | // It could happen that a stale web page has been opened up when VM was stopped but |
3996 | 3996 | // vm was turned on through another route - UI or API. so we should check again. |
3997 | 3997 | var existingDetails = virtualMachine.details; |
| 3998 | + var readOnlyUIDetails = []; |
| 3999 | + if (virtualMachine.readonlyuidetails && virtualMachine.readonlyuidetails.length > 0) { |
| 4000 | + $.each(virtualMachine.readonlyuidetails.split(","), function(){ |
| 4001 | + readOnlyUIDetails.push($.trim(this)); |
| 4002 | + }); |
| 4003 | + } |
3998 | 4004 | var newDetails = {}; |
3999 | 4005 | for (d in existingDetails) { |
4000 | | - if (d != data.name) { |
| 4006 | + if (d != data.name && $.inArray(d, readOnlyUIDetails) < 0) { |
4001 | 4007 | newDetails['details[0].' + d] = existingDetails[d]; |
4002 | 4008 | } |
4003 | 4009 | } |
|
4043 | 4049 | // vm was turned on through another route - UI or API. so we should check again. |
4044 | 4050 | var detailToDelete = args.data.jsonObj.name; |
4045 | 4051 | var existingDetails = virtualMachine.details; |
| 4052 | + var readOnlyUIDetails = []; |
| 4053 | + if (virtualMachine.readonlyuidetails && virtualMachine.readonlyuidetails.length > 0) { |
| 4054 | + $.each(virtualMachine.readonlyuidetails.split(","), function(){ |
| 4055 | + readOnlyUIDetails.push($.trim(this)); |
| 4056 | + }); |
| 4057 | + } |
4046 | 4058 | var newDetails = {}; |
4047 | 4059 | for (detail in existingDetails) { |
4048 | | - if (detail != detailToDelete) { |
| 4060 | + if (detail != detailToDelete && $.inArray(detail, readOnlyUIDetails) < 0) { |
4049 | 4061 | newDetails['details[0].' + detail] = existingDetails[detail]; |
4050 | 4062 | } |
4051 | 4063 | } |
|
4078 | 4090 | var value = args.data.value; |
4079 | 4091 |
|
4080 | 4092 | var details; |
| 4093 | + var readOnlyUIDetails = []; |
4081 | 4094 | $.ajax({ |
4082 | 4095 | url: createURL('listVirtualMachines&id=' + args.context.instances[0].id), |
4083 | 4096 | async:false, |
4084 | 4097 | success: function(json) { |
4085 | | - var dets = json.listvirtualmachinesresponse.virtualmachine[0].details; |
4086 | | - details = dets; |
| 4098 | + var virtualMachine = json.listvirtualmachinesresponse.virtualmachine[0] |
| 4099 | + if (virtualMachine) { |
| 4100 | + details = virtualMachine.details; |
| 4101 | + if (virtualMachine.readonlyuidetails && virtualMachine.readonlyuidetails.length > 0) { |
| 4102 | + $.each(virtualMachine.readonlyuidetails.split(","), function(){ |
| 4103 | + readOnlyUIDetails.push($.trim(this)); |
| 4104 | + }); |
| 4105 | + } |
| 4106 | + } |
4087 | 4107 | }, |
4088 | 4108 |
|
4089 | 4109 | error: function(json) { |
|
4093 | 4113 |
|
4094 | 4114 | var detailsFormat = ''; |
4095 | 4115 | for (key in details) { |
4096 | | - detailsFormat += "details[0]." + key + "=" + details[key] + "&"; |
| 4116 | + if ($.inArray(key, readOnlyUIDetails) < 0) { |
| 4117 | + detailsFormat += "details[0]." + key + "=" + details[key] + "&"; |
| 4118 | + } |
4097 | 4119 | } |
4098 | 4120 | // Add new detail to the existing ones |
4099 | 4121 | detailsFormat += "details[0]." + name + "=" + value; |
|
0 commit comments