acecalisto3 commited on
Commit
dd262f4
·
verified ·
1 Parent(s): e7a7e84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +136 -193
app.py CHANGED
@@ -230,44 +230,14 @@ bot = GitHubBot()
230
  # HTML and CSS integration
231
  custom_html = """
232
  <!DOCTYPE html>
233
- <html>
234
  <head>
235
- <title>GitHub Issue Manager</title>
236
  <meta charset="UTF-8">
237
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
238
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
239
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css" rel="stylesheet" type="text/css" />
 
240
  <style>
241
- body {
242
- background: linear-gradient(to bottom right, #121212, #303030) !important;
243
- color: #e0e0e0;
244
- font-family: 'Roboto', sans-serif;
245
- overflow-x: hidden; /* Prevent horizontal scrollbar */
246
-
247
- }
248
- .card {
249
- border-radius: 1.5rem;
250
- box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
251
- margin-bottom: 20px;
252
- }
253
- .input, .select, .textarea {
254
- border: 2px solid #4a4a4a;
255
- border-radius: 0.75rem;
256
- padding-inline: 1.5rem;
257
- padding-block: 0.75rem;
258
- }
259
- h1, h2, h3 {
260
- color: #e0e0e0;
261
- }
262
- .output-area {
263
- padding: 1.5rem;
264
- border-radius: 0.75rem;
265
- }
266
- .btn {
267
- border-radius: 0.75rem;
268
- padding-block: 0.75rem;
269
- padding-inline: 1.5rem;
270
- }
271
  .btn-primary {
272
  background-color: #7928CA;
273
  color: white;
@@ -280,173 +250,146 @@ custom_html = """
280
  }
281
  </style>
282
  </head>
283
- <body class="bg-gray-900">
284
- <div class="container mx-auto p-4" >
285
- <h1 class="text-4xl md:text-5xl font-extrabold text-center mb-8">GitHub Issue Manager</h1>
286
- <!-- GitHub Token & Repo URL -->
287
- <div class="card bg-gray-800 p-8">
288
- <div class="form-control">
289
- <label class="label">
290
- <span class="label-text">GitHub Token</span>
291
- </label>
292
- <input type="password" placeholder="Enter your GitHub Personal Access Token" class="input input-bordered input-primary" id="github-token">
293
- </div>
294
- <div class="form-control">
295
- <label class="label">
296
- <span class="label-text">Repository URL</span>
297
- </label>
298
- <input type="text" placeholder="Enter the full GitHub repository URL" class="input input-bordered input-primary" id="repo-url">
 
299
  </div>
300
- </div>
301
- <!-- Fetch & Resolve Section -->
302
- <div class="card bg-gray-800 p-8">
303
- <div class="flex justify-between gap-4">
304
- <button class="btn btn-primary" id="fetch-issues">Fetch Issues</button>
305
- <select class="select select-primary w-full max-w-xs" id="issue-dropdown" >
306
- <option disabled selected>Select Issue</option>
307
- </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  </div>
309
- <div class="form-control mt-4">
 
310
  <label class="label">
311
- <span class="label-text">Resolution</span>
312
  </label>
313
- <textarea class="textarea textarea-primary" placeholder="Enter the resolution details" id="resolution-textarea"></textarea>
314
  </div>
315
- <div class="form-control mt-4">
316
- <label class="label">
317
- <span class="label-text">Forked Repository URL</span>
318
- </label>
319
- <input type="text" placeholder="URL to your forked repository (Optional)" class="input input-bordered input-primary" id="forked-repo-url">
320
- </div>
321
- <div class="form-control mt-4">
322
- <button class="btn btn-success" id="resolve-issue">Resolve Issue</button>
323
- </div>
324
- </div>
325
- <!-- Output Area -->
326
- <div class="card bg-gray-800 p-8 mt-4" >
327
- <label class="label">
328
- <span class="label-text">Output</span>
329
- </label>
330
- <textarea class="textarea textarea-primary h-48" id="output-textarea" readonly></textarea>
331
- </div>
332
- <!-- URL to Extract -->
333
- <div class="card bg-gray-800 p-8 mt-4">
334
- <div class="form-control">
335
- <label class="label">
336
- <span class="label-text">URL</span>
337
- </label>
338
- <input type="text" placeholder="Enter a URL to extract information" class="input input-bordered input-primary" id="url-textbox">
339
- </div>
340
- <div class="form-control">
341
- <button class="btn btn-primary" id="extract-info">Extract Info</button>
342
  </div>
343
  </div>
