show caution dialog if shutting down or if server is unresponsive and include shutting down message in rest api. tested that i can stop and restart the server and it nicely cycles through sequence of: "shutting down", "server unreachable", then "starting up", then restores page.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/b06aa95a Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/b06aa95a Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/b06aa95a Branch: refs/heads/0.7.0-incubating Commit: b06aa95af8622e90160b619b4fa082c1aba43806 Parents: a889930 Author: Alex Heneveld <[email protected]> Authored: Mon Apr 27 14:30:26 2015 +0100 Committer: Alex Heneveld <[email protected]> Committed: Mon Apr 27 14:30:26 2015 +0100 ---------------------------------------------------------------------- .../assets/js/model/server-extended-status.js | 25 +++++++++++++++++--- usage/jsgui/src/main/webapp/assets/js/router.js | 18 +++++++++++--- .../src/main/webapp/assets/tpl/help/page.html | 5 ++-- .../webapp/assets/tpl/home/server-caution.html | 18 +++++++++++--- 4 files changed, 55 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b06aa95a/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js b/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js index 88e1ef2..2f5ccb3 100644 --- a/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js +++ b/usage/jsgui/src/main/webapp/assets/js/model/server-extended-status.js @@ -22,6 +22,20 @@ define(["backbone", "brooklyn", "view/viewutils"], function (Backbone, Brooklyn, callbacks: [], loaded: false, url: "/v1/server/up/extended", + onError: function(thiz,xhr,modelish) { + log("ServerExtendedStatus: error contacting Brooklyn server"); + log(xhr); + if (xhr.readyState==0) { + // server not contactable + this.loaded = false; + } else { + // server error + log(xhr.responseText); + // simply set unhealthy + this.set("healthy", false); + } + this.applyCallbacks(); + }, whenUp: function(f) { var that = this; if (this.isUp()) { @@ -48,6 +62,7 @@ define(["backbone", "brooklyn", "view/viewutils"], function (Backbone, Brooklyn, }, isUp: function() { return this.get("up") }, + isShuttingDown: function() { return this.get("shuttingDown") }, isHealthy: function() { return this.get("healthy") }, isMaster: function() { ha = this.get("ha") || {}; @@ -70,15 +85,19 @@ define(["backbone", "brooklyn", "view/viewutils"], function (Backbone, Brooklyn, return master.nodeUri; } }, + applyCallbacks: function() { + var currentCallbacks = this.callbacks; + this.callbacks = []; + _.invoke(currentCallbacks, "apply"); + }, }); var serverExtendedStatus = new ServerExtendedStatus(); serverExtendedStatus.on("sync", function() { serverExtendedStatus.loaded = true; - var currentCallbacks = serverExtendedStatus.callbacks; - serverExtendedStatus.callbacks = []; - _.invoke(currentCallbacks, "apply"); + serverExtendedStatus.applyCallbacks(); }); + serverExtendedStatus.on("error", serverExtendedStatus.onError); // Will returning the instance rather than the object be confusing? // It breaks the pattern used by all the other models. http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b06aa95a/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 4c7689a..8eb9c34 100644 --- a/usage/jsgui/src/main/webapp/assets/js/router.js +++ b/usage/jsgui/src/main/webapp/assets/js/router.js @@ -48,15 +48,22 @@ define([ var state = { loaded: serverStatus.loaded, up: serverStatus.isUp(), + shuttingDown: serverStatus.isShuttingDown(), healthy: serverStatus.isHealthy(), master: serverStatus.isMaster(), masterUri: serverStatus.getMasterUri(), }; - if (state.loaded && state.up && state.healthy && state.master) return this.renderEmpty(); + + if (state.loaded && state.up && state.healthy && state.master) { + // this div shows nothing in normal operation + return this.renderEmpty(); + } this.warningActive = true; this.$el.html(this.template(state)); - + $('#application-content').fadeTo(500,0.1); + this.$el.fadeTo(200,1); + $("#dismiss-standby-warning", this.$el).click(function() { that.carryOnRegardless = true; if (that.redirectPending) { @@ -91,8 +98,13 @@ define([ return this; }, renderEmpty: function() { + var that = this; this.warningActive = false; - this.$el.empty(); + this.$el.fadeTo(200,0.2, function() { + if (!that.warningActive) + that.$el.empty(); + }); + $('#application-content').fadeTo(200,1); return this; }, beforeClose: function() { http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b06aa95a/usage/jsgui/src/main/webapp/assets/tpl/help/page.html ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/tpl/help/page.html b/usage/jsgui/src/main/webapp/assets/tpl/help/page.html index 7d3ef0a..dc35b17 100644 --- a/usage/jsgui/src/main/webapp/assets/tpl/help/page.html +++ b/usage/jsgui/src/main/webapp/assets/tpl/help/page.html @@ -52,10 +52,11 @@ under the License. url:"/v1/server/shutdown", data: { stopAppsFirst: stopAppsFirst, shutdownTimeout: 0, requestTimeout: 0 }, success:function (data) { - $('#help-page').fadeTo(500,0.1); + // unfaded if server restarted, in router.js ServerCautionOverlay + $('#application-content').fadeTo(500,0.1); }, error: function(data) { - $('#help-page') + $('#application-content') .fadeTo(200,0.2) .delay(200).fadeTo(200,1) .delay(200).fadeTo(100,0.2) http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b06aa95a/usage/jsgui/src/main/webapp/assets/tpl/home/server-caution.html ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/tpl/home/server-caution.html b/usage/jsgui/src/main/webapp/assets/tpl/home/server-caution.html index 0f767c0..94bd622 100644 --- a/usage/jsgui/src/main/webapp/assets/tpl/home/server-caution.html +++ b/usage/jsgui/src/main/webapp/assets/tpl/home/server-caution.html @@ -27,16 +27,28 @@ under the License. <p><strong> Connecting to server...</strong></p> - <center><img src="/assets/images/throbber.gif"/></center> <p> No response from server (yet). - Please check your network connection, or if you are on a slow connection simply be patient! + Please check your network connection and the URL, or if you are on a slow connection simply be patient! This dialog will disappear if and when the server responds.</p> <p><i> If you understand the risks, that information may be unavailable and operations may fail, and wish to proceed regardless, click <a id="dismiss-standby-warning">here</a>.</i></p> +<% } else if (shuttingDown) { %> + <p><strong> + Server shutting down...</strong></p> + + <p> + The Brooklyn server is shutting down. + This dialog will disappear if and when the server is restarted at this address. + If in doubt, contact your system administrator.</p> + + <p><i> + If you understand the risks, that information may be unavailable and operations may fail, + and wish to proceed regardless, click <a id="dismiss-standby-warning">here</a>.</i></p> + <% } else if (!up) { %> <div style="float: right; position: relative; top: -45px; height: 0; overflow: visible;"> <img src="/assets/img/icon-status-starting.gif" width="60"/></div> @@ -50,7 +62,7 @@ under the License. This dialog will disappear when the server is ready.</p> <p><i> - If you understand the risks, that information may be unavailable and operations may fail, + If you understand the risks, that information may be incomplete and operations may fail, and wish to proceed regardless, click <a id="dismiss-standby-warning">here</a>.</i></p> <% } else if (healthy && !master) { %>
