include sensor actions in GUI table, as icons, populated from renderer hints


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

Branch: refs/heads/0.5.0
Commit: 8d99a20d37fdf9d375d9bdb3e5a4f83c2be4180e
Parents: 45e28c5
Author: Alex Heneveld <[email protected]>
Authored: Sat Dec 1 14:31:11 2012 -0800
Committer: Alex Heneveld <[email protected]>
Committed: Sat Dec 1 16:35:37 2012 -0800

----------------------------------------------------------------------
 .../src/main/webapp/assets/css/prettybrook.css   | 12 ++++++++++--
 .../main/webapp/assets/js/view/entity-sensors.js | 19 +++++++++++++------
 .../assets/tpl/app-add-wizard/modal-wizard.html  |  2 +-
 .../main/webapp/assets/tpl/apps/sensor-row.html  | 19 +++++++++++++++++--
 .../src/main/webapp/assets/tpl/apps/sensors.html |  2 +-
 5 files changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8d99a20d/usage/jsgui/src/main/webapp/assets/css/prettybrook.css
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/css/prettybrook.css 
b/usage/jsgui/src/main/webapp/assets/css/prettybrook.css
index a699234..11c2d0a 100644
--- a/usage/jsgui/src/main/webapp/assets/css/prettybrook.css
+++ b/usage/jsgui/src/main/webapp/assets/css/prettybrook.css
@@ -18,8 +18,8 @@
        margin-top: 40px;
        margin-bottom: 40px;
 }
-#application-content .modal-body {
-    padding: 0;
+.no-padding {
+    padding: 0 !important;
 }
 #application-content ul.nav-tabs {
     margin: 15px 15px 0px 15px;
@@ -72,6 +72,14 @@
 #application-content .template-lozenge .description {
        font-size: 85%;
 }
+#application-content .sensor-value {
+       font-weight: 700;
+       max-width: 500px;
+       max-height: 40px;
+       white-space: nowrap;
+       overflow-x: hidden;
+       overflow-y: scroll;
+}
 div#create-step-template-entries {
        width: 472px;
        margin-left: auto;

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8d99a20d/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js 
b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
index d9c150c..35b7c97 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
@@ -24,11 +24,18 @@ define([
             sensorsCollection.url = this.model.getLinkByName('sensors')
             var success = function () {
                 sensorsCollection.each(function (sensor) {
+                    var actions = {};
+                    _.each(sensor.get("links"), function(v,k) {
+                        if (k.slice(0, 7) == "action:") {
+                            actions[k.slice(7)] = v
+                        }
+                    })
                     $tableBody.append(that.sensorTemplate({
                         name:sensor.get("name"),
                         description:sensor.get("description"),
-                        value:'',
-                        type:sensor.get("type")
+                        actions:actions,
+                        type:sensor.get("type"),
+                        value:'' /* will be set later */
                     }))
                 })
                 that.updateSensorsPeriodically(that)
@@ -43,7 +50,7 @@ define([
             return this
         },
         toggleFilterEmpty: function() {
-            this.viewUtils.toggleFilterEmpty(this.$('#sensors-table'), 1)
+            this.viewUtils.toggleFilterEmpty(this.$('#sensors-table'), 2)
         },
         refreshSensors:function () {
             this.updateSensorsNow(this);  
@@ -58,14 +65,14 @@ define([
             // NB: this won't add new dynamic sensors
             var $table = this.$('#sensors-table');
             var url = that.model.getSensorUpdateUrl(),
-            $rows = that.$("tr.sensor-row")
-                $.get(url, function (data) {
+                $rows = that.$("tr.sensor-row")
+            $.get(url, function (data) {
                     // iterate over the sensors table and update each sensor
                     $rows.each(function (index,row) {
                         var key = $(this).find(".sensor-name").text()
                         var v = data[key]
                         if (v === undefined) v = ''
-                        $table.dataTable().fnUpdate(_.escape(v), row, 1)
+                        $table.dataTable().fnUpdate(_.escape(v), row, 2)
                     })
                 })
             }

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8d99a20d/usage/jsgui/src/main/webapp/assets/tpl/app-add-wizard/modal-wizard.html
----------------------------------------------------------------------
diff --git 
a/usage/jsgui/src/main/webapp/assets/tpl/app-add-wizard/modal-wizard.html 
b/usage/jsgui/src/main/webapp/assets/tpl/app-add-wizard/modal-wizard.html
index 540b37a..19f1874 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/app-add-wizard/modal-wizard.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/app-add-wizard/modal-wizard.html
@@ -5,7 +5,7 @@
     <p id="step_instructions">Instructions placeholder</p>
 </div>
 
-<div class="modal-body"></div>
+<div class="modal-body no-padding"></div>
 
 <div class="modal-footer">
     <button id="prev_step" type="button" class="btn btn-mini 
btn-info">Previous</button>

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8d99a20d/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-row.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-row.html 
b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-row.html
index 0ff2ca7..eaac4b7 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-row.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-row.html
@@ -2,8 +2,23 @@
     <td><span class="sensor-name" 
         rel="tooltip" title="<b><%= description %></b><br/>(<%= type %>)" 
data-placement="left"
         ><%= name %></span></td>
-    <td class="sensor-value"><%= value %></td>
     <td class="sensor-actions">
-        <!-- TODO return available actions e.g. open, jmx, etc (todo in REST 
api) -->
+        <% _.each(actions, function(v,k) {
+            var text=k
+            var icon=""
+            var title=""
+            if (k=="json") {
+                icon="icon-file"
+                title="JSON direct link"
+            }
+            if (k=="open") {
+                icon="icon-home"
+                title="Open URL"
+            }
+            if (icon!="") text=""
+        %>
+            <a href="<%= v %>" class="<%= icon %>" title="<%= title %>"><%= 
text %></a>
+        <% }) %>
     </td>
+    <td class="sensor-value"><%= value %></td>
 </tr>

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8d99a20d/usage/jsgui/src/main/webapp/assets/tpl/apps/sensors.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensors.html 
b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensors.html
index a826e79..4477901 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensors.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensors.html
@@ -2,8 +2,8 @@
     <thead>
     <tr>
         <th>Name</th>
-        <th>Value</th>
         <th>Actions</th>
+        <th>Value</th>
     </tr>
     </thead>
     <tbody></tbody>

Reply via email to