From c83361a7aee7a9edbd1924008ab1ed0e19493cc3 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 1 Sep 2010 12:06:05 -0400 Subject: [PATCH] Display error messages from the backend to the user. --- web_frontend/index.html | 1 + web_frontend/main.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/web_frontend/index.html b/web_frontend/index.html index 2ca064c..bccf5a0 100644 --- a/web_frontend/index.html +++ b/web_frontend/index.html @@ -5,6 +5,7 @@ +

List /

diff --git a/web_frontend/main.js b/web_frontend/main.js index 3ccbea5..75ae767 100644 --- a/web_frontend/main.js +++ b/web_frontend/main.js @@ -11,6 +11,7 @@ goog.provide('armadillo'); goog.require('goog.array'); goog.require('goog.dom'); +goog.require('goog.fx.dom.FadeInAndShow'); goog.require('goog.net.XhrIo'); goog.require('goog.Uri.QueryData'); @@ -44,8 +45,10 @@ armadillo.prototype.sendRequest_ = function(action, extra_data, callback) { */ armadillo.prototype.list = function(path) { var callback = function(e) { + app.clearError_(); var data = e.target.getResponseJson(); if (data['error']) { + app.showError_(data['message']); return; // Error. } // Unlisten all current listeners. @@ -122,3 +125,23 @@ armadillo.prototype.stripLastPathComponent_ = function(path) { } return '/'; }; + +/** + * Clears the error message. + */ +armadillo.prototype.clearError_ = function() { + var elm = goog.dom.getElement('error'); + goog.dom.setTextContent(elm, ''); + goog.dom.setProperties(elm, {'display':'none'}); +}; + +/** + * Shows an error message. + * @param {string} message + */ +armadillo.prototype.showError_ = function(message) { + this.clearError_(); + var elm = goog.dom.getElement('error'); + goog.dom.setTextContent(elm, message); + goog.fx.dom.FadeInAndShow(elm, 10.0); +}; -- 2.43.5