diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-07-29 18:07:09 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-09-17 17:08:14 +0200 |
commit | c58186483beffd3bc6261ae8c2ccb0b932b33304 (patch) | |
tree | 79364a042377f2412f0cb8d6ff37a2d7fe38c27b | |
parent | 5172d8d70e9bc0ed8ea2808128eb42596513f4bb (diff) | |
download | bugzilla-triage-c58186483beffd3bc6261ae8c2ccb0b932b33304.tar.gz |
Some thoughts on the backtrace showing
-rw-r--r-- | lib/bzpage.js | 37 | ||||
-rw-r--r-- | lib/rhbzpage.js | 96 |
2 files changed, 84 insertions, 49 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 635ec7d..cbaae12 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -774,6 +774,43 @@ BZPage.prototype.getDefaultBugzillaMaintainer = function getDefaultBugzillaMaint }; /** + * Parse the row with the attachment + * + * @param DOM element to be parsed + * @return array with string name of the attachment, integer its id number, + * string of MIME type, integer of size in kilobytes, and the whole + * element itself + */ +BZPage.prototype.parseAttachmentLine = function(inElem) { + var MIMEtype = ""; + var size = 0; + + // Skip over obsolete attachments + if (inElem.getElementsByClassName("bz_obsolete").length > 0) { + return ( []); + } + + // getting name of the attachment + // TODO probably could use url.URL object + var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); + + var aHrefsArr = inElem.getElementsByTagName("a"); + var aHref = Array.filter(aHrefsArr, function(x) { + return x.textContent.trim() === "Details"; + })[0]; + var id = parseInt(aHref.getAttribute("href").replace( + /^.*attachment.cgi\?id=/, ""), 10); + + // getting MIME type and size + var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent + .replace(/[\n ()]+/g, " ").trim().split(", "); + size = parseInt(stringArray[0], 10); + MIMEtype = stringArray[1].split(" ")[0]; + + return [ attName, id, MIMEtype, size, inElem ]; +}; + +/** * collect the list of attachments in a structured format * * @return Array of arrays, one for each attachments; diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 28fba16..ef49383 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -229,7 +229,12 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) } }; -RHBugzillaPage.prototype.addAttachment = function addAttachment(data) { +/** + * + * This has to stay in RHBugzillaPage because upstream doesn't have addAttachment + * XML-RPC call yet. + */ +RHBugzillaPage.prototype.addAttachment = function addAttachment(data, callback) { var msg = new xrpc.XMLRPCMessage("bugzilla.addAttachment"); var that = this; @@ -248,7 +253,11 @@ RHBugzillaPage.prototype.addAttachment = function addAttachment(data) { url: this.constantData.XMLRPCData[this.hostname].url, onComplete: function() { if (this.response.status == 200) { - that.XMLRPCcallback.call(that); + var respStr = this.response.text; // bug 270553 + respStr = respStr.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551 + var resp = new XML(respStr); + console.log("resp = " + resp.toXMLString()); + callback.call(that, parseInt(resp.id, 10)); } }, content: msg.xml(), @@ -257,7 +266,6 @@ RHBugzillaPage.prototype.addAttachment = function addAttachment(data) { this.reqCounter++; }; - /* Bugzilla functions. */ /** * @@ -311,24 +319,51 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { if (this.response.status == 200) { that.btSnippet = that.parseBacktrace(this.response.text); if (that.btSnippet) { - // FIXME add a button - // we have to create a new acttion addAttachment - // with handling in this.centralCommandDispatch - // - // that.addAttachment.call(that.btSnippet,that); - // that.addStuffToTextBox("status_whiteboard", - // "btparsed"); - // this.reqCounter++; + that.addCheckShowLink.call(that,x,that.btSnippet); } } } }).get(); - } }, this); } }; + +RHBugzillaPage.prototype.addCheckShowLink = function addCheckXorgLogLink(elem, snippet) { + var that = this; + var elemS = elem[4].getElementsByTagName("td"); + var elem = elemS[elemS.length - 1]; + elem.innerHTML += "<br/><a id='#attachBacktraceActivator' href='#'>check</a>"; + elem.addEventListener("click", function(x) { + var meAElem = that.doc.getElementById("attachBacktraceActivator"); + meAElem.parentNode.removeChild(meAElem); + that.addAttachment.call(that, snippet, function (attID) { + elem.innerHTML += "<br/><a id='#showBacktrace' href='#'>show BT</a>"; + elem.addEventListener("click", function(evt) { + that.showAttachment.call(that,attID); + }, false); + }); + }, false); + this.addStuffToTextBox("status_whiteboard", "btparsed"); +}; + +RHBugzillaPage.prototype.showAttachment = function showAttachment(id) { + var attURL = "https://"+ this.hostname + "/attachment.cgi?id="+id; + var infoWin = this.win.open("", "Check att. " + attachID, + "width=640,height=640,status=no,location=no"); + var doc = infoWin.document; + doc.body.innerHTML = "<pre id='textPre'>\n"+ + + "</pre>"; + +/* +FIXME this is unfinished and non-working +we have to also make somehow that "show" link is created when loading the page +*/ + +}; + /** * */ @@ -636,43 +671,6 @@ RHBugzillaPage.prototype.fillInChipMagic = function fillInChipMagic() { this.XorgLogAttListIndex++; }; -/** - * Parse the row with the attachment - * - * @param DOM element to be parsed - * @return array with string name of the attachment, integer its id number, - * string of MIME type, integer of size in kilobytes, and the whole - * element itself - */ -RHBugzillaPage.prototype.parseAttachmentLine = function(inElem) { - var MIMEtype = ""; - var size = 0; - - // Skip over obsolete attachments - if (inElem.getElementsByClassName("bz_obsolete").length > 0) { - return ( []); - } - - // getting name of the attachment - // TODO probably could use url.URL object - var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); - - var aHrefsArr = inElem.getElementsByTagName("a"); - var aHref = Array.filter(aHrefsArr, function(x) { - return x.textContent.trim() === "Details"; - })[0]; - var id = parseInt(aHref.getAttribute("href").replace( - /^.*attachment.cgi\?id=/, ""), 10); - - // getting MIME type and size - var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent - .replace(/[\n ()]+/g, " ").trim().split(", "); - size = parseInt(stringArray[0], 10); - MIMEtype = stringArray[1].split(" ")[0]; - - return [ attName, id, MIMEtype, size, inElem ]; -}; - RHBugzillaPage.prototype.analyzeXorgLog = function analyzeXorgLog(attachID) { var infoWin = this.win.open("", "Check att. " + attachID, "width=640,height=640,status=no,location=no"); |