diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-19 15:48:47 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-07-19 15:58:00 +0200 |
commit | fcfbd3f7f01df5c67182366dc25e41567addc3b8 (patch) | |
tree | 7c19d3d6aebc13b42a6984469ae00e987d7949b7 /lib | |
parent | f61df257aeac1b55bc6fb4b4cd67fc13201fa9ac (diff) | |
download | bugzilla-triage-fcfbd3f7f01df5c67182366dc25e41567addc3b8.tar.gz |
Add import JSON file to logs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bzpage.js | 29 | ||||
-rw-r--r-- | lib/prompts.js | 20 | ||||
-rw-r--r-- | lib/rhbzpage.js | 1 |
3 files changed, 48 insertions, 2 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 9276a2b..9c24256 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -6,6 +6,7 @@ var util = require("util"); var passUtils = require("passwords"); var apiUtils = require("api-utils"); var selfMod = require("self"); +var fileMod = require("file"); var simpleStorage = require("simple-storage"); var preferences = require("preferences-service"); var prompts = require("prompts"); @@ -781,7 +782,7 @@ BZPage.prototype.setUpLogging = function setUpLogging () { var generateTimeSheetUI = this.doc.createElement("li"); generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='generateTSButton'>" - + "Generate timesheet</a>"; + + "Generate TS</a>"; additionalButtons.appendChild(generateTimeSheetUI); this.doc.getElementById("generateTSButton").addEventListener( "click", @@ -792,9 +793,33 @@ BZPage.prototype.setUpLogging = function setUpLogging () { evt.preventDefault(); }, false); + var ImportTimeSheetUI = this.doc.createElement("li"); + ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='importTSButton'>" + + "Import TS</a>"; + additionalButtons.appendChild(ImportTimeSheetUI); + this.doc.getElementById("importTSButton").addEventListener( + "click", + function(evt) { + var otherTS = {}, thisTS = that.log.store; + + jsonPaths = prompts.promptFileOpenPicker(that.win); + if (fileMod.exists(jsonPaths)) { + otherTS = JSON.parse(fileMod.read(jsonPaths)); + if (otherTS.logs) { + for (var rec in otherTS.logs) { + thisTS[rec] = otherTS.logs[rec]; + } + } else { + console.error("This is not a log file!"); + } + } else { + console.error("File " + jsonPaths + " doesn't exist!"); + } + }, false); + var clearLogsUI = this.doc.createElement("li"); clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='#' id='clearLogs'>" - + "Clear logs</a>"; + + "Clear TS</a>"; additionalButtons.appendChild(clearLogsUI); var clearLogAElem = this.doc.getElementById("clearLogs"); clearLogAElem.addEventListener("click", function() { diff --git a/lib/prompts.js b/lib/prompts.js index ac21c49..8f7942e 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -80,3 +80,23 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) { return null; } }; + +/** + * + * documentation is https://developer.mozilla.org/en/NsIFilePicker + */ +exports.promptFileOpenPicker = function promptFilePicker (win) { + var fp = Cc["@mozilla.org/filepicker;1"] + .createInstance(Ci.nsIFilePicker); + fp.init(win, "JSON File Open", Ci.nsIFilePicker.modeOpen); + fp.appendFilter("JSON files", "*.json"); + fp.appendFilters(Ci.nsIFilePicker.filterAll); + fp.filterIndex = 0; + var res = fp.show(); + + if (res === Ci.nsIFilePicker.returnOK || + res === Ci.nsIFilePicker.returnReplace ) { + return fp.file.path + } + return null; +};
\ No newline at end of file diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 6782241..340e1fd 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -112,6 +112,7 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) { // TODO Get compiz bugs as well if (this.constantData.PCI_ID_Array && + (this.XorgLogAttList[0]) && (this.maintCCAddr === "xgl-maint@redhat.com")) { // Add find chip magic button var whiteboard_string = this.doc.getElementById("status_whiteboard").value; |