From e7975179c05384deea60d22fded20aee5c475d2f Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Thu, 3 Apr 2025 03:15:45 +0530 Subject: [PATCH 1/8] maybe works Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/popup.html | 34 +++++++++++++++++++ src/scripts/scrumHelper.js | 69 ++++++++++++++++++++++++++++++-------- 2 files changed, 89 insertions(+), 14 deletions(-) diff --git a/src/popup.html b/src/popup.html index 6390d99..a642399 100644 --- a/src/popup.html +++ b/src/popup.html @@ -73,6 +73,19 @@
+
+
Scrum Report
+ +
+
+ + + +
Note:
@@ -97,5 +110,26 @@
+ diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 785fab0..2edfe4c 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -1,6 +1,6 @@ var refreshButton_Placed = false; var enableToggle = true; -function allIncluded() { +function allIncluded(outputTarget = 'email') { /* global $*/ var scrumBody = null; var scrumSubject = null; @@ -69,9 +69,19 @@ function allIncluded() { if (items.githubUsername) { githubUsername = items.githubUsername; fetchGithubData(); - } else { - console.warn('No GitHub username found in storage'); - } + } else { + if (outputTarget === 'popup') { + // Show error in popup + const generateBtn = document.getElementById('generateReport'); + if (generateBtn) { + generateBtn.innerHTML = ' Generate Report'; + generateBtn.disabled = false; + } + Materialize.toast('Please enter your GitHub username', 3000); + } else { + console.warn('No GitHub username found in storage'); + } + } if (items.projectName) { projectName = items.projectName; } @@ -230,14 +240,37 @@ function allIncluded() {

      ${userReason}

`; } - // Use the adapter to inject content - const elements = window.emailClientAdapter.getEditorElements(); - if (!elements || !elements.body) { - console.error('Email client editor not found'); - return; - } + if (outputTarget === 'popup') { + // Update popup textarea + const scrumReport = document.getElementById('scrumReport'); + if (scrumReport) { + // Convert HTML to plain text for textarea + const plainContent = content + .replace(/
/g, '\n') + .replace(/<\/?[^>]+(>|$)/g, '') + .replace(/ /g, ' '); + + scrumReport.value = plainContent; + Materialize.textareaAutoResize(scrumReport); - window.emailClientAdapter.injectContent(elements.body, content, elements.eventTypes.contentChange); + // Reset generate button + const generateBtn = document.getElementById('generateReport'); + if (generateBtn) { + generateBtn.innerHTML = ' Generate Report'; + generateBtn.disabled = false; + } + + Materialize.toast('Report generated successfully!', 3000); + } + } else { + // Use the adapter to inject content + const elements = window.emailClientAdapter.getEditorElements(); + if (!elements || !elements.body) { + console.error('Email client editor not found'); + return; + } + window.emailClientAdapter.injectContent(elements.body, content, elements.eventTypes.contentChange); + } }); } @@ -547,13 +580,21 @@ function allIncluded() { }, 1000); } function handleRefresh() { - allIncluded(); + allIncluded('email'); } } -allIncluded(); +allIncluded('email'); // Auto-trigger on page load +$('button>span:contains(New conversation)').parent('button').click(() => { + allIncluded('email'); // Auto-trigger on new conversation +}); $('button>span:contains(New conversation)') .parent('button') .click(() => { - allIncluded(); + allIncluded('email'); }); + +// Export for use in popup +window.generateScrumReport = function() { + allIncluded('popup'); +}; From aab4b5dec68c91f9e11be6208e1369660d3482e0 Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Fri, 30 May 2025 17:36:01 +0530 Subject: [PATCH 2/8] rebased, removed extensive logging and commits. removed unused functions Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/index.css | 22 +++ src/popup.html | 28 +-- src/scripts/popup.js | 24 +++ src/scripts/scrumHelper.js | 370 +++++++++++++------------------------ 4 files changed, 179 insertions(+), 265 deletions(-) create mode 100644 src/scripts/popup.js diff --git a/src/index.css b/src/index.css index ee83783..77bed34 100644 --- a/src/index.css +++ b/src/index.css @@ -64,3 +64,25 @@ li { transition: color 0.3s ease-in-out, font-weight 0.3s ease-in-out; } +#scrumReport { + border: 1px solid #ccc; + padding: 10px; + min-height: 200px; + max-height: 400px; + overflow-y: auto; + background-color: white; +} + +#scrumReport:focus { + outline: none; + border-color: #26a69a; +} + +#scrumReport a { + color: #26a69a; + text-decoration: none; +} + +#scrumReport a:hover { + text-decoration: underline; +} diff --git a/src/popup.html b/src/popup.html index a642399..7a924f2 100644 --- a/src/popup.html +++ b/src/popup.html @@ -75,7 +75,10 @@
Scrum Report
- +
+
+ - + diff --git a/src/scripts/popup.js b/src/scripts/popup.js new file mode 100644 index 0000000..9f9a117 --- /dev/null +++ b/src/scripts/popup.js @@ -0,0 +1,24 @@ +document.addEventListener('DOMContentLoaded', function() { + const generateBtn = document.getElementById('generateReport'); + const copyBtn = document.getElementById('copyReport'); + + generateBtn.addEventListener('click', function() { + this.innerHTML = ' Generating...'; + this.disabled = true; + + // Call the scrum generation function + window.generateScrumReport(); + }); + + copyBtn.addEventListener('click', function() { + const scrumReport = document.getElementById('scrumReport'); + const range = document.createRange(); + range.selectNodeContents(scrumReport); + const selection = window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + document.execCommand('copy'); + selection.removeAllRanges(); + Materialize.toast('Report copied to clipboard!', 3000); + }); +}); \ No newline at end of file diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 2edfe4c..d2e80d3 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -1,6 +1,7 @@ -var refreshButton_Placed = false; var enableToggle = true; function allIncluded(outputTarget = 'email') { + console.log('allIncluded called with outputTarget:', outputTarget); + console.log('Current window context:', window.location.href); /* global $*/ var scrumBody = null; var scrumSubject = null; @@ -33,6 +34,7 @@ function allIncluded(outputTarget = 'email') { var linkStyle = ''; function getChromeData() { + console.log("Getting Chrome data for context:", outputTarget); chrome.storage.local.get( [ 'githubUsername', @@ -47,6 +49,7 @@ function allIncluded(outputTarget = 'email') { 'gsoc', ], (items) => { + console.log("Storage items received:", items); if (items.gsoc) { //gsoc gsoc = 1; @@ -68,9 +71,11 @@ function allIncluded(outputTarget = 'email') { } if (items.githubUsername) { githubUsername = items.githubUsername; + console.log("About to fetch GitHub data for:", githubUsername); fetchGithubData(); } else { if (outputTarget === 'popup') { + console.log("No username found - popup context"); // Show error in popup const generateBtn = document.getElementById('generateReport'); if (generateBtn) { @@ -79,6 +84,7 @@ function allIncluded(outputTarget = 'email') { } Materialize.toast('Please enter your GitHub username', 3000); } else { + console.log("No username found - email context"); console.warn('No GitHub username found in storage'); } } @@ -142,44 +148,59 @@ function allIncluded(outputTarget = 'email') { } // fetch github data function fetchGithubData() { - var issueUrl = - 'https://api.github.com/search/issues?q=author%3A' + + console.log("Starting GitHub data fetch..."); + var issueUrl = 'https://api.github.com/search/issues?q=author%3A' + githubUsername + '+org%3Afossasia+created%3A' + startingDate + '..' + endingDate + '&per_page=100'; + console.log("Fetching issues from:", issueUrl); + $.ajax({ dataType: 'json', type: 'GET', url: issueUrl, error: (xhr, textStatus, errorThrown) => { - // error + console.error('Error fetching GitHub data:', { + status: xhr.status, + textStatus: textStatus, + error: errorThrown + }); }, success: (data) => { + console.log("Received GitHub issues data:", data); githubIssuesData = data; + writeGithubIssuesPrs(); }, }); - // fetch github prs review data - var prUrl = - 'https://api.github.com/search/issues?q=commenter%3A' + + + // PR reviews fetch + var prUrl = 'https://api.github.com/search/issues?q=commenter%3A' + githubUsername + '+org%3Afossasia+updated%3A' + startingDate + '..' + endingDate + '&per_page=100'; + console.log("Fetching PR reviews from:", prUrl); $.ajax({ dataType: 'json', type: 'GET', url: prUrl, error: (xhr, textStatus, errorThrown) => { - // error + console.error('Error fetching PR reviews:', { + status: xhr.status, + textStatus: textStatus, + error: errorThrown + }); }, success: (data) => { + console.log("Received PR reviews data:", data); githubPrsReviewData = data; + writeGithubPrsReviews(); }, }); // fetch github user data @@ -205,9 +226,11 @@ function allIncluded(outputTarget = 'email') { //load initial text in scrum body function writeScrumBody() { + console.log("writeScrumBody called"); if (!enableToggle) return; setTimeout(() => { + console.log("generating content"); // Generate content first var lastWeekUl = '