X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-FE-common%2Fclient%2Fapp%2Fviews%2Fheader%2Fheader.controller.js;fp=ecomp-portal-FE-common%2Fclient%2Fapp%2Fviews%2Fheader%2Fheader.controller.js;h=e464048116042ba4dfdb087433293b25815f972b;hb=45d2f704aca7076d510749985d1f7a5f111f73d5;hp=e76ec169a31d793b662db46ef91d336afc4ae355;hpb=e5bdf8b209c5cc58c435c920c596f3c67f47de20;p=portal.git diff --git a/ecomp-portal-FE-common/client/app/views/header/header.controller.js b/ecomp-portal-FE-common/client/app/views/header/header.controller.js index e76ec169..e4640481 100644 --- a/ecomp-portal-FE-common/client/app/views/header/header.controller.js +++ b/ecomp-portal-FE-common/client/app/views/header/header.controller.js @@ -38,20 +38,46 @@ 'use strict'; (function () { class HeaderCtrl { - constructor($log, $window, userProfileService, menusService, $scope, ECOMP_URL_REGEX, $cookies, $state,auditLogService,notificationService,ngDialog,$modal) { - this.firstName = ''; - this.lastName = ''; - this.$log = $log; - this.menusService = menusService; - this.$scope = $scope; - this.favoritesMenuItems = ''; - $scope.favoriteItemsCount = 0; - $scope.favoritesMenuItems = ''; - $scope.showFavorites = false; - $scope.emptyFavorites = false; - $scope.favoritesWindow = false; - $scope.notificationCount=0; - $scope.showNotification = true; + constructor($log, $window, $translate, translateService,userProfileService, menusService, $scope, ECOMP_URL_REGEX, $cookies, $state,auditLogService,notificationService,ngDialog,$modal) { + this.firstName = ''; + this.lastName = ''; + this.$log = $log; + this.menusService = menusService; + this.$scope = $scope; + this.favoritesMenuItems = ''; + $scope.cur_lang = ''; + $scope.langList = [] + $scope.favoriteItemsCount = 0; + $scope.favoritesMenuItems = ''; + $scope.showFavorites = false; + $scope.emptyFavorites = false; + $scope.favoritesWindow = false; + $scope.notificationCount=0; + $scope.showNotification = true; + // get all languages + var loginId = sessionStorage.getItem('userId') + translateService.getCurrentLang(loginId).then(res => { + $scope.cur_lang = res.languageAlias + $translate.use($scope.cur_lang); + }) + translateService.getLangList().then(res => { + $scope.langList = res.languageList + }) + // switch language + $scope.switching = function(lang) { + $translate.use(lang); + var langs = $scope.langList + var langId = '' + var selectedLang = langs.find(function(item) { + return item.languageAlias === lang; + }); + langId = selectedLang.languageId + var loginId = sessionStorage.getItem('userId') + translateService.saveSelectedLang(loginId, {'languageId': langId}).then(res => { + window.location.reload(); + }) + } + $scope.cur_lang = $translate.use(); $scope.hideMenus = false; @@ -434,7 +460,7 @@ NotificationCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout', 'sessionService','notificationService','$interval','ngDialog','$modal']; LoginSnippetCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService']; - HeaderCtrl.$inject = ['$log', '$window', 'userProfileService', 'menusService', '$scope', 'ECOMP_URL_REGEX','$cookies','$state','auditLogService','notificationService','ngDialog','$modal']; + HeaderCtrl.$inject = ['$log', '$window', '$translate', 'translateService', 'userProfileService', 'menusService', '$scope', 'ECOMP_URL_REGEX','$cookies','$state','auditLogService','notificationService','ngDialog','$modal']; angular.module('ecompApp').controller('HeaderCtrl', HeaderCtrl); angular.module('ecompApp').controller('loginSnippetCtrl', LoginSnippetCtrl); angular.module('ecompApp').controller('notificationCtrl', NotificationCtrl);