Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,7 @@ div.more-link {
div.more-link:hover {
background: #f0f0f0;
}

emph {
color: red;
}
Binary file added favicon.ico
Binary file not shown.
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" media="all"
href="css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="all"
Expand Down Expand Up @@ -29,6 +30,8 @@ <h1 class="title">Bugzilla Dashboard</h1>
<div id="reports" class="requires-login hide-while-loading">
<div class="container">
<div id="code-reviews"><h2>Things To Review</h2></div>
<div id="awaiting-input"><h2>Waiting for Input</h2></div>
<div id="mentored-bugs"><h2>Mentored Bugs</h2></div>
<div id="assigned-bugs"><h2>Assigned Bugs</h2></div>
<div id="reported-bugs"><h2>Reported Bugs</h2></div>
<div id="cc-bugs"><h2>CC'd Bugs</h2></div>
Expand All @@ -41,7 +44,10 @@ <h1 class="title">Bugzilla Dashboard</h1>
<p>Enter a user's Bugzilla information below. If you don't
provide a password, you'll only be able to see the user's
public bugs, and you also won't be able to use some of this
page's awesome functionality.</p>
page's awesome functionality. If you don't provide a mentor
identity, you will not be able to see the user's mentored bugs.</p>
<p><emph>Security notice</emph> Any password will be
sent without encryption.</p>
<table>
<tr>
<td>Bugzilla Username</td>
Expand All @@ -51,6 +57,10 @@ <h1 class="title">Bugzilla Dashboard</h1>
<td>Bugzilla Password</td>
<td><input type="password" class="password" id="login-password"/></td>
</tr>
<tr>
<td>Bugzilla Mentoring Nickname</td>
<td><input type="text" class="mentorname" id="login-mentorname"/></td>
</tr>
</table>
<br/>
<input type="submit" id="login-submit" value="View Dashboard"/>
Expand Down
15 changes: 12 additions & 3 deletions js/bugzilla.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Bugzilla = {
BASE_URL: "https://api-dev.bugzilla.mozilla.org/latest",
BASE_URL: "https://bugzilla.mozilla.org/rest",
BASE_UI_URL: "https://bugzilla.mozilla.org",
DEFAULT_OPTIONS: {
method: "GET"
Expand Down Expand Up @@ -27,9 +27,17 @@ var Bugzilla = {
options = newOptions;

function onLoad() {
var response = JSON.parse(xhr.responseText);
if (!response.error)
try {
var response = JSON.parse(xhr.responseText);
} catch (SyntaxError) {
console.error("Response is not JSON", xhr.responseText);
return;
}
if (!response.error) {
options.success(response);
} else {
console.error("Error from Bugzilla", response);
}
// TODO: We should really call some kind of error callback
// if this didn't work.
}
Expand All @@ -39,6 +47,7 @@ var Bugzilla = {

if (options.data)
url = url + "?" + this.queryString(options.data);

xhr.open(options.method, url);
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
Expand Down
113 changes: 83 additions & 30 deletions js/modules/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Require.modules["app/loader"] = function(exports, require) {
Require.modules["app/login"] = function(exports) {
var callbacks = [];
var username;
var mentorname;
var password;
var passwordProvider;

Expand All @@ -37,26 +38,39 @@ Require.modules["app/login"] = function(exports) {
exports.get = function get() {
var isLoggedIn = (username && username != "");
var isAuthenticated = (isLoggedIn && password && password != "");
var isMentor = (mentorname && mentorname != "");

return {
username: username,
password: password,
mentorname: mentorname,
isLoggedIn: isLoggedIn,
isAuthenticated: isAuthenticated
isAuthenticated: isAuthenticated,
isMentor: isMentor
};
};

exports.set = function set(newUsername, newPassword) {
exports.setUsername = function setUsername(newUsername) {
exports.set(newUsername, password, mentorname);
};
exports.setMentorname = function setMentorname(newMentorname) {
exports.set(username, password, newMentorname);
};

exports.set = function set(newUsername, newPassword, newMentorname) {
if ((newUsername && newUsername != "") &&
(newMentorname && newMentorname != "") &&
(!newPassword || newPassword == "") &&
(passwordProvider))
newPassword = passwordProvider(newUsername);

if (newUsername == username && newPassword == password)
if (newUsername == username && newPassword == password
&& newMentorname == mentorname)
return;

username = newUsername;
password = newPassword;
mentorname = newMentorname;

var info = exports.get();

Expand Down Expand Up @@ -155,7 +169,8 @@ Require.modules["app/ui/login-form"] = function(exports, require) {
function(event) {
event.preventDefault();
require("app/login").set($("#login .username").val(),
$("#login .password").val());
$("#login .password").val(),
$("#login .mentorname").val());
$("#login").fadeOut();
});

Expand Down Expand Up @@ -421,7 +436,15 @@ Require.modules["app/ui"] = function(exports, require) {
Require.modules["app/ui/hash"] = function(exports, require) {
function usernameFromHash(location) {
if (location.hash) {
var match = location.hash.match(/#username=(.*)/);
var match = location.hash.match(/[#&]username=([^&]*)/);
if (match)
return unescape(match[1]);
}
return "";
}
function mentornameFromHash(location) {
if (location.hash) {
var match = location.hash.match(/[#&]mentorname=([^&]*)/);
if (match)
return unescape(match[1]);
}
Expand All @@ -430,21 +453,29 @@ Require.modules["app/ui/hash"] = function(exports, require) {

function setLoginFromHash(location) {
var username = usernameFromHash(location);
var mentorname = mentornameFromHash(location);

var user = require("app/login").get();
if (user.username != username)
require("app/login").set(username);
require("app/login").setUsername(username);
if (user.mentorname != mentorname)
require("app/login").setMentorname(mentorname);

}

exports.usernameToHash = function usernameToHash(username) {
return "#username=" + escape(username);
exports.usernameToHash = function usernameToHash(username, mentorname) {
var prefix = "#username=" + escape(username);
if (mentorname)
return prefix + "&mentorname="+escape(mentorname);
else
return prefix;
};

exports.init = function init(document) {
require("app/login").whenChanged(
function(user) {
if (user.isLoggedIn) {
var hash = exports.usernameToHash(user.username);
var hash = exports.usernameToHash(user.username, user.mentorname);
if (document.location.hash != hash)
document.location.hash = hash;
} else
Expand Down Expand Up @@ -580,8 +611,9 @@ Require.modules["app/ui/dashboard"] = function(exports, require) {

function report(selector, key, forceUpdate, searchTerms) {
var newTerms = {__proto__: defaults};
for (name in searchTerms)
for (var name in searchTerms)
newTerms[name.replace(/_DOT_/g, ".")] = searchTerms[name];
newTerms["include_fields"]="id,priority,severity,summary,status,component,assignee,last_change_time";

var cacheKey = key + "/" + selector;
var cached = cache.get(cacheKey);
Expand Down Expand Up @@ -613,56 +645,77 @@ Require.modules["app/ui/dashboard"] = function(exports, require) {
changed_after: dateUtils.timeAgo(MS_PER_WEEK * 14)
};

function update(myUsername, isAuthenticated, forceUpdate) {
function update(myUsername, isAuthenticated, mentorName, forceUpdate) {
xhrQueue.clear();

var key = myUsername + "_" + (isAuthenticated ? "PRIVATE" : "PUBLIC");

report("#code-reviews", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
flag_DOT_requestee: myUsername});
f1: "requestees.login_name",
o1: "substring",
v1: myUsername});

report("#assigned-bugs", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
email1: myUsername,
email1_type: "equals",
email1_assigned_to: 1});
emailtype1: "exact",
emailassigned_to1: 1,
email1: myUsername});

report("#reported-bugs", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
email1: myUsername,
email1_type: "equals",
email1_creator: 1,
emailtype1: "exact",
emailreporter1: 1,
email2: myUsername,
email2_type: "not_equals",
email2_assigned_to: 1});
emailtype2: "notequals",
emailassigned_to2: 1});


report("#cc-bugs", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
email1: myUsername,
email1_type: "equals",
email1_cc: 1,
emailtype1: "exact",
emailcc1: 1,
email2: myUsername,
email2_type: "not_equals",
email2_assigned_to: 1,
email2_creator: 1});
emailtype2: "notequals",
emailreporter2: 1,
emailassigned_to2: 1});

report("#awaiting-input", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
f1: "setters.login_name",
o1: "equals",
v1: myUsername,
f2: "flagtypes.name",
o2: "anywords",
v2: "f? r? needinfo?"
});

report("#mentored-bugs", key, forceUpdate,
{status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
f1: "bug_mentor",
o1: "substring",
v1: myUsername,
});

report("#fixed-bugs", key, forceUpdate,
{resolution: ["FIXED"],
changed_after: dateUtils.timeAgo(MS_PER_WEEK),
email1: myUsername,
email1_type: "equals",
email1_assigned_to: 1,
email1_creator: 1,
email1_cc: 1});
emailtype1: "exact",
emailbug_mentor1: 1,
emailassigned_to1: 1,
emailcc1: 1,
});
};

var refreshCommand = {
name: "refresh-dashboard",
execute: function execute() {
var user = require("app/login").get();
if (user.isLoggedIn)
update(user.username, user.isAuthenticated, true);
update(user.username, user.isAuthenticated, user.mentorname, true);
}
};

Expand All @@ -671,7 +724,7 @@ Require.modules["app/ui/dashboard"] = function(exports, require) {
require("app/login").whenChanged(
function changeSearchCriteria(user) {
if (user.isLoggedIn) {
update(user.username, user.isAuthenticated, false);
update(user.username, user.isAuthenticated, user.mentorname, false);
}
});
};
Expand Down