summaryrefslogtreecommitdiffstats
path: root/extensions/MyDashboard
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/MyDashboard')
-rw-r--r--extensions/MyDashboard/lib/Queries.pm3
-rw-r--r--extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl15
-rw-r--r--extensions/MyDashboard/web/js/flags.js135
-rw-r--r--extensions/MyDashboard/web/js/mydashboard.js306
-rw-r--r--extensions/MyDashboard/web/js/mydashboard_yui2.js159
-rw-r--r--extensions/MyDashboard/web/js/prod_comp_search.js127
-rw-r--r--extensions/MyDashboard/web/js/query.js114
7 files changed, 543 insertions, 316 deletions
diff --git a/extensions/MyDashboard/lib/Queries.pm b/extensions/MyDashboard/lib/Queries.pm
index a0419c7b2..cbba3b468 100644
--- a/extensions/MyDashboard/lib/Queries.pm
+++ b/extensions/MyDashboard/lib/Queries.pm
@@ -121,7 +121,6 @@ sub QUERY_DEFS {
foreach my $q (@{$user->queries}) {
next if !$q->in_mydashboard;
push(@query_defs, { name => $q->name,
- heading => $q->name,
saved => 1,
params => $q->url });
}
@@ -186,7 +185,7 @@ sub query_flags {
attachments.description AS attach_summary,
requesters.realname AS requester,
requestees.realname AS requestee,
- " . $dbh->sql_date_format('flags.creation_date', '%Y:%m:%d') . " AS created
+ " . $dbh->sql_date_format('flags.creation_date', '%Y:-%m-%d %H:%i') . " AS created
FROM flags
LEFT JOIN attachments
ON ($attach_join_clause)
diff --git a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
index b85ba3cc8..d7cdb0d28 100644
--- a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
+++ b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
@@ -10,8 +10,11 @@
[% PROCESS global/header.html.tmpl
title = "My Dashboard"
- style_urls = [ "extensions/MyDashboard/web/styles/mydashboard.css",
- "extensions/MyDashboard/web/styles/prod_comp_search.css" ]
+ style_urls = [ "extensions/MyDashboard/web/styles/mydashboard.css" ]
+ javascript_urls = [ "js/yui3/yui/yui-min.js",
+ "extensions/MyDashboard/web/js/query.js",
+ "extensions/MyDashboard/web/js/flags.js",
+ "extensions/MyDashboard/web/js/prod_comp_search.js" ]
%]
[% standard_queries = [] %]
@@ -21,10 +24,6 @@
[% saved_queries.push(q) IF q.saved %]
[% END %]
-<script src="http://yui.yahooapis.com/3.7.3/build/yui/yui-min.js"></script>
-[%# These need to load after yui-min.js %]
-<script type="text/javascript" src="[% 'extensions/MyDashboard/web/js/mydashboard.js' FILTER mtime FILTER html %]"></script>
-
<div id="mydashboard">
<div class="yui3-skin-sam">
<div id="left">
@@ -33,12 +32,12 @@
<select id="query" name="query">
<optgroup id="standard_queries" label="Standard">
[% FOREACH r = standard_queries %]
- <option value="[% r.name FILTER html %]">[% r.heading FILTER html %]</option>
+ <option value="[% r.name FILTER html %]">[% r.heading || r.name FILTER html %]</option>
[% END%]
</optgroup>
<optgroup id="saved_queries" label="Saved">
[% FOREACH r = saved_queries %]
- <option value="[% r.name FILTER html %]">[% r.heading FILTER html %]</option>
+ <option value="[% r.name FILTER html %]">[% r.heading || r.name FILTER html %]</option>
[% END %]
</optgroup>
</select>
diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js
new file mode 100644
index 000000000..b1605e04e
--- /dev/null
+++ b/extensions/MyDashboard/web/js/flags.js
@@ -0,0 +1,135 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0.
+ */
+
+// Flag tables
+YUI({
+ base: 'js/yui3/',
+ combine: false
+}).use("node", "datatable", "datatable-sort", "json-stringify",
+ "datatable-datasource", "datasource-io", "datasource-jsonschema", function (Y) {
+ // Common
+ var counter = 0;
+ var dataSource = {
+ requestee: null,
+ requester: null
+ };
+ var dataTable = {
+ requestee: null,
+ requester: null
+ };
+
+ var updateFlagTable = function (type) {
+ if (!type) return;
+
+ counter = counter + 1;
+
+ var callback = {
+ success: function(e) {
+ if (e.response) {
+ Y.one("#" + type + "_flags_found").setHTML(
+ e.response.results.length + ' flags found');
+ Y.one("#" + type + "_container .status").addClass('bz_default_hidden');
+ dataTable[type].set('data', e.response.results);
+ dataTable[type].render("#" + type + "_table");
+ }
+ },
+ failure: function(o) {
+ var resp = o.responseText;
+ alert("IO request failed : " + resp);
+ }
+ };
+
+ var json_object = {
+ version: "1.1",
+ method: "MyDashboard.run_flag_query",
+ id: counter,
+ params: { type : type }
+ };
+
+ var stringified = Y.JSON.stringify(json_object);
+
+ Y.one("#" + type + "_container .status").removeClass('bz_default_hidden');
+
+ dataSource[type].sendRequest({
+ request: stringified,
+ cfg: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ },
+ callback: callback
+ });
+ };
+
+ // Requestee
+ dataSource.requestee = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+ dataTable.requestee = new Y.DataTable({
+ columns: [
+ { key:"requester", label:"Requester", sortable:true },
+ { key:"type", label:"Flag", sortable:true },
+ { key:"bug_id", label:"Bug", sortable:true,
+ formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
+ { key:"created", label:"Created", sortable:true }
+ ],
+ strings: {
+ emptyMessage: 'No flag data found.',
+ }
+ });
+
+ dataTable.requestee.plug(Y.Plugin.DataTableSort);
+
+ dataTable.requestee.plug(Y.Plugin.DataTableDataSource, {
+ datasource: dataSource,
+ initialRequest: updateFlagTable("requestee"),
+ });
+
+ dataSource.requestee.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.requestee",
+ resultFields: ["requester", "type", "bug_id", "created"]
+ }
+ });
+
+ dataTable.requestee.render("#requestee_table");
+
+ Y.one('#requestee_refresh').on('click', function(e) {
+ updateFlagTable('requestee');
+ });
+
+ // Requester
+ dataSource.requester = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+ dataTable.requester = new Y.DataTable({
+ columns: [
+ { key:"requestee", label:"Requestee", sortable:true },
+ { key:"type", label:"Flag", sortable:true },
+ { key:"bug_id", label:"Bug", sortable:true,
+ formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
+ { key:"created", label:"Created", sortable:true }
+ ],
+ strings: {
+ emptyMessage: 'No flag data found.',
+ }
+ });
+
+ dataTable.requester.plug(Y.Plugin.DataTableSort);
+
+ dataTable.requester.plug(Y.Plugin.DataTableDataSource, {
+ datasource: dataSource,
+ initialRequest: updateFlagTable("requester"),
+ });
+
+ dataSource.requester.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.requester",
+ resultFields: ["requestee", "type", "bug_id", "created"]
+ }
+ });
+
+ Y.one('#requester_refresh').on('click', function(e) {
+ updateFlagTable('requester');
+ });
+});
diff --git a/extensions/MyDashboard/web/js/mydashboard.js b/extensions/MyDashboard/web/js/mydashboard.js
deleted file mode 100644
index 1383c28e5..000000000
--- a/extensions/MyDashboard/web/js/mydashboard.js
+++ /dev/null
@@ -1,306 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0.
- */
-
-// Main query code
-YUI().use("node", "datatable", "datatable-sort", "json-stringify",
- "datatable-datasource", "datasource-io", "datasource-jsonschema",
- "gallery-paginator-view", "gallery-datatable-paginator", function (Y) {
- var counter = 0,
- dataSource = null,
- dataTable = null;
-
- var updateQueryTable = function(query_name) {
- if (!query_name) return;
-
- counter = counter + 1;
-
- var callback = {
- success: function(e) {
- if (e.response) {
- Y.one("#query_container .query_description").setHTML(e.response.meta.description);
- Y.one("#query_container .query_heading").setHTML(e.response.meta.heading);
- Y.one("#query_bugs_found").setHTML(
- '<a href="buglist.cgi?' + e.response.meta.buffer +
- '">' + e.response.results.length + ' bugs found</a>');
- Y.one("#query_container .status").addClass('bz_default_hidden');
- dataTable.set('data', e.response.results);
- dataTable.render("#query_table");
- }
- },
- failure: function(o) {
- var resp = o.responseText;
- alert("IO request failed : " + resp);
- }
- };
-
- var json_object = {
- version: "1.1",
- method: "MyDashboard.run_bug_query",
- id: counter,
- params: { query : query_name }
- };
-
- var stringified = Y.JSON.stringify(json_object);
-
- Y.one("#query_container .status").removeClass('bz_default_hidden');
-
- dataSource.sendRequest({
- request: stringified,
- cfg: {
- method: "POST",
- headers: { 'Content-Type': 'application/json' }
- },
- callback: callback
- });
- };
-
- dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- dataTable = new Y.DataTable({
- columns: [
- { key:"bug_id", label:"Bug", sortable:true,
- formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
- { key:"changeddate", label:"Updated", sortable:true },
- { key:"bug_status", label:"Status", sortable:true },
- { key:"short_desc", label:"Summary", sortable:true },
- ],
- strings: {
- emptyMessage: 'No query data found.',
- },
- paginator: new Y.PaginatorView({
- container: '#query_pagination_top'
- })
- });
-
- dataTable.plug(Y.Plugin.DataTableSort);
-
- dataTable.plug(Y.Plugin.DataTableDataSource, {
- datasource: dataSource,
- initialRequest: updateQueryTable("assignedbugs"),
- });
-
- dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.bugs",
- resultFields: ["bug_id", "changeddate", "bug_status", "short_desc"],
- metaFields: {
- description: "result.result.description",
- heading: "result.result.heading",
- buffer: "result.result.buffer"
- }
- }
- });
-
- Y.one('#query').on('change', function(e) {
- var index = e.target.get('selectedIndex');
- var selected_value = e.target.get("options").item(index).getAttribute('value');
- updateQueryTable(selected_value);
- });
-
- Y.one('#query_refresh').on('click', function(e) {
- var query_select = Y.one('#query');
- var index = query_select.get('selectedIndex');
- var selected_value = query_select.get("options").item(index).getAttribute('value');
- updateQueryTable(selected_value);
- });
-});
-
-// Flag tables
-YUI().use("node", "datatable", "datatable-sort", "json-stringify",
- "datatable-datasource", "datasource-io", "datasource-jsonschema", function (Y) {
- // Common
- var counter = 0;
- var dataSource = {
- requestee: null,
- requester: null
- };
- var dataTable = {
- requestee: null,
- requester: null
- };
-
- var updateFlagTable = function (type) {
- if (!type) return;
-
- counter = counter + 1;
-
- var callback = {
- success: function(e) {
- if (e.response) {
- Y.one("#" + type + "_flags_found").setHTML(
- e.response.results.length + ' flags found');
- Y.one("#" + type + "_container .status").addClass('bz_default_hidden');
- dataTable[type].set('data', e.response.results);
- dataTable[type].render("#" + type + "_table");
- }
- },
- failure: function(o) {
- var resp = o.responseText;
- alert("IO request failed : " + resp);
- }
- };
-
- var json_object = {
- version: "1.1",
- method: "MyDashboard.run_flag_query",
- id: counter,
- params: { type : type }
- };
-
- var stringified = Y.JSON.stringify(json_object);
-
- Y.one("#" + type + "_container .status").removeClass('bz_default_hidden');
-
- dataSource[type].sendRequest({
- request: stringified,
- cfg: {
- method: "POST",
- headers: { 'Content-Type': 'application/json' }
- },
- callback: callback
- });
- };
-
- // Requestee
- dataSource.requestee = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- dataTable.requestee = new Y.DataTable({
- columns: [
- { key:"requester", label:"Requester", sortable:true },
- { key:"flag", label:"Flag", sortable:true },
- { key:"bug_id", label:"Bug", sortable:true,
- formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
- { key:"changeddate", label:"Updated", sortable:true },
- { key:"created", label:"Created", sortable:true }
- ],
- strings: {
- emptyMessage: 'No flag data found.',
- }
- });
-
- dataTable.requestee.plug(Y.Plugin.DataTableSort);
-
- dataTable.requestee.plug(Y.Plugin.DataTableDataSource, {
- datasource: dataSource,
- initialRequest: updateFlagTable("requestee"),
- });
-
- dataSource.requestee.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.requestee",
- resultFields: ["requester", "flag", "bug_id", "created"]
- }
- });
-
- dataTable.requestee.render("#requestee_table");
-
- Y.one('#requestee_refresh').on('click', function(e) {
- updateFlagTable('requestee');
- });
-
- // Requester
- dataSource.requester = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- dataTable.requester = new Y.DataTable({
- columns: [
- { key:"requestee", label:"Requestee", sortable:true },
- { key:"flag", label:"Flag", sortable:true },
- { key:"bug_id", label:"Bug", sortable:true,
- formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
- { key:"created", label:"Created", sortable:true }
- ],
- strings: {
- emptyMessage: 'No flag data found.',
- }
- });
-
- dataTable.requester.plug(Y.Plugin.DataTableSort);
-
- dataTable.requester.plug(Y.Plugin.DataTableDataSource, {
- datasource: dataSource,
- initialRequest: updateFlagTable("requester"),
- });
-
- dataSource.requester.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.requester",
- resultFields: ["requestee", "flag", "bug_id", "created"]
- }
- });
-
- Y.one('#requester_refresh').on('click', function(e) {
- updateFlagTable('requester');
- });
-});
-
-YUI().use("node", "json-stringify", "autocomplete", "autocomplete-highlighters",
- "datasource-io", "datasource-jsonschema", function (Y) {
- var counter = 0,
- format = '',
- cloned_bug_id = '',
- dataSource = null,
- autoComplete = null;
-
- var generateRequest = function (enteredText) {
- counter = counter + 1;
- var json_object = {
- version: "1.1",
- method : "MyDashboard.prod_comp_search",
- id : counter,
- params : { search: enteredText }
- };
- Y.one("#prod_comp_throbber").removeClass('bz_default_hidden');
- return Y.JSON.stringify(json_object);
- };
-
- var resultListFormat = function(oResultData, enteredText, sResultMatch) {
- return Y.Lang.escapeHTML(oResultData[0]) + " :: " +
- Y.Lang.escapeHTML(oResultData[1]);
- };
-
- var dataSource = new Y.DataSource.IO({
- source: 'jsonrpc.cgi',
- connTimeout: 30000,
- connMethodPost: true,
- connXhrMode: 'cancelStaleRequests',
- maxCacheEntries: 5,
- responseSchema: {
- resultsList : "result.products",
- metaFields : { error: "error", jsonRpcId: "id"},
- fields : [ "product", "component" ]
- }
- });
-
- Y.one('#prod_comp_search').plug(Y.Plugin.AutoComplete, {
- resultHighlighter: 'phraseMatch',
- source: dataSource,
- minQueryLength: 3,
- queryDelay: 0.05,
- generateRequest: generateRequest,
- formatResult: resultListFormat,
- maxResultsDisplayed: 25,
- suppressInputUpdate: true,
- doBeforeLoadData: function(sQuery, oResponse, oPayload) {
- Y.one("#prod_comp_throbber").addClass('bz_default_hidden');
- return true;
- }
- });
-
-// autoComplete.textboxFocusEvent.subscribe(function () {
-// var input = Y.one(field);
-// if (input.value && input.value.length > 3) {
-// sendQuery(input.value);
-// }
-// });
-//
-// autoComplete.itemSelectEvent.subscribe(function (e, args) {
-// var oData = args[2];
-// var url = "enter_bug.cgi?product=" + encodeURIComponent(oData[0]) +
-// "&component=" + encodeURIComponent(oData[1]);
-// autoComplete.dataReturnEvent.subscribe(function(type, args) {
-// args[0].autoHighlight = args[2].length == 1;
-// });
-// });
-});
diff --git a/extensions/MyDashboard/web/js/mydashboard_yui2.js b/extensions/MyDashboard/web/js/mydashboard_yui2.js
new file mode 100644
index 000000000..25529d8c8
--- /dev/null
+++ b/extensions/MyDashboard/web/js/mydashboard_yui2.js
@@ -0,0 +1,159 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0.
+ */
+
+YAHOO.namespace('MyDashboard');
+
+var MD = YAHOO.MyDashboard;
+
+MD.showQuerySection = function () {
+ var query_select = YAHOO.util.Dom.get('query');
+ var selected_value = '';
+ for (var i = 0, l = query_select.options.length; i < l; i++) {
+ if (query_select.options[i].selected) {
+ selected_value = query_select.options[i].value;
+ }
+ }
+ for (var i = 0, l = MD.full_query_list.length; i < l; i++) {
+ var query = MD.full_query_list[i];
+ if (selected_value == MD.full_query_list[i]) {
+ YAHOO.util.Dom.removeClass(query + '_container', 'bz_default_hidden');
+ }
+ else {
+ YAHOO.util.Dom.addClass(query + '_container', 'bz_default_hidden');
+ }
+ }
+}
+
+MD.query_column_defs = [
+ { key:"id", label:"ID", sortable:true, sortOptions:{ sortFunction: MD.sortBugIdLinks } },
+ { key:"updated", label:"Updated", sortable:true },
+ { key:"bug_status", label:"Status", sortable:true },
+ { key:"summary", label:"Summary", sortable:true },
+];
+
+MD.query_fields = [
+ { key:"id" },
+ { key:"updated" },
+ { key:"bug_status" },
+ { key:"summary" }
+];
+
+MD.requestee_column_defs = [
+ { key:"requester", label:"Requester", sortable:true },
+ { key:"flag", label:"Flag", sortable:true },
+ { key:"bug", label:"Bug", sortable:true },
+ { key:"created", label:"Created", sortable:true }
+];
+
+MD.requestee_fields = [
+ { key:"requester" },
+ { key:"flag" },
+ { key:"bug" },
+ { key:"created" }
+];
+
+MD.requester_column_defs = [
+ { key:"requestee", label:"Requestee", sortable:true },
+ { key:"flag", label:"Flag", sortable:true },
+ { key:"bug", label:"Bug", sortable:true },
+ { key:"created", label:"Created", sortable:true }
+];
+
+MD.requester_fields = [
+ { key:"requestee" },
+ { key:"flag" },
+ { key:"bug" },
+ { key:"created" }
+];
+
+MD.addStatListener = function (div_name, table_name, column_defs, fields, options) {
+ YAHOO.util.Event.addListener(window, "load", function() {
+ YAHOO.example.StatsFromMarkup = new function() {
+ this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get(table_name));
+ this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
+ this.myDataSource.responseSchema = { fields:fields };
+ this.myDataTable = new YAHOO.widget.DataTable(div_name, column_defs, this.myDataSource, options);
+ this.myDataTable.subscribe("rowMouseoverEvent", this.myDataTable.onEventHighlightRow);
+ this.myDataTable.subscribe("rowMouseoutEvent", this.myDataTable.onEventUnhighlightRow);
+ };
+ });
+}
+
+// Custom sort handler to sort by bug id inside an anchor tag
+MD.sortBugIdLinks = function (a, b, desc) {
+ // Deal with empty values
+ if (!YAHOO.lang.isValue(a)) {
+ return (!YAHOO.lang.isValue(b)) ? 0 : 1;
+ }
+ else if(!YAHOO.lang.isValue(b)) {
+ return -1;
+ }
+ // Now we need to pull out the ID text and convert to Numbers
+ // First we do 'a'
+ var container = document.createElement("bug_id_link");
+ container.innerHTML = a.getData("id");
+ var anchors = container.getElementsByTagName("a");
+ var text = anchors[0].textContent;
+ if (text === undefined) text = anchors[0].innerText;
+ var new_a = new Number(text);
+ // Then we do 'b'
+ container.innerHTML = b.getData("id");
+ anchors = container.getElementsByTagName("a");
+ text = anchors[0].textContent;
+ if (text == undefined) text = anchors[0].innerText;
+ var new_b = new Number(text);
+
+ if (!desc) {
+ return YAHOO.util.Sort.compare(new_a, new_b);
+ }
+ else {
+ return YAHOO.util.Sort.compare(new_b, new_a);
+ }
+}
+
+// Custom sort handler for bug severities
+MD.sortBugSeverity = function (a, b, desc) {
+ // Deal with empty values
+ if (!YAHOO.lang.isValue(a)) {
+ return (!YAHOO.lang.isValue(b)) ? 0 : 1;
+ }
+ else if(!YAHOO.lang.isValue(b)) {
+ return -1;
+ }
+
+ var new_a = new Number(MD.severities[YAHOO.lang.trim(a.getData('bug_severity'))]);
+ var new_b = new Number(MD.severities[YAHOO.lang.trim(b.getData('bug_severity'))]);
+
+ if (!desc) {
+ return YAHOO.util.Sort.compare(new_a, new_b);
+ }
+ else {
+ return YAHOO.util.Sort.compare(new_b, new_a);
+ }
+}
+
+// Custom sort handler for bug priorities
+MD.sortBugPriority = function (a, b, desc) {
+ // Deal with empty values
+ if (!YAHOO.lang.isValue(a)) {
+ return (!YAHOO.lang.isValue(b)) ? 0 : 1;
+ }
+ else if(!YAHOO.lang.isValue(b)) {
+ return -1;
+ }
+
+ var new_a = new Number(MD.priorities[YAHOO.lang.trim(a.getData('priority'))]);
+ var new_b = new Number(MD.priorities[YAHOO.lang.trim(b.getData('priority'))]);
+
+ if (!desc) {
+ return YAHOO.util.Sort.compare(new_a, new_b);
+ }
+ else {
+ return YAHOO.util.Sort.compare(new_b, new_a);
+ }
+}
diff --git a/extensions/MyDashboard/web/js/prod_comp_search.js b/extensions/MyDashboard/web/js/prod_comp_search.js
new file mode 100644
index 000000000..db9d47c5c
--- /dev/null
+++ b/extensions/MyDashboard/web/js/prod_comp_search.js
@@ -0,0 +1,127 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0.
+ */
+
+// Product and component search to file a new bug
+YUI({
+ base: 'js/yui3/',
+ combine: false
+}).use("node", "json-stringify", "autocomplete", "escape",
+ "datasource-io", "datasource-jsonschema", "array-extras", function (Y) {
+ var counter = 0,
+ format = '',
+ cloned_bug_id = '',
+ dataSource = null,
+ autoComplete = null;
+
+ var resultListFormat = function(query, results) {
+ Y.log(results);
+ return Y.Array.map(results, function (result) {
+ var data = result.raw;
+ return Y.Escape.html(data.product) + " :: " +
+ Y.Escape.html(data.component);
+ });
+ };
+
+ var dataSource = new Y.DataSource.IO({
+ source: 'jsonrpc.cgi',
+ ioConfig: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ }
+ });
+
+ dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultsListLocator : "result.products",
+ resultFields : [ "product", "component" ]
+ }
+ });
+
+ var input = Y.one('#prod_comp_search');
+
+ input.plug(Y.Plugin.AutoComplete, {
+ enableCache: true,
+ source: dataSource,
+ minQueryLength: 3,
+ queryDelay: 0.05,
+ resultFormatter: resultListFormat,
+ maxResultsDisplayed: 25,
+ suppressInputUpdate: true,
+ maxResults: 25,
+ requestTemplate: function (query) {
+ counter = counter + 1;
+ var json_object = {
+ version: "1.1",
+ method : "MyDashboard.prod_comp_search",
+ id : counter,
+ params : { search: query }
+ };
+ return Y.JSON.stringify(json_object);
+ },
+// resultListLocator: 'response.result.products',
+// resultListLocator: 'result.products'
+// resultListLocator: function (response) {
+// Y.log(response);
+// return (response && response.data && response.data.result.products) || [];
+// },
+// // Makes sure an array is returned even on an error.
+// if (response.error) {
+// return [];
+// }
+//
+// Y.log(response);
+//
+// return response.query.results;
+//
+// return [{
+// product: "Foo",
+// component: "Bar"
+// }];
+// var query = response.query.results.json,
+// addresses;
+//
+// if (query.status !== 'OK') {
+// return [];
+// }
+//
+// // Grab the actual addresses from the YQL query.
+// addresses = query.results;
+//
+// // Makes sure an array is always returned.
+// return addresses.length > 0 ? addresses : [addresses];
+// },
+ });
+
+ input.ac.on('query', function() {
+ Y.one("#prod_comp_throbber").removeClass('bz_default_hidden');
+ });
+
+ input.ac.after('results', function() {
+ Y.one("#prod_comp_throbber").addClass('bz_default_hidden');
+ });
+
+ input.ac.on('select', function (itemNode, result) {
+ var url = "enter_bug.cgi?product=" + encodeURIComponent(result.component) +
+ "&component=" + encodeURIComponent(result.product);
+ Y.log(url);
+ //autoComplete.dataReturnEvent.subscribe(function(type, args) {
+ // args[0].autoHighlight = args[2].length == 1;
+ //});
+// doBeforeLoadData: function(sQuery, oResponse, oPayload) {
+// Y.one("#prod_comp_throbber").addClass('bz_default_hidden');
+// return true;
+// }
+ });
+
+// autoComplete.textboxFocusEvent.subscribe(function () {
+// var input = Y.one(field);
+// if (input.value && input.value.length > 3) {
+// sendQuery(input.value);
+// }
+// });
+});
diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js
new file mode 100644
index 000000000..e0ebc1f14
--- /dev/null
+++ b/extensions/MyDashboard/web/js/query.js
@@ -0,0 +1,114 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0.
+ */
+
+// Main query code
+YUI({
+ base: 'js/yui3/',
+ combine: false
+}).use("node", "datatable", "datatable-sort", "json-stringify",
+ "datatable-datasource", "datasource-io", "datasource-jsonschema",
+ "gallery-paginator-view", "gallery-datatable-paginator", function (Y) {
+ var counter = 0,
+ dataSource = null,
+ dataTable = null;
+
+ var updateQueryTable = function(query_name) {
+ if (!query_name) return;
+
+ counter = counter + 1;
+
+ var callback = {
+ success: function(e) {
+ if (e.response) {
+ Y.one("#query_container .query_description").setHTML(e.response.meta.description);
+ Y.one("#query_container .query_heading").setHTML(e.response.meta.heading);
+ Y.one("#query_bugs_found").setHTML(
+ '<a href="buglist.cgi?' + e.response.meta.buffer +
+ '">' + e.response.results.length + ' bugs found</a>');
+ Y.one("#query_container .status").addClass('bz_default_hidden');
+ dataTable.set('data', e.response.results);
+ dataTable.render("#query_table");
+ }
+ },
+ failure: function(o) {
+ var resp = o.responseText;
+ alert("IO request failed : " + resp);
+ }
+ };
+
+ var json_object = {
+ version: "1.1",
+ method: "MyDashboard.run_bug_query",
+ id: counter,
+ params: { query : query_name }
+ };
+
+ var stringified = Y.JSON.stringify(json_object);
+
+ Y.one("#query_container .status").removeClass('bz_default_hidden');
+
+ dataSource.sendRequest({
+ request: stringified,
+ cfg: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ },
+ callback: callback
+ });
+ };
+
+ dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+ dataTable = new Y.DataTable({
+ columns: [
+ { key:"bug_id", label:"Bug", sortable:true,
+ formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>', allowHTML: true },
+ { key:"changeddate", label:"Updated", sortable:true },
+ { key:"bug_status", label:"Status", sortable:true },
+ { key:"short_desc", label:"Summary", sortable:true },
+ ],
+ strings: {
+ emptyMessage: 'No query data found.',
+ },
+ paginator: new Y.PaginatorView({
+ model: new Y.PaginatorModel({ itemsPerPage: 25 }),
+ container: '#query_pagination_top',
+ })
+ });
+
+ dataTable.plug(Y.Plugin.DataTableSort);
+
+ dataTable.plug(Y.Plugin.DataTableDataSource, {
+ datasource: dataSource,
+ initialRequest: updateQueryTable("assignedbugs"),
+ });
+
+ dataSource.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.bugs",
+ resultFields: ["bug_id", "changeddate", "bug_status", "short_desc"],
+ metaFields: {
+ description: "result.result.description",
+ heading: "result.result.heading",
+ buffer: "result.result.buffer"
+ }
+ }
+ });
+
+ Y.one('#query').on('change', function(e) {
+ var index = e.target.get('selectedIndex');
+ var selected_value = e.target.get("options").item(index).getAttribute('value');
+ updateQueryTable(selected_value);
+ });
+
+ Y.one('#query_refresh').on('click', function(e) {
+ var query_select = Y.one('#query');
+ var index = query_select.get('selectedIndex');
+ var selected_value = query_select.get("options").item(index).getAttribute('value');
+ updateQueryTable(selected_value);
+ });
+});