344
- </div>
345
- <script>
346
- const githubTokenInput = document.getElementById('github-token');
347
- const repoUrlInput = document.getElementById('repo-url');
348
- const fetchIssuesButton = document.getElementById('fetch-issues');
349
- const issueDropdown = document.getElementById('issue-dropdown');
350
- const resolutionTextarea = document.getElementById('resolution-textarea');
351
- const forkedRepoUrlInput = document.getElementById('forked-repo-url');
352
- const resolveIssueButton = document.getElementById('resolve-issue');
353
- const outputTextarea = document.getElementById('output-textarea');
354
- const urlTextbox = document.getElementById('url-textbox');
355
- const extractInfoButton = document.getElementById('extract-info');
356
- fetchIssuesButton.addEventListener('click', async () => {
357
- const token = githubTokenInput.value;
358
- const repoUrl = repoUrlInput.value;
359
- if (!token || !repoUrl) {
360
- outputTextarea.value = "Please provide both GitHub Token and Repository URL.";
361
- return;
362
- }
363
- try {
364
- const response = await fetch('/fetch_issues', {
365
- method: 'POST',
366
- headers: {
367
- 'Content-Type': 'application/json',
368
- },
369
- body: JSON.stringify({ token: token, repoUrl: repoUrl }),
370
- });
371
- if (!response.ok) {
372
- throw new Error(`HTTP error! status: ${response.status}`);
373
- }
374
- const data = await response.json();
375
- if (data.error) {
376
- outputTextarea.value = data.error;
377
- } else {
378
- issueDropdown.innerHTML = '';
379
- data.issues.forEach(issue => {
380
- const option = document.createElement('option');
381
- option.value = issue.number;
382
- option.text = `${issue.number}: ${issue.title}`;
383
- issueDropdown.add(option);
384
- });
385
- }
386
- } catch (error) {
387
- outputTextarea.value = `Error fetching issues: ${error.message}`;
388
- }
389
- });
390
- resolveIssueButton.addEventListener('click', async () => {
391
- const token = githubTokenInput.value;
392
- const repoUrl = repoUrlInput.value;
393
- const issueNumber = issueDropdown.value;
394
- const resolution = resolutionTextarea.value;
395
- const forkedRepoUrl = forkedRepoUrlInput.value;
396
- if (!token || !repoUrl || !issueNumber || !resolution) {
397
- outputTextarea.value ="Please provide all required fields.";
398
- return;
399
- }
400
- try {
401
- const response = await fetch('/resolve_issue', {
402
- method: 'POST',
403
- headers: {
404
- 'Content-Type': 'application/json',
405
- },
406
- body: JSON.stringify({ token: token, repoUrl: repoUrl, issueNumber: issueNumber, resolution: resolution, forkedRepoUrl: forkedRepoUrl }),
407
- });
408
- if (!response.ok) {
409
- throw new Error(`HTTP error! status: ${response.status}`);
410
- }
411
- const data = await response.json();
412
- if (data.error) {
413
- outputTextarea.value = data.error;
414
- } else {
415
- outputTextarea.value = data.result;
416
- }
417
- } catch (error) {
418
- outputTextarea.value = `Error resolving issue: ${error.message}`;
419
- }
420
- });
421
- extractInfoButton.addEventListener('click', async () => {
422
- const url = urlTextbox.value;
423
- if (!url) {
424
- outputTextarea.value = "Please provide a URL.";
425
- return;
426
- }
427
- try {
428
- const response = await fetch('/extract_info', {
429
- method: 'POST',
430
- headers: {
431
- 'Content-Type': 'application/json',
432
- },
433
- body: JSON.stringify({ url: url }),
434
  });
435
- if (!response.ok) {
436
- throw new Error(`HTTP error! status: ${response.status}`);
437
- }
438
- const data = await response.json();
439
- if (data.error) {
440
- outputTextarea.value = data.error;
441
- } else {
442
- outputTextarea.value = JSON.stringify(data, null, 2);
443
- }
444
- } catch (error) {
445
- outputTextarea.value = `Error extracting info: ${error.message}`;
446
- }
447
- });
448
-
449
- </script>
450
  </body>
451
  </html>
452
  """
 
230
  # HTML and CSS integration
231
  custom_html = """
232
  <!DOCTYPE html>
233
+ <html lang="en">
234
  <head>
 
235
  <meta charset="UTF-8">
236
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
237
+ <title>GitHub Issue Manager</title>
238
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.css">
239
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
240
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  .btn-primary {
242
  background-color: #7928CA;
243
  color: white;
 
250
  }
251
  </style>
252
  </head>
