var home = angular.module("agp.home", [ "agp.transversal", "agora.plus.emailValidation", "agora.plus.services.ApiService", "agora.plus.dashboard.services", "agora.plus.services.LoginService", "agp.essentials", "agp", "agp.homeModule", "agora.plus.process.services", "agp.security.level", "agp.newsmodule", "agp.language", "agp.workflowlist", "newProcessWidget.newProcess", "agp.dashboard", "agp.loggedIn", "agp.overlay", "ngIntlTelInput", "transversalModuleTemplates", "homeModuleTemplates", "agora.plus.eventStore", "md.data.table", "agpJsonExportExcel", "agpJsonExportPdf", "agora.plus.formComponent", "agp.logout" ]); angular.module("agora.plus.services.LoginService", []); angular.module("agp.security.level", []); angular.module("agp.homeModule.accountCreation", []); angular.module("agp.homeModule.accountCreation.notification", []); angular.module("agp.homeModule.login.services", []); angular.module("agp.homeModule.login", []); angular.module("agp.homeModule.landingPage", []); angular.module("agp.homeModule.franceConnect", []); angular.module("agp.homeModule.googleConnect", []); angular.module("agp.homeModule.ssoConnect", []); angular.module("agp.loggedIn", []); angular.module("agp.newsmodule", ["newsmodule.container", "newsmodule.news", "newsmodule.services"]); angular.module("agp.transversal", ["agp.transversal.content", "agp.transversal.header", "agp.transversal.footer", "agp.sidenav", "agp.usermenu"]); angular.module("agp.homeModule", ["agp.homeModule.main", "agp.homeModule.error", "agp.homeModule.accountCreation", "agp.homeModule.login", "agp.homeModule.login.services", "agp.homeModule.landingPage", "agp.homeModule.accountCreation.notification", "agp.homeModule.franceConnect", "agp.homeModule.googleConnect", "agp.homeModule.ssoConnect", "agp.phoneFormatter"]); angular.module("agp.essentials", ["oc.lazyLoad", "ngRoute", "ngMaterial", "ngMessages", "ngFlash", "pascalprecht.translate", "mdPickers", "ui.grid", "ui.grid.exporter", "ui.grid.selection", "ui.grid.cellNav", "ui.grid.treeView", "ui.grid.pagination"]); /**** TODO - improve this!!! loading the components ****/ angular.module("newProcessWidget.newProcess", []); angular.module("agp.workflowlist", []); angular.module("agp.actPrices", []); angular.module("agp.kids", []); angular.module("agp.nanny", []); angular.module("agp.contacts", []); angular.module("agp.processStatusArea", []); angular.module("agp.processNewArea", []); angular.module("agp.processMyArea", []); angular.module("agp.processToTreatComponent", []); angular.module("payIncoices.services", []); angular.module("payIncoices.invoices", []); angular.module("agp.processStatus", []); angular.module("agp.notifications", []); angular.module("agp.myDocuments", []); angular.module("agp.myDocumentsArea", []); angular.module("agp.accountBalance", []); angular.module("agp.accountBalanceArea", []); angular.module("agp.notificationsArea", []); angular.module("agp.dashboard.buttons", []); angular.module("agp.dashboard.button", []); angular.module("agora.plus.config", []); angular.module("agp.dashboard", ["agp.dashboard.buttons", "agp.dashboard.button", "agora.plus.config"]) angular.module("agora.plus.formComponent", ["ngSanitize"]); // Testing purposes my profile angular.module("agora.plus.ihm", []); angular.module("agora.plus.root.subscriber", []); angular.module("agp.phoneFormatter", []); home.config(function (ngIntlTelInputProvider) { ngIntlTelInputProvider.set({ initialCountry: 'fr' }); }); home.config(["$routeProvider", function ($routeProvider, $routeParams) { $routeProvider .when("/", { templateUrl: PCK_GLOBAL_VARIABLES.landing_page_view, controller: "LandingPageCtrl as $ctrl", title: "LOGIN", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.landingPage"); }] } }) .when("/france-connect", { template: "", controller: "FranceConnectCtrl as $ctrl", title: "FRANCE_CONNECT_LOGIN", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.franceConnect"); }] } }) .when("/google-connect", { template: "", controller: "GoogleConnectCtrl as $ctrl", title: "GOOGLE_CONNECT_LOGIN", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.googleConnect"); }] } }) .when("/sso-connect", { template: "", controller: "SSOConnectCtrl as $ctrl", title: "SSO_CONNECT_LOGIN", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.ssoConnect"); }] } }) .when("/create-account", { templateUrl: PCK_GLOBAL_VARIABLES.create_account_view, controller: "AccountCreationCtrl as $ctrl", title: "ACCOUNT_CREATION", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.accountCreation"); }] } }) .when("/dashboard", { templateUrl: PCK_GLOBAL_VARIABLES.logged_in_view, controller: "LoggedInCtrl as $ctrl", title: "DASHBOARD", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.loggedIn"); }] } }) .when("/my-profile", { templateUrl: PCK_GLOBAL_VARIABLES.my_profile_view, controller: "myProfileCtrl as $ctrl", title: "USER_CONFIGS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.myProfile"); }] } }) .when("/kids/:idKid", { templateUrl: "homeModule/template/kids_view.html", controller: "KidsCtrl as $ctrl", title: "KIDS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.kids"); }] } }) .when("/nanny-area", { templateUrl: PCK_GLOBAL_VARIABLES.nanny_view, controller: "NannyCtrl as $ctrl", title: "NANNY_AREA", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.nanny"); }] } }) .when("/contacts/:idContact", { templateUrl: "homeModule/template/contacts_view.html", controller: "ContactsCtrl as $ctrl", title: "CONTACTS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.contacts"); }] } }) .when("/invoices", { templateUrl: PCK_GLOBAL_VARIABLES.invoices_view, controller: "invoicesCtrl as $ctrl", title: "INVOICES", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.invoices"); }] } }) .when("/my-documents", { templateUrl: PCK_GLOBAL_VARIABLES.my_documents_area_view, controller: "MyDocumentsAreaCtrl as $ctrl", title: "MY_DOCUMENTS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.myDocumentsArea"); }] } }) .when("/account-balance", { templateUrl: PCK_GLOBAL_VARIABLES.account_balance_area_view, controller: "AccountBalanceAreaCtrl as $ctrl", title: "ACCOUNT_BALANCE", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.accountBalanceArea"); }] } }) .when("/activities-prices", { templateUrl: PCK_GLOBAL_VARIABLES.act_prices_view, controller: "ActPricesCtrl as $ctrl", title: "ACTIVITIES_PRICES", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.actPrices"); }] } }) .when("/process-status-area", { template: '', title: "PROCESS_STATUS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.processStatusArea"); }] } }) .when("/process-new-area", { template: '', title: "NEW_PROCESS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.processNewArea"); }] } }) .when("/process-my-area", { template: '', title: "MY_PROCESS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.processToTreatComponent"); }] } }) .when("/notifications-area", { template: '', title: "NOTIFICATIONS", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.notificationsArea"); }] } }) .when("/reset-password", { templateUrl: PCK_GLOBAL_VARIABLES.reset_password_view, controller: "resetPasswordCtrl as $ctrl", title: "RESET_PASSWORD", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.resetPassword"); }] } }) .when("/confirm-change-email", { templateUrl: PCK_GLOBAL_VARIABLES.confirm_change_email_view, controller: "confirmChangeEmailCtrl as $ctrl", title: "DASHBOARD", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.confirmChangeEmail"); }] } }) .when("/revert-change-email", { templateUrl: PCK_GLOBAL_VARIABLES.revert_change_email_view, controller: "revertChangeEmailCtrl as $ctrl", title: "RESET_PASSWORD", resolve: { lazy: ["$ocLazyLoad", function ($ocLazyLoad) { return $ocLazyLoad.load("agp.revertChangeEmail"); }] } }) .when("/update_your_browser", { templateUrl: PCK_GLOBAL_VARIABLES.update_your_browser_view, title: "WARNING" }) .when("/logout", { controller: "LogoutCtrl as $ctrl", templateUrl: "homeModule/template/logout_view.html", title: "LOGOUT" }) .otherwise({ template: '', controller: "HomeErrorCtrl as $ctrl", title: "ERROR" }); }]); home.constant("constant", { langsAvailable: CONFIGS.LANGS_AVAILABLE, bcp47: CONFIGS.BCP47, defaultLanguage: CONFIGS.DEFAULT_LANGUAGE, imgPath: PCK_GLOBAL_VARIABLES.IMG_PATH, logoPath: PCK_GLOBAL_VARIABLES.LOGO_PATH }); // Used to define the modules that will be lazy loaded in the router home.config(["$ocLazyLoadProvider", function ($ocLazyLoadProvider) { $ocLazyLoadProvider.config({ debug: false, modules: [ { name: "agp.accountCreation", files: HOME_MODULE_LAZY_LOAD.accountCreation }, { name: "agp.landingPage", files: HOME_MODULE_LAZY_LOAD.landingPage }, { name: "agp.franceConnect", files: HOME_MODULE_LAZY_LOAD.franceConnect }, { name: "agp.googleConnect", files: HOME_MODULE_LAZY_LOAD.googleConnect }, { name: "agp.ssoConnect", files: HOME_MODULE_LAZY_LOAD.ssoConnect }, { name: "agp.loggedIn", files: HOME_MODULE_LAZY_LOAD.loggedIn }, { name: "agp.myProfile", files: HOME_MODULE_LAZY_LOAD.myProfile }, { name: "agp.myDocumentsArea", files: HOME_MODULE_LAZY_LOAD.myDocumentsArea }, { name: "agp.accountBalanceArea", files: HOME_MODULE_LAZY_LOAD.accountBalanceArea }, { name: "agp.actPrices", files: HOME_MODULE_LAZY_LOAD.actPrices }, { name: "agp.kids", files: HOME_MODULE_LAZY_LOAD.kids }, { name: "agp.nanny", files: HOME_MODULE_LAZY_LOAD.nanny }, { name: "agp.contacts", files: HOME_MODULE_LAZY_LOAD.contacts }, { name: "agp.invoices", files: HOME_MODULE_LAZY_LOAD.invoices }, { name: "agp.processStatusArea", files: HOME_MODULE_LAZY_LOAD.processStatusArea }, { name: "agp.processNewArea", files: HOME_MODULE_LAZY_LOAD.processNewArea }, { name: "agp.processToTreatComponent", files: HOME_MODULE_LAZY_LOAD.processToTreatComponent }, { name: "agp.processMyArea", files: HOME_MODULE_LAZY_LOAD.processMyArea }, { name: "agp.notificationsArea", files: HOME_MODULE_LAZY_LOAD.notificationsArea }, { name: "agp.resetPassword", files: HOME_MODULE_LAZY_LOAD.resetPassword }, { name: "agp.confirmChangeEmail", files: HOME_MODULE_LAZY_LOAD.confirmChangeEmail }, { name: "agp.revertChangeEmail", files: HOME_MODULE_LAZY_LOAD.revertChangeEmail } ] }); }]); home.config(["$httpProvider", function ($httpProvider) { $httpProvider.defaults.timeout = 5000; // Disable cache due to IE if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } $httpProvider.defaults.headers.post = {}; $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; $httpProvider.defaults.headers.get['Pragma'] = 'no-cache'; $httpProvider.interceptors.push(function () { return { request: function (config) { if (!config.paramOrder) { return config; } // avoid leaking config modifications config = angular.copy(config, {}); var orderedParams = []; config.paramOrder.forEach(function (key) { if (config.params.hasOwnProperty(key)) { orderedParams.push(encodeURIComponent(key) + '=' + encodeURIComponent(config.params[key])); // leave only the unordered params in the `params` config delete config.params[key]; } }); config.url += (config.url.indexOf('?') === -1) ? '?' : '&'; config.url += orderedParams.join('&'); return config; }, }; }); }]); home.config(["$mdThemingProvider", function ($mdThemingProvider) { $mdThemingProvider.disableTheming(); }]); // Disable ripple efect globally home.config(["$mdInkRippleProvider", function ($mdInkRippleProvider) { $mdInkRippleProvider.disableInkRipple(); }]); // To increase angular performance home.config(["$compileProvider", function ($compileProvider) { // test to see the impact $compileProvider.debugInfoEnabled(true); // Due to update to angularJS 1.6.8 $compileProvider.preAssignBindingsEnabled(true); }]); /* Added because angularJS 1.6 changed the way how they deal with the "/" */ home.config(['$locationProvider', function ($locationProvider) { $locationProvider.hashPrefix(''); }]); home.config(["$translateProvider", function ($translateProvider) { var languageFile = ""; for (var i = 0; i < CONFIGS.LANGS_AVAILABLE.length; i++) { languageFile = "language" + CONFIGS.LANGS_AVAILABLE[i].toUpperCase(); $translateProvider.translations(CONFIGS.LANGS_AVAILABLE[i], window[languageFile]); } $translateProvider.registerAvailableLanguageKeys(CONFIGS.LANGS_AVAILABLE, CONFIGS.TRANSLATION_MAPPER); // Use local storage to "persist" the language if (typeof (Storage) !== "undefined") { if (sessionHandler.sessionStorage.get("currentLang") === null) { sessionHandler.sessionStorage.set("currentLang", CONFIGS.DEFAULT_LANGUAGE); sessionHandler.sessionStorage.set("currentLangFirstTime", true); } else { sessionHandler.sessionStorage.set("currentLangFirstTime", false); } $translateProvider.preferredLanguage(sessionHandler.sessionStorage.get("currentLang")); $translateProvider.fallbackLanguage(sessionHandler.sessionStorage.get("currentLang")); } else { // add translation tables sessionHandler.sessionStorage.set("currentLangFirstTime", true); $translateProvider.preferredLanguage(CONFIGS.DEFAULT_LANGUAGE); $translateProvider.fallbackLanguage(CONFIGS.DEFAULT_LANGUAGE); } $translateProvider.useSanitizeValueStrategy("sanitizeParameters"); }]); // This should be better analysed, there are reports that this breaks animations home.config(['$provide', function ($provide) { $provide.decorator('$templateRequest', ['$delegate', function ($delegate) { var fn = $delegate; $delegate = function (tpl) { for (var key in fn) { $delegate[key] = fn[key]; } return fn.apply(this, [tpl, true]); }; return $delegate; }]); $provide.decorator("mdAutocompleteDirective", mdAutocompleteDirectiveOverride); /** $provide.decorator('$mdSelect', ['$delegate', '$timeout', '$interval', function ($delegate, $timeout, $interval) { var origShow = $delegate.show; var stop; $delegate.show = function () { var onShow = origShow.apply(this, arguments); onShow.then(function () { $interval.cancel(stop); stop = undefined; }); var selectInput = arguments[0].target; var selectDropDown = arguments[0].element; //angular.element(selectDropDown[0]).find('md-select-menu')[0].style.display = 'none'; $timeout(function () { var boundings = selectInput.getBoundingClientRect(); selectDropDown[0].style.left = boundings.left + "px"; selectDropDown[0].style.top = (boundings.top + boundings.height) + "px"; var dropDownBoundings = selectDropDown[0].getBoundingClientRect(); if (dropDownBoundings.width < boundings.width) { selectDropDown[0].style.width = boundings.width + "px"; } //angular.element(selectDropDown[0]).find('md-select-menu')[0].style.display = ''; stop = $interval(function () { selectDropDown[0].style.minWidth = boundings.width + "px"; selectDropDown[0].style.width = boundings.width + "px"; selectDropDown[0].style.left = boundings.left + "px"; selectDropDown[0].style.top = (boundings.top + boundings.height + 2) + "px"; }, 13); }, 60); return onShow; }; return $delegate; }]); */ mdAutocompleteDirectiveOverride.$inject = ["$delegate", "$controller", "$interpolate"]; function mdAutocompleteDirectiveOverride($delegate, $controller, $interpolate) { var directive = $delegate[0]; var compile = directive.compile; angular.extend(directive.scope, { mdMenuContainerId: "=?mdMenuContainerId", mdMenuContainerClass: "=?mdMenuContainerClass" }); directive.compile = function (element, attr, $interpolate) { var template = compile.apply(this, arguments); // NOTE: leave this here if need to extend even more // var menuContainerId = attr.mdMenuContainerId ? attr.mdMenuContainerId : ""; // var menuContainerClass = attr.mdMenuContainerClass ? attr.mdMenuContainerClass : ""; // var menuContainer = element.find("md-virtual-repeat-container"); // // menuContainer.addClass(menuContainerClass); // menuContainer[0].id = menuContainerId; // recompile the template return function (e, a) { var menuContainer = a.find("md-virtual-repeat-container"); menuContainer[0].id = e.mdMenuContainerId; template.apply(this, arguments); }; }; return $delegate; } }]); // check if the user already logged in and closed the browser... home.run(function(HomeLoginService, $rootScope, DashboardService, $location, $translate, i18nService) { var currentTimestamp = Math.floor(Date.now() / 1000), sessionDataPersisted = sessionHandler.localStorage.get("sessionDataPersisted"); if (sessionDataPersisted) { // valid during 15 minutes if ((currentTimestamp - sessionDataPersisted.timestamp) <= 3600) { sessionHandler.sessionStorage.set("loginData", sessionDataPersisted.loginData); sessionHandler.sessionStorage.set("menu", sessionDataPersisted.menu); sessionHandler.sessionStorage.set("sessionObj", sessionDataPersisted.sessionObj); sessionHandler.sessionStorage.set("userInfo", sessionDataPersisted.userInfo); if ("logoImage" in sessionDataPersisted.initialConfig.configsList && sessionDataPersisted.initialConfig.configsList.logoImage.trim() === '') { sessionDataPersisted.initialConfig.configsList.logoImage = PCK_GLOBAL_VARIABLES.LOGO_PATH; } sessionHandler.sessionStorage.set("initialConfig", sessionDataPersisted.initialConfig); } else { sessionHandler.localStorage.clear(); sessionHandler.sessionStorage.clear(); if ("logoImage" in sessionDataPersisted.initialConfig.configsList && sessionDataPersisted.initialConfig.configsList.logoImage.trim() === '') { sessionDataPersisted.initialConfig.configsList.logoImage = PCK_GLOBAL_VARIABLES.LOGO_PATH; } sessionHandler.sessionStorage.set("initialConfig", sessionDataPersisted.initialConfig); HomeLoginService.deleteCookies(["portail_session_id", "ref_year", "session_id"]); } } }); //send headers by default home.run(function ($http, utils, $location, $rootScope, HomeLoginService) { var token = "", refYear = "", blacklistRoutes = [ "/france-connect", "/google-connect", "/sso-connect", "/create-account", "/reset-password", "/confirm-change-email", "/logout" ]; token = utils.readValueFromCookie("session_id"); refYear = utils.readValueFromCookie("ref_year"); if (token === "") { token = sessionHandler.sessionStorage.get("SESSION_ID"); } else { sessionHandler.sessionStorage.set("SESSION_ID", token); } if (refYear === "") { refYear = sessionHandler.sessionStorage.get("REF_YEAR"); } else { sessionHandler.sessionStorage.set("REF_YEAR", refYear); } if(typeof(refYear) === "undefined") { refYear = 0; } $http.defaults.headers.common.session_id = token; $http.defaults.headers.common.ref_year = refYear; $http.defaults.headers.common.a_access = PCK_GLOBAL_VARIABLES.JNDI; var currentPath = $location.path(); if (blacklistRoutes.indexOf(currentPath) < 0) { var mandatoryWorkflows = sessionHandler.sessionStorage.get("mandatoryWorkflows"); // check sessionStorage available mandatory workflows or get them (mandatoryWorkflows === null) ? $location.path('/') : checkMandatoryProcesses(); } /** * CheckMandatoryProcesses and show a dialog if a mandatory process has not been finalized */ function checkMandatoryProcesses() { if (mandatoryWorkflows.length > 0) { for (var i = 0; i < mandatoryWorkflows.length; i++) { if (mandatoryWorkflows[i].hasOwnProperty("mandatoryProcessDone") === false || mandatoryWorkflows[i].mandatoryProcessDone != 1) {$location.path('/'); break;} } } } }); /** * onLoadFunction load auth2 module on page load */ function onLoadFunction() { gapi.load("auth2", function(){}); } /** * * */ // Check User Session home.run(function(HomeLoginService, $rootScope, DashboardService, $location, $mdDialog, $translate) { blacklistRoutes = [ "/france-connect", "/google-connect", "/sso-connect", "/create-account", "/reset-password", "/confirm-change-email" ]; $rootScope.$on( "$routeChangeStart", function(t, r, a) { if ($location.path() != "" && $location.path() != "/") { if (blacklistRoutes.indexOf($location.path()) < 0) { checkLogin(); } } }); var checkLogin = function () { var s = true; var translation = "SEASON_EXPIRED"; DashboardService.validateLoginContext() .then(function (response) { resp = response; if (resp.DATA.APP_CONTEXT === "BACKOFFICE") { s = false; translation = "INVALID_USER_CONTEXT"; } }) .catch(function (error) { console.log(error); s = false; }) .finally(function () { if (!s) { $mdDialog.show( $mdDialog.alert() .parent(angular.element(document.querySelector('#popupContainer'))) .clickOutsideToClose(false) .escapeToClose(false) .title($translate.instant(translation)) .textContent() .ariaLabel($translate.instant(translation)) .ok($translate.instant('OK')) .targetEvent() ) .then(function () { HomeLoginService.logout(); }); } }); }; });