Skip to content

Commit

Permalink
Merge pull request #1089 from ushahidi/release/cycle-3-sms-csv
Browse files Browse the repository at this point in the history
Release/cycle 3 sms+csv To Master
  • Loading branch information
rowasc authored Apr 16, 2018
2 parents fffe9bd + 2384548 commit dd05401
Show file tree
Hide file tree
Showing 58 changed files with 2,631 additions and 344 deletions.
7 changes: 6 additions & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var backendUrl = window.ushahidi.backendUrl = (window.ushahidi.backendUrl || BAC
claimedAnonymousScopes = [
'apikeys',
'posts',
'country_codes',
'media',
'forms',
'api',
Expand Down Expand Up @@ -98,7 +99,8 @@ angular.module('app',
CLAIMED_USER_SCOPES : claimedAnonymousScopes.concat('dataproviders'),
MAPBOX_API_KEY : window.ushahidi.mapboxApiKey || 'pk.eyJ1IjoidXNoYWhpZGkiLCJhIjoiY2lxaXUzeHBvMDdndmZ0bmVmOWoyMzN6NiJ9.CX56ZmZJv0aUsxvH5huJBw', // Default OSS mapbox api key
TOS_RELEASE_DATE : new Date(window.ushahidi.tosReleaseDate).toJSON() ? new Date(window.ushahidi.tosReleaseDate) : false, // Date in UTC
PLATFORM_WEBSOCKET_REDIS_ADAPTER_URL : platform_websocket_redis_adapter_url
PLATFORM_WEBSOCKET_REDIS_ADAPTER_URL : platform_websocket_redis_adapter_url,
EXPORT_POLLING_INTERVAL : window.ushahidi.export_polling_interval || 30000
})
.config(['$compileProvider', function ($compileProvider) {
$compileProvider.debugInfoEnabled(false);
Expand Down Expand Up @@ -149,6 +151,9 @@ angular.module('app',
_.indexBy(window.ushahidi.bootstrapConfig, 'id') :
{ map: {}, site: {}, features: {} };
}])
.factory('Sortable', function () {
return require('sortablejs');
})
// inject the router instance into a `run` block by name
// .run(['$uiRouter', '$trace', '$location', function ($uiRouter, $trace, $location) {
// // * uncomment this to enable the visualizer *
Expand Down
114 changes: 61 additions & 53 deletions app/common/auth/authentication-events.run.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,10 @@
module.exports = AuthenticationEvents;
AuthenticationEvents.$inject = ['$rootScope', '$location', 'Authentication', 'Session', '_', '$state', 'TermsOfService', 'Notify', 'PostFilters'];
function AuthenticationEvents($rootScope, $location, Authentication, Session, _, $state, TermsOfService, Notify, PostFilters) {
AuthenticationEvents.$inject = ['$rootScope', '$location', 'Authentication', 'Session', '_', '$state', 'TermsOfService', 'Notify', 'PostFilters', 'DataExport'];
function AuthenticationEvents($rootScope, $location, Authentication, Session, _, $state, TermsOfService, Notify, PostFilters, DataExport) {
let loginPath = null;
$rootScope.currentUser = null;
$rootScope.loggedin = false;

activate();

function activate() {
if (Authentication.getLoginStatus()) {
doLogin(false, true);
} else {
doLogout(false);
}
}

function loadSessionData() {
$rootScope.currentUser = Session.getSessionData();
}

function doLogin(redirect, noReload) {
TermsOfService.getTosEntry()
.then(function () {
loadSessionData();
$rootScope.loggedin = true;
/**
* adminUserSetup is called AFRTER the user has agreed to terms of service.
* adminUserSetup is used to verify which user is logging in/logged in and opening a modal box
* when there is an admin login with the 'admin' email instead of a proper email.
* This is part of an effort to force admins to have proper emails and not use the default email/password combination that the
* system had during the setup process.
* references https://github.com/ushahidi/platform/issues/1714
*/
adminUserSetup();
PostFilters.resetDefaults();
if (redirect) {
$location.url(redirect);
}
noReload || $state.reload(); // in favor of $route.reload();

});
}

function doLogout(redirect) {
$rootScope.currentUser = null;
$rootScope.loggedin = false;
// we don' wat to reload until after filters are correctly set with the backend default that the user
// would get when logged out
PostFilters.resetDefaults().then(function () {
if (redirect) {
$location.url(redirect);
}

$state.go($state.$current.name ? $state.$current : 'map', null, { reload: true });
});
}

// todo: move to service
$rootScope.hasManagePermission = function () {
return $rootScope.isAdmin() ? true : ((($rootScope.currentUser || {}).permissions || {}).length > 0);
Expand Down Expand Up @@ -115,6 +64,65 @@ function AuthenticationEvents($rootScope, $location, Authentication, Session, _,
}
});

activate();

function activate() {
if (Authentication.getLoginStatus()) {
doLogin(false, true);
} else {
doLogout(false);
}
}

function loadSessionData() {
$rootScope.currentUser = Session.getSessionData();
}

function loadExportJob() {
if ($rootScope.hasPermission('Bulk Data Import')) {
DataExport.loadExportJob();
}
}

function doLogin(redirect, noReload) {
TermsOfService.getTosEntry()
.then(function () {
loadSessionData();
$rootScope.loggedin = true;

/**
* adminUserSetup is called AFRTER the user has agreed to terms of service.
* adminUserSetup is used to verify which user is logging in/logged in and opening a modal box
* when there is an admin login with the 'admin' email instead of a proper email.
* This is part of an effort to force admins to have proper emails and not use the default email/password combination that the
* system had during the setup process.
* references https://github.com/ushahidi/platform/issues/1714
*/
adminUserSetup();
loadExportJob();
PostFilters.resetDefaults();
if (redirect) {
$location.url(redirect);
}
noReload || $state.reload(); // in favor of $route.reload();

});
}

function doLogout(redirect) {
$rootScope.currentUser = null;
$rootScope.loggedin = false;
// we don' wat to reload until after filters are correctly set with the backend default that the user
// would get when logged out
PostFilters.resetDefaults().then(function () {
if (redirect) {
$location.url(redirect);
}

$state.go($state.$current.name ? $state.$current : 'map', null, { reload: true });
});
}

function adminUserSetup() {
if ($rootScope.currentUser.email === 'admin' && $rootScope.isAdmin()) {
Notify.adminUserSetupModal();
Expand Down
2 changes: 1 addition & 1 deletion app/common/auth/password-reset-confirm.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#warning"></use>
</svg>
<span translate="{{'user.valid.password.' + error}}" translate-default="{{error}}"></span>
<p translate="{{'user.valid.password.' + error}}" translate-default="{{error}}"></p>
</div>
</div>
<div class="form-field">
Expand Down
6 changes: 3 additions & 3 deletions app/common/auth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#warning"></use>
</svg>
<span translate="{{'user.valid.full_name.' + error}}" translate-default="{{error}}"></span>
<p translate="{{'user.valid.full_name.' + error}}" translate-default="{{error}}"></p>
</div>
</div>
<div class="form-field" ng-class="{ 'success': !form.email.$invalid && form.email.$dirty, 'error' : form.email.$invalid && form.email.$dirty}">
Expand All @@ -34,7 +34,7 @@
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#warning"></use>
</svg>
<span translate="{{'user.valid.email.' + error}}" translate-default="{{error}}"></span>
<p translate="{{'user.valid.email.' + error}}" translate-default="{{error}}"></p>
</div>
</div>
<div class="form-field" ng-class="{ 'success': !form.password.$invalid && form.password.$dirty, 'error' : form.password.$invalid && form.password.$dirty}">
Expand All @@ -51,7 +51,7 @@
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#warning"></use>
</svg>
<span translate="{{'user.valid.password.' + error}}" translate-default="{{error}}"></span>
<p translate="{{'user.valid.password.' + error}}" translate-default="{{error}}"></p>
</div>

</div>
Expand Down
3 changes: 2 additions & 1 deletion app/common/auth/session.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function (
grantType: undefined,
role: undefined,
permissions: undefined,
gravatar: undefined
gravatar: undefined,
language: undefined
};

this.sessionData = angular.copy(this.clearedSessionData);
Expand Down
6 changes: 6 additions & 0 deletions app/common/common-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ angular.module('ushahidi.common', [
.service('FormAttributeEndpoint', require('./services/endpoints/form-attributes.js'))
.service('FormRoleEndpoint', require('./services/endpoints/form-roles.js'))
.service('FormStageEndpoint', require('./services/endpoints/form-stages.js'))
.service('FormStatsEndpoint', require('./services/endpoints/form-stats-endpoint.js'))
.service('FormContactEndpoint', require('./services/endpoints/form-contact.js'))
.service('TagEndpoint', require('./services/endpoints/tag.js'))
.service('RoleEndpoint', require('./services/endpoints/role.js'))
.service('WebhookEndpoint', require('./services/endpoints/webhooks.js'))
Expand All @@ -48,6 +50,9 @@ angular.module('ushahidi.common', [
.service('ContactEndpoint', require('./services/endpoints/contact.js'))
.service('NotificationEndpoint', require('./services/endpoints/notification.js'))
.service('TermsOfServiceEndpoint', require('./services/endpoints/terms-of-service-endpoint.js'))
.service('ExportJobEndpoint', require('./services/endpoints/export-jobs.js'))
.service('CountryCodeEndpoint', require('./services/endpoints/country-code-endpoint.js'))


// Other services
.service('ViewHelper', require('./services/view-helper.js'))
Expand All @@ -65,6 +70,7 @@ angular.module('ushahidi.common', [
.controller('PageMetadata', require('./controllers/page-metadata.js'))
.controller('intercom', require('./controllers/intercom.js'))
.service('LoadingProgress', require('./services/loadingProgress.service.js'))
.service('DataExport', require('./services/data-export.service.js'))
// Global directives
.directive('publishSelector', require('./directives/publish-selector.js'))

Expand Down
10 changes: 6 additions & 4 deletions app/common/directives/language-switch.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function LanguageSwitchDirective() {
template: require('./language-switch.html')
};
}
LanguageSwitchController.$inject = ['$scope', 'Languages', 'TranslationService'];
function LanguageSwitchController($scope, Languages, TranslationService) {
LanguageSwitchController.$inject = ['$scope', 'Languages', 'TranslationService', '$location'];
function LanguageSwitchController($scope, Languages, TranslationService, $location) {
$scope.changeLanguage = changeLanguage;
$scope.$on('event:authentication:login:succeeded', TranslationService.setStartLanguage);
$scope.$on('event:authentication:logout:succeeded', TranslationService.setStartLanguage);
Expand All @@ -26,8 +26,10 @@ function LanguageSwitchController($scope, Languages, TranslationService) {
}

function changeLanguage(code) {
TranslationService.setLanguage(code);
TranslationService.translate(code);
if ($location.path() !== '/settings/general') {
TranslationService.setLanguage(code);
TranslationService.translate(code);
}
}
}

Loading

0 comments on commit dd05401

Please sign in to comment.