summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@vaadin.com>2014-07-21 14:21:40 +0200
committerVaadin Code Review <review@vaadin.com>2014-07-22 11:06:50 +0000
commit7326935a82ac0ff8e5ec73c4863a47f4fb9ff682 (patch)
treeadd68599fcdafd31d8c71b4bb885b0860eeb2333
parent6ae7843e46ee906adfc99bde71ded5f296caea74 (diff)
downloadvaadin-framework-7326935a82ac0ff8e5ec73c4863a47f4fb9ff682.tar.gz
vaadin-framework-7326935a82ac0ff8e5ec73c4863a47f4fb9ff682.zip
Export fetchRootConfig status so it can be read by TK (#14053)
Offline apps need to know when server errors are 500 or 400 in order to switch appropriatelly to the offline mode. Also we need exported the fetchRootConfig method and a reliable way to get loaded apps. Related with change I29635982514071e63221a9771d6729da14273ad3 [1] see temporal workaround in TouchKitServlet [1] https://dev.vaadin.com/review/#/c/4037/ Change-Id: I339ca697d035508a67d1eb24480cd12c4b9c6c0e
-rw-r--r--WebContent/VAADIN/vaadinBootstrap.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js
index df46d8bc72..ced077138f 100644
--- a/WebContent/VAADIN/vaadinBootstrap.js
+++ b/WebContent/VAADIN/vaadinBootstrap.js
@@ -101,7 +101,7 @@
return value;
};
- var fetchRootConfig = function() {
+ var fetchRootConfig = function(callback) {
log('Fetching root config');
var url = getConfig('browserDetailsUrl');
if (!url) {
@@ -141,6 +141,12 @@
r.open('POST', url, true);
r.onreadystatechange = function (aEvt) {
if (r.readyState == 4) {
+ // Save responseStatus so as Offline Applications know what happened
+ // when loading root configuration from server, and depending on the
+ // error status display an error message or the offline UI.
+ config.rootResponseStatus = r.status;
+ config.rootResponseText = r.responseText;
+
var text = r.responseText;
if (r.status == 200){
log("Got root config response", text);
@@ -166,6 +172,9 @@
appDiv.innerHTML = text;
appDiv.style['overflow'] = 'auto';
}
+
+ // Run the fetchRootConfig callback if present.
+ callback && callback(r);
}
};
// send parameters as POST data
@@ -177,7 +186,10 @@
//Export public data
var app = {
- 'getConfig': getConfig
+ getConfig: getConfig,
+ // Used when the app was started in offline, so as it is possible
+ // to defer root configuration loading until network is available.
+ fetchRootConfig: fetchRootConfig
};
apps[appId] = app;
@@ -224,9 +236,17 @@
return app;
},
clients: {},
+ getAppIds: function() {
+ var ids = [ ];
+ for (var id in apps) {
+ if (apps.hasOwnProperty(id)) {
+ ids.push(id);
+ }
+ }
+ return ids;
+ },
getApp: function(appId) {
- var app = apps[appId];
- return app;
+ return apps[appId];
},
loadTheme: loadTheme,
registerWidgetset: function(widgetset, callback) {