-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(odk): implement ODK Central Link
This commit implements the ODK Central link with BHIMA, developped during the `prosani-sprint`. The goal is to have a functional, optional link to ODK Central that can be merged into the BHIMA repository. Closes #6235.
- Loading branch information
Showing
20 changed files
with
1,087 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"ODK" : { | ||
"CONFIG_SETTINGS" : "ODK Central Configuration", | ||
"IMPORTED_SUCCESSFULLY" : "Records successfully imported", | ||
"LOAD_FOSA_DATA" : "Load data of FOSA", | ||
"NO_RECORD_FOUND" : "No record found", | ||
"ODK_ADMIN_PASSWORD" : "ODK Central Admin Password", | ||
"ODK_ADMIN_USER" : "ODK Central Admin Email", | ||
"ODK_CENTRAL_URL" : "ODK Central Server URL", | ||
"ODK_INTEGRATION_SETTINGS" : "ODK Integration Settings", | ||
"PROJECT_DETAILS" : "Project Details", | ||
"PROJECT_FORMS" : "Number of Forms", | ||
"PROJECT_ID" : "Project ID", | ||
"PROJECT_NAME" : "Project Name", | ||
"QRCODE" : "ODK QR Code", | ||
"SHOW_QRCODE" : "Show QR Code", | ||
"SYNC_ENTERPRISE" : "Synchronize enterprise settings", | ||
"SYNC_FORMS" : "Synchronize forms", | ||
"SYNC_SETTINGS" : "Synchronization Settings", | ||
"SYNC_SUBMISSIONS" : "Synchronize submissions", | ||
"SYNC_USERS" : "Synchronize users", | ||
"TOTAL_APP_USERS" : "Number of App Users", | ||
"TOTAL_FOUND" : "Total records found" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"ODK" : { | ||
"CONFIG_SETTINGS" : "ODK Central Configuration", | ||
"IMPORTED_SUCCESSFULLY" : "Données importées avec succès", | ||
"LOAD_FOSA_DATA" : "Chargement des données des FOSA", | ||
"NO_RECORD_FOUND" : "Aucun enregistrement trouvé", | ||
"ODK_ADMIN_PASSWORD" : "Mot de passe de l'administrateur", | ||
"ODK_ADMIN_USER" : "Adressse mail de l'administrateur", | ||
"ODK_CENTRAL_URL" : "URL du serveur ODK Central", | ||
"ODK_INTEGRATION_SETTINGS" : "Paramètres d'intégration ODK", | ||
"PROJECT_DETAILS" : "Détails du projet", | ||
"PROJECT_FORMS" : "Nombre de formulaire", | ||
"PROJECT_ID" : "ID Projet", | ||
"PROJECT_NAME" : "Nom du projet", | ||
"QRCODE" : "ODK QR Code", | ||
"SHOW_QRCODE" : "Afficher QR Code", | ||
"SYNC_ENTERPRISE" : "Synchroniser les paramètres d'entreprise", | ||
"SYNC_FORMS" : "Synchroniser les formulaires", | ||
"SYNC_SETTINGS" : "Synchroniser les paramètres", | ||
"SYNC_SUBMISSIONS" : "Synchroniser les soumissions des formulaires", | ||
"SYNC_USERS" : "Synchroniser les utilisateurs", | ||
"TOTAL_APP_USERS" : "Nombre des utilisateurs mobiles", | ||
"TOTAL_FOUND" : "Total des enregistrements trouvés" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<div class="flex-header"> | ||
<div class="bhima-title"> | ||
<ol class="headercrumb"> | ||
<li class="static" translate>TREE.ADMIN</li> | ||
<li class="title" translate>TREE.ODK_SETTINGS</li> | ||
</ol> | ||
</div> | ||
</div> | ||
|
||
<div class="flex-content"> | ||
<div class="container-fluid"> | ||
<div class="col-xs-12 col-md-6 col-lg-4"> | ||
<form | ||
name="ODKSettingsForm" | ||
bh-submit="ODKSettingsCtrl.submit(ODKSettingsForm)" | ||
ng-model-options="{ updateOn: 'blur' }" novalidate> | ||
<div class="panel panel-primary"> | ||
<div class="panel-heading"> | ||
<i class="fa fa-server"></i> | ||
<span translate>ODK.ODK_INTEGRATION_SETTINGS</span> | ||
</div> | ||
<div class="panel-body"> | ||
<div class="form-group" ng-class="{ 'has-error' : ODKSettingsForm.$submitted && ODKSettingsForm.odk_central_url.$invalid }"> | ||
<label class="control-label" translate>ODK.ODK_CENTRAL_URL</label> | ||
<input | ||
type="text" | ||
class="form-control" | ||
name="odk_central_url" | ||
ng-model="ODKSettingsCtrl.settings.odk_central_url" | ||
autocomplete="off"> | ||
<div class="help-block" ng-messages="ODKSettingsForm.odk_central_url.$error" ng-show="ODKSettingsForm.$submitted"> | ||
<div ng-messages-include="modules/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group" ng-class="{ 'has-error' : ODKSettingsForm.$submitted && ODKSettingsForm.odk_admin_user.$invalid }"> | ||
<label class="control-label" translate>ODK.ODK_ADMIN_USER</label> | ||
<input | ||
type="email" | ||
class="form-control" | ||
name="odk_admin_user" | ||
ng-model="ODKSettingsCtrl.settings.odk_admin_user" | ||
autocomplete="off" | ||
ng-required="!!ODKSettings.settings.odk_central_url"> | ||
<div class="help-block" ng-messages="ODKSettingsForm.odk_admin_user.$error" ng-show="ODKSettingsForm.$submitted"> | ||
<div ng-messages-include="modules/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group" ng-class="{ 'has-error' : ODKSettingsForm.$submitted && ODKSettingsForm.odk_admin_password.$invalid }"> | ||
<label class="control-label" translate>ODK.ODK_ADMIN_PASSWORD</label> | ||
<input | ||
type="password" | ||
class="form-control" | ||
name="odk_admin_password" | ||
ng-model="ODKSettingsCtrl.settings.odk_admin_password" | ||
autocomplete="off" | ||
ng-required="!!ODKSettings.settings.odk_admin_user"> | ||
<div class="help-block" ng-messages="ODKSettingsForm.odk_admin_password.$error" ng-show="ODKSettingsForm.$submitted"> | ||
<div ng-messages-include="modules/templates/messages.tmpl.html"></div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="panel-footer text-right"> | ||
<bh-loading-button loading-state="ODKSettingsForm.$loading"> | ||
<span translate>FORM.BUTTONS.UPDATE</span> | ||
</bh-loading-button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
|
||
<div class="col-xs-12 col-md-6 col-lg-4"> | ||
<div class="panel panel-danger"> | ||
<div class="panel-heading"> | ||
<i class="fa fa-cloud-upload"></i> | ||
<span translate>ODK.SYNC_SETTINGS</span> | ||
</div> | ||
|
||
<div class="panel-body"> | ||
<div class="form-group"> | ||
<label class="control-label" translate>ODK.SYNC_ENTERPRISE</label> | ||
<button type="button" class="btn btn-default btn-xs pull-right" ng-click="ODKSettingsCtrl.syncEnterprise()" translate>FORM.BUTTONS.SYNC</button> | ||
</div> | ||
|
||
<hr> | ||
|
||
<div class="form-group"> | ||
<label class="control-label" translate>ODK.SYNC_USERS</label> | ||
<button type="button" class="btn btn-default btn-xs pull-right" ng-click="ODKSettingsCtrl.syncUsers()" translate>FORM.BUTTONS.SYNC</button> | ||
</div> | ||
|
||
|
||
<hr> | ||
|
||
<div class="form-group"> | ||
<label class="control-label" translate>ODK.SYNC_FORMS</label> | ||
<button type="button" class="btn btn-default btn-xs pull-right" ng-click="ODKSettingsCtrl.syncForms()" translate>FORM.BUTTONS.SYNC</button> | ||
</div> | ||
|
||
<hr> | ||
|
||
<div class="form-group"> | ||
<label class="control-label" translate>ODK.SYNC_SUBMISSIONS</label> | ||
<button type="button" class="btn btn-default btn-xs pull-right" ng-click="ODKSettingsCtrl.syncSubmissions()" translate>FORM.BUTTONS.SYNC</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="col-xs-12 col-md-6 col-lg-4"> | ||
<div class="panel panel-success"> | ||
<div class="panel-heading"> | ||
<i class="fa fa-cogs"></i> | ||
<span translate>ODK.CONFIG_SETTINGS</span> | ||
</div> | ||
|
||
<div class="panel-body"> | ||
<div ng-show="ODKSettingsCtrl.loading" class="text-center"> | ||
<loading-indicator></loading-indicator> | ||
</div> | ||
<dl ng-hide="ODKSettingsCtrl.loading"> | ||
<dt translate>ODK.PROJECT_DETAILS</dt> | ||
<dd><span translate>ODK.PROJECT_NAME</span>: {{ODKSettingsCtrl.project.name}} </dd> | ||
<dd><span translate>ODK.PROJECT_ID</span>: {{ODKSettingsCtrl.project.id}} </dd> | ||
<dd><span translate>ODK.PROJECT_FORMS</span>: {{ODKSettingsCtrl.project.forms}} </dd> | ||
<dd><span translate>FORM.LABELS.CREATED</span>: {{ODKSettingsCtrl.project.createdAt | date}} </dd> | ||
<dd><span translate>ODK.TOTAL_APP_USERS</span>: {{ODKSettingsCtrl.appUsers.length | number}} </dd> | ||
</dl> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
angular.module('bhima.controllers') | ||
.controller('ODKSettingsController', ODKSettingsController); | ||
|
||
ODKSettingsController.$inject = [ | ||
'ODKSettingsService', 'util', 'NotifyService', 'SessionService', '$state', | ||
]; | ||
|
||
/** | ||
* ODK Settings Controller | ||
* | ||
* Provides configuration parameters for the link to ODK. | ||
*/ | ||
function ODKSettingsController( | ||
ODKSettings, util, Notify, Session, $state, | ||
) { | ||
const vm = this; | ||
|
||
vm.enterprise = Session.enterprise; | ||
vm.settings = { }; | ||
|
||
// bind methods | ||
vm.submit = submit; | ||
vm.syncEnterprise = () => { | ||
ODKSettings.syncEnterprise() | ||
.then(() => { $state.reload(); }) | ||
.catch(Notify.handleError); | ||
}; | ||
|
||
vm.syncUsers = () => { | ||
ODKSettings.syncUsers() | ||
.then(() => ODKSettings.syncAppUsers()) | ||
.then(() => { $state.reload(); }) | ||
.catch(Notify.handleError); | ||
}; | ||
|
||
vm.syncForms = () => { | ||
ODKSettings.syncForms() | ||
.then(() => { $state.reload(); }) | ||
.catch(Notify.handleError); | ||
}; | ||
|
||
vm.syncSubmissions = () => { | ||
ODKSettings.syncSubmissions() | ||
.then(() => { $state.reload(); }) | ||
.catch(Notify.handleError); | ||
}; | ||
|
||
// fired on startup | ||
function startup() { | ||
ODKSettings.read() | ||
.then(settings => { | ||
if (settings.length > 0) { | ||
[vm.settings] = settings; | ||
} | ||
}) | ||
.catch(Notify.handleError); | ||
|
||
vm.loading = true; | ||
|
||
ODKSettings.getProjectSettings() | ||
.then(project => { | ||
vm.project = project; | ||
}) | ||
.catch(Notify.handleError) | ||
.finally(() => { vm.loading = false; }); | ||
|
||
ODKSettings.getAppUsers() | ||
.then(appUsers => { | ||
vm.appUsers = appUsers; | ||
}) | ||
.catch(Notify.handleError) | ||
.finally(() => { vm.loading = false; }); | ||
|
||
// ODKSettings.getUserSettings() | ||
// .then(users => { | ||
// vm.users = users; | ||
// }) | ||
// .catch(Notify.handleError); | ||
} | ||
|
||
// form submission | ||
function submit(form) { | ||
if (form.$invalid) { | ||
Notify.danger('FORM.ERRORS.HAS_ERRORS'); | ||
return 0; | ||
} | ||
|
||
// make sure only fresh data is sent to the server. | ||
if (form.$pristine) { | ||
Notify.warn('FORM.WARNINGS.NO_CHANGES'); | ||
return 0; | ||
} | ||
|
||
const changes = angular.copy(vm.settings); | ||
|
||
return ODKSettings.create(changes) | ||
.then(() => Notify.success('FORM.INFO.UPDATE_SUCCESS')) | ||
.then(() => $state.reload()) // Should we just refresh the stock settings in the Session? | ||
.catch(Notify.handleError); | ||
} | ||
|
||
startup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
angular.module('bhima.routes') | ||
.config(['$stateProvider', $stateProvider => { | ||
$stateProvider | ||
.state('odkSettings', { | ||
url : '/admin/odk-settings', | ||
controller : 'ODKSettingsController as ODKSettingsCtrl', | ||
templateUrl : 'modules/odk-settings/odk-settings.html', | ||
}); | ||
}]); |
Oops, something went wrong.