diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css
index 23a8b24d79b..4dace3cde97 100644
--- a/ui/css/cloudstack3.css
+++ b/ui/css/cloudstack3.css
@@ -3207,6 +3207,8 @@ Dialogs*/
.dashboard.admin .dashboard-container.sub.alerts {
float: left;
margin: 0 17px 0 0;
+ height: 313px;
+ overflow: auto;
}
.dashboard.admin .dashboard-container.sub.alerts.last {
@@ -3214,6 +3216,9 @@ Dialogs*/
}
.dashboard.admin .dashboard-container.sub.alerts ul {
+ width: 362px;
+ height: 294px;
+ overflow: auto;
}
.dashboard.admin .dashboard-container.sub.alerts ul li {
diff --git a/ui/index-test.html b/ui/index-test.html
index 388bdab7785..63944dbde85 100644
--- a/ui/index-test.html
+++ b/ui/index-test.html
@@ -1442,6 +1442,7 @@
+
diff --git a/ui/index.jsp b/ui/index.jsp
index 85f5a5fd117..e1dbdc021f8 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -972,29 +972,11 @@
General Alerts
view all
-
+
-
-
- -
-
-
- -
-
-
- -
-
-
Alert 4
-
Alert 4
+
Alert 1
+
Alert 1
@@ -1006,29 +988,11 @@
Host Alerts
view all
-
+
-
-
- -
-
-
- -
-
-
- -
-
-
Alert 4
-
Alert 4
+
Alert 1
+
Alert 1
@@ -1447,6 +1411,7 @@
+
diff --git a/ui/scripts-test/dashboard.js b/ui/scripts-test/dashboard.js
index 705cf3cd425..db7da020c82 100644
--- a/ui/scripts-test/dashboard.js
+++ b/ui/scripts-test/dashboard.js
@@ -2,42 +2,7 @@
// Admin dashboard
cloudStack.sections.dashboard = {
title: 'Dashboard',
- show: function() {
- var $dashboard = $('#template').find('div.dashboard.admin').clone();
-
- $dashboard.find('.view-all').click(function() {
- $('#navigation li.events').click();
- });
-
- var getData = function() {
- // Populate data
- $dashboard.find('[data-item]').hide();
- cloudStack.sections.dashboard.dataProvider({
- response: {
- success: function(args) {
- var data = args.data;
-
- $.each(data, function(key, value) {
- var $elem = $dashboard.find('[data-item=' + key + ']');
-
- $elem.each(function() {
- var $item = $(this);
- if ($item.hasClass('chart-line')) {
- $item.show().animate({ width: value + '%' });
- } else {
- $item.hide().html(value).fadeIn();
- }
- });
- });
- }
- }
- });
- };
-
- getData();
-
- return $dashboard;
- },
+ show: cloudStack.uiCustom.dashboard,
dataProvider: function(args) {
args.response.success({
diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js
index 0de0544312e..c02afb68225 100644
--- a/ui/scripts/dashboard.js
+++ b/ui/scripts/dashboard.js
@@ -1,43 +1,8 @@
-(function(cloudStack, testData) {
+(function($, cloudStack, testData) {
// Admin dashboard
cloudStack.sections.dashboard = {
title: 'Dashboard',
- show: function() {
- var $dashboard = $('#template').find('div.dashboard.admin').clone();
-
- $dashboard.find('.view-all').click(function() {
- $('#navigation li.events').click();
- });
-
- var getData = function() {
- // Populate data
- $dashboard.find('[data-item]').hide();
- cloudStack.sections.dashboard.dataProvider({
- response: {
- success: function(args) {
- var data = args.data;
-
- $.each(data, function(key, value) {
- var $elem = $dashboard.find('[data-item=' + key + ']');
-
- $elem.each(function() {
- var $item = $(this);
- if ($item.hasClass('chart-line')) {
- $item.show().animate({ width: value + '%' });
- } else {
- $item.hide().html(value).fadeIn();
- }
- });
- });
- }
- }
- });
- };
-
- getData();
-
- return $dashboard;
- },
+ show: cloudStack.uiCustom.dashboard,
dataProvider: function(args) {
var dataFns = {
@@ -64,7 +29,7 @@
})[0];
};
- complete($.extend(data, {
+ dataFns.alerts($.extend(data, {
publicIPAllocated: capacity(8).capacityused,
publicIPTotal: capacity(8).capacitytotal,
publicIPPercentage: parseInt(capacity(8).percentused),
@@ -81,7 +46,7 @@
}
});
} else {
- complete($.extend(data, {
+ dataFns.alerts($.extend(data, {
publicIPAllocated: 0,
publicIPTotal: 0,
publicIPPercentage: 0,
@@ -96,6 +61,47 @@
cpuPercentage: 0
}));
}
+ },
+
+ alerts: function(data) {
+ $.ajax({
+ url: createURL('listAlerts'),
+ data: {
+ page: 1,
+ pageSize: 4
+ },
+ success: function(json) {
+ dataFns.hostAlerts($.extend(data, {
+ alerts: $.map(json.listalertsresponse.alert, function(alert) {
+ return {
+ name: cloudStack.converters.toAlertType(alert.type),
+ description: alert.description
+ };
+ })
+ }));
+ }
+ });
+ },
+
+ hostAlerts: function(data) {
+ $.ajax({
+ url: createURL('listHosts'),
+ data: {
+ state: 'Alert',
+ page: 1,
+ pageSize: 4
+ },
+ success: function(json) {
+ complete($.extend(data, {
+ hostAlerts: $.map(json.listhostsresponse.host, function(host) {
+ return {
+ name: host.name,
+ description: 'Alert state detected for ' + host.name
+ };
+ })
+ }));
+ }
+ });
}
};
@@ -108,4 +114,4 @@
dataFns.zones({});
}
};
-})(cloudStack, testData);
+})(jQuery, cloudStack, testData);
diff --git a/ui/scripts/ui-custom/dashboard.js b/ui/scripts/ui-custom/dashboard.js
new file mode 100644
index 00000000000..55655d7684f
--- /dev/null
+++ b/ui/scripts/ui-custom/dashboard.js
@@ -0,0 +1,57 @@
+(function($, cloudStack) {
+ cloudStack.uiCustom.dashboard = function() {
+ var $dashboard = $('#template').find('div.dashboard.admin').clone();
+
+ $dashboard.find('.view-all').click(function() {
+ $('#navigation li.events').click();
+ });
+
+ var getData = function() {
+ // Populate data
+ $dashboard.find('[data-item]').hide();
+ cloudStack.sections.dashboard.dataProvider({
+ response: {
+ success: function(args) {
+ var data = args.data;
+
+ $.each(data, function(key, value) {
+ var $elem = $dashboard.find('[data-item=' + key + ']');
+
+ if ($elem.is('ul')) {
+ $elem.show();
+ var $liTmpl = $elem.find('li').remove();
+ $(value).each(function() {
+ var item = this;
+ var $li = $liTmpl.clone().appendTo($elem).hide();
+
+ $.each(item, function(arrayKey, arrayValue) {
+ var $arrayElem = $li.find('[data-list-item=' + arrayKey + ']');
+
+ $arrayElem.html(arrayValue.substring(0, 50).concat('...'));
+ });
+
+ $li.attr({ title: item.description });
+
+ $li.fadeIn();
+ });
+ } else {
+ $elem.each(function() {
+ var $item = $(this);
+ if ($item.hasClass('chart-line')) {
+ $item.show().animate({ width: value + '%' });
+ } else {
+ $item.hide().html(value).fadeIn();
+ }
+ });
+ }
+ });
+ }
+ }
+ });
+ };
+
+ getData();
+
+ return $dashboard;
+ }
+}(jQuery, cloudStack));
\ No newline at end of file