Skip to content

Commit

Permalink
[#117] Language Change FrontEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
javieriserte committed Aug 27, 2024
1 parent 85dc6bb commit 64453ab
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 97 deletions.
153 changes: 111 additions & 42 deletions app/assets/javascripts/home/headerController.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,120 @@
define([], function() {
'use strict';

function HeaderController($scope, userService, $location, $modal, hotkeys, appConf) {

var modalInstance = null;

$scope.version = appConf.version;

hotkeys.bindTo($scope).add({
combo : 'ctrl+alt+b',
allowIn : [ 'INPUT', 'SELECT', 'TEXTAREA' ],
callback : function() {
modalInstance = $modal.open({
templateUrl : '/assets/javascripts/home/views/ee.html',
scope : $scope
define(
[],
function() {
'use strict';

function HeaderController(
$scope,
userService,
$location,
$modal,
$timeout,
hotkeys,
appConf
) {
var modalInstance = null;
$scope.version = appConf.version;
hotkeys.bindTo($scope).add({
combo : 'ctrl+alt+b',
allowIn : [ 'INPUT', 'SELECT', 'TEXTAREA' ],
callback : function() {
modalInstance = $modal.open({
templateUrl : '/assets/javascripts/home/views/ee.html',
scope : $scope
});
}
});
}
});

// Wrap the current user from the service in a watch expression
$scope.$watch(function() {
var user = userService.getUser();
return user;
}, function(user) {
$scope.user = user;
}, true);
// Wrap the current user from the service in a watch expression
$scope.$watch(
function() {
var user = userService.getUser();
return user;
},
function(user) {
$scope.user = user;
},
true
);

$scope.showAbout = function() {
modalInstance = $modal.open({
templateUrl : '/assets/javascripts/home/views/aboutModal.html',
scope : $scope
});
};
$scope.showAbout = function() {
modalInstance = $modal.open({
templateUrl : '/assets/javascripts/home/views/aboutModal.html',
scope : $scope
});
};

$scope.closeModal = function() {
modalInstance.close();
};
$scope.closeModal = function() {
modalInstance.close();
};

$scope.logout = function() {
$scope.selectedMenu = undefined;
userService.logout();
$scope.user = undefined;
};
$scope.logout = function() {
$scope.selectedMenu = undefined;
userService.logout();
$scope.user = undefined;
};

var set_menu_titles = function() {
$scope.menu_profiles= "menu.profiles";
$scope.menu_profilesList= "menu.profilesList";
$scope.menu_bulkUpload= "menu.bulkUpload";
$scope.menu_bulkAcceptance= "menu.bulkAcceptance";
$scope.menu_inferiorInstanceProfileApproval= "menu.inferiorInstanceProfileApproval";
$scope.menu_profileComparison= "menu.profileComparison";
$scope.menu_profileExporter= "menu.profileExporter";
$scope.menu_profileLIMSExporter= "menu.profileLIMSExporter";
$scope.menu_mpiDvi= "menu.mpiDvi";
$scope.menu_matches= "menu.matches";
$scope.menu_forensic= "menu.forensic";
$scope.menu_mpi= "menu.mpi";
$scope.menu_monitoring= "menu.monitoring";
$scope.menu_reports= "menu.reports";
$scope.menu_operationLog= "menu.operationLog";
$scope.menu_interconnection_inferiorInstances= "menu.interconnection.inferiorInstances";
$scope.menu_configuration= "menu.configuration";
$scope.menu_logout= "menu.logout";
$scope.generics_close = "generics.close";
$scope.about_version = "about.version";
};
set_menu_titles();

}
var clear_menu_titles = function() {
$scope.menu_profiles= "";
$scope.menu_profilesList= "";
$scope.menu_bulkUpload= "";
$scope.menu_bulkAcceptance= "";
$scope.menu_inferiorInstanceProfileApproval= "";
$scope.menu_profileComparison= "";
$scope.menu_profileExporter= "";
$scope.menu_profileLIMSExporter= "";
$scope.menu_mpiDvi= "";
$scope.menu_matches= "";
$scope.menu_forensic= "";
$scope.menu_mpi= "";
$scope.menu_monitoring= "";
$scope.menu_reports= "";
$scope.menu_operationLog= "";
$scope.menu_interconnection_inferiorInstances= "";
$scope.menu_configuration= "";
$scope.menu_logout= "";
$scope.generics_close = "";
$scope.about_version = "";
};

return HeaderController;
$scope.$on(
"i18nextLanguageChange",
function(event, args) {
clear_menu_titles();
$timeout(
function() {
set_menu_titles();
},
1
);
}
);

});
}
return HeaderController;
}
);
99 changes: 76 additions & 23 deletions app/assets/javascripts/home/main.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,76 @@
define(['angular', './loadingAppController', './totpPromptService', './totpPromptController', './errorService', './errorController', './headerController', './notificationsService', './notificationsController'],
function(angular, LoadingAppController, TotpPromptService, TotpPromptController, ErrorService, ErrorController, HeaderController, NotificationsService, NotificationsController) {
'use strict';

angular
.module('pdg.home', ['jm.i18next'])
.controller('loadingAppController', ['$scope', LoadingAppController])
.service('totpPromptService', ['$log', '$rootScope', '$q', TotpPromptService])
.controller('totpPromptController', ['$scope', 'totpPromptService', TotpPromptController])
.service('errorService', ['$log', ErrorService])
.controller('errorController', ['$scope', 'errorService', 'alertService', ErrorController])
.controller('headerController', ['$scope', 'userService', '$location', '$modal', 'hotkeys','appConf', HeaderController])
.service('notificationsService', ['$log','$rootScope', 'cryptoService', 'userService', NotificationsService])
.controller('notificationsController', [ '$scope', '$rootScope', '$log', '$timeout', '$route', '$i18next', 'notificationsService', 'userService', 'inboxService', NotificationsController])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/configuracion', {templateUrl: '/assets/javascripts/home/views/configuracion.html'});
}]);


return undefined;

});
define(
[
'angular',
'./loadingAppController',
'./totpPromptService',
'./totpPromptController',
'./errorService',
'./errorController',
'./headerController',
'./notificationsService',
'./notificationsController'
],
function (
angular,
LoadingAppController,
TotpPromptService,
TotpPromptController,
ErrorService,
ErrorController,
HeaderController,
NotificationsService,
NotificationsController
) {
'use strict';
angular
.module('pdg.home', ['jm.i18next'])
.controller(
'loadingAppController',
['$scope', LoadingAppController]
)
.service(
'totpPromptService',
['$log', '$rootScope', '$q', TotpPromptService]
)
.controller(
'totpPromptController',
['$scope', 'totpPromptService', TotpPromptController]
)
.service(
'errorService',
['$log', ErrorService]
)
.controller(
'errorController',
['$scope', 'errorService', 'alertService', ErrorController]
)
.controller(
'headerController',
['$scope', 'userService', '$location', '$modal', '$timeout', 'hotkeys', 'appConf', HeaderController]
)
.service(
'notificationsService',
['$log', '$rootScope', 'cryptoService', 'userService', NotificationsService]
)
.controller(
'notificationsController',
[
'$scope', '$rootScope', '$log', '$timeout', '$route',
'$i18next', 'notificationsService', 'userService', 'inboxService', NotificationsController
]
)
.config(
[
'$routeProvider',
function ($routeProvider) {
$routeProvider
.when(
'/configuracion',
{templateUrl: '/assets/javascripts/home/views/configuracion.html'}
);
}
]
);
return undefined;
}
);
10 changes: 2 additions & 8 deletions app/assets/javascripts/home/notificationsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ function NotificationsController($scope, $rootScope, $log, $timeout, $route, $i1
}
$i18next.options.lng = nextLangFront;
// userService.setLanguage(nextLangBack);
$rootScope.language = nextLangFront;
$scope.$emit("i18nextLanguageChange", { lang: nextLangFront });
$route.reload();
$rootScope.$apply();
$timeout(function() {
$rootScope.$broadcast('languageChanged');
$rootScope.$broadcast('languageChanged');
$rootScope.$digest();
});
$scope.apply();

};

}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/home/views/aboutModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<img src="/assets/images/sadosky-logo.png" style="float:right;" />
</div>
<div class="modal-body" style="padding-left:20px;">
<strong>{{ 'about.version' | i18next }}</strong>: {{version}}
<strong>{{ about_version | i18next }}</strong>: {{version}}
</div>
<div class="modal-footer">
<button class="btn btn-success" data-ng-click="closeModal()">{{ 'generics.close' | i18next }}</button>
<button class="btn btn-success" data-ng-click="closeModal()">{{ generics_close | i18next }}</button>
</div>
36 changes: 18 additions & 18 deletions app/assets/javascripts/home/views/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
<ul show-permissions="PROFILE_DATA_CRUD, DNA_PROFILE_CRUD, PROTOPROFILE_BULK_UPLOAD,PROTOPROFILE_BULK_ACCEPTANCE, IMP_PERF_INS" class="nav navbar-nav menu-item">
<li class="profile" data-ng-class="{itemselected: selectedMenu == 'profile'}">
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" class="menu-item">
<p><i class="icon-perfiles icon-lg"></i>{{"menu.profiles"|i18next}}<b class="caret"></b></p>
<p><i class="icon-perfiles icon-lg"></i>{{menu_profiles|i18next}}<b class="caret"></b></p>
</a>
<ul class="dropdown-menu dropdown-main-menu submenu">
<li show-permissions="PROFILE_DATA_CRUD, DNA_PROFILE_CRUD">
<a data-ng-click="selectedMenu = 'profile'" href="#/search/profiledata" aria-expanded="false" class="menu-item">{{"menu.profilesList"|i18next}}</a>
<a data-ng-click="selectedMenu = 'profile'" href="#/search/profiledata" aria-expanded="false" class="menu-item">{{menu_profilesList|i18next}}</a>
</li>
<li show-permissions="PROTOPROFILE_BULK_UPLOAD">
<a data-ng-click=" selectedMenu = 'profile'" href="#/profiles/bulkupload-step1" class="menu-item">{{"menu.bulkUpload"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'profile'" href="#/profiles/bulkupload-step1" class="menu-item">{{menu_bulkUpload|i18next}}</a>
</li>
<li show-permissions="PROTOPROFILE_BULK_ACCEPTANCE">
<a data-ng-click=" selectedMenu = 'profile'" href="#/profiles/bulkupload-step2" class="menu-item">{{"menu.bulkAcceptance"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'profile'" href="#/profiles/bulkupload-step2" class="menu-item">{{menu_bulkAcceptance|i18next}}</a>
</li>
<li show-permissions="IMP_PERF_INS">
<a data-ng-click=" selectedMenu = 'profile'" href="#/profile-approval" class="menu-item">{{"menu.inferiorInstanceProfileApproval"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'profile'" href="#/profile-approval" class="menu-item">{{menu_inferiorInstanceProfileApproval|i18next}}</a>
</li>
<li show-permissions="PROFILE_COMPARISON">
<a data-ng-click=" selectedMenu = 'profile'" href="#/profile-comparison">{{"menu.profileComparison"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'profile'" href="#/profile-comparison">{{menu_profileComparison|i18next}}</a>
</li>
<li show-permissions="PROFILE_EXPORTER">
<a data-ng-click="selectedMenu = 'profile'" href="#/profile-exporter" aria-expanded="false" class="menu-item">{{"menu.profileExporter"|i18next}}</a>
<a data-ng-click="selectedMenu = 'profile'" href="#/profile-exporter" aria-expanded="false" class="menu-item">{{menu_profileExporter|i18next}}</a>
</li>
<li show-permissions="PROFILE_EXPORTER_TO_LIMS">
<a data-ng-click="selectedMenu = 'profile'" href="#/profile-exporterToLims" aria-expanded="false" class="menu-item">{{"menu.profileLIMSExporter"|i18next}}</a>
<a data-ng-click="selectedMenu = 'profile'" href="#/profile-exporterToLims" aria-expanded="false" class="menu-item">{{menu_profileLIMSExporter|i18next}}</a>
</li>
</ul>
</li>
Expand All @@ -36,20 +36,20 @@
<ul show-permissions="PEDIGREE_CRUD" class="nav navbar-nav menu-item">
<li class="pedigree" data-ng-class="{itemselected: selectedMenu == 'courtcases'}" class="menu-item">
<a data-ng-click=" selectedMenu = 'courtcases'" href="#/courtcases" aria-expanded="false">
<p><i class="icon-pedigri icon-lg"></i>{{"menu.mpiDvi"|i18next}}</p>
<p><i class="icon-pedigri icon-lg"></i>{{menu_mpiDvi|i18next}}</p>
</a>
</li>
</ul>

<ul show-permissions="MATCHES_MANAGER, PEDIGREE_CRUD" class="nav navbar-nav menu-item">
<li class="matching" data-ng-class="{itemselected: selectedMenu=='matching'}" class="menu-item">
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<p><i class="icon-coincidencias icon-lg"></i>{{"menu.matches"|i18next}}<b class="caret"></b></p>
<p><i class="icon-coincidencias icon-lg"></i>{{menu_matches|i18next}}<b class="caret"></b></p>
</a>
<ul class="dropdown-menu dropdown-main-menu submenu">
<li class="menu-item"><a show-permissions="MATCHES_MANAGER" data-ng-click=" selectedMenu = 'matching'" href="#/matches">{{"menu.forensic"|i18next}}</a></li>
<li class="menu-item"><a show-permissions="MATCHES_MANAGER" data-ng-click=" selectedMenu = 'matching'" href="#/matches">{{menu_forensic|i18next}}</a></li>
<!--<li class="menu-item"><a show-permissions="MATCHES_MANAGER" data-ng-click=" selectedMenu = 'matching'" href="#/matches?isCollapsingMatch=true">Collapsing</a></li>-->
<li class="menu-item"><a show-permissions="PEDIGREE_CRUD" data-ng-click=" selectedMenu = 'matching'" href="#/pedigreeMatches">{{"menu.mpi"|i18next}}</a></li>
<li class="menu-item"><a show-permissions="PEDIGREE_CRUD" data-ng-click=" selectedMenu = 'matching'" href="#/pedigreeMatches">{{menu_mpi|i18next}}</a></li>
</li>
</ul>
</li>
Expand All @@ -58,17 +58,17 @@
<ul show-permissions="OPERATION_LOG_READ,REPORTING_VIEW, INF_INS_CRUD" class="nav navbar-nav menu-item">
<li class="menu-item audit" data-ng-class="{itemselected: selectedMenu=='audit'}" >
<a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<p><i class="icon-auditoria icon-lg"></i>{{"menu.monitoring"|i18next}}<b class="caret"></b></p>
<p><i class="icon-auditoria icon-lg"></i>{{menu_monitoring|i18next}}<b class="caret"></b></p>
</a>
<ul class="dropdown-menu dropdown-main-menu submenu">
<li show-permissions="REPORTING_VIEW" class="menu-item">
<a data-ng-click=" selectedMenu = 'audit'" href="#/reportes-main">{{"menu.reports"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'audit'" href="#/reportes-main">{{menu_reports|i18next}}</a>
</li>
<li show-permissions="OPERATION_LOG_READ" class="menu-item">
<a data-ng-click=" selectedMenu = 'audit'" href="#/audit/operationLogLots">{{"menu.operationLog"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'audit'" href="#/audit/operationLogLots">{{menu_operationLog|i18next}}</a>
</li>
<li show-permissions="INF_INS_CRUD" class="menu-item">
<a data-ng-click=" selectedMenu = 'audit'" href="#/inferior-instances">{{"menu.interconnection.inferiorInstances"|i18next}}</a>
<a data-ng-click=" selectedMenu = 'audit'" href="#/inferior-instances">{{menu_interconnection_inferiorInstances|i18next}}</a>
</li>

</ul>
Expand All @@ -79,7 +79,7 @@
class="nav navbar-nav menu-item">
<li class="menu-item stadistics" data-ng-class="{itemselected: selectedMenu=='configuration'}">
<a data-ng-click="selectedMenu = 'configuration'" href="#/configuracion" aria-expanded="false">
<p><i class="icon-configuracion icon-lg" ></i>{{"menu.configuration"|i18next}}</p>
<p><i class="icon-configuracion icon-lg" ></i>{{menu_configuration|i18next}}</p>
</a>
</li>
</ul>
Expand Down Expand Up @@ -123,7 +123,7 @@

<ul id="userMenuUl" class="dropdown-menu dropdown-main-menu submenu">
<li id="userMenuLogoutLi"><a id="userMenuLogoutA" href="" data-ng-click="logout()"> <span
class="icon-logout"></span>{{"menu.logout"|i18next}}
class="icon-logout"></span>{{menu_logout|i18next}}
</a></li>
</ul>
</li>
Expand Down
Loading

0 comments on commit 64453ab

Please sign in to comment.