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

Commit f6c1321

Browse files
committed
September release challenge updates
1 parent 5af4454 commit f6c1321

File tree

10 files changed

+84
-47
lines changed

10 files changed

+84
-47
lines changed

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
"angular-ui-bootstrap": "~2.5.0",
3838
"angular-ui-router": "~0.2.13",
3939
"auth0-angular": "~4.0.4",
40-
"auth0-js": "~6.4.2",
41-
"auth0-lock": "~7.6.2",
40+
"auth0-js": "^9.11.3",
41+
"auth0-lock": "^11.17.2",
4242
"bcryptjs": "^2.4.3",
4343
"bluebird": "^3.5.0",
4444
"body-parser": "^1.17.2",
45-
"bootstrap": "~3.3.5",
45+
"bootstrap": "^3.4.1",
4646
"concurrently": "^3.5.0",
4747
"config": "^1.26.2",
4848
"cookie-parser": "^1.4.3",
@@ -62,7 +62,7 @@
6262
"guid": "0.0.12",
6363
"icheck": "1.0.2",
6464
"joi": "^10.6.0",
65-
"jquery": "~2.1.1",
65+
"jquery": "^3.4.1",
6666
"jsonwebtoken": "^7.4.3",
6767
"jwt-decode": "^2.2.0",
6868
"lodash": "^4.17.4",
@@ -73,9 +73,9 @@
7373
"pace-js": "~1.0.2",
7474
"parse-domain": "^2.1.2",
7575
"shortid": "^2.2.8",
76+
"ssl-express-www": "^3.0.3",
7677
"superagent": "^3.6.0",
7778
"superagent-promise": "^1.1.0",
78-
"ssl-express-www": "^3.0.3",
7979
"typescript": "~2.3.3",
8080
"uuid": "^3.3.2",
8181
"winston": "^2.3.1"
@@ -87,10 +87,10 @@
8787
"babel-preset-env": "^1.7.0",
8888
"babel-preset-es2016": "^6.24.1",
8989
"babelify": "^8.0.0",
90-
"brfs": "1.4.3",
91-
"browser-sync": "~2.18.8",
92-
"browserify": "^9.0.3",
93-
"browserify-css": "0.10.1",
90+
"brfs": "^2.0.2",
91+
"browser-sync": "^2.26.7",
92+
"browserify": "^16.5.0",
93+
"browserify-css": "^0.15.0",
9494
"browserify-shim": "^3.8.10",
9595
"chai": "^4.1.1",
9696
"chalk": "~0.5.1",
@@ -116,26 +116,26 @@
116116
"gulp-flatten": "~0.0.4",
117117
"gulp-inject": "~1.0.2",
118118
"gulp-jshint": "~2.0.4",
119-
"gulp-less": "~1.3.6",
120-
"gulp-load-plugins": "~1.5.0",
119+
"gulp-less": "^1.3.6",
120+
"gulp-load-plugins": "^2.0.1",
121121
"gulp-minify-html": "~1.0.6",
122122
"gulp-ng-annotate": "~1.0.0",
123-
"gulp-ng-config": "~1.2.1",
124-
"gulp-protractor": "~4.0.0",
123+
"gulp-ng-config": "^1.5.1",
124+
"gulp-protractor": "^4.1.1",
125125
"gulp-rename": "~1.2.0",
126126
"gulp-replace": "~0.5.0",
127127
"gulp-rev": "~2.0.1",
128128
"gulp-rev-replace": "~0.3.1",
129129
"gulp-size": "~1.1.0",
130-
"gulp-uglify": "~1.0.1",
130+
"gulp-uglify": "^1.5.4",
131131
"gulp-useref": "^2.1.0",
132132
"http-proxy": "~1.7.0",
133133
"jasmine-core": "^2.5.2",
134134
"jshint": "~2.9.4",
135135
"jshint-stylish": "~1.0.0",
136-
"mocha": "^3.5.0",
136+
"mocha": "^6.2.0",
137137
"natives": "^1.1.6",
138-
"protractor": "~5.1.1",
138+
"protractor": "^6.0.0",
139139
"require-dir": "~0.3.2",
140140
"supertest": "^3.0.0",
141141
"uglify-save-license": "~0.4.1",

