view dashboard.js @ 2:5aa3693fe1ac

Replaced priority column w/ importance, added css styling for priority+severity components.
author Atul Varma <varmaa@toolness.com>
date Sun, 07 Mar 2010 14:51:03 -0800
parents bddbe7723643
children 11d242c482ca
line wrap: on
line source

$(window).ready(
  function() {
    function showBugs(query, bugs) {
      var table = $("#templates .bugs").clone();
      var rowTemplate = table.find(".bug-row").remove();
      bugs.reverse();
      bugs.forEach(
        function(bug) {
          var row = rowTemplate.clone();
          row.find(".summary").text(bug.summary);
          row.find(".summary").attr("href", 
                                    Bugzilla.getShowBugURL(bug.id));
          if (bug.priority != "--")
            row.find(".importance").text(bug.priority + NBSP +
                                         bug.severity)
                                   .addClass(bug.priority)
                                   .addClass(bug.severity);
          row.find(".last-changed").text(prettyDate(bug.last_change_time));
          table.append(row);
        });
      query.append(table);
    }

    function report(selector, searchTerms) {
      var newTerms = {__proto__: defaults};
      for (name in searchTerms)
        newTerms[name.replace(/_DOT_/g, ".")] = searchTerms[name];
      Bugzilla.search(newTerms,
                      function(response) {
                        showBugs($(selector),
                                 response.bugs);
                      });
    }

    function timeAgo(ms) {
      var now = new Date();
      var then = new Date(now - ms);
      return then.toLocaleFormat("%Y-%m-%d");
    }

    const NBSP = "\u00a0";
    const MS_PER_HOUR = 1000 * 60 * 60;
    const MS_PER_DAY =  MS_PER_HOUR * 24;
    const MS_PER_WEEK = MS_PER_DAY * 7;

    var defaults = {
      changed_after: timeAgo(MS_PER_WEEK * 14)
    };

    report("#assigned-bugs",
           {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
            email1: "avarma@mozilla.com",
            email1_type: "equals",
            email1_assigned_to: 1});

    report("#fixed-bugs",
           {resolution: ["FIXED"],
            changed_after: timeAgo(MS_PER_WEEK),
            email1: "avarma@mozilla.com",
            email1_type: "equals",
            email1_assigned_to: 1});

    report("#code-reviews",
           {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
            flag_DOT_requestee: "avarma@mozilla.com"});
  });