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