Mercurial > bugzilla-dashboard
annotate js/modules/app.js @ 90:d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 26 Apr 2010 18:16:56 -0700 |
parents | ee0a4597c067 |
children | e88fd29eee3a |
rev | line source |
---|---|
80 | 1 Require.modules["app/loader"] = function(exports, require) { |
2 exports.init = function init(moduleExports, options) { | |
3 var bugzilla = require("app/bugzilla-auth").create(options.Bugzilla); | |
4 moduleExports.bugzilla = bugzilla; | |
5 moduleExports.window = options.window; | |
82
03bf0a1b85da
made 'storage' point to sessionStorage instead of localStorage
Atul Varma <avarma@mozilla.com>
parents:
81
diff
changeset
|
6 moduleExports.storage = options.window.sessionStorage; |
80 | 7 moduleExports.jQuery = options.jQuery; |
8 | |
9 require("app/ui").init(options.window.document); | |
10 }; | |
11 }; | |
12 | |
41 | 13 Require.modules["app/login"] = function(exports) { |
14 var callbacks = []; | |
15 var username; | |
16 var password; | |
59
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
17 var passwordProvider; |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
18 |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
19 exports.setPasswordProvider = function setPasswordProvider(pp) { |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
20 passwordProvider = pp; |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
21 }; |
41 | 22 |
23 exports.whenChanged = function whenChanged(cb) { | |
24 callbacks.push(cb); | |
25 }; | |
26 | |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
27 exports.get = function get() { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
28 var isLoggedIn = (username && username != ""); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
29 var isAuthenticated = (isLoggedIn && password && password != ""); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
30 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
31 return { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
32 username: username, |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
33 password: password, |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
34 isLoggedIn: isLoggedIn, |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
35 isAuthenticated: isAuthenticated |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
36 }; |
41 | 37 }; |
38 | |
39 exports.set = function set(newUsername, newPassword) { | |
59
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
40 if ((newUsername && newUsername != "") && |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
41 (!newPassword || newPassword == "") && |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
42 (passwordProvider)) |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
43 newPassword = passwordProvider(newUsername); |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
44 |
41 | 45 if (newUsername == username && newPassword == password) |
46 return; | |
47 | |
48 username = newUsername; | |
49 password = newPassword; | |
50 | |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
51 var info = exports.get(); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
52 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
53 callbacks.forEach(function(cb) { cb(info); }); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
54 }; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
55 }; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
56 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
57 Require.modules["errors"] = function(exports, require) { |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
58 var $ = require("jQuery"); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
59 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
60 var errors = $("#errors"); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
61 var messages = $("#templates .errors"); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
62 var lastError = null; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
63 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
64 exports.log = function log(name) { |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
65 var message = messages.find("." + name); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
66 if (!message.length) { |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
67 exports.log("unknown-error"); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
68 return; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
69 } |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
70 if (lastError == message.get(0)) |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
71 return; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
72 lastError = message.get(0); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
73 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
74 message = message.clone(); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
75 errors.append(message); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
76 if (errors.children().length == 1) |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
77 errors.fadeIn(); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
78 else |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
79 message.fadeIn(); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
80 }; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
81 }; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
82 |
72
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
83 Require.modules["app/bugzilla-auth"] = function(exports, require) { |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
84 function onError(event) { |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
85 var xhr = event.target; |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
86 require("errors").log("bugzilla-api-error"); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
87 } |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
88 |
80 | 89 exports.create = function(Bugzilla) { |
90 function AuthenticatedBugzilla() { | |
91 this.ajax = function ajax(options) { | |
92 var user = require("app/login").get(); | |
58
f9001601bed6
authenticated users now get an authenticated dashboard w/ confidential bugs.
Atul Varma <avarma@mozilla.com>
parents:
56
diff
changeset
|
93 |
80 | 94 if (user.isAuthenticated) { |
95 if (!options.data) | |
96 options.data = {}; | |
97 options.data.username = user.username; | |
98 options.data.password = user.password; | |
99 } | |
58
f9001601bed6
authenticated users now get an authenticated dashboard w/ confidential bugs.
Atul Varma <avarma@mozilla.com>
parents:
56
diff
changeset
|
100 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
101 var xhr = Bugzilla.ajax.call(this, options); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
102 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
103 xhr.addEventListener("error", onError, false); |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
104 |
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.
Atul Varma <avarma@mozilla.com>
parents:
82
diff
changeset
|
105 return xhr; |
80 | 106 }; |
107 } | |
108 | |
109 AuthenticatedBugzilla.prototype = Bugzilla; | |
110 | |
111 return new AuthenticatedBugzilla(); | |
58
f9001601bed6
authenticated users now get an authenticated dashboard w/ confidential bugs.
Atul Varma <avarma@mozilla.com>
parents:
56
diff
changeset
|
112 }; |
f9001601bed6
authenticated users now get an authenticated dashboard w/ confidential bugs.
Atul Varma <avarma@mozilla.com>
parents:
56
diff
changeset
|
113 }; |
f9001601bed6
authenticated users now get an authenticated dashboard w/ confidential bugs.
Atul Varma <avarma@mozilla.com>
parents:
56
diff
changeset
|
114 |
68 | 115 Require.modules["app/commands"] = function(exports, require) { |
116 var commands = {}; | |
117 | |
118 exports.get = function get(name) { | |
119 if (!(name in commands)) | |
120 throw new Error("command not found: " + name); | |
121 return commands[name]; | |
122 }; | |
123 | |
124 exports.register = function(options) { | |
125 if (options.name in commands) | |
126 throw new Error("command already registered: " + options.name); | |
127 commands[options.name] = options; | |
128 }; | |
129 }; | |
130 | |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
131 Require.modules["app/ui/login-form"] = function(exports, require) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
132 var $ = require("jQuery"); |
59
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
133 var cachedUsername = $("#login .username").val(); |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
134 var cachedPassword = $("#login .password").val(); |
41 | 135 |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
136 $("#login form").submit( |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
137 function(event) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
138 event.preventDefault(); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
139 require("app/login").set($("#login .username").val(), |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
140 $("#login .password").val()); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
141 $("#login").fadeOut(); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
142 }); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
143 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
144 require("app/login").whenChanged( |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
145 function maybeChangeUsernameField(user) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
146 var usernameField = $("#login .username"); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
147 if (user.isLoggedIn && usernameField.val() != user.username) |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
148 usernameField.val(user.username); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
149 }); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
150 |
59
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
151 require("app/login").setPasswordProvider( |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
152 function maybeGetCachedPasswordFromForm(username) { |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
153 if (cachedUsername == username) |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
154 return cachedPassword; |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
155 return ""; |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
156 }); |
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
157 |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
158 exports.init = function init() { |
41 | 159 }; |
160 }; | |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
161 |
63 | 162 Require.modules["app/ui/file-bug"] = function(exports, require) { |
163 const EM_DASH = "\u2014"; | |
164 | |
165 var $ = require("jQuery"); | |
166 var cache = require("cache"); | |
80 | 167 var bugzilla = require("bugzilla"); |
63 | 168 var window = require("window"); |
169 var config = cache.get("configuration"); | |
170 var needToFetchConfig = config ? false : true; | |
171 var categories; | |
172 var queuedRespond; | |
173 | |
174 function buildCategories() { | |
175 categories = []; | |
176 for (product in config.product) | |
177 for (component in config.product[product].component) | |
178 categories.push(product + EM_DASH + component); | |
179 } | |
180 | |
181 function fetchConfig() { | |
182 bugzilla.ajax({url: "/configuration", | |
183 data: {flags: 0}, | |
184 success: function(result) { | |
185 config = result; | |
186 cache.set("configuration", result); | |
187 if (queuedRespond) | |
188 queuedRespond(); | |
189 }}); | |
190 } | |
191 | |
192 var categoryOptions = { | |
193 minLength: 2, | |
194 source: function(request, response) { | |
195 function respond() { | |
196 queuedRespond = null; | |
197 | |
198 var suggs = []; | |
199 var terms = request.term.split(" "); | |
200 | |
201 if (!categories) | |
202 buildCategories(); | |
203 | |
204 categories.forEach( | |
205 function(category) { | |
206 for (var i = 0; i < terms.length; i++) | |
207 if (!category.match(terms[i], "i")) | |
208 return; | |
209 suggs.push(category); | |
210 }); | |
211 | |
212 response(suggs); | |
213 }; | |
214 | |
215 if (!config) { | |
216 queuedRespond = respond; | |
217 if (needToFetchConfig) { | |
218 needToFetchConfig = false; | |
219 fetchConfig(); | |
220 } | |
221 } else | |
222 respond(); | |
223 } | |
224 }; | |
225 | |
78 | 226 $("#file-bug .category").autocomplete(categoryOptions); |
63 | 227 $("#file-bug").submit( |
228 function(event) { | |
229 event.preventDefault(); | |
78 | 230 var parts = $("#file-bug .category").val().split(EM_DASH); |
63 | 231 window.open(bugzilla.BASE_UI_URL + "/enter_bug.cgi?" + |
232 "product=" + escape(parts[0]) + "&" + | |
233 "component=" + escape(parts[1])); | |
234 }); | |
235 | |
236 exports.init = function init() { | |
237 }; | |
238 }; | |
239 | |
78 | 240 Require.modules["app/ui/repair"] = function(exports, require) { |
241 var $ = require("jQuery"); | |
242 | |
243 $("#repair form").submit( | |
244 function() { | |
245 var phrase = $("#repair .phrase").val(); | |
246 var response; | |
247 if (phrase == "repair my dashboard") { | |
248 require("cache").clear(); | |
249 response = $("#templates .repair-success").clone(); | |
250 } else | |
251 response = $("#templates .repair-failure").clone(); | |
252 $("#repair .result").empty().append(response); | |
253 $("#repair .result").hide().slideDown(); | |
254 }); | |
255 | |
256 exports.init = function init() { | |
257 }; | |
258 }; | |
259 | |
60
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
260 Require.modules["app/ui/find-user"] = function(exports, require) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
261 var $ = require("jQuery"); |
80 | 262 var bugzilla = require("bugzilla"); |
60
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
263 var window = require("window"); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
264 var currReq; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
265 |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
266 var options = { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
267 minLength: 2, |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
268 delay: 1000, |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
269 source: function(request, response) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
270 function success(result) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
271 currReq = null; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
272 var suggs = []; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
273 result.users.forEach( |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
274 function(user) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
275 suggs.push({label: user.real_name + " (" + user.name + ")", |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
276 value: user.name}); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
277 }); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
278 response(suggs); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
279 } |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
280 if (currReq) |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
281 currReq.abort(); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
282 currReq = bugzilla.ajax({url: "/user", |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
283 data: {match: request.term}, |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
284 success: success}); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
285 } |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
286 }; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
287 |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
288 $("#find-user .query").autocomplete(options); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
289 $("#find-user form").submit( |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
290 function(event) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
291 event.preventDefault(); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
292 var username = $("#find-user .query").val(); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
293 var url = require("app/ui/hash").usernameToHash(username); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
294 window.open(url); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
295 }); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
296 |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
297 exports.init = function init() { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
298 }; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
299 }; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
300 |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
301 Require.modules["app/ui"] = function(exports, require) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
302 var $ = require("jQuery"); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
303 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
304 require("app/login").whenChanged( |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
305 function changeUI(user) { |
54
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
306 var show = { |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
307 "no-login": false, |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
308 "login": false, |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
309 "auth-login": false, |
56
4728c2db6fd6
changed 'Log In' to 'Authenticate' if user is logged in but unauthenticated.
Atul Varma <avarma@mozilla.com>
parents:
55
diff
changeset
|
310 "no-auth": false, |
4728c2db6fd6
changed 'Log In' to 'Authenticate' if user is logged in but unauthenticated.
Atul Varma <avarma@mozilla.com>
parents:
55
diff
changeset
|
311 "no-auth-login": false |
54
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
312 }; |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
313 |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
314 if (user.isLoggedIn) { |
54
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
315 show["login"] = true; |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
316 if (user.isAuthenticated) |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
317 show["auth-login"] = true; |
56
4728c2db6fd6
changed 'Log In' to 'Authenticate' if user is logged in but unauthenticated.
Atul Varma <avarma@mozilla.com>
parents:
55
diff
changeset
|
318 else { |
54
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
319 show["no-auth"] = true; |
56
4728c2db6fd6
changed 'Log In' to 'Authenticate' if user is logged in but unauthenticated.
Atul Varma <avarma@mozilla.com>
parents:
55
diff
changeset
|
320 show["no-auth-login"] = true; |
4728c2db6fd6
changed 'Log In' to 'Authenticate' if user is logged in but unauthenticated.
Atul Varma <avarma@mozilla.com>
parents:
55
diff
changeset
|
321 } |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
322 } else { |
54
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
323 show["no-login"] = true; |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
324 show["no-auth"] = true; |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
325 } |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
326 |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
327 for (classSuffix in show) { |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
328 var query = $(".requires-" + classSuffix); |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
329 if (show[classSuffix]) |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
330 query.show(); |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
331 else |
1199b970c68b
present 'Log In' when user isn't authenticated
Atul Varma <avarma@mozilla.com>
parents:
53
diff
changeset
|
332 query.hide(); |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
333 } |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
334 }); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
335 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
336 $("#header .menu li").click( |
68 | 337 function onMenuItemClick(event) { |
338 if (this.hasAttribute("data-command")) { | |
339 var cmdName = this.getAttribute("data-command"); | |
340 require("app/commands").get(cmdName).execute(); | |
341 } else | |
342 openDialog(this.getAttribute("data-dialog")); | |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
343 }); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
344 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
345 $(".dialog").click( |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
346 function dismissDialogOnOutsideClick(event) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
347 if (event.target == this) |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
348 $(this).fadeOut(); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
349 }); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
350 |
64
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
351 function dismissDialogOnEscape(event) { |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
352 if (event.keyCode == 27) |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
353 $(this).fadeOut(); |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
354 } |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
355 |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
356 // For Safari. |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
357 $(".dialog").keyup(dismissDialogOnEscape); |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
358 // For Firefox. |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
359 $(".dialog").keypress(dismissDialogOnEscape); |
a196cc29fffb
ESC in dialog now makes it go away
Atul Varma <avarma@mozilla.com>
parents:
63
diff
changeset
|
360 |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
361 function setupDocumentTitleChanger(document) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
362 const BASE_TITLE = document.title; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
363 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
364 require("app/login").whenChanged( |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
365 function changeTitle(user) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
366 var title = BASE_TITLE; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
367 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
368 if (user.isLoggedIn) |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
369 title = user.username + "'s " + BASE_TITLE; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
370 |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
371 if (document.title != title) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
372 document.title = title; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
373 $("#header .title").text(title); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
374 } |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
375 }); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
376 }; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
377 |
65
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
378 function openDialog(name) { |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
379 var dialog = $("#" + name); |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
380 if (dialog.length == 0) |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
381 throw new Error("dialog not found: " + name); |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
382 dialog.fadeIn( |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
383 function() { |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
384 dialog.find("input:first").focus(); |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
385 }); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
386 }; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
387 |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
388 exports.init = function init(document) { |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
389 setupDocumentTitleChanger(document); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
390 |
78 | 391 require("app/ui/repair").init(); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
392 require("app/ui/dashboard").init(); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
393 require("app/ui/login-form").init(); |
60
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
394 require("app/ui/find-user").init(); |
63 | 395 require("app/ui/file-bug").init(); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
396 require("app/ui/hash").init(document); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
397 |
65
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
398 if (!require("app/login").get().isLoggedIn) |
8294f3d1efee
Startup dialog gains focus on open
Atul Varma <avarma@mozilla.com>
parents:
64
diff
changeset
|
399 openDialog("login"); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
400 }; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
401 }; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
402 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
403 Require.modules["app/ui/hash"] = function(exports, require) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
404 function usernameFromHash(location) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
405 if (location.hash) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
406 var match = location.hash.match(/#username=(.*)/); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
407 if (match) |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
408 return unescape(match[1]); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
409 } |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
410 return ""; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
411 } |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
412 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
413 function setLoginFromHash(location) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
414 var username = usernameFromHash(location); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
415 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
416 var user = require("app/login").get(); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
417 if (user.username != username) |
59
440c8e2d776d
dashboard now auto-authenticated via cached form field password on firefox, if available.
Atul Varma <avarma@mozilla.com>
parents:
58
diff
changeset
|
418 require("app/login").set(username); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
419 } |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
420 |
60
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
421 exports.usernameToHash = function usernameToHash(username) { |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
422 return "#username=" + escape(username); |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
423 }; |
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
424 |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
425 exports.init = function init(document) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
426 require("app/login").whenChanged( |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
427 function(user) { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
428 if (user.isLoggedIn) { |
60
07d3d1560b93
added find a user functionality
Atul Varma <avarma@mozilla.com>
parents:
59
diff
changeset
|
429 var hash = exports.usernameToHash(user.username); |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
430 if (document.location.hash != hash) |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
431 document.location.hash = hash; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
432 } else |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
433 document.location.hash = ""; |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
434 }); |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
435 |
53
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
436 var window = document.defaultView; |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
437 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
438 function onHashChange() { |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
439 setLoginFromHash(document.location); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
440 } |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
441 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
442 if ("onhashchange" in window) |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
443 window.addEventListener("hashchange", onHashChange, false); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
444 else |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
445 window.setInterval(onHashChange, 1000); |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
446 |
aa9b33b10820
dashboard responds to location.hash changes now.
Atul Varma <avarma@mozilla.com>
parents:
51
diff
changeset
|
447 onHashChange(); |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
448 }; |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
41
diff
changeset
|
449 }; |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
450 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
451 Require.modules["app/ui/dashboard"] = function(exports, require) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
452 var $ = require("jQuery"); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
453 var cache = require("cache"); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
454 var dateUtils = require("date-utils"); |
80 | 455 var bugzilla = require("bugzilla"); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
456 var window = require("window"); |
72
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
457 var xhrQueue = require("xhr/queue").create(); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
458 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
459 function sortByLastChanged(bugs) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
460 var lctimes = {}; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
461 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
462 bugs.forEach( |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
463 function(bug) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
464 lctimes[bug.id] = dateUtils.dateFromISO8601(bug.last_change_time); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
465 }); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
466 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
467 function compare(a, b) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
468 var alc = lctimes[a.id]; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
469 var blc = lctimes[b.id]; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
470 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
471 if (alc < blc) |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
472 return -1; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
473 if (alc > blc) |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
474 return 1; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
475 return 0; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
476 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
477 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
478 bugs.sort(compare); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
479 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
480 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
481 function updatePrettyDates(query) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
482 query.find(".last-changed").each( |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
483 function() { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
484 var lcTime = $(this).attr("data-last-change"); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
485 $(this).text(dateUtils.prettyDate(lcTime)); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
486 }); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
487 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
488 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
489 const PRETTY_DATE_UPDATE_INTERVAL = 1000 * 60; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
490 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
491 window.setInterval(function() { updatePrettyDates($("#reports")); }, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
492 PRETTY_DATE_UPDATE_INTERVAL); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
493 |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
494 const BUGS_TO_SHOW = 10; |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
495 |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
496 function showBugs(query, bugs) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
497 var table = $("#templates .bugs").clone(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
498 var rowTemplate = table.find(".bug-row").remove(); |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
499 |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
500 function appendRowForBug(bug) { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
501 var row = rowTemplate.clone(); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
502 row.attr("id", "bug-id-" + bug.id); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
503 row.find(".summary").text(bug.summary); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
504 row.addClass("status-" + bug.status); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
505 if (bug.priority != "--") { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
506 row.addClass(bug.priority); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
507 row.addClass(bug.severity); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
508 } |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
509 row.find(".last-changed").attr("data-last-change", |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
510 bug.last_change_time); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
511 |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
512 row.click( |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
513 function onClick() { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
514 window.open(bugzilla.getShowBugURL(bug.id)); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
515 }); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
516 |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
517 row.hover( |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
518 function onIn() { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
519 var tooltip = $("#templates .bug-tooltip").clone(); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
520 tooltip.find(".priority").text(bug.priority); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
521 // TODO: Show more information in tooltip. |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
522 $(this).append(tooltip); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
523 }, |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
524 function onOut() { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
525 $(this).find(".bug-tooltip").remove(); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
526 }); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
527 |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
528 table.append(row); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
529 } |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
530 |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
531 sortByLastChanged(bugs); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
532 bugs.reverse(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
533 |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
534 var extraBugs = bugs.slice(BUGS_TO_SHOW); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
535 bugs = bugs.slice(0, BUGS_TO_SHOW); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
536 |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
537 bugs.forEach(appendRowForBug); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
538 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
539 updatePrettyDates(table); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
540 query.find(".bugs").remove(); |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
541 query.find(".more-link").remove(); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
542 query.append(table); |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
543 |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
544 if (extraBugs.length) { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
545 var moreLink = $("#templates .more-link").clone(); |
74
1a0a3abbba93
more links now have # next to them
Atul Varma <avarma@mozilla.com>
parents:
73
diff
changeset
|
546 moreLink.find(".number").text(extraBugs.length); |
73
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
547 moreLink.click( |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
548 function() { |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
549 moreLink.remove(); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
550 extraBugs.forEach(appendRowForBug); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
551 updatePrettyDates(table); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
552 removeDuplicateBugs(); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
553 }); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
554 query.append(moreLink); |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
555 } |
1cd66cabe153
Added a 'more...' link at the bottom of columns that have more than 10 bugs.
Atul Varma <avarma@mozilla.com>
parents:
72
diff
changeset
|
556 |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
557 table.hide(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
558 removeDuplicateBugs(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
559 table.fadeIn(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
560 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
561 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
562 // Remove duplicate bugs, preferring the first listing of a bug in |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
563 // the DOM to later ones. This is b/c the reports further down the |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
564 // page are the less "interesting" ones, and we want to capture |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
565 // the most "interesting" part of each bug. |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
566 function removeDuplicateBugs() { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
567 var visited = {}; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
568 $("#reports .bug-row").each( |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
569 function() { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
570 var id = $(this).attr("id"); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
571 if (id in visited) |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
572 $(this).remove(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
573 else |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
574 visited[id] = true; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
575 }); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
576 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
577 |
79
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
578 function report(selector, key, forceUpdate, searchTerms) { |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
579 var newTerms = {__proto__: defaults}; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
580 for (name in searchTerms) |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
581 newTerms[name.replace(/_DOT_/g, ".")] = searchTerms[name]; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
582 |
67
d0f5f87e0b0a
dashboard stores per-user data in cache now.
Atul Varma <avarma@mozilla.com>
parents:
65
diff
changeset
|
583 var cacheKey = key + "/" + selector; |
d0f5f87e0b0a
dashboard stores per-user data in cache now.
Atul Varma <avarma@mozilla.com>
parents:
65
diff
changeset
|
584 var cached = cache.get(cacheKey); |
79
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
585 if (cached) { |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
586 showBugs($(selector), cached); |
79
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
587 if (!forceUpdate) |
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
588 return; |
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
589 } |
a6ad06a2dbc1
don't refresh data on page reload; only when user clicks 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
78
diff
changeset
|
590 |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
591 $(selector).find("h2").addClass("loading"); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
592 |
72
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
593 xhrQueue.enqueue( |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
594 function() { |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
595 return bugzilla.search( |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
596 newTerms, |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
597 function(response) { |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
598 cache.set(cacheKey, response.bugs); |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
599 showBugs($(selector), response.bugs); |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
600 $(selector).find("h2").removeClass("loading"); |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
601 }); |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
602 }); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
603 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
604 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
605 function timeAgo(ms) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
606 var now = new Date(); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
607 var then = new Date(now - ms); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
608 return dateUtils.dateToISO8601(then); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
609 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
610 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
611 const MS_PER_HOUR = 1000 * 60 * 60; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
612 const MS_PER_DAY = MS_PER_HOUR * 24; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
613 const MS_PER_WEEK = MS_PER_DAY * 7; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
614 |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
615 var defaults = { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
616 changed_after: timeAgo(MS_PER_WEEK * 14) |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
617 }; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
618 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
619 function update(myUsername, isAuthenticated, forceUpdate) { |
72
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
620 xhrQueue.clear(); |
0eab9a3ff12f
replaced my last commit w/ a serial xhr queue, so that the dashboard requests are serialized but other ones aren't.
Atul Varma <avarma@mozilla.com>
parents:
71
diff
changeset
|
621 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
622 var key = myUsername + "_" + (isAuthenticated ? "PRIVATE" : "PUBLIC"); |
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
623 |
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
624 report("#code-reviews", key, forceUpdate, |
71
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
625 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
626 flag_DOT_requestee: myUsername}); |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
627 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
628 report("#assigned-bugs", key, forceUpdate, |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
629 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
630 email1: myUsername, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
631 email1_type: "equals", |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
632 email1_assigned_to: 1}); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
633 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
634 report("#reported-bugs", key, forceUpdate, |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
635 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
636 email1: myUsername, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
637 email1_type: "equals", |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
638 email1_reporter: 1, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
639 email2: myUsername, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
640 email2_type: "not_equals", |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
641 email2_assigned_to: 1}); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
642 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
643 report("#cc-bugs", key, forceUpdate, |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
644 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
645 email1: myUsername, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
646 email1_type: "equals", |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
647 email1_cc: 1, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
648 email2: myUsername, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
649 email2_type: "not_equals", |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
650 email2_assigned_to: 1, |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
651 email2_reporter: 1}); |
71
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
652 |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
653 report("#fixed-bugs", key, forceUpdate, |
71
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
654 {resolution: ["FIXED"], |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
655 changed_after: timeAgo(MS_PER_WEEK), |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
656 email1: myUsername, |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
657 email1_type: "equals", |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
658 email1_assigned_to: 1, |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
659 email1_reporter: 1, |
4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
Atul Varma <avarma@mozilla.com>
parents:
68
diff
changeset
|
660 email1_cc: 1}); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
661 }; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
662 |
68 | 663 var refreshCommand = { |
664 name: "refresh-dashboard", | |
665 execute: function execute() { | |
666 var user = require("app/login").get(); | |
667 if (user.isLoggedIn) | |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
668 update(user.username, user.isAuthenticated, true); |
68 | 669 } |
670 }; | |
671 | |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
672 exports.init = function init() { |
68 | 673 require("app/commands").register(refreshCommand); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
674 require("app/login").whenChanged( |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
675 function changeSearchCriteria(user) { |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
676 if (user.isLoggedIn) { |
90
d48599d7a9ae
Fixed a bug where users going from unauthenticated -> authenticated wouldn't see their private bugs unless they hit 'refresh'
Atul Varma <avarma@mozilla.com>
parents:
89
diff
changeset
|
677 update(user.username, user.isAuthenticated, false); |
47
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
678 } |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
679 }); |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
680 }; |
0b71df72ebe1
integrated dashboard into main.html.
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
681 }; |