brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/9] git commit: catalog item id in GUI (clickable) and on REST
Date Thu, 06 Nov 2014 10:36:50 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master c323b00d3 -> 04ce06b97


catalog item id in GUI (clickable) and on REST

in REST API for EntitySummary and PolicySummary,
and in summary tab on GUI when available;
also better spacing and suppressing of absent/redundant information in entity-summary page


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/e9c8c5ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/e9c8c5ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/e9c8c5ef

Branch: refs/heads/master
Commit: e9c8c5efbfb3d862e776931a96b8b7e0a1847196
Parents: d563652
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Nov 4 17:59:20 2014 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Nov 4 18:01:00 2014 +0000

----------------------------------------------------------------------
 usage/jsgui/src/main/webapp/assets/css/base.css       |  4 ++++
 .../src/main/webapp/assets/js/model/entity-summary.js |  1 +
 .../src/main/webapp/assets/js/view/entity-summary.js  |  4 ++++
 .../src/main/webapp/assets/tpl/apps/summary.html      |  4 ++++
 .../webapp/assets/tpl/catalog/details-entity.html     |  8 ++++++--
 .../src/main/java/brooklyn/rest/api/ServerApi.java    |  4 ++--
 .../main/java/brooklyn/rest/domain/EntitySummary.java | 14 ++++++++++++++
 .../main/java/brooklyn/rest/domain/PolicySummary.java | 11 +++++++++++
 .../java/brooklyn/rest/domain/EntitySummaryTest.java  |  2 +-
 .../java/brooklyn/rest/resources/EntityResource.java  |  1 +
 .../brooklyn/rest/transform/EntityTransformer.java    |  2 +-
 .../brooklyn/rest/transform/PolicyTransformer.java    |  2 +-
 12 files changed, 50 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/jsgui/src/main/webapp/assets/css/base.css
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/css/base.css b/usage/jsgui/src/main/webapp/assets/css/base.css
index 6aebb7e..c567ecb 100644
--- a/usage/jsgui/src/main/webapp/assets/css/base.css
+++ b/usage/jsgui/src/main/webapp/assets/css/base.css
@@ -1432,3 +1432,7 @@ textarea.param-value {
     height: 18px;
     overflow: auto;
 }
+
+#catalog-details-accordion {
+    margin-top: 12px;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/jsgui/src/main/webapp/assets/js/model/entity-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/model/entity-summary.js b/usage/jsgui/src/main/webapp/assets/js/model/entity-summary.js
index f5e4d37..d8a3d66 100644
--- a/usage/jsgui/src/main/webapp/assets/js/model/entity-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/model/entity-summary.js
@@ -26,6 +26,7 @@ define(["underscore", "backbone"], function (_, Backbone) {
                 'id':'',
                 'name':'',
                 'type':'',
+                'catalogItemId':'',
                 'links':{}
             }
         },

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
index 3436832..70ca86a 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-summary.js
@@ -38,6 +38,10 @@ define([
                 entity:this.model,
                 application:this.options.application,
             }));
