Skip to content

Commit 8c242b7

Browse files
committed
Projects dashboard fixes and cleanup
-Fix dashboard calling API twice per item -Only show 8 latest events, to shortern load time -Whitespace/code cleanup
1 parent 0d013cf commit 8c242b7

2 files changed

Lines changed: 32 additions & 25 deletions

File tree

‎ui/scripts/projects.js‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
success: function(json) {
1919
updatedResources++;
2020
if (updatedResources == totalResources) {
21-
args.response.success();
21+
args.response.success();
2222
}
2323
}
2424
});
2525
});
2626
},
27-
27+
2828
dataProvider: function(args) {
2929
$.ajax({
3030
url: createURL('listResourceLimits'),
@@ -70,7 +70,7 @@
7070
});
7171
}
7272
});
73-
73+
7474
}
7575
},
7676

@@ -80,9 +80,9 @@
8080
$.ajax({
8181
url: createURL('listVirtualMachines'),
8282
success: function(json) {
83-
var instances = json.listvirtualmachinesresponse.virtualmachine ?
83+
var instances = json.listvirtualmachinesresponse.virtualmachine ?
8484
json.listvirtualmachinesresponse.virtualmachine : [];
85-
85+
8686
dataFns.storage($.extend(data, {
8787
runningInstances: $.grep(instances, function(instance) {
8888
return instance.state == 'Running';
@@ -124,7 +124,7 @@
124124
id: network.networkofferingid
125125
},
126126
success: function(json) {
127-
totalBandwidth +=
127+
totalBandwidth +=
128128
json.listnetworkofferingsresponse.networkoffering[0].networkrate;
129129
}
130130
});
@@ -193,13 +193,19 @@
193193
events: function(data) {
194194
$.ajax({
195195
url: createURL('listEvents', { ignoreProject: true }),
196+
data: {
197+
page: 1,
198+
pageSize: 8
199+
},
196200
success: function(json) {
197201
var events = json.listeventsresponse.event;
198202

199203
complete($.extend(data, {
200204
events: $.map(events, function(event) {
201205
return {
202-
date: event.created.substr(5, 2) + '/' + event.created.substr(8, 2) + '/' + event.created.substr(2, 2),
206+
date: event.created.substr(5, 2) +
207+
'/' + event.created.substr(8, 2) +
208+
'/' + event.created.substr(2, 2),
203209
desc: event.description
204210
};
205211
})
@@ -381,7 +387,7 @@
381387
actionPreFilter: function(args) {
382388
if (!cloudStack.context.projects &&
383389
args.context.multiRule[0].role != 'Admin') { // This is for the new project wizard
384-
return ['destroy'];
390+
return ['destroy'];
385391
}
386392

387393
if (args.context.multiRule[0].role != 'Admin') {
@@ -489,10 +495,10 @@
489495
data.listprojectsresponse.project ?
490496
data.listprojectsresponse.project : [],
491497
function(elem) {
492-
return $.extend(elem, {
493-
displayText: elem.displaytext
494-
});
495-
})
498+
return $.extend(elem, {
499+
displayText: elem.displaytext
500+
});
501+
})
496502
});
497503
}
498504
});
@@ -812,14 +818,14 @@
812818

813819
var projectsActionFilter = function(args) {
814820
var allowedActions = ['destroy'];
815-
821+
816822
if (args.context.item.account == cloudStack.context.users[0].account || args.context.users[0].role == '1') {
817823
if (args.context.item.state == 'Suspended') {
818824
allowedActions.push('enable');
819825
} else if (args.context.item.state == 'Active') {
820826
allowedActions.push('disable');
821827
}
822-
828+
823829
return allowedActions;
824830
}
825831

‎ui/scripts/ui-custom/projects.js‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* User management multi-edit
55
*/
66
userManagement: function(args) {
7-
var multiEdit = !args.useInvites ?
7+
var multiEdit = !args.useInvites ?
88
cloudStack.projects.addUserForm :
99
cloudStack.projects.inviteForm;
1010

@@ -62,7 +62,7 @@
6262
} else {
6363
$item.hide().html(value).fadeIn();
6464
}
65-
});
65+
});
6666
}
6767
});
6868
}
@@ -94,14 +94,14 @@
9494
if (g_capabilities.projectinviterequired) {
9595
tabs.invitations = function() {
9696
return $('<div>').addClass('management-invite').data('tab-title', 'Invitations');
97-
};
97+
};
9898
}
9999

100100
tabs.resources = function() {
101101
var $resources = $('<div>').addClass('resources').data('tab-title', 'Resources');
102102
var $form = $('<form>');
103103
var $submit = $('<input>').attr({
104-
type: 'submit'
104+
type: 'submit'
105105
}).val('Apply');
106106

107107
cloudStack.projects.resourceManagement.dataProvider({
@@ -118,7 +118,7 @@
118118
name: resource.type,
119119
value: resource.value
120120
}).addClass('required');
121-
121+
122122
$field.append($label, $input);
123123
$field.appendTo($form);
124124
});
@@ -147,7 +147,7 @@
147147
}
148148
}
149149
});
150-
150+
151151
return false;
152152
});
153153

@@ -156,7 +156,7 @@
156156
}
157157
}
158158
});
159-
159+
160160
return $resources;
161161
};
162162
}
@@ -167,14 +167,15 @@
167167
// Make UI tabs
168168
$.each(tabs, function(tabName, tab) {
169169
var $tab = $('<li>').appendTo($tabs.find('ul:first'));
170+
var $tabContent = tab();
170171
var $tabLink = $('<a>')
171172
.attr({ href: '#project-view-dashboard-' + tabName })
172-
.html(tab().data('tab-title'))
173+
.html($tabContent.data('tab-title'))
173174
.appendTo($tab);
174175
var $content = $('<div>')
175176
.appendTo($tabs)
176177
.attr({ id: 'project-view-dashboard-' + tabName })
177-
.append(tab);
178+
.append($tabContent);
178179
});
179180

180181
$tabs.find('ul li:first').addClass('first');
@@ -252,7 +253,7 @@
252253
var project = args.data;
253254

254255
$(window).trigger('cloudStack.fullRefresh');
255-
256+
256257
$loading.remove();
257258

258259
// Confirmation
@@ -346,7 +347,7 @@
346347
var $instanceRow = args.$instanceRow;
347348

348349
$instanceRow.animate({ opacity: 0.5 });
349-
350+
350351
cloudStack.projects.addUserForm.actions.destroy.action({
351352
context: $.extend(true, {}, cloudStack.context, {
352353
projects: [project],

0 commit comments

Comments
 (0)