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