summaryrefslogtreecommitdiffstats
path: root/extensions/MyDashboard
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-05-17 22:19:36 +0200
committerDylan William Hardison <dylan@hardison.net>2017-05-17 23:07:31 +0200
commit3a372a916f3545d37390f692f24f7e1c4d5351b5 (patch)
tree2e0cd93ee1a897e196e86eedfa1233a37cbb2dae /extensions/MyDashboard
parent38b13ae3f1885faa0da1d0040a0dda87dc786515 (diff)
downloadbugzilla-3a372a916f3545d37390f692f24f7e1c4d5351b5.tar.gz
bugzilla-3a372a916f3545d37390f692f24f7e1c4d5351b5.tar.xz
Bug 1363803 - Consolidate YUI js and css into one js and one css file
Diffstat (limited to 'extensions/MyDashboard')
-rw-r--r--extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl6
-rw-r--r--extensions/MyDashboard/web/js/flags.js394
-rw-r--r--extensions/MyDashboard/web/js/query.js462
3 files changed, 433 insertions, 429 deletions
diff --git a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
index eda53ebe4..028d1b9b0 100644
--- a/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
+++ b/extensions/MyDashboard/template/en/default/pages/mydashboard.html.tmpl
@@ -11,10 +11,10 @@
[% PROCESS global/header.html.tmpl
title = "My Dashboard"
generate_api_token = 1
- style_urls = [ "extensions/MyDashboard/web/styles/mydashboard.css",
+ style_urls = [ "skins/yui3.css",
+ "extensions/MyDashboard/web/styles/mydashboard.css",
"extensions/ProdCompSearch/web/styles/prod_comp_search.css" ]
- yui = ["json", "connection"],
- javascript_urls = [ "js/yui3/yui/yui-min.js",
+ javascript_urls = [ "js/yui3.js",
"extensions/MyDashboard/web/js/query.js",
"extensions/MyDashboard/web/js/flags.js",
"extensions/ProdCompSearch/web/js/prod_comp_search.js",
diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js
index e8c175155..95b256708 100644
--- a/extensions/MyDashboard/web/js/flags.js
+++ b/extensions/MyDashboard/web/js/flags.js
@@ -7,224 +7,226 @@
*/
// Flag tables
-YUI({
- base: 'js/yui3/',
- combine: false
-}).use("node", "datatable", "datatable-sort", "json-stringify", "escape",
- "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 + '_count_refresh').removeClass('bz_default_hidden');
- Y.one("#" + type + "_flags_found").setHTML(
- e.response.results.length + ' flags found');
- dataTable[type].set('data', e.response.results);
+$(function () {
+ YUI({
+ base: 'js/yui3/',
+ combine: false
+ }).use("node", "datatable", "datatable-sort", "json-stringify", "escape",
+ "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 + '_count_refresh').removeClass('bz_default_hidden');
+ Y.one("#" + type + "_flags_found").setHTML(
+ e.response.results.length + ' flags found');
+ dataTable[type].set('data', e.response.results);
+ }
+ },
+ failure: function(o) {
+ if (o.error) {
+ alert("Failed to load flag list from Bugzilla:\n\n" + o.error.message);
+ } else {
+ alert("Failed to load flag list from Bugzilla.");
+ }
}
- },
- failure: function(o) {
- if (o.error) {
- alert("Failed to load flag list from Bugzilla:\n\n" + o.error.message);
- } else {
- alert("Failed to load flag list from Bugzilla.");
+ };
+
+ var json_object = {
+ version: "1.1",
+ method: "MyDashboard.run_flag_query",
+ id: counter,
+ params: { type : type,
+ Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
}
+ };
+
+ var stringified = Y.JSON.stringify(json_object);
+
+ Y.one('#' + type + '_count_refresh').addClass('bz_default_hidden');
+
+ dataTable[type].set('data', []);
+ dataTable[type].render("#" + type + "_table");
+ dataTable[type].showMessage('loadingMessage');
+
+ dataSource[type].sendRequest({
+ request: stringified,
+ cfg: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ },
+ callback: callback
+ });
+ };
+
+ var loadBugList = function(type) {
+ if (!type) return;
+ var data = dataTable[type].data;
+ var ids = [];
+ for (var i = 0, l = data.size(); i < l; i++) {
+ ids.push(data.item(i).get('bug_id'));
}
+ var url = 'buglist.cgi?bug_id=' + ids.join('%2C');
+ window.open(url, '_blank');
};
- var json_object = {
- version: "1.1",
- method: "MyDashboard.run_flag_query",
- id: counter,
- params: { type : type,
- Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
+ var bugLinkFormatter = function(o) {
+ var bug_closed = "";
+ if (o.data.bug_status == 'RESOLVED' || o.data.bug_status == 'VERIFIED') {
+ bug_closed = "bz_closed";
}
+ return '<a href="show_bug.cgi?id=' + encodeURIComponent(o.value) +
+ '" target="_blank" ' + 'title="' + Y.Escape.html(o.data.bug_status) + ' - ' +
+ Y.Escape.html(o.data.bug_summary) + '" class="' + Y.Escape.html(bug_closed) +
+ '">' + o.value + '</a>';
};
- var stringified = Y.JSON.stringify(json_object);
+ var updatedFormatter = function(o) {
+ return '<span title="' + Y.Escape.html(o.value) + '">' +
+ Y.Escape.html(o.data.updated_fancy) + '</span>';
+ };
- Y.one('#' + type + '_count_refresh').addClass('bz_default_hidden');
+ var requesteeFormatter = function(o) {
+ return o.value
+ ? Y.Escape.html(o.value)
+ : '<i>anyone</i>';
+ };
- dataTable[type].set('data', []);
- dataTable[type].render("#" + type + "_table");
- dataTable[type].showMessage('loadingMessage');
+ var flagNameFormatter = function(o) {
+ if (parseInt(o.data.attach_id)
+ && parseInt(o.data.is_patch)
+ && MyDashboard.splinter_base)
+ {
+ return '<a href="' + MyDashboard.splinter_base +
+ (MyDashboard.splinter_base.indexOf('?') == -1 ? '?' : '&') +
+ 'bug=' + encodeURIComponent(o.data.bug_id) +
+ '&attachment=' + encodeURIComponent(o.data.attach_id) +
+ '" target="_blank" title="Review this patch">' +
+ Y.Escape.html(o.value) + '</a>';
+ }
+ else {
+ return Y.Escape.html(o.value);
+ }
+ };
- 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' });
+ dataSource.requestee.on('error', function(e) {
+ try {
+ var response = Y.JSON.parse(e.data.responseText);
+ if (response.error)
+ e.error.message = response.error.message;
+ } catch(ex) {
+ // ignore
+ }
+ });
+ dataTable.requestee = new Y.DataTable({
+ columns: [
+ { key: "requester", label: "Requester", sortable: true },
+ { key: "type", label: "Flag", sortable: true,
+ formatter: flagNameFormatter, allowHTML: true },
+ { key: "bug_id", label: "Bug", sortable: true,
+ formatter: bugLinkFormatter, allowHTML: true },
+ { key: "updated", label: "Updated", sortable: true,
+ formatter: updatedFormatter, allowHTML: true }
+ ],
+ strings: {
+ emptyMessage: 'No flag data found.',
+ }
});
- };
-
- var loadBugList = function(type) {
- if (!type) return;
- var data = dataTable[type].data;
- var ids = [];
- for (var i = 0, l = data.size(); i < l; i++) {
- ids.push(data.item(i).get('bug_id'));
- }
- var url = 'buglist.cgi?bug_id=' + ids.join('%2C');
- window.open(url, '_blank');
- };
-
- var bugLinkFormatter = function(o) {
- var bug_closed = "";
- if (o.data.bug_status == 'RESOLVED' || o.data.bug_status == 'VERIFIED') {
- bug_closed = "bz_closed";
- }
- return '<a href="show_bug.cgi?id=' + encodeURIComponent(o.value) +
- '" target="_blank" ' + 'title="' + Y.Escape.html(o.data.bug_status) + ' - ' +
- Y.Escape.html(o.data.bug_summary) + '" class="' + Y.Escape.html(bug_closed) +
- '">' + o.value + '</a>';
- };
-
- var updatedFormatter = function(o) {
- return '<span title="' + Y.Escape.html(o.value) + '">' +
- Y.Escape.html(o.data.updated_fancy) + '</span>';
- };
-
- var requesteeFormatter = function(o) {
- return o.value
- ? Y.Escape.html(o.value)
- : '<i>anyone</i>';
- };
-
- var flagNameFormatter = function(o) {
- if (parseInt(o.data.attach_id)
- && parseInt(o.data.is_patch)
- && MyDashboard.splinter_base)
- {
- return '<a href="' + MyDashboard.splinter_base +
- (MyDashboard.splinter_base.indexOf('?') == -1 ? '?' : '&') +
- 'bug=' + encodeURIComponent(o.data.bug_id) +
- '&attachment=' + encodeURIComponent(o.data.attach_id) +
- '" target="_blank" title="Review this patch">' +
- Y.Escape.html(o.value) + '</a>';
- }
- else {
- return Y.Escape.html(o.value);
- }
- };
-
- // Requestee
- dataSource.requestee = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- dataSource.requestee.on('error', function(e) {
- try {
- var response = Y.JSON.parse(e.data.responseText);
- if (response.error)
- e.error.message = response.error.message;
- } catch(ex) {
- // ignore
- }
- });
- dataTable.requestee = new Y.DataTable({
- columns: [
- { key: "requester", label: "Requester", sortable: true },
- { key: "type", label: "Flag", sortable: true,
- formatter: flagNameFormatter, allowHTML: true },
- { key: "bug_id", label: "Bug", sortable: true,
- formatter: bugLinkFormatter, allowHTML: true },
- { key: "updated", label: "Updated", sortable: true,
- formatter: updatedFormatter, allowHTML: true }
- ],
- strings: {
- emptyMessage: 'No flag data found.',
- }
- });
- dataTable.requestee.plug(Y.Plugin.DataTableSort);
+ dataTable.requestee.plug(Y.Plugin.DataTableSort);
- dataTable.requestee.plug(Y.Plugin.DataTableDataSource, {
- datasource: dataSource.requestee
- });
+ dataTable.requestee.plug(Y.Plugin.DataTableDataSource, {
+ datasource: dataSource.requestee
+ });
- dataSource.requestee.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.requestee",
- resultFields: ["requester", "type", "attach_id", "is_patch", "bug_id",
- "bug_status", "bug_summary", "updated", "updated_fancy"]
- }
- });
+ dataSource.requestee.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.requestee",
+ resultFields: ["requester", "type", "attach_id", "is_patch", "bug_id",
+ "bug_status", "bug_summary", "updated", "updated_fancy"]
+ }
+ });
- dataTable.requestee.render("#requestee_table");
+ dataTable.requestee.render("#requestee_table");
- Y.one('#requestee_refresh').on('click', function(e) {
- updateFlagTable('requestee');
- });
- Y.one('#requestee_buglist').on('click', function(e) {
- loadBugList('requestee');
- });
+ Y.one('#requestee_refresh').on('click', function(e) {
+ updateFlagTable('requestee');
+ });
+ Y.one('#requestee_buglist').on('click', function(e) {
+ loadBugList('requestee');
+ });
- // Requester
- dataSource.requester = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- dataSource.requester.on('error', function(e) {
- try {
- var response = Y.JSON.parse(e.data.responseText);
- if (response.error)
- e.error.message = response.error.message;
- } catch(ex) {
- // ignore
- }
- });
- dataTable.requester = new Y.DataTable({
- columns: [
- { key:"requestee", label:"Requestee", sortable:true,
- formatter: requesteeFormatter, allowHTML: true },
- { key:"type", label:"Flag", sortable:true,
- formatter: flagNameFormatter, allowHTML: true },
- { key:"bug_id", label:"Bug", sortable:true,
- formatter: bugLinkFormatter, allowHTML: true },
- { key: "updated", label: "Updated", sortable: true,
- formatter: updatedFormatter, allowHTML: true }
- ],
- strings: {
- emptyMessage: 'No flag data found.',
- }
- });
+ // Requester
+ dataSource.requester = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+ dataSource.requester.on('error', function(e) {
+ try {
+ var response = Y.JSON.parse(e.data.responseText);
+ if (response.error)
+ e.error.message = response.error.message;
+ } catch(ex) {
+ // ignore
+ }
+ });
+ dataTable.requester = new Y.DataTable({
+ columns: [
+ { key:"requestee", label:"Requestee", sortable:true,
+ formatter: requesteeFormatter, allowHTML: true },
+ { key:"type", label:"Flag", sortable:true,
+ formatter: flagNameFormatter, allowHTML: true },
+ { key:"bug_id", label:"Bug", sortable:true,
+ formatter: bugLinkFormatter, allowHTML: true },
+ { key: "updated", label: "Updated", sortable: true,
+ formatter: updatedFormatter, allowHTML: true }
+ ],
+ strings: {
+ emptyMessage: 'No flag data found.',
+ }
+ });
- dataTable.requester.plug(Y.Plugin.DataTableSort);
+ dataTable.requester.plug(Y.Plugin.DataTableSort);
- dataTable.requester.plug(Y.Plugin.DataTableDataSource, {
- datasource: dataSource.requester
- });
+ dataTable.requester.plug(Y.Plugin.DataTableDataSource, {
+ datasource: dataSource.requester
+ });
- dataSource.requester.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.requester",
- resultFields: ["requestee", "type", "attach_id", "is_patch", "bug_id",
- "bug_status", "bug_summary", "updated", "updated_fancy"]
- }
- });
+ dataSource.requester.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.requester",
+ resultFields: ["requestee", "type", "attach_id", "is_patch", "bug_id",
+ "bug_status", "bug_summary", "updated", "updated_fancy"]
+ }
+ });
- // Initial load
- Y.on("contentready", function (e) {
- updateFlagTable("requestee");
- }, "#requestee_table");
- Y.on("contentready", function (e) {
- updateFlagTable("requester");
- }, "#requester_table");
+ // Initial load
+ Y.on("contentready", function (e) {
+ updateFlagTable("requestee");
+ }, "#requestee_table");
+ Y.on("contentready", function (e) {
+ updateFlagTable("requester");
+ }, "#requester_table");
- Y.one('#requester_refresh').on('click', function(e) {
- updateFlagTable('requester');
- });
- Y.one('#requester_buglist').on('click', function(e) {
- loadBugList('requester');
+ Y.one('#requester_refresh').on('click', function(e) {
+ updateFlagTable('requester');
+ });
+ Y.one('#requester_buglist').on('click', function(e) {
+ loadBugList('requester');
+ });
});
});
diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js
index 9cea27f87..a95c0be61 100644
--- a/extensions/MyDashboard/web/js/query.js
+++ b/extensions/MyDashboard/web/js/query.js
@@ -11,274 +11,276 @@ if (typeof(MyDashboard) == 'undefined') {
}
// Main query code
-YUI({
- base: 'js/yui3/',
- combine: false,
- groups: {
- gallery: {
- combine: false,
- base: 'js/yui3/',
- patterns: { 'gallery-': {} }
- }
- }
-}).use("node", "datatable", "datatable-sort", "datatable-message", "json-stringify",
- "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie",
- "gallery-datatable-row-expansion-bmo", "handlebars", "escape", function(Y) {
- var counter = 0,
- bugQueryTable = null,
- bugQuery = null,
- lastChangesQuery = null,
- lastChangesCache = {},
- default_query = "assignedbugs";
-
- // Grab last used query name from cookie or use default
- var query_cookie = Y.Cookie.get("my_dashboard_query");
- if (query_cookie) {
- var cookie_value_found = 0;
- Y.one("#query").get("options").each( function() {
- if (this.get("value") == query_cookie) {
- this.set('selected', true);
- default_query = query_cookie;
- cookie_value_found = 1;
+$(function() {
+ YUI({
+ base: 'js/yui3/',
+ combine: false,
+ groups: {
+ gallery: {
+ combine: false,
+ base: 'js/yui3/',
+ patterns: { 'gallery-': {} }
}
- });
- if (!cookie_value_found) {
- Y.Cookie.set("my_dashboard_query", "");
}
- }
-
- var bugQuery = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
-
- bugQuery.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.result.bugs",
- resultFields: ["bug_id", "changeddate", "changeddate_fancy",
- "bug_status", "short_desc", "changeddate_api" ],
- metaFields: {
- description: "result.result.description",
- heading: "result.result.heading",
- buffer: "result.result.buffer",
- mark_read: "result.result.mark_read"
+ }).use("node", "datatable", "datatable-sort", "datatable-message", "json-stringify",
+ "datatable-datasource", "datasource-io", "datasource-jsonschema", "cookie",
+ "gallery-datatable-row-expansion-bmo", "handlebars", "escape", function(Y) {
+ var counter = 0,
+ bugQueryTable = null,
+ bugQuery = null,
+ lastChangesQuery = null,
+ lastChangesCache = {},
+ default_query = "assignedbugs";
+
+ // Grab last used query name from cookie or use default
+ var query_cookie = Y.Cookie.get("my_dashboard_query");
+ if (query_cookie) {
+ var cookie_value_found = 0;
+ Y.one("#query").get("options").each( function() {
+ if (this.get("value") == query_cookie) {
+ this.set('selected', true);
+ default_query = query_cookie;
+ cookie_value_found = 1;
+ }
+ });
+ if (!cookie_value_found) {
+ Y.Cookie.set("my_dashboard_query", "");
}
}
- });
- bugQuery.on('error', function(e) {
- try {
- var response = Y.JSON.parse(e.data.responseText);
- if (response.error)
- e.error.message = response.error.message;
- } catch(ex) {
- // ignore
- }
- });
-
- var bugQueryCallback = {
- success: function(e) {
- if (e.response) {
- Y.one('#query_count_refresh').removeClass('bz_default_hidden');
- 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 +
- '" target="_blank">' + e.response.results.length + ' bugs found</a>');
- bugQueryTable.set('data', e.response.results);
-
- var mark_read = e.response.meta.mark_read;
- if (mark_read) {
- Y.one('#query_markread').setHTML( mark_read );
- Y.one('#bar_markread').removeClass('bz_default_hidden');
- Y.one('#query_markread_text').setHTML( mark_read );
- Y.one('#query_markread').removeClass('bz_default_hidden');
- }
- else {
- Y.one('#bar_markread').addClass('bz_default_hidden');
- Y.one('#query_markread').addClass('bz_default_hidden');
+ var bugQuery = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
+
+ bugQuery.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.result.bugs",
+ resultFields: ["bug_id", "changeddate", "changeddate_fancy",
+ "bug_status", "short_desc", "changeddate_api" ],
+ metaFields: {
+ description: "result.result.description",
+ heading: "result.result.heading",
+ buffer: "result.result.buffer",
+ mark_read: "result.result.mark_read"
}
- Y.one('#query_markread_text').addClass('bz_default_hidden');
}
- },
- failure: function(o) {
- if (o.error) {
- alert("Failed to load bug list from Bugzilla:\n\n" + o.error.message);
- } else {
- alert("Failed to load bug list from Bugzilla.");
+ });
+
+ bugQuery.on('error', function(e) {
+ try {
+ var response = Y.JSON.parse(e.data.responseText);
+ if (response.error)
+ e.error.message = response.error.message;
+ } catch(ex) {
+ // ignore
}
- }
- };
+ });
- var updateQueryTable = function(query_name) {
- if (!query_name) return;
+ var bugQueryCallback = {
+ success: function(e) {
+ if (e.response) {
+ Y.one('#query_count_refresh').removeClass('bz_default_hidden');
+ 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 +
+ '" target="_blank">' + e.response.results.length + ' bugs found</a>');
+ bugQueryTable.set('data', e.response.results);
+
+ var mark_read = e.response.meta.mark_read;
+ if (mark_read) {
+ Y.one('#query_markread').setHTML( mark_read );
+ Y.one('#bar_markread').removeClass('bz_default_hidden');
+ Y.one('#query_markread_text').setHTML( mark_read );
+ Y.one('#query_markread').removeClass('bz_default_hidden');
+ }
+ else {
+ Y.one('#bar_markread').addClass('bz_default_hidden');
+ Y.one('#query_markread').addClass('bz_default_hidden');
+ }
+ Y.one('#query_markread_text').addClass('bz_default_hidden');
+ }
+ },
+ failure: function(o) {
+ if (o.error) {
+ alert("Failed to load bug list from Bugzilla:\n\n" + o.error.message);
+ } else {
+ alert("Failed to load bug list from Bugzilla.");
+ }
+ }
+ };
- counter = counter + 1;
- lastChangesCache = {};
+ var updateQueryTable = function(query_name) {
+ if (!query_name) return;
- Y.one('#query_count_refresh').addClass('bz_default_hidden');
- bugQueryTable.set('data', []);
- bugQueryTable.render("#query_table");
- bugQueryTable.showMessage('loadingMessage');
+ counter = counter + 1;
+ lastChangesCache = {};
- var bugQueryParams = {
- version: "1.1",
- method: "MyDashboard.run_bug_query",
- id: counter,
- params: { query : query_name,
- Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
- }
- };
+ Y.one('#query_count_refresh').addClass('bz_default_hidden');
+ bugQueryTable.set('data', []);
+ bugQueryTable.render("#query_table");
+ bugQueryTable.showMessage('loadingMessage');
- bugQuery.sendRequest({
- request: Y.JSON.stringify(bugQueryParams),
- cfg: {
- method: "POST",
- headers: { 'Content-Type': 'application/json' }
- },
- callback: bugQueryCallback
- });
- };
+ var bugQueryParams = {
+ version: "1.1",
+ method: "MyDashboard.run_bug_query",
+ id: counter,
+ params: { query : query_name,
+ Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
+ }
+ };
- var updatedFormatter = function(o) {
- return '<span title="' + Y.Escape.html(o.value) + '">' +
- Y.Escape.html(o.data.changeddate_fancy) + '</span>';
- };
+ bugQuery.sendRequest({
+ request: Y.JSON.stringify(bugQueryParams),
+ cfg: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ },
+ callback: bugQueryCallback
+ });
+ };
+ var updatedFormatter = function(o) {
+ return '<span title="' + Y.Escape.html(o.value) + '">' +
+ Y.Escape.html(o.data.changeddate_fancy) + '</span>';
+ };
- lastChangesQuery = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- lastChangesQuery.plug(Y.Plugin.DataSourceJSONSchema, {
- schema: {
- resultListLocator: "result.results",
- resultFields: ["last_changes"],
- }
- });
+ lastChangesQuery = new Y.DataSource.IO({ source: 'jsonrpc.cgi' });
- lastChangesQuery.on('error', function(e) {
- try {
- var response = Y.JSON.parse(e.data.responseText);
- if (response.error)
- e.error.message = response.error.message;
- } catch(ex) {
- // ignore
- }
- });
+ lastChangesQuery.plug(Y.Plugin.DataSourceJSONSchema, {
+ schema: {
+ resultListLocator: "result.results",
+ resultFields: ["last_changes"],
+ }
+ });
- bugQueryTable = new Y.DataTable({
- columns: [
- { key: Y.Plugin.DataTableRowExpansion.column_key, label: ' ', sortable: false },
- { key: "bug_id", label: "Bug", allowHTML: true, sortable: true,
- formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>' },
- { key: "changeddate", label: "Updated", formatter: updatedFormatter,
- allowHTML: true, sortable: true },
- { key: "bug_status", label: "Status", sortable: true },
- { key: "short_desc", label: "Summary", sortable: true },
- ],
- });
+ lastChangesQuery.on('error', function(e) {
+ try {
+ var response = Y.JSON.parse(e.data.responseText);
+ if (response.error)
+ e.error.message = response.error.message;
+ } catch(ex) {
+ // ignore
+ }
+ });
- var last_changes_source = Y.one('#last-changes-template').getHTML(),
- last_changes_template = Y.Handlebars.compile(last_changes_source);
+ bugQueryTable = new Y.DataTable({
+ columns: [
+ { key: Y.Plugin.DataTableRowExpansion.column_key, label: ' ', sortable: false },
+ { key: "bug_id", label: "Bug", allowHTML: true, sortable: true,
+ formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>' },
+ { key: "changeddate", label: "Updated", formatter: updatedFormatter,
+ allowHTML: true, sortable: true },
+ { key: "bug_status", label: "Status", sortable: true },
+ { key: "short_desc", label: "Summary", sortable: true },
+ ],
+ });
- var stub_source = Y.one('#last-changes-stub').getHTML(),
- stub_template = Y.Handlebars.compile(stub_source);
+ var last_changes_source = Y.one('#last-changes-template').getHTML(),
+ last_changes_template = Y.Handlebars.compile(last_changes_source);
+ var stub_source = Y.one('#last-changes-stub').getHTML(),
+ stub_template = Y.Handlebars.compile(stub_source);
- bugQueryTable.plug(Y.Plugin.DataTableRowExpansion, {
- uniqueIdKey: 'bug_id',
- template: function(data) {
- var bug_id = data.bug_id;
- var lastChangesCallback = {
- success: function(e) {
- if (e.response) {
- var last_changes = e.response.results[0].last_changes;
- last_changes['bug_id'] = bug_id;
- lastChangesCache[bug_id] = last_changes;
- Y.one('#last_changes_stub_' + bug_id).setHTML(last_changes_template(last_changes));
- }
- },
- failure: function(o) {
- if (o.error) {
- alert("Failed to load last changes from Bugzilla:\n\n" + o.error.message);
- } else {
- alert("Failed to load last changes from Bugzilla.");
- }
- }
- };
+ bugQueryTable.plug(Y.Plugin.DataTableRowExpansion, {
+ uniqueIdKey: 'bug_id',
+ template: function(data) {
+ var bug_id = data.bug_id;
- if (!lastChangesCache[bug_id]) {
- var lastChangesParams = {
- version: "1.1",
- method: "MyDashboard.run_last_changes",
- params: {
- bug_id: data.bug_id,
- changeddate_api: data.changeddate_api,
- Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
+ var lastChangesCallback = {
+ success: function(e) {
+ if (e.response) {
+ var last_changes = e.response.results[0].last_changes;
+ last_changes['bug_id'] = bug_id;
+ lastChangesCache[bug_id] = last_changes;
+ Y.one('#last_changes_stub_' + bug_id).setHTML(last_changes_template(last_changes));
+ }
+ },
+ failure: function(o) {
+ if (o.error) {
+ alert("Failed to load last changes from Bugzilla:\n\n" + o.error.message);
+ } else {
+ alert("Failed to load last changes from Bugzilla.");
+ }
}
};
- lastChangesQuery.sendRequest({
- request: Y.JSON.stringify(lastChangesParams),
- cfg: {
- method: "POST",
- headers: { 'Content-Type': 'application/json' }
- },
- callback: lastChangesCallback
- });
+ if (!lastChangesCache[bug_id]) {
+ var lastChangesParams = {
+ version: "1.1",
+ method: "MyDashboard.run_last_changes",
+ params: {
+ bug_id: data.bug_id,
+ changeddate_api: data.changeddate_api,
+ Bugzilla_api_token : (BUGZILLA.api_token ? BUGZILLA.api_token : '')
+ }
+ };
+
+ lastChangesQuery.sendRequest({
+ request: Y.JSON.stringify(lastChangesParams),
+ cfg: {
+ method: "POST",
+ headers: { 'Content-Type': 'application/json' }
+ },
+ callback: lastChangesCallback
+ });
+
+ return stub_template({bug_id: bug_id});
+ }
+ else {
+ return last_changes_template(lastChangesCache[bug_id]);
+ }
- return stub_template({bug_id: bug_id});
- }
- else {
- return last_changes_template(lastChangesCache[bug_id]);
}
+ });
- }
- });
-
- bugQueryTable.plug(Y.Plugin.DataTableSort);
+ bugQueryTable.plug(Y.Plugin.DataTableSort);
- bugQueryTable.plug(Y.Plugin.DataTableDataSource, {
- datasource: bugQuery
- });
+ bugQueryTable.plug(Y.Plugin.DataTableDataSource, {
+ datasource: bugQuery
+ });
- // Initial load
- Y.on("contentready", function (e) {
- updateQueryTable(default_query);
- }, "#query_table");
+ // Initial load
+ Y.on("contentready", function (e) {
+ updateQueryTable(default_query);
+ }, "#query_table");
- 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.Cookie.set("my_dashboard_query", selected_value, { expires: new Date("January 12, 2025") });
- });
+ 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.Cookie.set("my_dashboard_query", selected_value, { expires: new Date("January 12, 2025") });
+ });
- 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);
- });
+ 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);
+ });
- Y.one('#query_markread').on('click', function(e) {
- var data = bugQueryTable.data;
- var bug_ids = [];
+ Y.one('#query_markread').on('click', function(e) {
+ var data = bugQueryTable.data;
+ var bug_ids = [];
- Y.one('#query_markread').addClass('bz_default_hidden');
- Y.one('#query_markread_text').removeClass('bz_default_hidden');
+ Y.one('#query_markread').addClass('bz_default_hidden');
+ Y.one('#query_markread_text').removeClass('bz_default_hidden');
- for (var i = 0, l = data.size(); i < l; i++) {
- bug_ids.push(data.item(i).get('bug_id'));
- }
- YAHOO.bugzilla.bugUserLastVisit.update(bug_ids);
- YAHOO.bugzilla.bugInterest.unmark(bug_ids);
- });
+ for (var i = 0, l = data.size(); i < l; i++) {
+ bug_ids.push(data.item(i).get('bug_id'));
+ }
+ YAHOO.bugzilla.bugUserLastVisit.update(bug_ids);
+ YAHOO.bugzilla.bugInterest.unmark(bug_ids);
+ });
- Y.one('#query_buglist').on('click', function(e) {
- var data = bugQueryTable.data;
- var ids = [];
- for (var i = 0, l = data.size(); i < l; i++) {
- ids.push(data.item(i).get('bug_id'));
- }
- var url = 'buglist.cgi?bug_id=' + ids.join('%2C');
- window.open(url, '_blank');
+ Y.one('#query_buglist').on('click', function(e) {
+ var data = bugQueryTable.data;
+ var ids = [];
+ for (var i = 0, l = data.size(); i < l; i++) {
+ ids.push(data.item(i).get('bug_id'));
+ }
+ var url = 'buglist.cgi?bug_id=' + ids.join('%2C');
+ window.open(url, '_blank');
+ });
});
});