Skip to content

Commit

Permalink
Merge pull request #160 from fga-eps-mds/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
lucasmidlhey authored Nov 20, 2019
2 parents a93ba33 + 052371d commit d138a5d
Show file tree
Hide file tree
Showing 22 changed files with 868 additions and 316 deletions.
4 changes: 2 additions & 2 deletions APIs/branches_request/src/controllers/branchController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.get = async (req, res, next) =>

const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand All @@ -44,7 +44,7 @@ exports.get = async (req, res, next) =>

const header_optionB = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand Down
2 changes: 1 addition & 1 deletion APIs/commits_request/src/controllers/commitController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ commit_route.get = async (req, res, next) => {
const url_endpoint = `${gitApiUrl}/repos/${owner}/${repository}/${endpoint}`
const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${req.query.token}`
Expand Down
2 changes: 1 addition & 1 deletion APIs/issues_request/src/controllers/issueController.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports.get = async (req, res, next) => {

const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand Down
4 changes: 2 additions & 2 deletions APIs/issues_request/src/controllers/rankingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.get = async (req, res, next) => {

const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand All @@ -50,7 +50,7 @@ exports.get = async (req, res, next) => {

const header_option_2 = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand Down
2 changes: 1 addition & 1 deletion APIs/profile_request/src/controllers/profileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ profile_route.get = async (req, res, next) => {
const url_endpoint = `${gitApiUrl}/${endpoint}/${owner}`
const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${req.query.token}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.get = async (req, res, next) => {

const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports.get = async (req, res, next) => {

const header_option = {
headers: {
'Accept': 'application/json',
'Accept': 'application/vnd.github.v3+json',
'Accept-Charset': 'utf-8',
'User-Agent': '2019.2-Git-Breakdown',
'Authorization': `token ${token}`
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<h1 align="center"> Git Breakdown </h1>

<p align="right">
<img src="https://api.codeclimate.com/v1/badges/208bad6783e37daacf22/maintainability">

<img src="https://img.shields.io/badge/docs-Github%20Pages-blue.svg">

<img src="https://gitlab.com/omateusp/2019-2-Git-Breakdown/badges/master/pipeline.svg">
Expand Down
13 changes: 10 additions & 3 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"scripts/bootstrap.min.js",
"scripts/Chart.min.js",
"scripts/settings.js",
"scripts/hashChangeListener.js",
"scripts/graph.js",
"scripts/loadingPage.js",
"scripts/profilePage.js",
"scripts/branchesPage.js",
"scripts/commitsPage.js",
"scripts/issuesPage.js",
Expand All @@ -42,19 +45,23 @@
"scripts/observers.js",
"scripts/zenhubRequirements.js",
"scripts/button.js",
"scripts/screenConfig.js"
"scripts/screenConfig.js",
"scripts/metricsCalc.js"


],
"css":
[
"styles/bootstrap.min.css",
"styles/gbdStyle.css",
"styles/githubWebKit.css",
"styles/githubMainPageWebKit.css"
"styles/githubMainPageWebKit.css"

]
}],
"browser_action":
{
"default_popup": "popup.html"
"default_popup": "popup/popup.html"
},
"manifest_version": 2
}
45 changes: 0 additions & 45 deletions extension/popup.html

This file was deleted.

86 changes: 86 additions & 0 deletions extension/popup/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" alt="avatar" class="avatar">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


<style>
#popupContainer{
background: #24292e;
width: 100%;
margin-top: 5%;
margin-bottom: 6%;
margin-right: 10%;

}
button{
position: relative;
height: 50px;
width: 220px;
margin-top: 2%;
margin-bottom: 2%;
border-radius: 3px;
text-emphasis: none;
}
h4{
margin-top: 5%;
font-style: normal;
font-family: Arial, Helvetica, sans-serif;
color: white;
}
div{
margin-bottom: 2%;
margin-top: 2%;
}
a{
margin-bottom: 2%;
margin-top: 2%;
position: relative;
}
p{
font-size: 80%;
color: white;
}
.card{
margin-bottom: 0;
}
</style>
<script src="scripts/Chart.min.js"></script>
</head>

<body style="background-color: #24292e;">
<div class="container-fluid" id="popupContainer" data-toggle="center">
<img id="logo" src="../images/logo.jpg" class="img-thumbnail" alt="Responsive image">

<h4 class="text-center">Git Breakdown App</h4>

<div id="login">
<button type="button" class="btn btn-primary btn-dark " id="loginButton">Login</button>
</div>

<div id="logout">
<button type="button" class="btn-primary btn-dark" id="logoutButton">Logout</button>
</div>

<div id="aboutus_link">
<button type="button" class="btn btn-dark btn-sm" data-toggle="collapse" href="#aboutus_text">About Us</button>
</div>

<div class="collapse" id="aboutus_text" data-toggle="center">
<div class="w3-card w3-card-silver card-body">
<p>The Git Breakdown project is a Google Chrome extension for Github plug-in that seeks help or the user better defines a repository for contribution.
Our software has an API to extract data from Github to analyze created metrics.</p>
</div>
<a href="https://fga-eps-mds.github.io/2019.2-Git-Breakdown/#/" class="btn btn-secondary btn-sm" id="gitpages">Link Git Pages</a>
</div>

</div>

<script src="../scripts/jquery.min.js"></script>
<script src="../scripts/popper.min.js"></script>
<script src="../scripts/bootstrap.min.js"></script>
<script type="module" src="../scripts/popup.js"> </script>
</body>
</html>
72 changes: 64 additions & 8 deletions extension/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const FETCH_METRICS =
'ranking' // 4
]

const FETCH_PROFILE =
[
'profile'
]

async function fetchData(type, aux)
{
let url_fetch = `${url_base}/${type}/${aux}`
Expand All @@ -34,6 +39,46 @@ async function execute(request, aux)
{
try {
const data_ = await Promise.all(FETCH_METRICS.map(type => fetchData(type, aux)))

data_[0] = removeDuplicates(data_[0])
data_[4] = removeDuplicates(data_[4])

fetchedData = data_
fetchedData[5] = aux

return data_

} catch(err){
console.log("GBD error at background.js\nAt execute():", err)
}
}

function removeDuplicates(data)
{
let array = data
let seenNames = {}

array = array.filter(function(curr)
{
if (curr.name in seenNames)
{
return false
}
else
{
seenNames[curr.name] = true
return true
}
})

return array
}

async function executeProfile(request, aux)
{
try {
console.log("executing profile")
const data_ = await Promise.all(FETCH_PROFILE.map(type => fetchData(type, aux)))
fetchedData = data_
fetchedData[5] = aux
return data_
Expand Down Expand Up @@ -63,19 +108,30 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) =>
let repo = url[4].split("#")[0]
let url_aux =
`?owner=${owner}&repository=${repo}&token=${res.oauth2_token}&commits=${weights[0]}&merged=${weights[1]}&openissues=${weights[2]}&commentpr=${weights[3]}`
if (fetchedData.length > 0 && fetchedData[0] != undefined &&
fetchedData[5] == url_aux)
if (request.getProfile)
{
console.log("returning fetched data")
sendResponse(fetchedData)
console.log("fetching profile")
url_aux =
`?owner=${request.profile}&repository=${repo}&token=${res.oauth2_token}`
executeProfile(request, url_aux).then(sendResponse)
}
else
{
if (fetchedData.length > 0 && fetchedData[0] != undefined && fetchedData[4] != url_aux)
console.log("updating data")
console.log("not fetching profile")
if (fetchedData.length > 0 && fetchedData[0] != undefined &&
fetchedData[5] == url_aux)
{
console.log("returning fetched data")
sendResponse(fetchedData)
}
else
{
if (fetchedData.length > 0 && fetchedData[0] != undefined && fetchedData[5] != url_aux)
console.log("updating data")

console.log("fetching data")
execute(request, url_aux).then(sendResponse)
console.log("fetching data")
execute(request, url_aux).then(sendResponse)
}
}
} catch (err) {
console.log("GBD erro at background.js\nAt chrome.runtime.onMessage.addListener\n At function(tab):", err)
Expand Down
Loading

0 comments on commit d138a5d

Please sign in to comment.