acecalisto3 commited on
Commit
1887d43
·
verified ·
1 Parent(s): 4436fc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -37
app.py CHANGED
@@ -228,6 +228,26 @@ def extract_info_from_url(url: str) -> Dict[str, Any]:
228
  # Initialize GitHubBot globally
229
  bot = GitHubBot()
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  # HTML and CSS integration
232
  custom_html = """
233
  <!DOCTYPE html>
@@ -244,7 +264,6 @@ custom_html = """
244
  color: #e0e0e0;
245
  font-family: 'Roboto', sans-serif;
246
  overflow-x: hidden; /* Prevent horizontal scrollbar */
247
-
248
  }
249
  .card {
250
  border-radius: 1.5rem;
@@ -354,6 +373,7 @@ custom_html = """
354
  const outputTextarea = document.getElementById('output-textarea');
355
  const urlTextbox = document.getElementById('url-textbox');
356
  const extractInfoButton = document.getElementById('extract-info');
 
357
  fetchIssuesButton.addEventListener('click', async () => {
358
  const token = githubTokenInput.value;
359
  const repoUrl = repoUrlInput.value;
@@ -388,12 +408,14 @@ custom_html = """
388
  outputTextarea.value = `Error fetching issues: ${error.message}`;
389
  }
390
  });
 
391
  resolveIssueButton.addEventListener('click', async () => {
392
  const token = githubTokenInput.value;
393
  const repoUrl = repoUrlInput.value;
394
  const issueNumber = issueDropdown.value;
395
  const resolution = resolutionTextarea.value;
396
  const forkedRepoUrl = forkedRepoUrlInput.value;
 
397
  if (!token || !repoUrl || !issueNumber || !resolution) {
398
  outputTextarea.value ="Please provide all required fields.";
399
  return;
@@ -419,6 +441,7 @@ custom_html = """
419
  outputTextarea.value = `Error resolving issue: ${error.message}`;
420
  }
421
  });
 
422
  extractInfoButton.addEventListener('click', async () => {
423
  const url = urlTextbox.value;
424
  if (!url) {
@@ -446,42 +469,6 @@ custom_html = """
446
  outputTextarea.value = `Error extracting info: ${error.message}`;
447
  }
448
  });
449
-
450
- const submitButton = document.createElement('button');
451
- submitButton.textContent = 'Submit';
452
- submitButton.classList.add('btn', 'btn-primary');
453
- submitButton.addEventListener('click', async () => {
454
- const token = githubTokenInput.value;
455
- const repoUrl = repoUrlInput.value;
456
- const issueNumber = issueDropdown.value;
457
- const resolution = resolutionTextarea.value;
458
- const forkedRepoUrl = forkedRepoUrlInput.value;
459
- if (!token || !repoUrl || !issueNumber || !resolution) {
460
- outputTextarea.value ="Please provide all required fields.";
461
- return;
462
- }
463
- try {
464
- const response = await fetch('/submit', {
465
- method: 'POST',
466
- headers: {
467
- 'Content-Type': 'application/json',
468
- },
469
- body: JSON.stringify({ token: token, repoUrl: repoUrl, issueNumber: issueNumber, resolution: resolution, forkedRepoUrl: forkedRepoUrl }),
470
- });
471
- if (!response.ok) {
472
- throw new Error(`HTTP error! status: ${response.status}`);
473
- }
474
- const data = await response.json();
475
- if (data.error) {
476
- outputTextarea.value = data.error;
477
- } else {
478
- outputTextarea.value = data.result;
479
- }
480
- } catch (error) {
481
- outputTextarea.value = `Error submitting issue: ${error.message}`;
482
- }
483
- });
484
- document.body.appendChild(submitButton);
485
  </script>
486
  </body>
487
  </html>
 
228
  # Initialize GitHubBot globally
229
  bot = GitHubBot()
230
 
231
+ # Define missing functions
232
+ def fetch_issues(token, repo_url):
233
+ owner, repo = repo_url.split('/')[-2:]
234
+ issues = bot.fetch_issues(token, owner, repo)
235
+ return issues
236
+
237
+ def resolve_issue(token, repo_url, issue_number, resolution, forked_repo_url):
238
+ owner, repo = repo_url.split('/')[-2:]
239
+ result = bot.resolve_issue(token, owner, repo, issue_number, resolution, forked_repo_url)
240
+ return result
241
+
242
+ def extract_info(url):
243
+ info = extract_info_from_url(url)
244
+ return info
245
+
246
+ def submit_issue(token, repo_url, issue_number, resolution, forked_repo_url):
247
+ owner, repo = repo_url.split('/')[-2:]
248
+ result = bot.resolve_issue(token, owner, repo, issue_number, resolution, forked_repo_url)
249
+ return result
250
+
251
  # HTML and CSS integration
252
  custom_html = """
253
  <!DOCTYPE html>
 
264
  color: #e0e0e0;
265
  font-family: 'Roboto', sans-serif;
266
  overflow-x: hidden; /* Prevent horizontal scrollbar */
 
267
  }
268
  .card {
269
  border-radius: 1.5rem;
 
373
  const outputTextarea = document.getElementById('output-textarea');
374
  const urlTextbox = document.getElementById('url-textbox');
375
  const extractInfoButton = document.getElementById('extract-info');
376
+
377
  fetchIssuesButton.addEventListener('click', async () => {
378
  const token = githubTokenInput.value;
379
  const repoUrl = repoUrlInput.value;
 
408
  outputTextarea.value = `Error fetching issues: ${error.message}`;
409
  }
410
  });
411
+
412
  resolveIssueButton.addEventListener('click', async () => {
413
  const token = githubTokenInput.value;
414
  const repoUrl = repoUrlInput.value;
415
  const issueNumber = issueDropdown.value;
416
  const resolution = resolutionTextarea.value;
417
  const forkedRepoUrl = forkedRepoUrlInput.value;
418
+
419
  if (!token || !repoUrl || !issueNumber || !resolution) {
420
  outputTextarea.value ="Please provide all required fields.";
421
  return;
 
441
  outputTextarea.value = `Error resolving issue: ${error.message}`;
442
  }
443
  });
444
+
445
  extractInfoButton.addEventListener('click', async () => {
446
  const url = urlTextbox.value;
447
  if (!url) {
 
469
  outputTextarea.value = `Error extracting info: ${error.message}`;
470
  }
471
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  </script>
473
  </body>
474
  </html>