src/app.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ _.forEach(routes, (verbs, path) => {
101101

102102
// static content
103103
app.use(express.static(Path.join(__dirname, 'public')));
104-
// mount the angular app
105-
app.use('*', express.static(Path.join(__dirname, 'public')));
104+
app.use('*', (req, res) => {
105+
res.redirect('/');
106+
});
106107

107108
// Error handler
108109
app.use((err, req, res, next) => {

src/config.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (c) 2017 TopCoder, Inc. All rights reserved.
33
*/
4-
// const fs = require('fs');
4+
const fs = require('fs');
55
/**
66
* Define config.
77
*
@@ -27,11 +27,11 @@ module.exports = {
2727
TOPIC: process.env.TOPIC || 'tc-x-events',
2828
KAFKA_OPTIONS: {
2929
connectionString: process.env.KAFKA_URL || 'localhost:9092',
30-
// ssl: {
31-
// cert: process.env.KAFKA_CLIENT_CERT || fs.readFileSync('./kafka_client.cer'), // eslint-disable-line no-sync
32-
// key: process.env.KAFKA_CLIENT_CERT_KEY || fs.readFileSync('./kafka_client.key'), // eslint-disable-line no-sync
33-
// passphrase: 'secret', // NOTE:* This configuration specifies the private key passphrase used while creating it.
34-
// },
30+
ssl: {
31+
cert: process.env.KAFKA_CLIENT_CERT || fs.readFileSync('./kafka_client.cer'), // eslint-disable-line no-sync
32+
key: process.env.KAFKA_CLIENT_CERT_KEY || fs.readFileSync('./kafka_client.key'), // eslint-disable-line no-sync
33+
passphrase: 'secret', // NOTE:* This configuration specifies the private key passphrase used while creating it.
34+
},
3535
},
3636
HOOK_BASE_URL: process.env.HOOK_BASE_URL || 'http://topcoderx.topcoder-dev.com',
3737
TOPCODER_ENV: process.env.TOPCODER_ENV || 'dev',

src/front/src/app/less/custom.less

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
font-size: 16px;
2222
}
2323

24+
.orange-warning-icon {
25+
color: orange;
26+
font-size: 16px;
27+
}
28+
2429
.white-remove-icon {
2530
color: white;
2631
font-size: 16px;

src/front/src/app/main/main.controller.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

33
angular.module('topcoderX')
4-
.controller('MainController', ['$scope', '$rootScope', 'Alert', '$state', 'AuthService', 'IssueService',
5-
function ($scope, $rootScope, Alert, $state, AuthService, IssueService) {
4+
.controller('MainController', ['$scope', '$rootScope', 'Alert', '$state', 'AuthService', 'IssueService', 'SettingService', '$log',
5+
function ($scope, $rootScope, Alert, $state, AuthService, IssueService, SettingService, $log) {
66
$scope.isLoaded = false;
77
$scope.tableConfig = {
88
readyForReview: {
@@ -139,4 +139,15 @@ angular.module('topcoderX')
139139
_search(provider);
140140
};
141141

142+
SettingService.userSetting($rootScope.currentUser.handle).then(function (response) {
143+
$log.log('logku');
144+
$log.log(response);
145+
if (response.data.expired.github) {
146+
Alert.error('Your Github token has expired. Please go to settings to renew your token', $scope);
147+
}
148+
if (response.data.expired.gitlab) {
149+
Alert.error('Your Gitlab token has expired. Please go to settings to renew your token', $scope);
150+
}
151+
});
152+
142153
}]);

src/front/src/app/main/main.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h2>Dashboard</h2>
99
<i class="fa fa-plus"></i> Add Project</button>
1010
</div>
1111
</div>
12-
12+
<div class="col-md-10 col-md-offset-1" ng-include src="'components/alert/alert.html'"></div>
1313
<div class="wrapper wrapper-content animated fadeInRight">
1414
<div class="row">
1515
<div class="col-lg-12">
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

33
angular.module('topcoderX').controller('SettingController', ['currentUser', '$scope', 'OWNER_LOGIN_GITHUB_URL',
4-
'OWNER_LOGIN_GITLAB_URL', 'SettingService', '$rootScope', 'Dialog', 'Alert', 'Helper',
4+
'OWNER_LOGIN_GITLAB_URL', 'SettingService', '$rootScope', 'Dialog', 'Alert', 'Helper', '$window',
55
function (currentUser, $scope, OWNER_LOGIN_GITHUB_URL,
6-
OWNER_LOGIN_GITLAB_URL, SettingService, $rootScope, Dialog, Alert, Helper) {
6+
OWNER_LOGIN_GITLAB_URL, SettingService, $rootScope, Dialog, Alert, Helper, $window) {
77
$scope.settings = {};
88
$scope.isLoaded = false;
99

@@ -24,23 +24,36 @@ angular.module('topcoderX').controller('SettingController', ['currentUser', '$sc
2424
gitlab: Helper.baseUrl + OWNER_LOGIN_GITLAB_URL,
2525
}
2626

27+
$scope.$on('dialog.finished', function (event, args) {
28+
if (args.proceed) {
29+
SettingService.revokeUserSetting(currentUser.handle, $rootScope.dialog.provider).then(function () {
30+
_getSetting();
31+
}).catch(function (error) {
32+
var errMsg = error.data ? error.data.message : "An error occurred while revoking the account."
33+
Alert.error(errMsg, $scope);
34+
});
35+
} else {
36+
$rootScope.dialog = {};
37+
}
38+
});
39+
2740
// Revoke gitlab or github account
2841
$scope.revoke = function(provider) {
2942
$rootScope.dialog = {
30-
proceed: false
43+
proceed: false,
44+
provider: provider
3145
};
32-
$scope.$on('dialog.finished', function (event, args) {
33-
if (args.proceed) {
34-
SettingService.revokeUserSetting(currentUser.handle, provider).then(function () {
35-
_getSetting();
36-
}).catch(function (error) {
37-
var errMsg = error.data ? error.data.message : "An error occurred while revoking the account."
38-
Alert.error(errMsg, $scope);
39-
});
40-
} else {
41-
$rootScope.dialog = {};
42-
}
43-
});
4446
Dialog.show('Are you sure you want to revoke the authorization token for ' + provider + '?', $scope);
4547
}
48+
49+
// Renew gitlab or github account token
50+
$scope.renew = function(provider) {
51+
SettingService.revokeUserSetting(currentUser.handle, provider).then(function () {
52+
$window.location.href = $scope.loginUrl[provider];
53+
}).catch(function (error) {
54+
var errMsg = error.data ? error.data.message : "An error occurred while renewing the token."
55+
Alert.error(errMsg, $scope);
56+
});
57+
}
58+
4659
}]);

src/front/src/app/settings/settings.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ <h2>Settings</h2>
1616
<div class="col-xs-6 col-md-2">Github</div>
1717
<div class="col-xs-6 col-md-2" ng-if='isLoaded'>
1818
<div ng-if='settings.github'>
19-
<i class="btn fa fa-check green-check-icon"></i>&nbsp;&nbsp;
20-
<i class="btn btn-sm btn-danger fa fa-remove white-remove-icon" ng-click="revoke('github')"></i>
19+
<i ng-if='!settings.expired.github' class="btn fa fa-check green-check-icon"></i>
20+
<i ng-if='settings.expired.github' class="btn fa fa-warning orange-warning-icon" ng-click="renew('github')" title="Renew the token"></i>&#09;
21+
<i class="btn btn-sm btn-danger fa fa-remove white-remove-icon" ng-click="revoke('github')" title="Revoke"></i>
2122
</div>
2223
<div ng-if='!settings.github'>
2324
<a class="btn btn-sm btn-info" ng-href="{{loginUrl.github}}">
@@ -30,8 +31,9 @@ <h2>Settings</h2>
3031
<div class="col-xs-6 col-md-2">Gitlab</div>
3132
<div class="col-xs-6 col-md-2" ng-if='isLoaded'>
3233
<div ng-if='settings.gitlab'>
33-
<i class="btn fa fa-check green-check-icon"></i>&nbsp;&nbsp;
34-
<i class="btn btn-sm btn-danger fa fa-remove white-remove-icon" ng-click="revoke('gitlab')"></i>
34+
<i ng-if='!settings.expired.gitlab' class="btn fa fa-check green-check-icon"></i>
35+
<i ng-if='settings.expired.gitlab' class="btn fa fa-warning orange-warning-icon" ng-click="renew('gitlab')" title="Renew the token"></i>&#09;
36+
<i class="btn btn-sm btn-danger fa fa-remove white-remove-icon" ng-click="revoke('gitlab')" title="Revoke"></i>
3537
</div>
3638
<div ng-if='!settings.gitlab'>
3739
<a class="btn btn-sm btn-info" ng-href="{{loginUrl.gitlab}}" target="_self">

src/services/ProjectService.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ async function createHook(body, currentUser) {
381381
if (err.statusCode === 404) { // eslint-disable-line no-magic-numbers
382382
err.message = `The repository is not found or doesn't have access to create webhook`;
383383
}
384-
throw helper.convertGitHubError(err, errMsg);
384+
throw helper.convertGitLabError(err, errMsg);
385385
}
386386
}
387387
return {

src/services/UserService.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async function getUserSetting(handle) {
2929
const setting = {
3030
github: false,
3131
gitlab: false,
32+
expired: {}
3233
};
3334

3435
if (!mapping) {
@@ -58,6 +59,10 @@ async function getUserSetting(handle) {
5859

5960
_.forEach(constants.USER_TYPES, (item) => {
6061
setting[item] = !!users.find((i) => i.type === item && i.accessToken);
62+
if (setting[item]) {
63+
setting['expired'][item] = !!users.find((i) =>
64+
i.type === item && i.accessTokenExpiration && i.accessTokenExpiration <= new Date().getTime());
65+
}
6166
});
6267
return setting;
6368
}

0 commit comments

Comments
 (0)