You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:52:17 UTC
[44/50] [abbrv] brooklyn-ui git commit: fix refresh for activities
fix refresh for activities
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/7405405b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/7405405b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/7405405b
Branch: refs/heads/0.5.0
Commit: 7405405ba4309712dad3888ca04744ab2dc7b1b5
Parents: 94c35f1
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Mar 11 15:29:23 2013 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Mar 11 15:32:39 2013 +0000
----------------------------------------------------------------------
.../webapp/assets/js/libs/brooklyn-utils.js | 23 +++------
.../webapp/assets/js/view/entity-activities.js | 53 ++++++++++----------
.../main/webapp/assets/tpl/apps/activities.html | 7 ---
.../assets/tpl/apps/activity-row-details.html | 2 +-
4 files changed, 33 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/7405405b/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-utils.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-utils.js b/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-utils.js
index e902158..bf29825 100644
--- a/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-utils.js
+++ b/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-utils.js
@@ -12,24 +12,13 @@ function count_occurrences(string, subString, allowOverlapping) {
return(n);
}
-function log(obj) {
+function log(args) {
if (typeof window.console != 'undefined') {
- console.log(obj);
- }
-}
-
-function log(obj1, obj2) {
- if (typeof window.console != 'undefined') {
- console.log(obj1);
- console.log(obj2);
- }
-}
-
-function log(obj1, obj2, obj3) {
- if (typeof window.console != 'undefined') {
- console.log(obj1);
- console.log(obj2);
- console.log(obj3);
+ console.log(args);
+ if (arguments.length>1) {
+ for (i=1; i<arguments.length; i++)
+ console.log(arguments[i])
+ }
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/7405405b/usage/jsgui/src/main/webapp/assets/js/view/entity-activities.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-activities.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-activities.js
index d3a9702..ce74bbb 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-activities.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-activities.js
@@ -15,6 +15,7 @@ define([
selectedRow:null,
events:{
"click #activities-table tr":"rowClick",
+ 'click .refresh':'refreshNow',
'click .toggleAutoRefresh':'toggleAutoRefresh',
'click .toggleFullDetail':'toggleFullDetail'
},
@@ -55,11 +56,14 @@ define([
that.collection.on("reset", that.render, that);
that.callPeriodically("entity-activities", function () {
- if (self.refreshActive)
+ if (that.refreshActive)
that.collection.fetch();
}, 3000);
that.collection.fetch();
},
+ refreshNow: function() {
+ this.collection.fetch();
+ },
beforeClose:function () {
this.collection.off("reset", this.render);
},
@@ -71,12 +75,9 @@ define([
},
render:function () {
var that = this;
- $('.expanded-node', that.table).remove()
if (that.table == null || this.collection.length==0) {
- $(".has-no-activities").show();
- $("#activity-details-none-selected").hide();
+ // nothing to do
} else {
- $(".has-no-activities").hide();
ViewUtils.updateMyDataTable(that.table, that.collection, function(task, index) {
return [
// columns are: id, name, when submitted, status
@@ -90,6 +91,7 @@ define([
// endTimeUtc:task.get("endTimeUtc"),
// entityDisplayName:task.get("entityDisplayName")
})
+ this.showDetailRow(true);
}
return this;
},
@@ -98,6 +100,7 @@ define([
// $(this).toggleClass('icon-chevron-down icon-chevron-right')
// var open = $(this).hasClass('icon-chevron-down')
+ var that = this;
var row = $(evt.currentTarget).closest("tr");
var id = row.attr("id");
@@ -107,28 +110,38 @@ define([
$("#activities-table tr").removeClass("selected");
- if (this.selectedRow!=null)
- this.table.fnClose(this.selectedRow);
+ if (this.selectedRow!=null) {
+ var r = this.selectedRow;
+ // slide it up, then close once it is hidden (else it vanishes suddenly)
+ // the slide effect isn't just cool, it helps keep rows in a visually consistent place
+ // (so that it doesn't just jump when you click, if a row above it was previously selected)
+ $('tr[#'+id+'] .activity-row-details').slideUp(50, "swing", function() {
+ that.table.fnClose(r);
+ })
+ }
if (this.selectedId == id) {
// deselected
this.selectedRow = null;
this.selectedId = null;
this.showFullActivity(null);
-
} else {
row.addClass("selected");
this.selectedRow = row[0];
this.selectedId = id;
this.table.fnOpen(row[0], '', 'row-expansion');
- this.showDetailRow();
+ this.showDetailRow(false);
}
},
- showDetailRow: function() {
- var task = this.collection.get(this.selectedId);
- var html = _.template(ActivityRowDetailsHtml, { task: task==null ? null : task.attributes })
- $('.row-expansion').html(html)
+ showDetailRow: function(updateOnly) {
+ var id = this.selectedId;
+ if (id==null) return;
+ var task = this.collection.get(id);
+ if (task==null) return;
+ var html = _.template(ActivityRowDetailsHtml, { task: task==null ? null : task.attributes, updateOnly: updateOnly })
+ $('tr#'+id).next().find('.row-expansion').html(html)
+ $('tr#'+id).next().find('.row-expansion .activity-row-details').slideDown(50);
},
toggleFullDetail: function() {
var i = $('.toggleFullDetail');
@@ -140,7 +153,6 @@ define([
},
showFullActivity: function() {
var id = this.selectedId
- $("#activity-details-none-selected").slideUp(50);
var task = this.collection.get(id);
if (task==null) {
this.hideFullActivity();
@@ -152,21 +164,8 @@ define([
},
hideFullActivity: function() {
$("#activity-details").slideUp(100);
- $("#activity-details-none-selected").slideDown(50);
}
});
-// ActivitiesView.Details = Backbone.View.extend({
-// tagName:"div",
-// className:"modal hide",
-// template:_.template(ActivityFullDetailsHtml),
-// render:function () {
-// this.$el.html(this.template({
-// displayName:this.model.get("displayName"),
-// description:FormatJSON(this.model.toJSON())
-// }));
-// return this;
-// }
-// });
return ActivitiesView;
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/7405405b/usage/jsgui/src/main/webapp/assets/tpl/apps/activities.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/activities.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/activities.html
index 622c058..7d2c159 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/activities.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/activities.html
@@ -14,13 +14,6 @@
<div> </div>
-<div class="has-no-activities for-empty-table hide">
- <i>No activities currently available on this entity</i>
-</div>
-
<div id="activity-details">
</div>
-<div id="activity-details-none-selected">
- <i>Select an entry above to view details.</i>
-</div>
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/7405405b/usage/jsgui/src/main/webapp/assets/tpl/apps/activity-row-details.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/activity-row-details.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/activity-row-details.html
index 553380f..6e99ac8 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/activity-row-details.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/activity-row-details.html
@@ -1,4 +1,4 @@
-<div class="activity-row-details">
+<div class="activity-row-details<% if (!updateOnly) { %> hide<% } %>">
<% if (task == null) { %> <i>No information available</i> <% } else { %>
<div style="float: right;" class="toolbar-row">
<!-- <a class="handy icon-book toggleLog"></a> -->