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/bzpage.js | |
parent | f61df257aeac1b55bc6fb4b4cd67fc13201fa9ac (diff) | |
download | bugzilla-triage-fcfbd3f7f01df5c67182366dc25e41567addc3b8.tar.gz |
Add import JSON file to logs
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r-- | lib/bzpage.js | 29 |
1 files changed, 27 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() { |