From: Manolo Carrasco Date: Mon, 21 Jul 2014 12:21:40 +0000 (+0200) Subject: Export fetchRootConfig status so it can be read by TK (#14053) X-Git-Tag: 7.3.0.rc1~11^2~103 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7326935a82ac0ff8e5ec73c4863a47f4fb9ff682;p=vaadin-framework.git 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 --- 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) {