webapp tweaks, to show cleaner info on summary page, and a bit more info, including status and app id; and not to show circles at 0,0
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/8f1d41d5 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/8f1d41d5 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/8f1d41d5 Branch: refs/heads/0.4.0 Commit: 8f1d41d57260b2d37f4fc68992e8f3e8b3b49765 Parents: 807f375 Author: Alex Heneveld <[email protected]> Authored: Tue Jun 5 14:21:43 2012 +0100 Committer: Alex Heneveld <[email protected]> Committed: Tue Jun 5 15:58:30 2012 +0100 ---------------------------------------------------------------------- .../web/console/entity/EntitySummary.groovy | 22 ++++++++++++++++++++ .../js/console/dashboard/widgets/circles.js | 4 +++- .../console/detail-tab/detail-tabs/summary.js | 10 +++++---- .../web-app/js/console/util/brooklyn-util.js | 9 +++++--- 4 files changed, 37 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8f1d41d5/usage/web-console/grails-app/utils/brooklyn/web/console/entity/EntitySummary.groovy ---------------------------------------------------------------------- diff --git a/usage/web-console/grails-app/utils/brooklyn/web/console/entity/EntitySummary.groovy b/usage/web-console/grails-app/utils/brooklyn/web/console/entity/EntitySummary.groovy index 664250e..c77c18f 100644 --- a/usage/web-console/grails-app/utils/brooklyn/web/console/entity/EntitySummary.groovy +++ b/usage/web-console/grails-app/utils/brooklyn/web/console/entity/EntitySummary.groovy @@ -3,6 +3,8 @@ package brooklyn.web.console.entity; import brooklyn.entity.Entity import brooklyn.entity.EntityClass import brooklyn.entity.Group +import brooklyn.entity.basic.Attributes +import brooklyn.entity.trait.Startable /** Summary of a Brookln Entity */ public class EntitySummary { @@ -12,6 +14,7 @@ public class EntitySummary { final String displayName; final String applicationId; final String ownerId; + final String status; final Collection<LocationSummary> locations; final Collection<String> children; final Collection<String> groupNames; @@ -26,6 +29,25 @@ public class EntitySummary { this.groupNames = entity.getGroups().collect { it.getDisplayName() } if (entity instanceof Group) { this.children = ((Group) entity).members.collect { it.id }; + } else { + this.children = null; } + this.status = deriveStatus(entity); + } + + private String deriveStatus(Entity entity) { + // a simple status check. more sophisticated would be nice. + + Object result = entity.getAttribute(Attributes.SERVICE_STATE); + if (result!=null) + return result.toString().toUpperCase(); + + result = entity.getAttribute(Startable.SERVICE_UP); + if (result!=null) { + if (result) return "UP"; + else return "DOWN"; + } + + return "(no status)"; } } http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8f1d41d5/usage/web-console/web-app/js/console/dashboard/widgets/circles.js ---------------------------------------------------------------------- diff --git a/usage/web-console/web-app/js/console/dashboard/widgets/circles.js b/usage/web-console/web-app/js/console/dashboard/widgets/circles.js index b95332f..93d402b 100644 --- a/usage/web-console/web-app/js/console/dashboard/widgets/circles.js +++ b/usage/web-console/web-app/js/console/dashboard/widgets/circles.js @@ -41,7 +41,9 @@ Brooklyn.circles = (function() { for (id in json) { var l = json[id]; - if (lm = locationMarkers[id]) { + if (l.lat == null || l.lng == null || (l.lat == 0 && l.lng == 0)) { + // Suppress circle if not set or at (0,0); slightly clumsy, but workable + } else if (lm = locationMarkers[id]) { // Update var latlng = new google.maps.LatLng(l.lat, l.lng); http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8f1d41d5/usage/web-console/web-app/js/console/detail-tab/detail-tabs/summary.js ---------------------------------------------------------------------- diff --git a/usage/web-console/web-app/js/console/detail-tab/detail-tabs/summary.js b/usage/web-console/web-app/js/console/detail-tab/detail-tabs/summary.js index 40f02c1..a77c9e9 100644 --- a/usage/web-console/web-app/js/console/detail-tab/detail-tabs/summary.js +++ b/usage/web-console/web-app/js/console/detail-tab/detail-tabs/summary.js @@ -28,7 +28,7 @@ Brooklyn.summary = (function() { $("#summary-basic-info").html(name_html + locations_html); - var status_html = '<span class="label">Status: </span>TODO'; + var status_html = '<p><span class="label">Status: </span>'+json.status+'</p><br/>'; $("#summary-status").html(status_html); var groups_html = '<h4>Groups</h4>'; @@ -41,9 +41,11 @@ Brooklyn.summary = (function() { } $("#summary-groups").html(groups_html); - var activity_html = '<h4>Recent Activity</h4>'; - activity_html += '<p>TODO</p>'; - $("#summary-activity").html(activity_html); + var identity_html = '<p>Self: '+json.id+'</p><br/>'; + var owner_html = ''; + if (json.ownerId) owner_html = '<p>Owner: '+json.ownerId+'</p><br/>'; + var app_html = '<p>App: '+json.applicationId+'</p>'; + $("#summary-activity").html('<h4>IDs</h4>'+identity_html + owner_html + app_html); $(Brooklyn.eventBus).trigger('update_ok'); }; http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8f1d41d5/usage/web-console/web-app/js/console/util/brooklyn-util.js ---------------------------------------------------------------------- diff --git a/usage/web-console/web-app/js/console/util/brooklyn-util.js b/usage/web-console/web-app/js/console/util/brooklyn-util.js index 832f571..fabb0ba 100644 --- a/usage/web-console/web-app/js/console/util/brooklyn-util.js +++ b/usage/web-console/web-app/js/console/util/brooklyn-util.js @@ -69,10 +69,13 @@ Brooklyn.util = (function(){ $(id + " tbody").click(clickCallback); } - if (data) { + if ((typeof data === "undefined") || (data==null)) { + // do nothing + } else { + // clear and repopulate (have to force a redraw, in case data was empty add would not redraw) table.fnClearTable(false); - table.fnAddData(data); - + table.fnAddData(data, false); + table.fnDraw(true); } return table;
