diff options
Diffstat (limited to 'extensions/MyDashboard/web')
-rw-r--r-- | extensions/MyDashboard/web/js/flags.js | 157 | ||||
-rw-r--r-- | extensions/MyDashboard/web/js/query.js | 160 | ||||
-rw-r--r-- | extensions/MyDashboard/web/styles/mydashboard.css | 73 |
3 files changed, 390 insertions, 0 deletions
diff --git a/extensions/MyDashboard/web/js/flags.js b/extensions/MyDashboard/web/js/flags.js new file mode 100644 index 000000000..fc360fdc1 --- /dev/null +++ b/extensions/MyDashboard/web/js/flags.js @@ -0,0 +1,157 @@ +/* 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", "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 + "_flags_found").setHTML( + e.response.results.length + ' flags found'); + dataTable[type].set('data', e.response.results); + } + }, + 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); + + 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 bugLinkFormatter = function (o) { + 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) + '">' + o.value + '</a>'; + }; + + var createdFormatter = function (o) { + return '<span title="' + Y.Escape.html(o.value) + '">' + + Y.Escape.html(o.data.created_fancy) + '</span>'; + }; + + var requesteeFormatter = function (o) { + return o.value + ? Y.Escape.html(o.value) + : '<i>anyone</i>'; + }; + + // 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: bugLinkFormatter, allowHTML: true }, + { key: "created", label: "Created", sortable: true, + formatter: createdFormatter, allowHTML: 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", "bug_status", + "bug_summary", "created", "created_fancy"] + } + }); + + 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, + formatter: requesteeFormatter, allowHTML: true }, + { key:"type", label:"Flag", sortable:true }, + { key:"bug_id", label:"Bug", sortable:true, + formatter: bugLinkFormatter, allowHTML: true }, + { key: "created", label: "Created", sortable: true, + formatter: createdFormatter, allowHTML: 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", "bug_status", + "bug_summary", "created", "created_fancy"] + } + }); + + Y.one('#requester_refresh').on('click', function(e) { + updateFlagTable('requester'); + }); +}); diff --git a/extensions/MyDashboard/web/js/query.js b/extensions/MyDashboard/web/js/query.js new file mode 100644 index 000000000..2ce438509 --- /dev/null +++ b/extensions/MyDashboard/web/js/query.js @@ -0,0 +1,160 @@ +/* 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, + 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, + dataSource = null, + dataTable = null, + 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", ""); + } + } + + 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>'); + dataTable.set('data', e.response.results); + } + }, + 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); + + dataTable.set('data', []); + dataTable.render("#query_table"); + dataTable.showMessage('loadingMessage'); + + dataSource.sendRequest({ + request: stringified, + cfg: { + method: "POST", + headers: { 'Content-Type': 'application/json' } + }, + callback: callback + }); + }; + + var updatedFormatter = function (o) { + return '<span title="' + Y.Escape.html(o.value) + '">' + + Y.Escape.html(o.data.changeddate_fancy) + '</span>'; + }; + + dataSource = new Y.DataSource.IO({ source: 'jsonrpc.cgi' }); + + dataSource.plug(Y.Plugin.DataSourceJSONSchema, { + schema: { + resultListLocator: "result.result.bugs", + resultFields: ["bug_id", "changeddate", "changeddate_fancy", + "bug_status", "short_desc", "last_changes"], + metaFields: { + description: "result.result.description", + heading: "result.result.heading", + buffer: "result.result.buffer" + } + } + }); + + dataTable = new Y.DataTable({ + columns: [ + { key: Y.Plugin.DataTableRowExpansion.column_key, label: ' ', sortable: false }, + { key: "bug_id", label: "Bug", allowHTML: true, + formatter: '<a href="show_bug.cgi?id={value}" target="_blank">{value}</a>' }, + { key: "changeddate", label: "Updated", formatter: updatedFormatter, allowHTML: true }, + { key: "bug_status", label: "Status" }, + { key: "short_desc", label: "Summary" }, + ], + sortable: true + }); + + var last_changes_source = Y.one('#last-changes-template').getHTML(), + last_changes_template = Y.Handlebars.compile(last_changes_source); + + dataTable.plug(Y.Plugin.DataTableRowExpansion, { + uniqueIdKey: 'bug_id', + template: function(data) { + var last_changes = {}; + if (data.last_changes.email) { + last_changes = { + activity: data.last_changes.activity, + email: data.last_changes.email, + when: data.last_changes.when, + comment: data.last_changes.comment, + }; + } + return last_changes_template(last_changes); + } + }); + + dataTable.plug(Y.Plugin.DataTableSort); + + dataTable.plug(Y.Plugin.DataTableDataSource, { + datasource: dataSource, + initialRequest: updateQueryTable(default_query), + }); + + 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); + }); +}); diff --git a/extensions/MyDashboard/web/styles/mydashboard.css b/extensions/MyDashboard/web/styles/mydashboard.css new file mode 100644 index 000000000..050fd95c2 --- /dev/null +++ b/extensions/MyDashboard/web/styles/mydashboard.css @@ -0,0 +1,73 @@ +/* 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. */ + +#mydashboard { + min-width: 900px; +} + +#mydashboard .yui3-skin-sam .yui3-datatable-table { + width: 100%; +} + +.yui3-datatable-col-changeddate, +.yui3-datatable-col-created { + white-space: nowrap; +} + +.query_heading { + font-size: 18px; + font-weight: strong; + padding-bottom: 5px; + padding-top: 5px; + color: rgb(72, 72, 72); +} + +.query_description { + font-size: 90%; + font-style: italic; + padding-bottom: 5px; + color: rgb(109, 117, 129); +} + +#mydashboard_container { + margin: 0 auto; +} + +#left { + float: left; + width: 58%; +} + +#right { + float: right; + width: 40%; +} + +.items_found, .refresh { + font-size: 80%; +} + +#query_list_container { + text-align:center; +} + +#query_list_container, +#prod_comp_search_main { + padding: 20px !important; + height: 40px; +} + +#last_changes_header { + font-size: 12px; + font-weight: bold; + padding-bottom: 5px; + border-bottom: 1px solid rgb(200, 200, 186); +} + +#last_changes .field_label { + text-align: left; +} |