From 4eadc30ed3b9a347f2eaae0b484511b177f3329c Mon Sep 17 00:00:00 2001 From: KVGarg Date: Fri, 9 Aug 2019 17:54:21 +0530 Subject: [PATCH] app.js: Get mentors from Webservices The webservices now has a table for mentors, that stores the requests created by contributor on the community website. After all checks are green, the contributor is added a mentor for the upcoming program based on the request. Therefore, fetch all those contributors from webservices for the upcoming GSoC program and append them to the mentors list Closes https://github.com/coala/projects/issues/728 --- partials/tabs/mentors.html | 8 ++++---- resources/css/style.css | 3 +++ resources/js/app.js | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/partials/tabs/mentors.html b/partials/tabs/mentors.html index 28b87b02..061a6fe9 100644 --- a/partials/tabs/mentors.html +++ b/partials/tabs/mentors.html @@ -4,7 +4,7 @@

Hello there!

- We are the mentors for coala in GSoC 2018. + We are the mentors for coala in GSoC {{ gic.nextProgramYear }}.

Just drop a message on Gitter - @@ -18,7 +18,7 @@

-
+
@@ -42,7 +42,7 @@

Admins

- We are the admins for coala in GSoC 2018. + We are the admins for coala in GSoC {{ gic.nextProgramYear }}.

Just drop a message on Gitter @@ -55,7 +55,7 @@

-
+
diff --git a/resources/css/style.css b/resources/css/style.css index f2395d87..1f94747e 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -1,3 +1,6 @@ +.black-shadow { + box-shadow: 0 0 15px 2px black; +} .hash_value_dup { position: 'absolute'; left: '-9999px'; diff --git a/resources/js/app.js b/resources/js/app.js index af811167..548a5c35 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -381,25 +381,49 @@ return { restrict: 'E', templateUrl: '/partials/tabs/mentors.html', - controller: function ($scope, $rootScope) { + controller: function ($scope, $rootScope, $log) { self = this self.mentorsList = {} self.adminsList = {} + $scope.getMentorsWebservicesURL = function(year){ + return 'https://webservices.coala.io/mentors?year='+year+'&program=GSoC' + } + + var today = new Date() + if(today.getMonth() > 9){ + self.nextProgramYear = today.getFullYear() + 1 + } + else { + self.nextProgramYear = today.getFullYear() + } + + var mentorsWebservicesURL = $scope.getMentorsWebservicesURL(self.nextProgramYear); + + $http.get(mentorsWebservicesURL) + .then(function(response){ + var mentors = response.data + angular.forEach(mentors, function (data) { + self.mentorsList[data.user.login] = { + "github_handle": data.user.login, + "github_avatar_url": "https://avatars.githubusercontent.com/" + data.user.login + } + }); + }) $http.get('data/projects.liquid') .then(function (res) { $scope.projects = res.data.filter(project => project.status != "completed") - angular.forEach($scope.projects, function(value, key){ - angular.forEach(value.mentors, function(value, key){ - self.mentorsList[value] = { - "github_handle" : value, - "github_avatar_url": "https://avatars.githubusercontent.com/" +value + angular.forEach($scope.projects, function (value, key) { + angular.forEach(value.mentors, function (value, key) { + self.mentorsList[value] = { + "github_handle": value, + "github_avatar_url": "https://avatars.githubusercontent.com/" + value } }); }); }) - $http.get('data/admins.json') + $http.get('data/admins.json') .then(function (res) { admins = res.data angular.forEach(admins, function(value, key){