Mercurial > bugzilla-dashboard
changeset 78:4bb45ff5788a
added repair dialog
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 20:54:51 -0700 |
parents | 00d2584cdd7b |
children | a6ad06a2dbc1 |
files | index.html js/modules/app.js js/modules/cache.js |
diffstat | 3 files changed, 53 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/index.html Sun Apr 25 19:47:53 2010 -0700 +++ b/index.html Sun Apr 25 20:54:51 2010 -0700 @@ -19,10 +19,11 @@ class="requires-login"><span>Change User</span></li> <li data-command="refresh-dashboard" class="requires-login"><span>Refresh</span></li> + <li data-dialog="repair"><span>Repair</span></li> <li data-dialog="find-user" class="requires-auth-login"><span>Find A User</span></li> <li data-dialog="file-bug"><span>File A Bug</span></li> - </ul> + </ul> </div> <div id="loading-screen" class="loading"> </div> <div id="reports" class="requires-login hide-while-loading"> @@ -59,19 +60,31 @@ <div id="file-bug" class="dialog"> <div class="content"> <form id="file-bug"> - <p>Just type in part of a product or component below, select from + <p>Type in part of a product or component below, select from the auto-complete list, and press enter. You'll then get sent to a Bugzilla page where you can fill out a summary, description, and more details for the bug.</p> <table> <tr> <td>Category</td> - <td><input type="text" id="category"/></td> + <td><input type="text" class="category" id="file-bug-category"/></td> </tr> </table> </form> </div> </div> +<div id="repair" class="dialog"> + <div class="content"> + <form id="repair-form"> + <p>If this page isn't working as you expect, enter the + text “repair my dashboard” below and + press enter. Hopefully that will fix things.</p> + <br/> + <input type="text" class="phrase" id="repair-phrase"/> + </form> + <div class="result"></div> + </div> +</div> <div id="find-user" class="dialog"> <div class="content"> <form id="find-user-form"> @@ -90,6 +103,9 @@ </div> </div> <div id="templates"> + <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> <div class="more-link"><span class="number"></span> more…</div> <div class="bug-tooltip"> <div>
--- a/js/modules/app.js Sun Apr 25 19:47:53 2010 -0700 +++ b/js/modules/app.js Sun Apr 25 20:54:51 2010 -0700 @@ -173,11 +173,11 @@ } }; - $("input#category").autocomplete(categoryOptions); + $("#file-bug .category").autocomplete(categoryOptions); $("#file-bug").submit( function(event) { event.preventDefault(); - var parts = $("input#category").val().split(EM_DASH); + var parts = $("#file-bug .category").val().split(EM_DASH); window.open(bugzilla.BASE_UI_URL + "/enter_bug.cgi?" + "product=" + escape(parts[0]) + "&" + "component=" + escape(parts[1])); @@ -187,6 +187,26 @@ }; }; +Require.modules["app/ui/repair"] = function(exports, require) { + var $ = require("jQuery"); + + $("#repair form").submit( + function() { + var phrase = $("#repair .phrase").val(); + var response; + if (phrase == "repair my dashboard") { + require("cache").clear(); + response = $("#templates .repair-success").clone(); + } else + response = $("#templates .repair-failure").clone(); + $("#repair .result").empty().append(response); + $("#repair .result").hide().slideDown(); + }); + + exports.init = function init() { + }; +}; + Require.modules["app/ui/find-user"] = function(exports, require) { var $ = require("jQuery"); var bugzilla = require("app/bugzilla-auth").Bugzilla; @@ -318,6 +338,7 @@ exports.init = function init(document) { setupDocumentTitleChanger(document); + require("app/ui/repair").init(); require("app/ui/dashboard").init(); require("app/ui/login-form").init(); require("app/ui/find-user").init();
--- a/js/modules/cache.js Sun Apr 25 19:47:53 2010 -0700 +++ b/js/modules/cache.js Sun Apr 25 20:54:51 2010 -0700 @@ -1,6 +1,8 @@ Require.modules["cache"] = function(exports, require) { + const CACHE_NAME = "cache"; + var window = require("window"); - var cache = window.localStorage.getItem("cache"); + var cache = window.localStorage.getItem(CACHE_NAME); if (cache) cache = JSON.parse(cache); @@ -12,14 +14,20 @@ // Remove the key first, to get around a strange iPad // issue: http://stackoverflow.com/questions/2603682/is-anyone-else-receiving-a-quota-exceeded-err-on-their-ipad-when-accessing-locals - window.localStorage.removeItem("cache"); + window.localStorage.removeItem(CACHE_NAME); // TODO: We should really catch QUOTA_EXCEEDED_ERR here, // which could be thrown if the user is in private // browsing mode. - window.localStorage.setItem("cache", JSON.stringify(cache)); + window.localStorage.setItem(CACHE_NAME, JSON.stringify(cache)); }; + exports.get = function get(key) { return cache[key]; }; + + exports.clear = function clear() { + window.localStorage.removeItem(CACHE_NAME); + cache = {}; + }; };