diff --git a/APIs/branches_request/src/controllers/branchController.js b/APIs/branches_request/src/controllers/branchController.js
index e766cc7..335096a 100644
--- a/APIs/branches_request/src/controllers/branchController.js
+++ b/APIs/branches_request/src/controllers/branchController.js
@@ -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}`
@@ -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}`
diff --git a/APIs/commits_request/src/controllers/commitController.js b/APIs/commits_request/src/controllers/commitController.js
index cbe7136..ce01c47 100644
--- a/APIs/commits_request/src/controllers/commitController.js
+++ b/APIs/commits_request/src/controllers/commitController.js
@@ -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}`
diff --git a/APIs/issues_request/src/controllers/issueController.js b/APIs/issues_request/src/controllers/issueController.js
index cbe3294..72357da 100644
--- a/APIs/issues_request/src/controllers/issueController.js
+++ b/APIs/issues_request/src/controllers/issueController.js
@@ -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}`
diff --git a/APIs/issues_request/src/controllers/rankingController.js b/APIs/issues_request/src/controllers/rankingController.js
index 866d66c..e1c08cb 100644
--- a/APIs/issues_request/src/controllers/rankingController.js
+++ b/APIs/issues_request/src/controllers/rankingController.js
@@ -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}`
@@ -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}`
diff --git a/APIs/profile_request/src/controllers/profileController.js b/APIs/profile_request/src/controllers/profileController.js
index b8ec315..a23f6b8 100644
--- a/APIs/profile_request/src/controllers/profileController.js
+++ b/APIs/profile_request/src/controllers/profileController.js
@@ -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}`
diff --git a/APIs/pullrequests_request/src/controllers/pullrequestController.js b/APIs/pullrequests_request/src/controllers/pullrequestController.js
index 0e40423..203808f 100644
--- a/APIs/pullrequests_request/src/controllers/pullrequestController.js
+++ b/APIs/pullrequests_request/src/controllers/pullrequestController.js
@@ -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}`
diff --git a/APIs/pullrequests_request/src/controllers/rankingController.js b/APIs/pullrequests_request/src/controllers/rankingController.js
index 03da6ad..30010ac 100644
--- a/APIs/pullrequests_request/src/controllers/rankingController.js
+++ b/APIs/pullrequests_request/src/controllers/rankingController.js
@@ -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}`
diff --git a/README.md b/README.md
index 6ba65e5..32943fb 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,8 @@
Git Breakdown
+
+
diff --git a/extension/manifest.json b/extension/manifest.json
index 4ab725e..ca47862 100644
--- a/extension/manifest.json
+++ b/extension/manifest.json
@@ -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",
@@ -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
}
diff --git a/extension/popup.html b/extension/popup.html
deleted file mode 100644
index 4b3016b..0000000
--- a/extension/popup.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
GitBreakdown
- Log in to GitHub
- Logout
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/extension/popup/popup.html b/extension/popup/popup.html
new file mode 100644
index 0000000..bd18ac3
--- /dev/null
+++ b/extension/popup/popup.html
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extension/scripts/background.js b/extension/scripts/background.js
index 8a815ab..d7796f2 100644
--- a/extension/scripts/background.js
+++ b/extension/scripts/background.js
@@ -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}`
@@ -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_
@@ -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)
diff --git a/extension/scripts/hashChangeListener.js b/extension/scripts/hashChangeListener.js
new file mode 100644
index 0000000..6d87b94
--- /dev/null
+++ b/extension/scripts/hashChangeListener.js
@@ -0,0 +1,84 @@
+window.onhashchange = async function()
+{
+
+ let gbdButton = document.getElementById('gbdButton')
+ if (gbdButton !== this.undefined)
+ {
+ zenhubOnClick()
+ if (window.location.href.includes('#breakdown/issues'))
+ {
+ try{
+
+ document.getElementsByClassName('gbdContent')[0].innerHTML = issuesPage()
+ }catch(err){
+ console.log('GDB Erro: ', err)
+ }
+ }
+ else if (window.location.href.includes('#breakdown/commits')){
+ try {
+
+ document.getElementsByClassName('gbdContent')[0].innerHTML = commitsPage()
+ plotTop10Commiter()
+
+ } catch(err) {
+ console.log('GDB Erro: ', err)
+ }
+ }
+ else if (window.location.href.includes('#breakdown/branches') ) {
+ try{
+ document.getElementsByClassName('gbdContent')[0].innerHTML = branchPage()
+ }catch(err){
+ console.log('GBD error:', err)
+ }
+ }
+ else if ( window.location.href.includes('#breakdown/pr')) {
+ try{
+
+ document.getElementsByClassName('gbdContent')[0].innerHTML = prPage()
+
+ }catch(err){
+ console.log('GBD error:', err)
+ }
+
+ }
+ else if(window.location.href.includes('#breakdown/Profile')){
+ try{
+
+ let url = window.location.hash
+ url = url.split('=')
+
+ await getProfile(url[1])
+ setTimeout(function(){
+ plotPercentGraphics(url[1])
+ }, 2000)
+
+
+
+
+ }catch(err){
+ console.log('GBD error:', err)
+ }
+ }
+ else if (window.location.href.includes('#breakdown'))
+ {
+ let screen = document.getElementById('gbdScreen')
+ if (screen == null)
+ try{
+
+
+
+ selectBehavior()
+ initScreen()
+ }catch(err){
+ console.log('GBD error:', err)
+ }
+ }
+ else
+ {
+ if (gbdButton.className == 'js-selected-navigation-item gbdselected reponav-item')
+ {
+ gbdButton.classList.remove('gbdselected')
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/extension/scripts/loadingPage.js b/extension/scripts/loadingPage.js
new file mode 100644
index 0000000..59684cf
--- /dev/null
+++ b/extension/scripts/loadingPage.js
@@ -0,0 +1,23 @@
+function loadPage(){
+ let loadPage =
+ `
+
+ `
+ return loadPage
+}
+
+
+function plotProgress(size){
+ let progressBar = document.getElementById('gbdProgressBar')
+ progressBar.style.width = `${size}%`
+}
\ No newline at end of file
diff --git a/extension/scripts/metricsCalc.js b/extension/scripts/metricsCalc.js
new file mode 100644
index 0000000..042b06d
--- /dev/null
+++ b/extension/scripts/metricsCalc.js
@@ -0,0 +1,150 @@
+
+function calcPercentCommits(commitsData, userName){
+ let totalCommits = 0
+ for(user in commitsData)
+ totalCommits += commitsData[user].commits
+
+ let userCommits = commitsData.filter((user)=>{
+ return user.name === userName
+ })
+
+
+
+ let percent = ((+userCommits[0].commits) / (+totalCommits)).toString() * 100
+ return [totalCommits, userCommits[0].commits, percent]
+}
+
+
+function calcPercentOpenedIssues(rankingData , userName){
+ let totalOpenedIssues = 0
+ for(user in rankingData){
+ if (rankingData[user].opened_issues != undefined)
+ totalOpenedIssues += rankingData[user].opened_issues
+ }
+ let userOpenedIssues = rankingData.filter((user)=>{
+ return user.name === userName
+ })
+ let percent = ((+userOpenedIssues[0].opened_issues) / (+totalOpenedIssues)).toString() * 100
+
+ return [totalOpenedIssues, userOpenedIssues[0].opened_issues, percent]
+}
+
+//closed_issues always 0 in the server response
+function calcPercentClosedIssues(rankingData, userName){
+ let totalClosedIssues = 0
+
+ for(user in rankingData){
+ if(rankingData[user].closed_issues != undefined)
+ totalClosedIssues += rankingData[user].closed_issues
+ }
+
+ let userClosedIssues = rankingData.filter((user)=>{
+ return user.name === userName
+ })
+
+ let percent = ((+userClosedIssues[0].closed_issues) / (+totalClosedIssues)).toString() * 100
+
+ return [percent]
+}
+
+
+function calcPercentMergedPullRequest(rankingData , userName){
+ let totalPrMerged = 0
+ for(user in rankingData){
+ if(rankingData[user].merged_pull_requests != undefined)
+ totalPrMerged += rankingData[user].merged_pull_requests
+ }
+
+ let userMergedPrs = rankingData.filter((user)=>{
+ return user.name === userName
+ })
+
+
+ let percent = ((+userMergedPrs[0].merged_pull_requests) / (+totalPrMerged)).toString() * 100
+
+
+ return [totalPrMerged, userMergedPrs[0].merged_pull_requests, percent]
+
+}
+
+function createPercentGraphic(data, ctx, labels , label, title)
+{
+ const PercentChart= new Chart(ctx,
+ {
+ type: 'pie',
+ data:
+ {
+ labels: [labels[0], labels[1]],
+ datasets:
+ [{
+ label: label,
+ fontColor: 'white',
+ data: [data[0], data[1]],
+ backgroundColor:
+ [
+ 'rgba(255, 99, 132, 0.6)',
+ 'rgba(54, 162, 235, 0.6)'
+ ],
+ borderColor:
+ [
+ 'rgba(255, 99, 132, 1)',
+ 'rgba(54, 162, 235, 1)'
+ ],
+ borderWidth: 1
+ }]
+ },
+ options:
+ {
+ tooltips:
+ {
+ titleFontSize: 12,
+ bodyFontSize: 12
+ },
+ maintainAspectRatio: false,
+ title:
+ {
+ fontSize: 12,
+ fontColor: 'white',
+ display: true,
+ text: title
+ },
+ scales:
+ {
+ ticks:
+ {
+ display: false
+ }
+ },
+ legend: {
+ labels: {
+ fontColor: 'white',
+ fontSize: 12
+ }
+ }
+ }
+ })
+}
+
+
+function plotPercentGraphics(userName){
+
+
+ let percentOpenedIssues = calcPercentOpenedIssues(rankingData, userName)
+ let percentOpenedIssuesGraphic = document.getElementById('percentIssues').getContext('2d')
+ let percentOpenedIssuesLabels = ['total of issues', `issues opened by ${userName}`]
+ createPercentGraphic(percentOpenedIssues, percentOpenedIssuesGraphic, percentOpenedIssuesLabels,
+ '# of issues opened', `issues opened by ${userName}`)
+
+ let percentMergedPr = calcPercentMergedPullRequest(rankingData, userName)
+ let percentMergedPrGraphic = document.getElementById('percentPullRequests').getContext('2d')
+ let percentMergedPrLabels = ['total of merged Pull Requests', `Merged pull requests opened by ${userName}`]
+ createPercentGraphic(percentMergedPr , percentMergedPrGraphic , percentMergedPrLabels,
+ '# of merged Pull Request', `Pull requests merged by ${userName}`)
+
+ let percentCommits = calcPercentCommits(commitsData , userName)
+ let percentCommitsGraphic = document.getElementById('percentCommits').getContext('2d')
+ let percentCommitsLabels = ['total of commits', `${userName} commits`]
+ createPercentGraphic(percentCommits, percentCommitsGraphic, percentCommitsLabels,
+ '# of commits', `commits from ${userName}`)
+
+}
\ No newline at end of file
diff --git a/extension/scripts/popup.js b/extension/scripts/popup.js
index 9d43edc..e62b37a 100644
--- a/extension/scripts/popup.js
+++ b/extension/scripts/popup.js
@@ -21,6 +21,11 @@ document.getElementById('logoutButton').addEventListener("click", function()
}
})
+document.getElementById('gitpages').addEventListener("click", function()
+{
+ window.open('https://fga-eps-mds.github.io/2019.2-Git-Breakdown/#/')
+},false)
+
document.addEventListener('DOMContentLoaded', function()
{
chrome.tabs.query
diff --git a/extension/scripts/profilePage.js b/extension/scripts/profilePage.js
new file mode 100644
index 0000000..d2def7d
--- /dev/null
+++ b/extension/scripts/profilePage.js
@@ -0,0 +1,87 @@
+//this function is not used yet
+function profilePage(user, profile){
+ let profilePage =
+ `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `
+ return profilePage
+}
+//percentPullRequests
+//percentCommits
+//percentIssues
+
+function findUser(){
+ let url = window.location.hash
+ url = url.split('=')
+ for(user in rankingData){
+ if( url[1] === rankingData[user].name)
+ return [rankingData[user], ((+user)+(+1)).toString(), rankingData.length]
+ }
+}
+
+
+function getProfile(username)
+{
+ return new Promise((resolve, reject) =>{
+ chrome.runtime.sendMessage({metric: weights, getProfile: true, profile: username}, function(response)
+ {
+ if (response !== undefined)
+ {
+
+ document.getElementsByClassName('gbdContent')[0].innerHTML = profilePage(findUser(), response[0])
+ }
+ else
+ {
+ console.log("profile response undefined")
+ }
+
+
+ })
+ resolve('profile displaying')
+ })
+
+}
+
+
+function getLocation(location){
+ if (location != null){
+ return location
+ }else{
+ return 'unknown'
+ }
+}
\ No newline at end of file
diff --git a/extension/scripts/screenConfig.js b/extension/scripts/screenConfig.js
index 9b8142d..b8b0fdd 100644
--- a/extension/scripts/screenConfig.js
+++ b/extension/scripts/screenConfig.js
@@ -1,25 +1,45 @@
let url_base = 'http://18.215.242.203:3000'
-let issuesData , branchsData, prData, commitsData, rankingData
+let issuesData, branchsData, prData, commitsData, rankingData, profileData
-let weights = [4,5,3,2] // default weights
-let sprintLength = 7 // default sprint size
+let weights = [4,5,2,3] // default weights
-function getMetrics()
+let sprintLength = 7
+
+
+function getMetrics(updateRanking)
{
- chrome.runtime.sendMessage({metric: weights}, function(response)
+ if (updateRanking === undefined)
{
- if (response !== undefined)
+ console.log("updateRanking undefined")
+ updateRanking = false
+ }
+
+ return new Promise((resolve, reject) =>{
+ chrome.runtime.sendMessage({metric: weights, getProfile: false, profile: ""}, function(response)
{
- commitsData = response[0]
- issuesData = response[1]
- branchsData = response[2]
- prData = response[3]
- rankingData = response[4]
- console.log(rankingData)
- }
+ if (response !== undefined)
+ {
+ commitsData = response[0]
+ issuesData = response[1]
+ branchsData = response[2]
+ prData = response[3]
+ rankingData = response[4]
+ profileData = response[5]
+
+ if (updateRanking)
+ {
+ console.log("updating ranking")
+ setTimeout(function(){
+ plotRanking(updateRanking)
+ },3000)
+ }
+ }
+ })
+ resolve('metrics Done')
})
+
}
const METRICS =
@@ -31,54 +51,59 @@ const METRICS =
'ranking' // 4
]
-const homeBtn = () => {
- let homeBtn = document.getElementById('gbdHomeBtn')
- homeBtn.addEventListener('click', () => {
- try{
- document.getElementsByClassName('gbdContent')[0].innerHTML = initScreen()
- }catch(err) {
- console.log("GBD error:", err)
- }
- })
+function homeBtn(){
+ return new Promise((resolve, reject)=>{
+ let homeBtn = document.getElementById('gbdHomeBtn')
+ homeBtn.addEventListener('click', () => {
+ try{
+ document.getElementsByClassName('gbdContent')[0].innerHTML = initScreen()
+ }catch(err) {
+ console.log('GBD error:', err)
+ }
+ })
+ resolve('Home Button ready')
+ })
+
}
-const initScreen = () =>
-{
-
- //function to control the select behavior in buttons inside navbar
- zhplugin()
- selectBehavior()
+ function placeScreen(){
+ return new Promise((resolve, reject)=>{
+ let mainContainer = document.getElementById('gbdScreen')
+ mainContainer.innerHTML = gbdScreen()
+ resolve('GBD screen Ready')
+ })
+ }
-
- //Catching the container
- try{
+ function placeContainer(){
+ return new Promise((resolve, reject)=>{
let mainContainer = document.getElementsByTagName('div')
let containgerPattern = /.*(container-lg clearfix new-discussion-timeline experiment-repo-nav)+.*/
for(let i = 0 ; i < mainContainer.length ; i++){
let className = mainContainer[i].className
let answer = containgerPattern.exec(className)
if (answer != null){
- mainContainer[i].innerHTML = gbdScreen()
- mainContainer[i].style.maxWidth = "100%"
+ mainContainer[i].innerHTML = loadPage()
+ mainContainer[i].style.maxWidth = '100%'
break;
- }
-
+ }
}
- homeBtn()
- }catch(err) {
- console.log('GBD Error:', err)
- }
-
- try{
+ resolve('MainContainer Ready')
+ })
+ }
+
+ function plotGraphics(){
+ return new Promise((resolve, reject)=>{
if (typeof chrome.app.isInstalled !== 'undefined'){
chrome.runtime.sendMessage({metric: weights}, function(response) {
if (response !== undefined){
- console.log("good response")
+
commitsData = response[0]
issuesData = response[1]
branchsData = response[2]
prData = response[3]
rankingData = response[4]
+ profileData = response[5]
+
try{
let issuesCtx = document.getElementById('issuesDashboard').getContext('2d')
@@ -96,24 +121,44 @@ const initScreen = () =>
for (let i = 0; i < 4; i++)
chartOnClick(i, response[i])
}catch(err){
- console.log("GBD error:", err)
+ console.log('GBD error:', err)
}
}else
- console.log("undefined response")
+ console.log('undefined response')
})
}
else
- console.log("undefined chrome app")
+ console.log('undefined chrome app')
+
+ resolve('Graphics Done')
+ })
+ }
+
+async function initScreen() {
+
+ //function to control the select behavior in buttons inside navbar
+ zhplugin()
+ selectBehavior()
+ try{
+ await placeContainer()
+ plotProgress()
+ await placeScreen()
+ await homeBtn()
+ await plotGraphics()
+ settingsOnClick()
+ setTimeout(function(){
+ plotRanking(false)
+ },3000)
- }catch(err) {
- console.log("GBD error:", err)
+ }catch(err){
+ console.log('GBD error:', err)
}
- settingsOnClick()
-
+
+
+
}
-// triggers when save button from configuration page is clicked
$(document).on("click", "#settingsSave", function()
{
sprintLength = $('#sprintLength').val()
@@ -122,73 +167,10 @@ $(document).on("click", "#settingsSave", function()
weights[2] = $('#openWeight').val()
weights[3] = $('#commentsWeight').val()
alert("Configurations saved!")
- getMetrics()
+ getMetrics(true)
+ $('#settingsButton').popover('hide')
})
-window.onhashchange = function()
-{
- console.log("changed")
- let gbdButton = document.getElementById('gbdButton')
- if (gbdButton !== this.undefined)
- {
- zenhubOnClick()
- if (window.location.href.includes("#breakdown/issues"))
- {
- try{
-
- document.getElementsByClassName('gbdContent')[0].innerHTML = issuesPage()
- }catch(err){
- console.log("GDB Erro: ", err)
- }
- }
- else if (window.location.href.includes("#breakdown/commits")){
- try {
-
- document.getElementsByClassName('gbdContent')[0].innerHTML = commitsPage()
- plotTop10Commiter()
-
- } catch(err) {
- console.log("GDB Erro: ", err)
- }
- }
- else if (window.location.href.includes("#breakdown/branches") ) {
- try{
- document.getElementsByClassName('gbdContent')[0].innerHTML = branchPage()
- }catch(err){
- console.log("GBD error:", err)
- }
- }
- else if ( window.location.href.includes("#breakdown/pr")) {
- try{
-
- document.getElementsByClassName('gbdContent')[0].innerHTML = prPage()
-
- }catch(err){
- console.log("GBD error:", err)
- }
-
- }
- else if (window.location.href.includes("#breakdown"))
- {
- let screen = document.getElementById('gbdScreen')
- if (screen == null)
- try{
- selectBehavior()
- initScreen()
- }catch(err){
- console.log("GBD error:", err)
- }
- }
- else
- {
- if (gbdButton.className == 'js-selected-navigation-item gbdselected reponav-item')
- {
- gbdButton.classList.remove('gbdselected')
- }
- }
- }
-}
-
const chartOnClick = (type, data) =>
{
const chart = document.getElementById(METRICS[type])
@@ -199,31 +181,42 @@ const chartOnClick = (type, data) =>
let screen = document.getElementById('gbdScreen')
if (screen != null)
{
- console.log(METRICS[type].split("Dashboard")[0])
- window.location.hash = `#breakdown/${METRICS[type].split("Dashboard")[0]}`
+ console.log(METRICS[type].split('Dashboard')[0])
+ window.location.hash = `#breakdown/${METRICS[type].split('Dashboard')[0]}`
}
})
}
}
-const gbdButtonOnClick = () =>{
- const gbdtab = document.getElementById('gbdButton')
- if (gbdtab !== null){
- gbdtab.addEventListener('click', function(){
- let screen = document.getElementById('gbdScreen')
- if (screen == null && window.location.href.includes("#breakdown"))
- initScreen()
- selectBehavior()
- zenhubOnClick()
- })
- }
+function gbdButtonOnClick() {
+ return new Promise((resolve, reject)=>{
+ const gbdtab = document.getElementById('gbdButton')
+ if (gbdtab !== null){
+ gbdtab.addEventListener('click', function(){
+ let screen = document.getElementById('gbdScreen')
+ if (screen == null && window.location.href.includes('#breakdown'))
+ initScreen()
+ selectBehavior()
+ zenhubOnClick()
+ })
+ }
+ resolve('ok')
+ })
}
+
+
+async function initExtension(){
+ await getMetrics(false)
+ await gbdButtonOnClick()
+}
+
+
try{
- getMetrics()
- gbdButtonOnClick()
-}catch(err){
- console.log("GBD error:", err)
+ initExtension()
+}
+catch(err){
+ console.log('GBD error:', err)
}
diff --git a/extension/scripts/screenPage.js b/extension/scripts/screenPage.js
index d1fdb68..de20c05 100644
--- a/extension/scripts/screenPage.js
+++ b/extension/scripts/screenPage.js
@@ -1,14 +1,13 @@
+
+
function gbdScreen()
{
let urlLogo = chrome.extension.getURL("images/logo.jpg")
let urlCog = chrome.extension.getURL("images/cog-8x.png")
let gbdScreen =
- `
-
-
+ `
-
GitBreakdown
@@ -88,91 +87,148 @@ function gbdScreen()
-
-
-
-
-
-
-
-
-
-
-
- Rank
- User
- Score
-
-
-
-
- 1
- pxpc2
- 2000
-
-
- 2
- wdvictor
- 420
-
-
- 3
- baea
- 120
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ Rank
+ User
+ Score
+
+
+
+
+
+
Contribution status Legends
+
good
+
ok
+
bad
+
+
+
-
-
-
`
return gbdScreen
-}
\ No newline at end of file
+}
+
+
+
+
+function plotRanking(updateRanking){
+ console.log(weights)
+ if(updateRanking){
+ try{
+ let rankingTable = document.getElementById('gbdRanking')
+ let tbody = document.getElementById('gbdRankingTbody')
+ rankingTable.removeChild(tbody)
+ plotRanking(false)
+ }catch(err){
+ console.error(err)
+ }
+ }
+ else{
+ let rankingTable = document.getElementById('gbdRanking')
+ let tbody = document.createElement('tbody')
+ tbody.id = 'gbdRankingTbody'
+ let pos = 1
+ try{
+ for(user in rankingData){
+
+ let tr = document.createElement('tr')
+ tr.innerHTML =
+ `
+
${pos}
+
${rankingData[user].name}
+
${rankingData[user].score}
+
+ `
+ pos+=1
+ tbody.appendChild(tr)
+ tr.id = `${rankingData[user].name}`
+ tr.addEventListener('click', ()=>{
+ window.location.hash = `#breakdown/Profile=${tr.id}`
+
+ })
+
+ tr.onpointerover = () => {
+ tr.style.opacity = '50%'
+ }
+
+ tr.onpointerleave = () => {
+ tr.style.opacity = '100%'
+ }
+
+ }
+ rankingTable.appendChild(tbody)
+ plotColorStatus()
+ }catch(err){
+ console.log("GBD error:", err)
+ }
+
+ }
+
+
+
+}
+
+
+function plotColorStatus(){
+ let ranking = document.getElementById('gbdRankingTbody').childNodes
+
+ let avarage = getScoreAvarage(rankingData)
+
+ for(user in ranking){
+ if(ranking[user].id != undefined)
+ if(rankingData[user].score > avarage+15)
+ document.getElementById(ranking[user].id).style.backgroundColor = 'green'
+ else if( rankingData[user].score < avarage+15 && rankingData[user].score > avarage-15)
+ document.getElementById(ranking[user].id).style.backgroundColor = 'blue'
+ else
+ document.getElementById(ranking[user].id).style.backgroundColor = 'red'
+ }
+
+
+
+}
+
+function getScoreAvarage(rankingData){
+ let scoreAvarage = 0
+ let total = 0
+
+ for(user in rankingData){
+ if(rankingData[user].score != undefined){
+ scoreAvarage += rankingData[user].score
+ total++
+ }
+ }
+ return scoreAvarage / total
+}
diff --git a/extension/scripts/settings.js b/extension/scripts/settings.js
index 5690350..1ae4e1d 100644
--- a/extension/scripts/settings.js
+++ b/extension/scripts/settings.js
@@ -1,6 +1,3 @@
-
-
-
function settingsOnClick()
{
let button = document.getElementById("settingsButton")
@@ -12,10 +9,20 @@ function settingsOnClick()
sanitize: false,
selector: true,
html: true,
- title: '
Settings page ',
+ title: '
Settings ',
content: $("#settingsContent").remove().html()
}
)
+ $(document).mouseup(function (e)
+ {
+ let container = $(".popover")
+
+ if (!container.is(e.target)
+ && container.has(e.target).length === 0)
+ {
+ container.popover("hide")
+ }
+ })
}
}
\ No newline at end of file
diff --git a/extension/styles/gbdStyle.css b/extension/styles/gbdStyle.css
index 7a20dd1..c02d8fb 100644
--- a/extension/styles/gbdStyle.css
+++ b/extension/styles/gbdStyle.css
@@ -1,3 +1,8 @@
+
+/*
+ Always you want to override the default bootstrap behavior, use !important
+*/
+
#gbdScreen {
background-color: lightgray;
position: relative;
@@ -5,9 +10,9 @@ border-radius : 25px;
box-shadow: #24292e;
border-top : 0;
width : 100%;
-height : 600px;
+height : 100%;
left:0;
-
+overflow: hidden;
}
.popover
@@ -34,46 +39,6 @@ top:5%;
max-height: inherit;
}
-.col
-{
- height: 400px !important;
- padding-right: 2%;
-}
-
-.row
-{
- max-height: 80% !important;
-}
-
-.right
-{
- margin-right: 1.5%;
-}
-
-.nopadding {
- padding: 0 !important;
- margin: 0 !important;
- }
-
-.card
-{
- position: relative;
- display: block;
- width: 100% !important;
- min-width: 450px !important;
- min-height: 235px !important;
- max-width: 478px !important;
- max-height: 240px !important;
-}
-
-.card-body
-{
- position: relative;
- display: block;
- height: 20% !important;
- width: 100%;
- padding: 0 !important;
-}
.reponav-item.gbdselected {
color:#24292e;
@@ -91,6 +56,26 @@ rgba(0,51,102,0.7) #e1e4e8 transparent;
left : 40%;
}
+.col {
+ margin-left: 2%;
+ margin-right: 2%;
+}
+
+.row {
+ margin-top: 2%;
+ margin-bottom: 2%;
+}
+
+.table{
+ margin-top: 2%;
+ margin-bottom: 2%;
+}
+
+.card {
+ width: 95%;
+ margin-left: 2%;
+ margin-right: 2%;
+}
.chartjs-render-monitor {
display: block;
@@ -129,7 +114,9 @@ rgba(0,51,102,0.7) #e1e4e8 transparent;
}
#metricContainer {
+ position: relative;
display:flex;
+ overflow: scroll;
padding-top: 15px;
height: 90%;
}
@@ -159,3 +146,53 @@ input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
-webkit-appearance: inner-spin-button !important;
}
+
+
+.table-responsive{
+ max-height: 1000px !important;
+ overflow: auto !important;
+}
+
+#repoRanking{
+ max-height: 1000px !important;
+ overflow: auto !important;
+}
+
+#gbdProgressBar{
+ background-color: black;
+}
+
+
+
+.container {
+ margin-left: 0;
+}
+
+
+#legends{
+ text-align: center;
+ padding-top: 10%;
+}
+
+#legends div{
+ margin: 0 auto;
+ padding-top: 2%;
+ width: 70%;
+ height: 10%;
+ text-align: center;
+}
+
+#good{
+ background-color: green;
+
+}
+
+#ok{
+ background-color: blue;
+
+}
+
+#bad{
+ background-color: red;
+
+}
diff --git a/extension/styles/popupStyle.css b/extension/styles/popupStyle.css
new file mode 100644
index 0000000..ef55a97
--- /dev/null
+++ b/extension/styles/popupStyle.css
@@ -0,0 +1,4 @@
+.container-fluid{
+ width: 30%;
+ height: 50%;
+}
\ No newline at end of file