brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [2/4] git commit: Standby jsguis redirect to the master if known
Date Mon, 02 Jun 2014 11:25:18 GMT
Standby jsguis redirect to the master if known


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

Branch: refs/heads/master
Commit: e095718e7e3933b91231fd2db0d350d83c4e2703
Parents: af1cada
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Fri May 30 18:52:43 2014 +0100
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Fri May 30 18:52:43 2014 +0100

----------------------------------------------------------------------
 usage/jsgui/src/main/webapp/assets/js/router.js        | 13 ++++++++++++-
 .../webapp/assets/tpl/home/server-not-ha-master.html   |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e095718e/usage/jsgui/src/main/webapp/assets/js/router.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/router.js b/usage/jsgui/src/main/webapp/assets/js/router.js
index 843f83b..573a703 100644
--- a/usage/jsgui/src/main/webapp/assets/js/router.js
+++ b/usage/jsgui/src/main/webapp/assets/js/router.js
@@ -169,12 +169,23 @@ define([
 
     var HaStandbyOverlay = Backbone.View.extend({
         template: _.template(ServerNotMasterHtml),
+        scheduledRedirect: false,
         initialize: function() {
             this.listenTo(ha, "change", this.render);
         },
         render: function() {
             if (!ha.isMaster()) {
-                this.$el.html(this.template({"masterUri": ha.getMasterUri()}));
+                var masterUri = ha.getMasterUri();
+                this.$el.html(this.template({"masterUri": masterUri}));
+                if (masterUri && !this.scheduledRedirect) {
+                    var destination = masterUri + "#" + Backbone.history.fragment;
+                    var time = 5;
+                    this.scheduledRedirect = true;
+                    console.log("Redirecting to " + destination + " in " + time + " seconds");
+                    setTimeout(function () {
+                        window.location.href = destination;
+                    }, time * 1000);
+                }
             } else {
                 this.$el.empty();
             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e095718e/usage/jsgui/src/main/webapp/assets/tpl/home/server-not-ha-master.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/home/server-not-ha-master.html b/usage/jsgui/src/main/webapp/assets/tpl/home/server-not-ha-master.html
index a2028b9..7f48790 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/home/server-not-ha-master.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/home/server-not-ha-master.html
@@ -5,7 +5,7 @@
         <p><strong>This Brooklyn server is not the high availability master.</strong></p>
         <p>You cannot use this server directly.</p>
     <% if (masterUri) { %>
-        <p>The master Brooklyn server is at: <a href="<%= masterUri %>"><%=
masterUri %></a></p>
+        <p>Redirecting to the master server at <a href="<%= masterUri %>"><%=
masterUri %></a> shortly.</p>
     <% } else { %>
         <p>The master Brooklyn server is not currently known.</p>
     <% } %>


Mime
View raw message