From 268905d303371674d42d15e59f18b0189ce94c54 Mon Sep 17 00:00:00 2001
From: CherrelleTucker <106271365+CherrelleTucker@users.noreply.github.com>
Date: Fri, 13 Dec 2024 15:48:35 -0600
Subject: [PATCH] #79
---
.../QuickGit_WebApp.js | 80 ++++++++-----------
1 file changed, 34 insertions(+), 46 deletions(-)
rename {DynamicDocToGitHubIssue => QuickGit}/QuickGit_WebApp.js (83%)
diff --git a/DynamicDocToGitHubIssue/QuickGit_WebApp.js b/QuickGit/QuickGit_WebApp.js
similarity index 83%
rename from DynamicDocToGitHubIssue/QuickGit_WebApp.js
rename to QuickGit/QuickGit_WebApp.js
index 98d6b0a..a156b44 100644
--- a/DynamicDocToGitHubIssue/QuickGit_WebApp.js
+++ b/QuickGit/QuickGit_WebApp.js
@@ -1,12 +1,16 @@
-/** Contains web app specific functions (doGet, handling web requests)
- - Contains doGet function for serving the web app
- - Has endpoint functions called directly by the frontend
- - Handles web-specific error reporting
- - Acts as a bridge between the frontend and core functionality
-**/
+/**
+ * WEBAPP.GS - Web Application Interface
+ * Contains web app specific functions and request handling
+ * Acts as bridge between frontend and core functionality
+ */
+
+// =============================================================================
+// WEB APP INITIALIZATION
+// =============================================================================
/**
* Handles web app requests and OAuth flow
+ * Entry point for the web application
* @param {Object} e - Event object from web app
* @returns {HtmlOutput} The HTML page
*/
@@ -15,27 +19,19 @@ function doGet(e) {
if (e.parameter.code) {
const result = handleOAuthCallback(e.parameter.code, e.parameter.state);
if (!result.success) {
- return HtmlService.createHtmlOutput(
- `
Authentication Failed
- Error: ${result.error}
- Please close this window and try again.
`
- );
+ return HtmlService.createHtmlOutput('Authentication Failed
Error: ' + result.error + '
');
}
- return HtmlService.createHtmlOutput(
- `Authentication Successful!
- You can close this window and return to QuickGit Refresh the page to access the tool.
- `
- );
+ return HtmlService.createHtmlOutput('Authentication Successful!
');
}
// Check if user is authenticated
const userProperties = PropertiesService.getUserProperties();
const isAuthenticated = Boolean(userProperties.getProperty('github_access_token'));
- // Create template and add authentication state
+ // Pass `isAuthenticated` to the HTML template
const template = HtmlService.createTemplateFromFile('index');
template.isAuthenticated = isAuthenticated;
-
+
// Log authentication state for debugging
console.log('User authentication state:', isAuthenticated);
@@ -45,15 +41,17 @@ function doGet(e) {
.addMetaTag('viewport', 'width=device-width, initial-scale=1');
}
+/* =============================================================================
+DOCUMENT PROCESSING ENDPOINTS
+=============================================================================
+*/
+
/**
- * Checks if user is authenticated
- * @returns {boolean} Authentication status
+ * Processes document from URL
+ * Called by frontend when processing a new document
+ * @param {string} docUrl - URL of document to process
+ * @returns {Object} Processing results or error
*/
-function checkAuthStatus() {
- const userProperties = PropertiesService.getUserProperties();
- return Boolean(userProperties.getProperty('github_access_token'));
-}
-
function processDocument(docUrl) {
try {
const doc = DocumentApp.openByUrl(docUrl);
@@ -99,6 +97,12 @@ function processDocument(docUrl) {
}
}
+/* =============================================================================
+ISSUE MANAGEMENT ENDPOINTS
+=============================================================================
+*/
+
+
/**
* Processes issues based on UI data
* @param {Object} data - Data object containing issue information
@@ -203,6 +207,11 @@ function validateIssue(issue, type) {
return false;
}
+/* =============================================================================
+GITHUB DATA ENDPOINTS
+=============================================================================
+*/
+
/**
* Gets repositories for frontend display
* @returns {Array} List of repositories
@@ -279,24 +288,3 @@ function fetchRepoIssues(repoName) {
}
}
-/**
- * Parses the document and returns structured content
- * Called by the frontend when processing a document
- * @param {string} docUrl - The URL of the document to process
- * @returns {Object} Parsed document content
- */
-function parseDocument(docUrl) {
- try {
- Logger.log('WebApp: Starting to parse document: ' + docUrl);
- const results = processGoogleDoc(docUrl);
- Logger.log('WebApp: Processing results: ' + JSON.stringify(results));
- return results;
- } catch (error) {
- Logger.log('WebApp: Error in parseDocument: ' + error.message);
- throw new Error(error.message);
- }
-}
-
-
-
-