Author: croberts
Date: 2011-05-26 15:42:48 +0000 (Thu, 26 May 2011)
New Revision: 4790
Modified:
trunk/cumin/python/cumin/widgets.strings
trunk/wooly/resources/wooly.js
Log:
To address BZ
https://bugzilla.redhat.com/show_bug.cgi?id=682447 we put an extra check
after the ajax call is made. In the event of a non-200 status code, we let the page
listeners know that the call failed. The page update listener has been updated to address
the failure status.
Modified: trunk/cumin/python/cumin/widgets.strings
===================================================================
--- trunk/cumin/python/cumin/widgets.strings 2011-05-26 13:30:41 UTC (rev 4789)
+++ trunk/cumin/python/cumin/widgets.strings 2011-05-26 15:42:48 UTC (rev 4790)
@@ -109,13 +109,14 @@
}
[CuminMainView.javascript]
- cumin.set_updated = function () {
+ cumin.set_updated = function (success) {
var updateStr;
+
var kiosk = wooly.session.branch()["kiosk"];
if (kiosk != null && kiosk != undefined)
- updateStr = "**Updated "
+ updateStr = success ? "**Updated " : "Last update failed
";
else
- updateStr = "Updated "
+ updateStr = success ? "Updated " : "Last update failed
";
$('heartbeat').set('text', updateStr + new
Date().format("%Y-%m-%d %H:%M:%S"));
$('shock').style.display = "none";
$('heartbeat').style.display = "inline";
@@ -125,9 +126,8 @@
cumin.myEffect = new Fx.Morph('heartbeat', {duration: 1000});
setTimeout(function () {cumin.myEffect.start({ 'color':
['#000000', '#666666'] })}, 500);
}
- wooly.addPageUpdateListener( function () {
- cumin.set_updated();
- });
+ wooly.addPageUpdateListener(cumin.set_updated);
+
cumin.expireIntervalUpdate = function () {
if (typeof cumin.expireID != "undefined") {
if (cumin.expireID) {
@@ -148,14 +148,14 @@
wooly.updateNow();
wooly.resumeIntervalUpdate();
cumin.expireIntervalUpdate();
- cumin.set_updated();
+ cumin.set_updated(true);
}
}, 30*60*1000);
};
};
cumin.expireIntervalUpdate();
window.addEvent('domready', function () {
- cumin.set_updated();
+ cumin.set_updated(true);
});
[CuminMainView.html]
Modified: trunk/wooly/resources/wooly.js
===================================================================
--- trunk/wooly/resources/wooly.js 2011-05-26 13:30:41 UTC (rev 4789)
+++ trunk/wooly/resources/wooly.js 2011-05-26 15:42:48 UTC (rev 4790)
@@ -328,49 +328,54 @@
}
this.updatePage = function(xml) {
- var child = xml.documentElement.firstChild;
-
- while (child) {
- if (child.nodeType == 1 && child.nodeName == "widget")
{
- var id = child.getAttribute("id");
- var oldElem = document.getElementById(id);
-
- if (oldElem) {
- var newElem = child.firstChild;
-
- while (newElem && newElem.nodeType != 1) {
- newElem = newElem.nextSibling;
- }
-
- if (newElem) {
- // only update a sub-block of html
-
- var updateId = newElem.getAttribute("update");
-
- if (updateId) {
- oldElem = document.getElementById(updateId);
- newElem = xmlGetElementById(newElem, updateId);
- }
-
- replaceNode(newElem, oldElem);
- } else {
- oldElem.parentNode.removeChild(oldElem);
- }
- } else {
- wooly.log("Element '" + id + "' not
found");
- }
- // find and execute any javascript
- executeJS(child);
- }
-
- child = child.nextSibling;
- }
-
+ var success = true;
+ if(xml == null) {
+ success = false;
+ } else {
+ var child = xml.documentElement.firstChild;
+
+ while (child) {
+ if (child.nodeType == 1 && child.nodeName == "widget")
{
+ var id = child.getAttribute("id");
+ var oldElem = document.getElementById(id);
+
+ if (oldElem) {
+ var newElem = child.firstChild;
+
+ while (newElem && newElem.nodeType != 1) {
+ newElem = newElem.nextSibling;
+ }
+
+ if (newElem) {
+ // only update a sub-block of html
+
+ var updateId = newElem.getAttribute("update");
+
+ if (updateId) {
+ oldElem = document.getElementById(updateId);
+ newElem = xmlGetElementById(newElem, updateId);
+ }
+
+ replaceNode(newElem, oldElem);
+ } else {
+ oldElem.parentNode.removeChild(oldElem);
+ }
+ } else {
+ wooly.log("Element '" + id + "' not
found");
+ }
+ // find and execute any javascript
+ executeJS(child);
+ }
+
+ child = child.nextSibling;
+ }
+ }
+
var len = wooly.pageUpdateListeners.length;
for (var i = 0; i < len; i++) {
- wooly.pageUpdateListeners[i]();
- }
+ wooly.pageUpdateListeners[i](success);
+ }
}
this.backgroundUpdate = function(url, callback, passback) {
@@ -436,6 +441,11 @@
callback(req.responseText, passback);
else
callback(req.responseXML, passback);
+ } else {
+ if(req.readyState == 4) {
+ //readyState == 4 means that the call is done...a non-200 status
means that something bad happened, call the callback with null for the XML
+ callback(null, passback);
+ }
}
} catch (e) {
log(e);