diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-21 01:21:23 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-21 01:21:23 +0200 |
commit | 9c78d98edef12613da157c8cfa366bf937edd422 (patch) | |
tree | 5a6e61a9bca39bcfa71ae48dbe08c8b5c756e81b | |
parent | 47b6e6fb91372b54bb309e57c14e3f9f987e0322 (diff) | |
download | bugzilla-triage-9c78d98edef12613da157c8cfa366bf937edd422.tar.gz |
Logger works and some cleanup
Juhuuu, logger works (almost, I haven't tested generation of reports yet)
remove all trailing blank space
-rw-r--r-- | lib/bzpage.js | 14 | ||||
-rw-r--r-- | lib/clipboard.js | 18 | ||||
-rw-r--r-- | lib/logger.js | 41 | ||||
-rw-r--r-- | lib/main.js | 11 | ||||
-rw-r--r-- | lib/rhbzpage.js | 44 | ||||
-rw-r--r-- | lib/skip-process-bug.js | 2 | ||||
-rw-r--r-- | lib/util.js | 6 |
7 files changed, 90 insertions, 46 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 1b44b97..5344fbb 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -32,24 +32,25 @@ var BZPage = function BZPage(doc, config) { this.packages = this.getInstalledPackages(config); if ("commentStrings" in config.gJSONData) { - this.commentStrings = config.gJSONData.commentStrings; + this.commentStrings = config.gJSONData.commentStrings; } - + if ("constantData" in config.gJSONData) { this.constantData = config.gJSONData.constantData; } - + if ("CCmaintainer" in config.gJSONData.constantData) { this.defBugzillaMaintainerArr = config.gJSONData.constantData.CCmaintainer; } if ("suspiciousComponents" in config.gJSONData.configData) { - this.suspiciousComponents = config.gJSONData.configData.suspiciousComponents; + this.suspiciousComponents = config.gJSONData.configData.suspiciousComponents; } - + if ("submitsLogging" in config.gJSONData.configData && config.gJSONData.configData.submitsLogging) { this.log = config.logger; + console.log("this.log = " + this.log.toSource()); this.setUpLogging(); } @@ -62,7 +63,7 @@ var BZPage = function BZPage(doc, config) { this.version = this.getVersion(); this.title = this.doc.getElementById("short_desc_nonedit_display").textContent; this.CCList = this.getCCList(); - + // Prepare for query buttons // FIXME getting null for commentArea sometimes var commentArea = this.doc.getElementById("comment_status_commit"); @@ -659,6 +660,7 @@ BZPage.prototype.setUpLogging = function setUpLogging () { console.log("Installing submit callback!"); this.doc.forms.namedItem("changeform").addEventListener("submit",function (evt) { console.log("Submit callback!"); + var resp = that.log.addLogRecord(that); console.log("resp = " + resp); if (resp === null) { diff --git a/lib/clipboard.js b/lib/clipboard.js index 0051a55..c601649 100644 --- a/lib/clipboard.js +++ b/lib/clipboard.js @@ -35,7 +35,7 @@ var getMethod = exports.get = function getMethod( flavor ) { if (flavor === undefined) { flavor = "plain"; } - + if (flavor === "plain") { mimeType = "text/unicode"; } else if (favor === "html") { @@ -45,7 +45,7 @@ var getMethod = exports.get = function getMethod( flavor ) { } clip = getClipboard(); - + trans = createTransferable(); trans.addDataFlavor(mimeType); @@ -66,12 +66,12 @@ var getMethod = exports.get = function getMethod( flavor ) { var setMethod = exports.set = function setMethod(content, flavor) { var mimeType = "", stuff = {}; var len = 0, clipId = 0, clip = {}, trans = {}; - + // flavor argument is optional if (flavor === undefined) { flavor = "plain"; } - + if (flavor === "plain") { mimeType = "text/unicode"; } else if (favor === "html") { @@ -80,21 +80,21 @@ var setMethod = exports.set = function setMethod(content, flavor) { throw new Error("Unsupported flavor '" + flavor + "'!"); } - stuff = Cc["@mozilla.org/supports-string;1"]. + stuff = Cc["@mozilla.org/supports-string;1"]. createInstance(Ci.nsISupportsString); if (!stuff) { return false; - } + } stuff.data = content; - len = content.length * 2; + len = content.length * 2; clip = getClipboard(); - + trans = createTransferable(); trans.addDataFlavor(mimeType); trans.setTransferData(mimeType, stuff, content.length * 2); - + clip.setData(trans, null, clip.kGlobalClipboard); return true; }; diff --git a/lib/logger.js b/lib/logger.js index 1aec908..594f5c2 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -2,7 +2,7 @@ // http://www.opensource.org/licenses/mit-license.php "use strict"; var urlMod = require("url"); -var urilMod = require("util"); +var utilMod = require("util"); var Color = require("color").Color; var tabs = require("tabs"); var apiUtils = require("api-utils"); @@ -11,36 +11,45 @@ function Logger(store, abbsMap) { this.EmptyLogsColor = new Color(0, 255, 0); this.FullLogsColor = new Color(0, 40, 103); + console.log("store = " + store.toSource()); this.store = store; + console.log("abbsMap = " + abbsMap.toSource()); this.abbsMap = abbsMap; }; -exports.Logger = apiUtils.publicConstructor(Logger); +exports.Logger = Logger; Logger.prototype.addLogRecord = function(that) { + console.log("Adding log record!"); var rec = {}; rec.date = new Date(); rec.url = that.doc.location.toString(); rec.title = that.title; var comment = tabs.activeTab.contentWindow.prompt( "Enter comments for this comment"); + console.log("comment = " + comment); if (comment && comment.length > 0) { + console.log("I am in!"); comment = comment.trim(); rec.comment = comment; - var recKey = utilMod.getISODate(rec.date) + "+" - + urlMod.parse(rec.url).host + console.log("rec.comment = " + rec.comment); + // FIXME We break on the following line. Not sure what's going on! + var dateStr = utilMod.getISODate(rec.date); + console.log("rec.date = " + rec.date + ", dateStr = " + dateStr); + var urlStr = urlMod.URL(rec.url).host; + console.log("rec.url = " + rec.url + ", urlStr = " + urlStr); + var recKey = dateStr + "+" + + urlStr + "+" + that.bugNo; + console.log("recKey = " + recKey); console.log("rec = " + rec.toSource()); - - var clearLogAElem = that.doc.getElementById("clearLogs"); - if (clearLogAElem.style.color != that.FullLogsColor) { - clearLogAElem.style.color = that.FullLogsColor; - clearLogAElem.style.fontWeight = "bolder"; - } - if (that.store[recKey]) { - that.store[recKey].comment += "<br/>\n" + comment; + + console.log("this.store = " + this.store); + + if (this.store[recKey]) { + this.store[recKey].comment += "<br/>\n" + comment; } else { - that.store[recKey] = rec; + this.store[recKey] = rec; } } return comment; @@ -49,7 +58,7 @@ Logger.prototype.addLogRecord = function(that) { Logger.prototype.getBugzillaAbbr = function(url) { // for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH // for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo - var abbr = this.abbsMap[urlMod.parse(url).host]; + var abbr = this.abbsMap[urlMod.URL(url).host]; return abbr; } @@ -73,7 +82,7 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) { tmpArr.forEach(function(rec) { var x = rec[1]; var dayStr = utilMod.getISODate(x.date); - var host = urlMod.parse(x.url).host; + var host = urlMod.URL(x.url).host; var BZName = that.getBugzillaAbbr(x.url); var bugNo = utilMod.getBugNo(x.url); if (dayStr != currentDay) { @@ -95,7 +104,7 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) { }; /** - * + * */ Logger.prototype.createBlankPage = function (ttl, bodyBuildCB) { var title = ttl || "Yet another untitled page"; diff --git a/lib/main.js b/lib/main.js index 04d89aa..867c3d5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -9,7 +9,7 @@ // http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\ // /facebook-acquaintances/lib/main.js#l11 // http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 -// +// "use strict"; var util = require("util"); var logger = require("logger"); @@ -63,10 +63,10 @@ function isOurPage(window, matchingURLs) { window = window.window; } var url = window.location.href; - + // like ["regexp-url1", "regexp-url2"] return matchingURLs.some(function (element,i,a) { - return new RegExp(element).test(url); + return new RegExp(element).test(url); }); } @@ -92,9 +92,10 @@ function initialize(callback) { myStorage.logs = {}; } - config.logger = new logger.Logger(myStorage.logs, + var logConstructor = logger.Logger; + config.logger = new logConstructor(myStorage.logs, config.gJSONData.constantData.bugzillalabelAbbreviations); - + callback(config); }, this); } diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index d7860a2..a6acff4 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -29,7 +29,7 @@ var RHBugzillaPage = function RHBugzillaPage(doc, config) { var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], [ "ATI Mobility Radeon", "ATI", "1002" ], [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; - + // http://en.wikipedia.org/wiki/HSL_color_space // when only the value of S is changed // stupido!!! the string is value in hex for each color @@ -141,7 +141,7 @@ RHBugzillaPage.prototype.getDefaultAssignee = function() { RHBugzillaPage.prototype.setDefaultAssignee = function() { this.defaultAssignee = this.getDefaultAssignee(); var defAss = this.defaultAssignee; - + // Add setting default assignee if ((defAss.length > 0) && (defAss !== this.getOwner())) { this.constantData.defaultAssigneeTrigger = true; @@ -162,11 +162,11 @@ RHBugzillaPage.prototype.closeSomeRelease = function() { this.selectOption("bug_status", "CLOSED"); var text = ""; var resolution = ""; - + if (selection.text) { text = selection.text.trim(); } - if (text.length > 0) { + if (text.length > 0) { resolution = "CURRENTRELEASE"; this.doc.getElementById("cf_fixed_in").value = text; } else if (verNo === 999) { @@ -758,6 +758,38 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { }); msg.addParameter(this.login); msg.addParameter(this.password); + console.log("msg.xml() = " + msg.xml()); +/* +https://bugzilla.redhat.com/docs/en/html/api/extensions/compat_xmlrpc/code/webservice.html +<methodCall> +<methodName>bugzilla.updateAttachMimeType</methodName> +<params> +<param> +<value><struct> +<member> +<name>attach_id</name> +<value><i4>388923</i4></value> +</member> +<member> +<name>mime_type</name> +<value><string>text/plain</string></value> +</member> +<member> +<name>nomail</name> +<value><boolean>1</boolean></value> +</member> +</struct> +</value> +</param> +<param> +<value><string>mcepl@redhat.com</string></value> +</param> +<param> +<value><string>kyrios</string></value> +</param> +</params> +</methodCall> +*/ var req = new XMLHttpRequest(); var that = this; @@ -785,7 +817,7 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { * @return button fixing all bad Attachments */ RHBugzillaPage.prototype.createFixAllButton = function(list) { - if (!XMLRPCMessage) { + if (!xrpc.XMLRPCMessage) { return; } var that = this; @@ -869,7 +901,7 @@ RHBugzillaPage.prototype.addClosingUpstream = function() { // FIXME THis is not good, we don't have a feedback for other commands, // not to be run, if this fails. - + // It is not good to close bug as UPSTREAM, if there is no reference // to the upstream bug. if ((externalBugID > 0) || (refs.length > 2)) { diff --git a/lib/skip-process-bug.js b/lib/skip-process-bug.js index 3f82578..f4e98cc 100644 --- a/lib/skip-process-bug.js +++ b/lib/skip-process-bug.js @@ -1,4 +1,4 @@ -jetpack.future.import("pageMods"); +jetpack.future.import("pageMods"); // http://maymay.net/blog/2008/06/15/\ // ridiculously-simple-javascript-version-string-to-object-parser/ diff --git a/lib/util.js b/lib/util.js index 4a5eef2..4cb158a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -11,7 +11,7 @@ var urlMod = require("url"); * Function for the management of the prototypal inheritace * David Flanagan, Javascript: The Definitve Guide, * IV. edition, O'Reilly, 2006, p. 168 - * + * * @param superobject * @return new object, it needs new prototype.constructor * @@ -30,7 +30,7 @@ var urlMod = require("url"); */ exports.heir = function heir(p) { function f() {}; - f.prototype = p.prototype; + f.prototype = p.prototype; return new f(); }; @@ -84,7 +84,7 @@ var valToArray = exports.valToArray = function valToArray(val) { * * @param str String with old values * @param value String/Array with other values - * @return String with merged lists + * @return String with merged lists */ exports.addCSVValue = function addCSVValue(str, value) { var parts = (str.trim().length > 0 ? str.split(/,\s*/) : []); |