Skip to content

Commit 030235b

Browse files
author
Jessica Wang
committed
CLOUDSTACK-2074: cloudstack UI - Affinity - Affinity Group page - details tab - implement "View Instances" on right top corner.
1 parent 3390f01 commit 030235b

2 files changed

Lines changed: 53 additions & 6 deletions

File tree

‎ui/scripts/affinity.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@
201201
for(var k = 0; k < firstPageVms.length; k++) {
202202
if(firstPageVms[k].id == vmIds[i]) {
203203
matchFound = true;
204-
item.displayname = firstPageVms[k].displayname;
205-
item.state = firstPageVms[k].state;
204+
item = firstPageVms[k];
206205
break; //break for looup
207206
}
208207
}
@@ -213,9 +212,7 @@
213212
async: false,
214213
data: {id: vmIds[i]},
215214
success: function(json) {
216-
var vmObj = json.listvirtualmachinesresponse.virtualmachine[0];
217-
item.displayname = vmObj.displayname;
218-
item.state = vmObj.state;
215+
item = json.listvirtualmachinesresponse.virtualmachine[0];
219216
}
220217
});
221218
}

‎ui/scripts/instances.js‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,57 @@
197197
hostid: args.context.hosts[0].id
198198
});
199199
}
200-
200+
201+
if("affinityGroups" in args.context) {
202+
var vmIds = args.context.affinityGroups[0].virtualmachineIds;
203+
if(vmIds == null || vmIds.length == 0) {
204+
args.response.success({data: null});
205+
return;
206+
}
207+
$.ajax({
208+
url: createURL('listVirtualMachines'),
209+
data: data,
210+
success: function(json) {
211+
var firstPageVms = json.listvirtualmachinesresponse.virtualmachine;
212+
var items = [];
213+
if(vmIds != null) {
214+
for(var i = 0; i < vmIds.length; i++) {
215+
var item = null;
216+
var matchFound = false;
217+
if(firstPageVms != null) {
218+
for(var k = 0; k < firstPageVms.length; k++) {
219+
if(firstPageVms[k].id == vmIds[i]) {
220+
matchFound = true;
221+
item = firstPageVms[k];
222+
break; //break for looup
223+
}
224+
}
225+
}
226+
/*
227+
if(matchFound == false) { //Either the VM is not in API response of "listVirtualMachines&page=1&pagesize=500" OR its state doesn't match value in state filter on top in instance listView
228+
$.ajax({
229+
url: createURL('listVirtualMachines'),
230+
async: false,
231+
data: {id: vmIds[i]},
232+
success: function(json) {
233+
item = json.listvirtualmachinesresponse.virtualmachine[0];
234+
}
235+
});
236+
}
237+
*/
238+
if(item != null)
239+
items.push(item);
240+
}
241+
}
242+
args.response.success({
243+
actionFilter: vmActionfilter,
244+
data: items
245+
});
246+
}
247+
});
248+
return;
249+
}
250+
201251
$.ajax({
202252
url: createURL('listVirtualMachines'),
203253
data: data,

0 commit comments

Comments
 (0)