Skip to content
Snippets Groups Projects
Commit a9adb003 authored by xangyr's avatar xangyr
Browse files

uploading

parent c73e10ae
No related branches found
No related tags found
No related merge requests found
app.py 0 → 100644
import time
from tkinter import messagebox
from github import Github
from tkinter import *
import webbrowser
root = Tk()
root.title('Git Dash')
root.geometry('600x600')
labelCount_issue = 0
labelCount_repo = 0
checkCount_issue = 0
checkCount_repo = 0
def open_web():
webbrowser.open(f'file://D:/code/UIUC/437/Git Dash/templates/index.html')
# webbrowser.open(f'file:///home/pi/Desktop/Git Dash/templates/index.html')
def create_issue_label():
global labelCount_issue
issueFrameLabel = Label(issueFrame, text='List of top open issues', font=("Courier", 10))
issueFrameLabel.pack(pady=10)
labelCount_issue += 1
def create_repo_label():
global labelCount_repo
repoFrameLabel = Label(repoFrame, text='List of repository', font=("Courier", 10))
repoFrameLabel.pack(pady=10)
labelCount_repo += 1
def check_issue():
global checkCount_issue
global issueList
global scrollbar
if not labelCount_issue:
create_issue_label()
if not checkCount_issue:
scrollbar = Scrollbar(issueFrame)
scrollbar.pack(side=RIGHT, fill=Y)
issueList = Listbox(issueFrame, yscrollcommand=scrollbar.set)
else:
issueList.delete(0, END)
for repo in repos:
if repo.get_issues().totalCount:
print(repo.name, repo.description)
for i in repo.get_issues():
print(f'title:\t{i.title}\nnumber:\t{i.number}')
print(i.created_at)
list_issue.append(i)
issueList.insert(END,
f'{i.title}; #{i.number}; \"{i.body if i.body else "empty description"}\"')
# print(repo.get_issue(1).html_url)
issueList.pack(side=LEFT, expand=TRUE, fill=BOTH)
scrollbar.config(command=issueList.yview)
checkCount_issue += 1
issueList.bind('<Double-1>', issue_select)
def check_repo():
global checkCount_repo, checkCount_event
global repoList
global scrollbar
if not labelCount_repo:
create_repo_label()
if not checkCount_repo:
scrollbar = Scrollbar(repoFrame)
scrollbar.pack(side=RIGHT, fill=Y)
repoList = Listbox(repoFrame, yscrollcommand=scrollbar.set)
else:
repoList.delete(0, END)
for repo in repos:
list_repo.append(repo)
print(f'{repo.name}; {repo.language}')
repoList.insert(END, f'{repo.name}; {repo.language}')
repoList.pack(side=LEFT, expand=TRUE, fill=BOTH)
scrollbar.config(command=repoList.yview)
checkCount_repo += 1
checkCount_event = 0
repoList.bind('<Double-1>', repo_select)
def issue_select(event):
global newWindow
issue = list_issue[issueList.curselection()[0]]
print(issue)
print(issue.user.name)
newWindow = Toplevel(root)
newWindow.title('Open Issue')
newWindow.geometry('400x400')
Label(newWindow, text='Issue window').pack()
owner = Label(newWindow, text=f'owner: {issue.user.name}')
title = Label(newWindow, text=f'title: {issue.title}')
id = Label(newWindow, text=f'id: {issue.number}')
# url = Label(newWindow, text=f'url: {issue.html_url}')
creation = Label(newWindow, text=f'created date: {issue.created_at}')
update = Label(newWindow, text=f'last updated date: {issue.updated_at}')
description = Label(newWindow, text=f'Description: {issue.body}')
btn5 = Button(newWindow, text='open this issue in browser',
command=lambda: webbrowser.open_new(f'{issue.html_url}'))
owner.pack(pady=5)
title.pack(pady=5)
id.pack(pady=5)
# url.pack(pady=5)
creation.pack(pady=5)
update.pack(pady=5)
description.pack(pady=10)
btn5.pack(pady=10)
def repo_select(event):
global repoList
repo = list_repo[repoList.curselection()[0]]
print(repo)
print(repo.name)
webbrowser.open_new(repo.html_url)
# for e in repo.get_event():
def check_noti():
noti_count = g.get_user().get_notifications().totalCount
print(f'notification counts: \t{noti_count}')
if noti_count:
messagebox.showinfo("Message", f'You currently have {noti_count} notifications.\nJumping to notification page.')
# time.sleep(2)
# webbrowser.open_new('https://github.com/notifications')
else:
messagebox.showinfo("Message", f'You have {noti_count} notification.\nRelax.')
time.sleep(2)
webbrowser.open_new('https://github.com/notifications')
access_token = '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'
g = Github(access_token)
repos = g.get_user().get_repos()
list_issue = []
list_repo = []
mainFrame = Frame(root)
mainFrame.pack(side=TOP)
mainFrameLabel = Label(mainFrame, text="GitHub Dashboard", font=("Courier", 25))
mainFrameLabel.pack()
issueFrame = Frame(root)
issueFrame.pack(side=LEFT, expand=TRUE, fill=BOTH)
repoFrame = Frame(root)
repoFrame.pack(side=RIGHT, expand=TRUE, fill=BOTH)
btn1 = Button(mainFrame, text='Open browser', command=open_web)
btn1.pack(side=LEFT, padx=20)
btn2 = Button(mainFrame, text='Check open issues', command=check_issue)
btn2.pack(side=LEFT, padx=20)
btn3 = Button(mainFrame, text='Check notifications', command=check_noti)
btn3.pack(side=LEFT, padx=20)
btn4 = Button(mainFrame, text='Check your repos', command=check_repo)
btn4.pack(side=LEFT, padx=20)
root.mainloop()
// Get the GitHub username input form
const gitHubForm = document.getElementById('gitHubForm');
// Listen for submissions on GitHub username input form
gitHubForm.addEventListener('submit', (e) => {
// Prevent default form submission action
e.preventDefault();
// Get the GitHub username input field on the DOM
let usernameInput = document.getElementById('usernameInput');
// Get the value of the GitHub username input field
let gitHubUsername = usernameInput.value;
// Run GitHub API function, passing in the GitHub username
requestUserRepos(gitHubUsername);
})
function requestUserRepos(username) {
// Create new XMLHttpRequest object
const xhr = new XMLHttpRequest();
// GitHub endpoint, dynamically passing in specified username
const url = `https://api.github.com/users/${username}/repos?sort=updated`;
// Open a new connection, using a GET request via URL endpoint
// Providing 3 arguments (GET/POST, The URL, Async True/False)
xhr.open('GET', url, true);
// When request is received
// Process it here
xhr.onload = function() {
// Parse API data into JSON
const data = JSON.parse(this.response);
let root = document.getElementById('userRepos');
while (root.firstChild) {
root.removeChild(root.firstChild);
}
if (data.message === "Not Found") {
let ul = document.getElementById('userRepos');
// Create variable that will create li's to be added to ul
let li = document.createElement('li');
// Add Bootstrap list item class to each li
li.classList.add('list-group-item')
// Create the html markup for each li
li.innerHTML = (`
<p><strong>No account exists with username:</strong> ${username}</p>`);
// Append each li to the ul
ul.appendChild(li);
} else {
// Get the ul with id of of userRepos
let ul = document.getElementById('userRepos');
let p = document.createElement('p');
// ul.appendChild(p);
let cmp = 0;
let ref;
let count = 0;
// Loop over each object in data array
for (let i in data) {
// Create variable that will create li's to be added to ul
let li = document.createElement('li');
let rank = data[i].open_issues;
count = count + rank
// Add Bootstrap list item class to each li
li.classList.add('list-group-item')
// Create the html markup for each li
li.innerHTML = (`
<p><strong>Repo Name:</strong> ${data[i].name}</p>
<p><strong>Description:</strong> ${data[i].description}</p>
<p><strong>Main Language:</strong> ${data[i].language}</p>
<p><strong>Open Issues:</strong> ${data[i].open_issues}</p>
<p><strong>URL:</strong> <a href="${data[i].html_url}">${data[i].html_url}</a></p>
`);
if (rank > cmp) {
ul.insertBefore(li, ref);
cmp = rank;
ref = li;
} else {
// Append each li to the ul
ul.appendChild(li);
ref = ul.firstChild;
}
}
p.innerHTML = (`
<p><strong>Number of Public Repos</strong>: ${data.length}</p>
<p><strong>Total number of open issues</strong>: ${count}</p>`);
ul.insertBefore(p, ul.firstChild);
}
}
// Send the request to the server
xhr.send();
}
\ No newline at end of file
templates/assets/favicon.png

22.3 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GitHub API</title>
<link rel="icon" type="image/png" href="assets/favicon.png">
<!-- Import the Bootstrap CSS CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<h3 class="text-center mt-5">GitHub Dashboard</h3>
<form id="gitHubForm" class="form-inline mx-auto" style="width: 280px">
<input id="usernameInput" class="form-control mb-5" type="text" name="username" placeholder="GitHub Username">
<input type="submit" class="btn btn-primary ml-2 mb-5" value="Submit">
</form>
<ul id="userRepos" class="list-group mx-auto mb-5" style="width: 800px">
</ul>
<script src="app.js"></script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment