Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ushahidi/platform-client
Browse files Browse the repository at this point in the history
  • Loading branch information
rowasc committed Sep 25, 2019
2 parents 7c41722 + 8dc523b commit 4c68b41
Show file tree
Hide file tree
Showing 15 changed files with 954 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"-event",
"makeTestApp",
"BACKEND_URL",
"USH_DISABLE_CHECKS",
"VERIFIER",
"RAVEN_URL",
"ENVIRONMENT",
"GIT_COMMIT"
Expand Down
4 changes: 4 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ window.ushahidi = window.ushahidi || {};
// this 'environment variable' will be set within the gulpfile
var backendUrl = window.ushahidi.backendUrl = (window.ushahidi.backendUrl || BACKEND_URL).replace(/\/$/, ''),
intercomAppId = window.ushahidi.intercomAppId = window.ushahidi.intercomAppId || '',
ushDisableChecks = (window.ushahidi.ushDisableChecks || USH_DISABLE_CHECKS),
verifier = window.ushahidi.verifier = (window.ushahidi.verifier || VERIFIER),
appStoreId = window.ushahidi.appStoreId = window.ushahidi.appStoreId || '',
apiUrl = window.ushahidi.apiUrl = backendUrl + '/api/v3',
claimedAnonymousScopes = [
Expand Down Expand Up @@ -89,12 +91,14 @@ angular.module('app',
API_URL : apiUrl,
INTERCOM_APP_ID : intercomAppId,
APP_STORE_ID : appStoreId,
VERIFIER : verifier,
DEFAULT_LOCALE : 'en_US',
OAUTH_CLIENT_ID : 'ushahidiui',
OAUTH_CLIENT_SECRET : '35e7f0bca957836d05ca0492211b0ac707671261',
CLAIMED_ANONYMOUS_SCOPES : claimedAnonymousScopes,
CLAIMED_USER_SCOPES : ['*'],
MAPBOX_API_KEY : window.ushahidi.mapboxApiKey || 'pk.eyJ1IjoidXNoYWhpZGkiLCJhIjoiY2lxaXUzeHBvMDdndmZ0bmVmOWoyMzN6NiJ9.CX56ZmZJv0aUsxvH5huJBw', // Default OSS mapbox api key
USH_DISABLE_CHECKS : ushDisableChecks,
TOS_RELEASE_DATE : new Date(window.ushahidi.tosReleaseDate).toJSON() ? new Date(window.ushahidi.tosReleaseDate) : false, // Date in UTC
EXPORT_POLLING_INTERVAL : window.ushahidi.export_polling_interval || 30000
})
Expand Down
10 changes: 6 additions & 4 deletions app/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ require('angular-lazy-bootstrap/src/bootstrap.js');
// Load site config THEN bootstrap the app
angular.lazy()
.resolve(['$q', '$http', function ($q, $http) {
return $http.get(window.ushahidi.apiUrl + '/config')
.then(function (response) {
window.ushahidi.bootstrapConfig = response.data.results;
});
if (!window.ushahidi.verifier) {
return $http.get(window.ushahidi.apiUrl + '/config')
.then(function (response) {
window.ushahidi.bootstrapConfig = response.data.results;
});
}
}])
.loading(function () {
// Show loading
Expand Down
4 changes: 3 additions & 1 deletion app/common/common-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ angular.module('ushahidi.common', [
.directive('categorySelector', require('./directives/category-selector.directive.js'))
.directive('languageSwitch', require('./directives/language-switch.directive.js'))
.directive('loadingDots', require('./directives/loading-dots.directive.js'))

// Event actions
.constant('EVENT', {
ACTIONS : {
Expand All @@ -128,6 +127,9 @@ angular.module('ushahidi.common', [
.run(['$templateCache', function ($templateCache) {
$templateCache.put('common/directives/mode-bar/ushahidi-logo.html', require('./directives/mode-bar/ushahidi-logo.html'));
}])
.factory('Verifier', function () {
return require('./verifier/verifier.js');
})
;

// Load submodules
Expand Down
6 changes: 6 additions & 0 deletions app/common/common-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@ module.exports = ['$stateProvider', '$urlMatcherFactoryProvider', function ($sta
template: require('./auth/404.html')
}
)
.state({
name: 'verifier',
url: '/verifier',
controller: require('./verifier/verifier.controller.js'),
template: require('./verifier/verifier.html')
})
;
}];
122 changes: 122 additions & 0 deletions app/common/verifier/verifier.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
module.exports = [
'$scope',
'CONST',
'Verifier',
function ($scope, CONST, Verifier) {
$scope.networkCheck = true;
$scope.envCheck = true;
$scope.endpointStatuses = [];
$scope.endpointStructureChecks = [];
$scope.transifexCheck = true;
$scope.oauthCheck = true;
$scope.dbConnection = true;
$scope.apiEnvs = true;
$scope.allDisabled = Verifier.isCheckDisabled(CONST, 'ALL');

function activate() {
if ($scope.allDisabled) {
return;
}
checkNetwork();
envCheck();
endpointStatusCheck();
endpointStructureCheck();
checkTransifex();
verifyOauth();
verifyDbConnection();
verifyAPIEnvs();
}

function checkNetwork() {
const verifyNetwork = Verifier.verifyNetwork(CONST);
if (!verifyNetwork) {
$scope.networkCheck = false;
} else {
verifyNetwork
.then(response => {
$scope.networkCheck = response;
$scope.$apply();
});
}
}

function envCheck() {
$scope.envCheck = Verifier.verifyEnv(CONST);
}

function endpointStatusCheck() {
const endpointStatusCheck = Verifier.verifyEndpointStatus(CONST);
if (!endpointStatusCheck) {
$scope.endpointStatuses = false;
} else {
endpointStatusCheck.forEach(response => {
response.then(result => {
$scope.endpointStatuses.push(result);
$scope.$apply();
});
});
}
}

function endpointStructureCheck() {
const endpointStructureCheck = Verifier.verifyEndpointStructure(CONST);
if (!endpointStructureCheck) {
$scope.endpointStructureChecks = false;
} else {
endpointStructureCheck.forEach(response => {
response.then(result => {
$scope.endpointStructureChecks.push(result);
$scope.$apply();
});
});
}
}

function checkTransifex() {
$scope.transifexCheck = Verifier.verifyTransifex(CONST);
}

function verifyOauth() {
const results = Verifier.verifyOauth(CONST);
if (!results) {
$scope.oauthCheck = false;
} else {
results.status.then(status => {
$scope.oauthStatus = status;
$scope.$apply();
});
results.structure.then(structure => {
$scope.oauthStructure = structure;
$scope.$apply();
});
results.token.then(token => {
$scope.oauthToken = token;
$scope.$apply();
});
}
}

function verifyDbConnection() {
Verifier.verifyDbConnection(CONST).then(dbCheck => {
if (dbCheck === 'DISABLED') {
$scope.dbConnection = false;
} else {
$scope.dbConnection = dbCheck;
$scope.$apply();
}
});
}

function verifyAPIEnvs() {
Verifier.verifyAPIEnvs(CONST).then(apiEnvCheck => {
if (apiEnvCheck === 'DISABLED') {
$scope.apiEnvs = false;
} else {
$scope.apiEnvs = apiEnvCheck;
$scope.$apply();
}
});
}
activate();
}
];
Loading

0 comments on commit 4c68b41

Please sign in to comment.