253
+ <body>
254
+ <div id="app" class="container mx-auto p-4">
255
+ <h1 class="text-4xl md:text-5xl font-extrabold text-center mb-8">GitHub Issue Manager</h1>
256
+
257
+ <div class="card bg-gray-800 p-8">
258
+ <div class="form-control">
259
+ <label class="label">
260
+ <span class="label-text">GitHub Token</span>
261
+ </label>
262
+ <input type="password" placeholder="Enter your GitHub Personal Access Token" class="input input-bordered input-primary" v-model="githubToken">
263
+ </div>
264
+ <div class="form-control">
265
+ <label class="label">
266
+ <span class="label-text">Repository URL</span>
267
+ </label>
268
+ <input type="text" placeholder="Enter the full GitHub repository URL" class="input input-bordered input-primary" v-model="repoUrl">
269
+ </div>
270
  </div>
271
+
272
+ <div class="card bg-gray-800 p-8">
273
+ <div class="flex justify-between gap-4">
274
+ <button class="btn btn-primary" @click="fetchIssues">Fetch Issues</button>
275
+ <select class="select select-primary w-full max-w-xs" v-model="selectedIssue">
276
+ <option disabled="" selected="">Select Issue</option>
277
+ <option v-for="issue in issues" :key="issue.id" :value="issue">{{ issue.title }}</option>
278
+ </select>
279
+ </div>
280
+ <div class="form-control mt-4">
281
+ <label class="label">
282
+ <span class="label-text">Resolution</span>
283
+ </label>
284
+ <textarea class="textarea textarea-primary" placeholder="Enter the resolution details" v-model="resolution"></textarea>
285
+ </div>
286
+ <div class="form-control mt-4">
287
+ <label class="label">
288
+ <span class="label-text">Forked Repository URL</span>
289
+ </label>
290
+ <input type="text" placeholder="URL to your forked repository (Optional)" class="input input-bordered input-primary" v-model="forkedRepoUrl">
291
+ </div>
292
+ <div class="form-control mt-4">
293
+ <button class="btn btn-success" @click="resolveIssue">Resolve Issue</button>
294
+ </div>
295
  </div>
296
+
297
+ <div class="card bg-gray-800 p-8 mt-4">
298
  <label class="label">
299
+ <span class="label-text">Output</span>
300
  </label>
301
+ <textarea class="textarea textarea-primary h-48" v-model="output" readonly></textarea>
302
  </div>
303
+
304
+ <div class="card bg-gray-800 p-8 mt-4">
305
+ <div class="form-control">
306
+ <label class="label">
307
+ <span class="label-text">URL</span>
308
+ </label>
309
+ <input type="text" placeholder="Enter a URL to extract information" class="input input-bordered input-primary" v-model="url">
310
+ </div>
311
+ <div class="form-control">
312
+ <button class="btn btn-primary" @click="extractInfo">Extract Info</button>
313
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  </div>
315
  </div>
316
+
317
+ <script>
318
+ new Vue({
319
+ el: '#app',
320
+ data: {
321
+ githubToken: '',
322
+ repoUrl: '',
323
+ issues: [],
324
+ selectedIssue: '',
325
+ resolution: '',
326
+ forkedRepoUrl: '',
327
+ output: '',
328
+ url: ''
329
+ },
330
+ methods: {
331
+ fetchIssues() {
332
+ fetch('/fetch-issues', {
333
+ method: 'POST',
334
+ headers: {
335
+ 'Content-Type': 'application/json'
336
+ },
337
+ body: JSON.stringify({
338
+ githubToken: this.githubToken,
339
+ repoUrl: this.repoUrl
340
+ })
341
+ })
342
+ .then(response => response.json())
343
+ .then(data => {
344
+ this.issues = data.issues;
345
+ })
346
+ .catch(error => {
347
+ console.error(error);
348
+ });
349
+ },
350
+ resolveIssue() {
351
+ fetch('/resolve-issue', {
352
+ method: 'POST',
353
+ headers: {
354
+ 'Content-Type': 'application/json'
355
+ },
356
+ body: JSON.stringify({
357
+ githubToken: this.githubToken,
358
+ repoUrl: this.repoUrl,
359
+ issue: this.selectedIssue,
360
+ resolution: this.resolution,
361
+ forkedRepoUrl: this.forkedRepoUrl
362
+ })
363
+ })
364
+ .then(response => response.json())
365
+ .then(data => {
366
+ this.output = data.output;
367
+ })
368
+ .catch(error => {
369
+ console.error(error);
370
+ });
371
+ },
372
+ extractInfo() {
373
+ fetch('/extract-info', {
374
+ method: 'POST',
375
+ headers: {
376
+ 'Content-Type': 'application/json'
377
+ },
378
+ body: JSON.stringify({
379
+ url: this.url
380
+ })
381
+ })
382
+ .then(response => response.json())
383
+ .then(data => {
384
+ this.output = data.output;
385
+ })
386
+ .catch(error => {
387
+ console.error(error);
388
+ });
389
+ }
390
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  });
392
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
  </body>
394
  </html>
395
  """