changeset 89:ee0a4597c067

Added a really basic error log that gets populated when the wrong username/pass is entered. Also, the username/password prompt for login now emphasizes the fact that it is a bugzilla login.
author Atul Varma <avarma@mozilla.com>
date Mon, 26 Apr 2010 17:45:02 -0700
parents 392fd25a6e21
children d48599d7a9ae
files css/main.css index.html js/modules/app.js
diffstat 3 files changed, 61 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/css/main.css	Mon Apr 26 16:41:32 2010 -0700
+++ b/css/main.css	Mon Apr 26 17:45:02 2010 -0700
@@ -116,6 +116,16 @@
     padding: 0.5em;
 }
 
+#errors {
+    display: none;
+    position: fixed;
+    left: 0px;
+    bottom: 0px;
+    padding: 1em;
+    background: #cc0033;
+    color: white;
+}
+
 .P1.critical, .P1.blocker {
     color: red;
 }
--- a/index.html	Mon Apr 26 16:41:32 2010 -0700
+++ b/index.html	Mon Apr 26 17:45:02 2010 -0700
@@ -44,11 +44,11 @@
   page's awesome functionality.</p>
   <table>
     <tr>
-      <td>Username</td>
+      <td>Bugzilla Username</td>
       <td><input type="text" class="username" id="login-username"/></td>
     </tr>
     <tr>
-      <td>Password</td>
+      <td>Bugzilla Password</td>
       <td><input type="password" class="password" id="login-password"/></td>
     </tr>
   </table>
@@ -102,7 +102,14 @@
   </form>
   </div>
 </div>
+<div id="errors"></div>
 <div id="templates">
+  <div class="errors">
+    <div class="bugzilla-api-error">I had trouble talking to Bugzilla.
+    Perhaps you entered the wrong username/password, or I
+    messed up.</div>
+    <div class="unknown-error">An unknown error occurred.</div>
+ </div>
   <div class="repair-success">Done. Try reloading this page and see
   if your problem is fixed.</div>
   <div class="repair-failure">Hey, that wasn't the right text.</div>
--- a/js/modules/app.js	Mon Apr 26 16:41:32 2010 -0700
+++ b/js/modules/app.js	Mon Apr 26 17:45:02 2010 -0700
@@ -54,7 +54,43 @@
   };
 };
 
+Require.modules["errors"] = function(exports, require) {
+  var $ = require("jQuery");
+
+  var errors = $("#errors");
+  var messages = $("#templates .errors");
+  var lastError = null;
+
+  exports.log = function log(name) {
+    var message = messages.find("." + name);
+    if (!message.length) {
+      exports.log("unknown-error");
+      return;
+    }
+    if (lastError == message.get(0))
+      return;
+    lastError = message.get(0);
+
+    message = message.clone();
+    errors.append(message);
+    if (errors.children().length == 1)
+      errors.fadeIn();
+    else
+      message.fadeIn();
+  };
+};
+
 Require.modules["app/bugzilla-auth"] = function(exports, require) {
+  function onLoad(event) {
+    var xhr = event.target;
+    console.log("load", xhr);
+  }
+
+  function onError(event) {
+    var xhr = event.target;
+    require("errors").log("bugzilla-api-error");
+  }
+
   exports.create = function(Bugzilla) {
     function AuthenticatedBugzilla() {
       this.ajax = function ajax(options) {
@@ -67,7 +103,12 @@
           options.data.password = user.password;
         }
 
-        return Bugzilla.ajax.call(this, options);
+        var xhr = Bugzilla.ajax.call(this, options);
+
+        xhr.addEventListener("load", onLoad, false);
+        xhr.addEventListener("error", onError, false);
+
+        return xhr;
       };
     }