diff --git a/.gitignore b/.gitignore index f655426..4d8dd43 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,6 @@ backend/__pycache__/ # Config files .prettierrc.js + +# Visual Studio +/.vs diff --git a/public/assets/badges/predefined/babysteps.png b/public/assets/badges/predefined/babysteps.png new file mode 100644 index 0000000..a3beecf Binary files /dev/null and b/public/assets/badges/predefined/babysteps.png differ diff --git a/public/assets/badges/special/topcommits.png b/public/assets/badges/special/topcommits.png new file mode 100644 index 0000000..bfb752f Binary files /dev/null and b/public/assets/badges/special/topcommits.png differ diff --git a/public/assets/badges/special/topmonthcommits.png b/public/assets/badges/special/topmonthcommits.png new file mode 100644 index 0000000..bdf899e Binary files /dev/null and b/public/assets/badges/special/topmonthcommits.png differ diff --git a/public/assets/badges/special/topweekcommits.png b/public/assets/badges/special/topweekcommits.png new file mode 100644 index 0000000..8332943 Binary files /dev/null and b/public/assets/badges/special/topweekcommits.png differ diff --git a/public/assets/badges/special/topyearcommits.png b/public/assets/badges/special/topyearcommits.png new file mode 100644 index 0000000..d8109ed Binary files /dev/null and b/public/assets/badges/special/topyearcommits.png differ diff --git a/public/index.html b/public/index.html index 5de8c81..0cc3873 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ - + CodeBadge + = badge.min_commits && commits <= badge.max_commits) { + url = badgeURLPrefix + badge.badge; + tooltip = badge.tooltip; + } + }); + return {url: url, tooltip: tooltip}; + } + + getBadgeFromName(name) { + let data = {}; + json.forEach(function(badge) { + if(badge.name === name) + { + data = badge; + } + }); + return data; + } + + getBadgeURLPrefix() + { + return badgeURLPrefix; + } + + getAllBadgeIDs() + { + let keys = []; + for(let i in json) + keys.push(json[i].name); + return keys; + } +} diff --git a/src/assets/badges/special/badges.json b/src/assets/badges/special/badges.json new file mode 100644 index 0000000..3eaea63 --- /dev/null +++ b/src/assets/badges/special/badges.json @@ -0,0 +1,34 @@ +{ + "topContributor": { + "badge": "topcommits.png", + "tooltip": "Awarded to the top contributor of your organization!", + "information": { + "title": "Top Contributor of All Time", + "description": "Assigned to the person who has the highest commits in your organization!" + } + }, + "topWeekContributor": { + "badge": "topweekcommits.png", + "tooltip": "Awarded to the one with with highest commits last week!", + "information": { + "title": "Top Contributor this Week", + "description": "Assigned to the person who had the highest commits last week in your organization!" + } + }, + "topMonthContributor": { + "badge": "topmonthcommits.png", + "tooltip": "Awarded to the one with with highest commits this month!", + "information": { + "title": "Top Contributor this Month", + "description": "Assigned to the person who has the highest commits this month in your organization!" + } + }, + "topYearContributor": { + "badge": "topyearcommits.png", + "tooltip": "Awarded to the one with with highest commits this year!", + "information": { + "title": "Top Contributor this Year", + "description": "Assigned to the person who has the highest commits this year in your organization!" + } + } +} \ No newline at end of file diff --git a/src/assets/badges/special/specialBadges.js b/src/assets/badges/special/specialBadges.js new file mode 100644 index 0000000..f8a3a45 --- /dev/null +++ b/src/assets/badges/special/specialBadges.js @@ -0,0 +1,83 @@ +import store from "../../../store"; +import rawdata from "./badges"; + +const json = JSON.parse(JSON.stringify(rawdata)); +const badgeURLPrefix = "/assets/badges/special/"; + +export default class SpecialBadges { + getBadges(name, orgName) { + let badges = []; + + const topCommits = store.getters.getTopCommits(orgName); + const topWeekCommits = store.getters.getTopWeekCommits(orgName); + const topMonthCommits = store.getters.getTopMonthCommits(orgName); + const topYearCommits = store.getters.getTopYearCommits(orgName); + + //Make sure to sort in descending order of priority of display + + if (topCommits[0].name === name) { + badges.push({ + url: badgeURLPrefix + json["topContributor"].badge, + tooltip: json["topContributor"].tooltip + }); + } + + if (topWeekCommits[0].name === name) { + if (topWeekCommits[0].weeks[topWeekCommits[0].weeks.length - 1].c > 0) { + badges.push({ + url: badgeURLPrefix + json["topWeekContributor"].badge, + tooltip: json["topWeekContributor"].tooltip + }); + } + } + + if (topMonthCommits[0].name === name) { + let actuallyHasCommited = false; + for (let week in topMonthCommits[0].weeks) { + if (week.c > 0) { + actuallyHasCommited = true; + break; + } + } + if (topMonthCommits[0].weeks.length < 4) actuallyHasCommited = false; + if (actuallyHasCommited) + badges.push({ + url: badgeURLPrefix + json["topMonthContributor"].badge, + tooltip: json["topMonthContributor"].tooltip + }); + } + + if (topYearCommits[0].name === name) { + let actuallyHasCommited = false; + for (let week in topYearCommits[0].weeks) { + if (week.c > 0) { + actuallyHasCommited = true; + break; + } + } + if (topYearCommits[0].weeks.length < 52) actuallyHasCommited = false; + if (actuallyHasCommited) + badges.push({ + url: badgeURLPrefix + json["topYearContributor"].badge, + tooltip: json["topYearContributor"].tooltip + }); + } + + return badges; + } + + getBadgeFromName(name) { + return json[name]; + } + + getBadgePrefixURL() { + return badgeURLPrefix; + } + + getAllBadgeIDs() { + let keys = []; + for(let key in json) + keys.push(key); + return keys; + } +} diff --git a/src/components/auth/Login.vue b/src/components/auth/Login.vue index 818c837..20413cc 100644 --- a/src/components/auth/Login.vue +++ b/src/components/auth/Login.vue @@ -35,7 +35,6 @@ export default { const code = window.location.href.match(/\?code=(.*)/); if (code) { this.isLoading = true; - console.log(this.isLoading); axios({ method: `post`, url: `${AxiosHelper.gatekeeperUrl}?client_id=${ diff --git a/src/components/badgeList/BadgeListItem.vue b/src/components/badgeList/BadgeListItem.vue new file mode 100644 index 0000000..9f17945 --- /dev/null +++ b/src/components/badgeList/BadgeListItem.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/components/general/Toolbar.vue b/src/components/general/Toolbar.vue index cf40562..9461e4c 100644 --- a/src/components/general/Toolbar.vue +++ b/src/components/general/Toolbar.vue @@ -1,6 +1,6 @@