From 6a38a9ae2c72fff768adbc992590fb59f2ccc616 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 15 Dec 2011 10:10:01 -0800 Subject: [PATCH] Fix dashboard when 0 hosts are present --- ui/scripts/dashboard.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js index 325ef47edd9..baa07c1529a 100644 --- a/ui/scripts/dashboard.js +++ b/ui/scripts/dashboard.js @@ -123,8 +123,11 @@ pageSize: 4 }, success: function(json) { + var alerts = json.listalertsresponse.alert ? + json.listalertsresponse.alert : []; + dataFns.hostAlerts($.extend(data, { - alerts: $.map(json.listalertsresponse.alert, function(alert) { + alerts: $.map(alerts, function(alert) { return { name: cloudStack.converters.toAlertType(alert.type), description: alert.description @@ -144,8 +147,11 @@ pageSize: 4 }, success: function(json) { + var hosts = json.listhostsresponse.host ? + json.listhostsresponse.host : []; + complete($.extend(data, { - hostAlerts: $.map(json.listhostsresponse.host, function(host) { + hostAlerts: $.map(hosts, function(host) { return { name: host.name, description: 'Alert state detected for ' + host.name