+            if (this.model.get('catalogItemId'))
+                this.$("div.catalogItemId").show();
+            else
+                this.$("div.catalogItemId").hide();
             
             this.options.tabView.configView = new EntityConfigView({
                 model:this.options.model,

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/jsgui/src/main/webapp/assets/tpl/apps/summary.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/summary.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/summary.html
index 4a8b4b4..ccd1710 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/summary.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/summary.html
@@ -66,6 +66,10 @@ under the License.
             <div class="name">ID</div>
             <div class="value"><%= entity.get('id') %></div>
         </div>
+        <div class="info-name-value catalogItemId hide">
+            <div class="name">Catalog Item</div>
+            <div class="value"><a href="#v1/catalog/entities/<%= entity.get('catalogItemId')
%>"><%= entity.get('catalogItemId') %></a></div>
+        </div>
 
         <div class="additional-info-on-problem hide" style="margin-top: 12px;">
         </div>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/jsgui/src/main/webapp/assets/tpl/catalog/details-entity.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/catalog/details-entity.html b/usage/jsgui/src/main/webapp/assets/tpl/catalog/details-entity.html
index 133e746..b8bc86f 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/catalog/details-entity.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/catalog/details-entity.html
@@ -19,8 +19,12 @@ under the License.
 <div class="catalog-details">
 
     <h2><%- model.get("name") %></h2>
-    <p><%- model.get("registeredType") %></p>
-    <p><%- model.get("description") %></p>
+    <% if (model.get("registeredType") && (model.get("name") != model.get("registeredType")))
{ %>
+        <p><%- model.get("registeredType") %></p>
+    <% } %>
+    <% if (model.get("description")) { %>
+        <p><%- model.get("description") %></p>
+    <% } %>
 
     <div id="catalog-details-accordion" class="accordion">
       <% if (model.get("planYaml")) { %>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
index 5d1ca9b..f77daa4 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/api/ServerApi.java
@@ -74,7 +74,7 @@ public interface ServerApi {
     @Deprecated /** @deprecated since 0.7.0 use /ha/node (which returns correct JSON) */
     @GET
     @Path("/status")
-    @ApiOperation(value = "Returns the status of this Brooklyn instance",
+    @ApiOperation(value = "Returns the status of this Brooklyn instance [DEPRECATED; see
../ha/state]",
         responseClass = "String",
         multiValueResponse = false)
     public String getStatus();
@@ -82,7 +82,7 @@ public interface ServerApi {
     @Deprecated /** @deprecated since 0.7.0 use /ha/states */
     @GET
     @Path("/highAvailability")
-    @ApiOperation(value = "Returns the status of all Brooklyn instances in the management
plane",
+    @ApiOperation(value = "Returns the status of all Brooklyn instances in the management
plane [DEPRECATED; see ../ha/states]",
         responseClass = "brooklyn.rest.domain.HighAvailabilitySummary")
     public HighAvailabilitySummary getHighAvailability();
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java
index 6ec84e5..3118986 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/EntitySummary.java
@@ -19,7 +19,10 @@
 package brooklyn.rest.domain;
 
 import com.google.common.collect.ImmutableMap;
+
 import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 
 import java.net.URI;
 import java.util.Map;
@@ -29,17 +32,21 @@ public class EntitySummary implements HasId, HasName {
   private final String id;
   private final String name;
   private final String type;
+  @JsonSerialize(include=Inclusion.NON_NULL)
+  private final String catalogItemId;
   private final Map<String, URI> links;
 
   public EntitySummary(
       @JsonProperty("id") String id,
       @JsonProperty("name") String name,
       @JsonProperty("type") String type,
+      @JsonProperty("catalogItemId") String catalogItemId,
       @JsonProperty("links") Map<String, URI> links
   ) {
     this.type = type;
     this.id = id;
     this.name = name;
+    this.catalogItemId = catalogItemId;
     this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links);
   }
 
@@ -57,6 +64,10 @@ public class EntitySummary implements HasId, HasName {
     return name;
   }
   
+  public String getCatalogItemId() {
+    return catalogItemId;
+}
+  
   public Map<String, URI> getLinks() {
     return links;
   }
@@ -75,6 +86,9 @@ public class EntitySummary implements HasId, HasName {
   public String toString() {
     return "EntitySummary{" +
         "id='" + id + '\'' +
+        ", name=" + name +
+        ", type=" + type +
+        ", catalogItemId=" + catalogItemId +
         ", links=" + links +
         '}';
   }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java
index 42c670e..cf7df6b 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/domain/PolicySummary.java
@@ -21,6 +21,8 @@ package brooklyn.rest.domain;
 import com.google.common.collect.ImmutableMap;
 
 import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 
 import java.net.URI;
 import java.util.Map;
@@ -29,17 +31,21 @@ public class PolicySummary implements HasName, HasId {
 
   private final String id;
   private final String name;
+  @JsonSerialize(include=Inclusion.NON_NULL)
+  private final String catalogItemId;
   private final Status state;
   private final Map<String, URI> links;
 
   public PolicySummary(
       @JsonProperty("id") String id,
       @JsonProperty("name") String name,
+      @JsonProperty("catalogItemId") String catalogItemId,
       @JsonProperty("state") Status state,
       @JsonProperty("links") Map<String, URI> links
   ) {
     this.id = id;
     this.name = name;
+    this.catalogItemId = catalogItemId;
     this.state = state;
     this.links = (links == null) ? ImmutableMap.<String, URI>of() : ImmutableMap.copyOf(links);
   }
@@ -54,6 +60,10 @@ public class PolicySummary implements HasName, HasId {
     return name;
   }
 
+  public String getCatalogItemId() {
+    return catalogItemId;
+  }
+  
   public Status getState() {
     return state;
   }
@@ -89,6 +99,7 @@ public class PolicySummary implements HasName, HasId {
     return "ConfigSummary{" +
         "name='" + name + '\'' +
         ", id='" + id + '\'' +
+        ", catalogItemId='" + catalogItemId + '\'' +
         ", links=" + links +
         '}';
   }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-api/src/test/java/brooklyn/rest/domain/EntitySummaryTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/test/java/brooklyn/rest/domain/EntitySummaryTest.java b/usage/rest-api/src/test/java/brooklyn/rest/domain/EntitySummaryTest.java
index 393bc3e..242be13 100644
--- a/usage/rest-api/src/test/java/brooklyn/rest/domain/EntitySummaryTest.java
+++ b/usage/rest-api/src/test/java/brooklyn/rest/domain/EntitySummaryTest.java
@@ -46,7 +46,7 @@ public class EntitySummaryTest {
   }
 
   static final EntitySummary entitySummary = new EntitySummary(
-          "zQsqdXzi", "MyTomcat", "brooklyn.entity.webapp.tomcat.TomcatServer", links);
+          "zQsqdXzi", "MyTomcat", "brooklyn.entity.webapp.tomcat.TomcatServer", null, links);
 
   @Test
   public void testSerializeToJSON() throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
index cfbbac6..caa26c6 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
@@ -212,6 +212,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements
Enti
       return result;
   }
 
+  @Override
   public String getSpec(String applicationToken,  String entityToken) {
       EntityLocal entity = brooklyn().getEntity(applicationToken, entityToken);
       NamedStringTag spec = BrooklynTags.findFirst(BrooklynTags.YAML_SPEC_KIND, entity.tags().getTags());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-server/src/main/java/brooklyn/rest/transform/EntityTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/EntityTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/EntityTransformer.java
index 9b717c9..0d2a64f 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/EntityTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/EntityTransformer.java
@@ -78,7 +78,7 @@ public class EntityTransformer {
         if (entity.getIconUrl()!=null)
             lb.put("iconUrl", URI.create(entityUri + "/icon"));
 
-        return new EntitySummary(entity.getId(), entity.getDisplayName(), type, lb.build());
+        return new EntitySummary(entity.getId(), entity.getDisplayName(), type, entity.getCatalogItemId(),
lb.build());
     }
 
     public static List<EntitySummary> entitySummaries(Iterable<? extends Entity>
entities) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e9c8c5ef/usage/rest-server/src/main/java/brooklyn/rest/transform/PolicyTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/transform/PolicyTransformer.java
b/usage/rest-server/src/main/java/brooklyn/rest/transform/PolicyTransformer.java
index e15c97f..0d9d9f0 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/transform/PolicyTransformer.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/transform/PolicyTransformer.java
@@ -54,7 +54,7 @@ public class PolicyTransformer {
                 .put("entity", URI.create(entityUri))
                 .build();
 
-        return new PolicySummary(policy.getId(), policy.getDisplayName(), ApplicationTransformer.statusFromLifecycle(Policies.getPolicyStatus(policy)),
links);
+        return new PolicySummary(policy.getId(), policy.getDisplayName(), policy.getCatalogItemId(),
ApplicationTransformer.statusFromLifecycle(Policies.getPolicyStatus(policy)), links);
     }
 
     public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils,
ApplicationSummary application, EntityLocal entity, Policy policy, ConfigKey<?> config)
{


Mime
View raw message