Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 092714a

Browse files
committed
Merge branch 'fixes_30065364' into 'develop'
Fixes 30065364 See merge request luettich/website!1
2 parents b7a1a88 + c03ec5f commit 092714a

File tree

9 files changed

+89
-46
lines changed

9 files changed

+89
-46
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
node_modules/
2+
.history
3+
.vscode
4+
.env
5+
public/
6+
7+
# compiled output
8+
/tmp
9+
/out-tsc
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
testem.log
34+
/typings
35+
36+
# e2e
37+
/e2e/*.js
38+
/e2e/*.map
39+
40+
# System Files
41+
.DS_Store
42+
Thumbs.db
43+
44+
src/public/
45+
.tmp

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- Nodejs 8 is required
66
- MongoDB 3.2
77
- kafka
8-
8+
- nodemon (for local development)
99

1010
## Install dependencies
1111

@@ -67,12 +67,12 @@ The following config parameters are supported, they are defined in `config.js` a
6767
| GITHUB_CLIENT_SECRET | the GitHub client secret | |
6868
| GITLAB_CLIENT_ID | the GitLab client id | |
6969
| GITLAB_CLIENT_SECRET | the GitLab client secret | |
70-
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder.com/ |
70+
| WEBSITE | used as base to construct various URLs | http://topcoderx.topcoder-dev.com/ |
7171

7272
| GITLAB_API_BASE_URL | The Gitlab API base URL | https://gitlab.com/api/v4 |
7373

7474
| TC_LOGIN_URL | URL to do TopCoder login | |
75-
| TC_USER_PROFILE_URL | URL to to call TopCoder API to get profile from token | https://accounts.topcoder.com/member?retUrl=http:%2F%2Ftopcoderx.topcoder.com%2Fapi%2Fv1%2Ftclogin |
75+
| TC_USER_PROFILE_URL | URL to to call TopCoder API to get profile from token | https://accounts.topcoder-dev.com/member?retUrl=http:%2F%2Ftopcoderx.topcoder-dev.com%2Fapi%2Fv1%2Ftclogin |
7676
|TOPIC | kafka topic| |
7777
|KAFKA_OPTIONS | kafka options| |
7878

@@ -102,7 +102,7 @@ The frontend config file contains following variables to be configured in `src/f
102102
- click the left panel --> Developer settings --> OAuth Apps
103103
- click the `Register a new application`, fill in the fields,
104104
note that the `Authorization callback URL` should be the deployed web site,
105-
for local deployment, it should be `http://topcoderx.topcoder.com`
105+
for local deployment, it should be `http://topcoderx.topcoder-dev.com`
106106
- after creating the OAuth app, you can see its client id and client secret,
107107
these should be set to GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET environment variables
108108

@@ -113,8 +113,8 @@ The frontend config file contains following variables to be configured in `src/f
113113
- click the `Applications` tab
114114
- enter application name, e.g. `Topcoder-x`
115115
- for Redirect URI, enter two callback URLs, one callback URL per line, so there are two lines:
116-
http://topcoderx.topcoder.com/api/v1/gitlab/owneruser/callback
117-
http://topcoderx.topcoder.com/api/v1/gitlab/normaluser/callback
116+
http://topcoderx.topcoder-dev.com/api/v1/gitlab/owneruser/callback
117+
http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback
118118
- for Scopes, check the `api` and `read_user`, the `api` is for owner user, the `read_user` is for normal user
119119
- finally click `Save application` to save the OAuth app, then you will see its generated Application Id and Secret,
120120
these should be set to GITLAB_CLIENT_ID and GITLAB_CLIENT_SECRET environment variables
@@ -134,12 +134,12 @@ Import docs/Ragnar.postman_collection.json and docs/Ragnar.postman_environment.j
134134
After admin login, the admin token is automatically set to ADMIN-TOKEN environment variable,
135135
then you may run the `Save GitHub User` and `Save GitLab User` tests to create owner user of your GitHub/GitLab usernames,
136136
note that you must modify the request body username to use your GitHub/GitLab user names.
137-
For the `Get User Mapping` test, you may quety mapping by providing either topcoderUsername, githubUsername or gitlabUsername.
137+
For the `Get User Mapping` test, you may query mapping by providing either topcoderUsername, githubUsername or gitlabUsername.
138138

139139
## Verification
140140

141141
- run `npm serve` to start the app
142-
- go to topcoderx.topcoder.com and it will redirect to Topcoder login page, after successful login it will redirect back to Topcoder x app.
142+
- go to topcoderx.topcoder-dev.com and it will redirect to Topcoder login page, after successful login it will redirect back to Topcoder x app.
143143
- go to settings by clicking username at top right corner
144144
- setup both git provider to authorize topcoder-x to manage your repo on behalf of you
145145
- go to project management and create/edit projects, create hook and label
@@ -149,10 +149,11 @@ For the `Get User Mapping` test, you may quety mapping by providing either topco
149149
## Heroku Deployment
150150
Follow the below steps to deploy the app to heroku
151151
1. `heroku login`
152-
2. `heroku create`
153-
3. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
154-
5. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
155-
6. `heroku open` to load the app on browser
152+
1. `heroku create`
153+
1. `heroku addons:create mongolab`
154+
1. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
155+
1. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
156+
1. `heroku open` to load the app on browser
156157

157158
NOTE: Once environment variable are changed in heroku please run
158159
`heroku run npm run build`

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
"serve": "./node_modules/.bin/concurrently \"npm run start:be\" \"npm run start:fe\"",
1616
"start:be": "nodemon src/app.js",
1717
"start:fe": "gulp build:watch",
18-
"build:fe": "gulp build",
19-
"build":"gulp build",
18+
"build": "gulp build",
2019
"test": "node ./node_modules/mocha/bin/mocha --recursive --timeout 999999 --colors tests/*.test.js --bail",
2120
"clean": "gulp clean",
2221
"publish": "gulp publish",
2322
"test:fe": "gulp protractor",
2423
"lint": "gulp lint",
25-
"serve:dist": "gulp serve:dist",
2624
"heroku-postbuild": "gulp build"
2725
},
2826
"dependencies": {

src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _.forEach(routes, (verbs, path) => {
4242
if (v3jwt) {
4343
const decoded = jwtDecode(v3jwt);
4444
req.currentUser = {
45-
handle: decoded.handle,
45+
handle: decoded.handle.toLowerCase(),
4646
};
4747
}
4848
req.signature = `${def.controller}#${def.method}`;

src/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
GITLAB_CLIENT_ID: process.env.GITLAB_CLIENT_ID || '',
2121
GITLAB_CLIENT_SECRET: process.env.GITLAB_CLIENT_SECRET || '',
2222
// used as base to construct various URLs
23-
WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder.com',
23+
WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder-dev.com',
2424

2525
GITHUB_OWNER_CALLBACK_URL: '/api/v1/github/owneruser/callback',
2626
GITLAB_OWNER_CALLBACK_URL: '/api/v1/gitlab/owneruser/callback',
@@ -29,9 +29,9 @@ module.exports = {
2929
USER_ADDED_TO_TEAM_SUCCESS_URL: '/#/app/members',
3030

3131
GITLAB_API_BASE_URL: process.env.GITLAB_API_BASE_URL || 'https://gitlab.com/api/v4',
32-
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts.topcoder.com/member',
32+
TC_LOGIN_URL: process.env.TC_LOGIN_URL || 'https://accounts.topcoder-dev.com/member',
3333
TC_LOGIN_CALLBACK_URL: '/api/v1/tclogin',
34-
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'http://api.topcoder.com/v2/user/profile',
34+
TC_USER_PROFILE_URL: process.env.TC_USER_PROFILE_URL || 'http://api.topcoder-dev.com/v2/user/profile',
3535

3636
// kafka configuration
3737
TOPIC: process.env.TOPIC || 'tc-x-events',

src/front/src/app/app.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,11 @@ angular.module('topcoderX', [
120120
})
121121
.state('app.membersAdded', {
122122
url: '/members',
123-
templateUrl: 'app/members/members.html',
124-
controller: 'MemberConroller',
123+
templateUrl: 'app/members/member.html',
124+
controller: 'MemberController',
125125
controllerAs: 'vm',
126126
});
127127

128128
$urlRouterProvider.otherwise('/app/main');
129129
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/);
130-
// use the HTML5 History API
131-
// $locationProvider.html5Mode(true);
132-
// $locationProvider.html5Mode({
133-
// enabled: true,
134-
// requireBase: false,
135-
// hashPrefix:'!'
136-
// });
137130
}]);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

33
angular.module('topcoderX')
4-
.controller('MainController', ['$scope', function ($scope) {
4+
.controller('MemberController', ['$scope', function ($scope) {
55
$scope.title = 'Members';
66
}]);

src/front/src/app/upsertproject/upsertproject.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
2828
if ($rootScope.project) {
2929
$scope.title = 'Edit a Project';
3030
$scope.project = $rootScope.project;
31-
$scope.project.id = $rootScope.project._id;
31+
$scope.project.id = $rootScope.project.id;
3232
$scope.editing = true;
3333
} else {
3434
$scope.title = 'Add a Project';
@@ -100,7 +100,7 @@ angular.module('topcoderX').controller('ProjectController', ['currentUser', '$sc
100100
'repoToken': $scope.token,
101101
'baseUrl': HOOK_BASE_URL,
102102
'repoType': $scope.repoType,
103-
'challengeId': $scope.project.id
103+
'projectId': $scope.project.id
104104
};
105105
ProjectService.createHooks(objc).then(function () {
106106
Alert.info('Webhook Added Successfully', $scope);

src/services/ProjectService.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Project = require('../models').Project;
1919

2020
const projectSchema = {
2121
project: {
22+
id: Joi.string().required(),
2223
title: Joi.string().required(),
2324
tcDirectId: Joi.number().required(),
2425
repoUrl: Joi.string().required(),
@@ -141,25 +142,27 @@ async function createLabel(body) {
141142
description: body.description,
142143
});
143144
}
145+
return;
144146
}
145147

146148
createLabel.schema = Joi.object().keys({
147-
repoType: Joi.string().required(),
148-
repoToken: Joi.string().required(),
149-
repoOwner: Joi.string().required(),
150-
repoName: Joi.string().required(),
151-
label: Joi.string().required(),
152-
description: Joi.string().required(),
153-
color: Joi.string().required(),
154-
baseUrl: Joi.string().required(),
149+
body: Joi.object().keys({
150+
repoType: Joi.string().required(),
151+
repoToken: Joi.string().required(),
152+
repoOwner: Joi.string().required(),
153+
repoName: Joi.string().required(),
154+
label: Joi.string().required(),
155+
description: Joi.string().required(),
156+
color: Joi.string().required(),
157+
}),
155158
});
156159

157160
/**
158161
* creates hook
159162
* @param {Object} body the request body
160163
*/
161164
async function createHook(body) {
162-
const projectDetail = await helper.ensureExists(Project, body.challengeId);
165+
const projectDetail = await helper.ensureExists(Project, body.projectId);
163166
if (body.repoType === 'github') {
164167
const client = gitHubApi.client(body.repoToken);
165168
const ghrepo = client.repo(`${body.repoOwner}/${body.repoName}`);
@@ -201,15 +204,18 @@ async function createHook(body) {
201204
}
202205
);
203206
}
207+
return;
204208
}
205209

206210
createHook.schema = Joi.object().keys({
207-
challengeId: Joi.string().required(),
208-
repoType: Joi.string().required(),
209-
repoOwner: Joi.string().required(),
210-
repoToken: Joi.string().required(),
211-
repoName: Joi.string().required(),
212-
baseUrl: Joi.string().required(),
211+
body: Joi.object().keys({
212+
projectId: Joi.string().required(),
213+
repoType: Joi.string().required(),
214+
repoOwner: Joi.string().required(),
215+
repoToken: Joi.string().required(),
216+
repoName: Joi.string().required(),
217+
baseUrl: Joi.string().required(),
218+
}),
213219
});
214220

215221
module.exports = {

0 commit comments

Comments
 (0)