{ "version": 3, "sources": ["src/app/ui/gateways/global-http-exception-handller.ts", "src/app/ui/gateways/request-http-interceptor.ts", "src/app/ui/models/domains/grids/custom-paginator.ts", "src/app/ui/providers/providers.module.ts"], "sourcesContent": ["import { Injectable } from \"@angular/core\";\r\nimport { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpErrorResponse } from \"@angular/common/http\";\r\nimport { Observable, throwError } from \"rxjs\";\r\nimport { catchError } from \"rxjs/operators\";\r\nimport { Router } from \"@angular/router\";\r\nimport { RoutePath } from \"../models/domains/route-paths.model\";\r\nimport { AuthService } from \"../services/auth.service\";\r\nimport { RouteStrategyFactory } from \"./route-strategy-factory\";\r\n\r\n@Injectable()\r\nexport class GlobalHttpExceptionHandller implements HttpInterceptor {\r\n constructor(private router: Router, private authService: AuthService, private routeStrategyFactory: RouteStrategyFactory) {}\r\n\r\n intercept(req: HttpRequest, next: HttpHandler): Observable> {\r\n return next.handle(req).pipe(\r\n catchError((error) => {\r\n if (error instanceof HttpErrorResponse) {\r\n this.doHandleUnauthorized(error);\r\n }\r\n return throwError(error);\r\n }),\r\n );\r\n }\r\n\r\n private doHandleUnauthorized(error: any) {\r\n if (error.status === 401) {\r\n this.authService.logout();\r\n this.routeStrategyFactory.createStrategy().redirect();\r\n }\r\n }\r\n}\r\n", "import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from \"@angular/common/http\";\r\nimport { Injectable } from \"@angular/core\";\r\nimport { Observable } from \"rxjs/Observable\";\r\nimport { AppContext } from \"../contexts/app-context\";\r\n\r\n@Injectable()\r\nexport class RequestInterceptor implements HttpInterceptor {\r\n constructor(public auth: AppContext) {}\r\n intercept(request: HttpRequest, next: HttpHandler): Observable> {\r\n let token: string;\r\n let userId: string;\r\n\r\n let userCredentials = this.auth.getUserCredential();\r\n let currentTenant = this.auth.getCurrentTenant();\r\n\r\n if (userCredentials && userCredentials.token && userCredentials.userId) {\r\n token = userCredentials.token;\r\n userId = userCredentials.userId;\r\n } else {\r\n let serviceCredentials = this.auth.getServiceCredential();\r\n if (serviceCredentials && serviceCredentials.token) {\r\n token = serviceCredentials.token;\r\n }\r\n }\r\n\r\n if (token) {\r\n if (userId) {\r\n request = this.requestClone({ Authorization: `Bearer ${token}`, UserId: userId }, request);\r\n } else {\r\n request = this.requestClone({ Authorization: `Bearer ${token}` }, request);\r\n }\r\n }\r\n\r\n if (currentTenant && currentTenant.key) {\r\n request.headers.append(\"pbm-tenant-key\", currentTenant.key);\r\n }\r\n return next.handle(request);\r\n }\r\n\r\n private requestClone(headers: { [name: string]: string | string[] }, request: HttpRequest): HttpRequest {\r\n return request.clone({\r\n setHeaders: headers,\r\n });\r\n }\r\n}\r\n", "import { Injectable } from \"@angular/core\";\r\nimport { MatPaginatorIntl } from \"@angular/material/paginator\";\r\n\r\n@Injectable()\r\nexport class CustomPaginator extends MatPaginatorIntl {\r\n itemsPerPageLabel = \"Itens por página\";\r\n firstPageLabel = \"Primeira página\";\r\n nextPageLabel = \"Próxima página\";\r\n previousPageLabel = \"Página anterior\";\r\n lastPageLabel = \"Última página\";\r\n\r\n getRangeLabel = function (page, pageSize, length) {\r\n if (length === 0 || pageSize === 0) {\r\n return \"0 de \" + length;\r\n }\r\n length = Math.max(length, 0);\r\n const startIndex = page * pageSize;\r\n\r\n const endIndex = startIndex < length ? Math.min(startIndex + pageSize, length) : startIndex + pageSize;\r\n return startIndex + 1 + \" - \" + endIndex + \" de \" + length;\r\n };\r\n}\r\n", "import { NgModule, LOCALE_ID } from \"@angular/core\";\r\nimport { ModuleWithProviders } from \"@angular/core\";\r\nimport { HTTP_INTERCEPTORS } from \"@angular/common/http\";\r\nimport { GlobalHttpExceptionHandller } from \"../gateways/global-http-exception-handller\";\r\nimport { TOAST_CONFIG_TOKEN, ToastConfig, toastConfig } from \"../models/domains/toast/toast-config\";\r\nimport { RequestInterceptor } from \"../gateways/request-http-interceptor\";\r\nimport { CustomPaginator } from \"../models/domains/grids/custom-paginator\";\r\nimport { MatDialogRef } from \"@angular/material/dialog\";\r\nimport { MatPaginatorIntl } from \"@angular/material/paginator\";\r\n\r\n@NgModule({})\r\nexport class ProviderModule {\r\n static forRoot(config: ToastConfig = toastConfig): ModuleWithProviders {\r\n return {\r\n ngModule: ProviderModule,\r\n providers: [\r\n { provide: HTTP_INTERCEPTORS, useClass: GlobalHttpExceptionHandller, multi: true },\r\n { provide: HTTP_INTERCEPTORS, useClass: RequestInterceptor, multi: true },\r\n { provide: MatDialogRef, useValue: {} },\r\n { provide: LOCALE_ID, useValue: \"pt-BR\" },\r\n { provide: TOAST_CONFIG_TOKEN, useValue: config },\r\n { provide: MatPaginatorIntl, useClass: CustomPaginator },\r\n ],\r\n };\r\n }\r\n}\r\n"], "mappings": "iLAEAA,IAQA,IAAaC,GAA2B,IAAA,CAAlC,IAAOA,EAAP,MAAOA,CAA2B,CACtCC,YAAoBC,EAAwBC,EAAkCC,EAA0C,CAApG,KAAAF,OAAAA,EAAwB,KAAAC,YAAAA,EAAkC,KAAAC,qBAAAA,CAA6C,CAE3HC,UAAUC,EAAuBC,EAAiB,CAChD,OAAOA,EAAKC,OAAOF,CAAG,EAAEG,KACtBC,EAAYC,IACNA,aAAiBC,GACnB,KAAKC,qBAAqBF,CAAK,EAE1BG,EAAWH,CAAK,EACxB,CAAC,CAEN,CAEQE,qBAAqBF,EAAU,CACjCA,EAAMI,SAAW,MACnB,KAAKZ,YAAYa,OAAM,EACvB,KAAKZ,qBAAqBa,eAAc,EAAGC,SAAQ,EAEvD,yCAnBWlB,GAA2BmB,EAAAC,CAAA,EAAAD,EAAAE,CAAA,EAAAF,EAAAG,CAAA,CAAA,CAAA,wBAA3BtB,EAA2BuB,QAA3BvB,EAA2BwB,SAAA,CAAA,EAAlC,IAAOxB,EAAPyB,SAAOzB,CAA2B,GAAA,ECJxC,IAAa0B,GAAkB,IAAA,CAAzB,IAAOA,EAAP,MAAOA,CAAkB,CAC7BC,YAAmBC,EAAgB,CAAhB,KAAAA,KAAAA,CAAmB,CACtCC,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KI,IAAIF,EAAaJ,EAAUC,CAAM,EAAIG,EAAaJ,EAC9F,OAAOI,EAAa,EAAI,MAAQC,EAAW,OAASJ,CACtD,8DAhBWX,CAAe,IAAAiB,GAAfjB,CAAe,CAAA,CAAA,GAAA,wBAAfA,EAAekB,QAAflB,EAAemB,SAAA,CAAA,EAAtB,IAAOnB,EAAPoB,SAAOpB,CAAgB,GAAA,ECO7B,IAAaqB,GAAc,IAAA,CAArB,IAAOA,EAAP,MAAOA,CAAc,CACzB,OAAOC,QAAQC,EAAsBC,EAAW,CAC9C,MAAO,CACLC,SAAUJ,EACVK,UAAW,CACT,CAAEC,QAASC,EAAmBC,SAAUC,EAA6BC,MAAO,EAAI,EAChF,CAAEJ,QAASC,EAAmBC,SAAUG,EAAoBD,MAAO,EAAI,EACvE,CAAEJ,QAASM,EAAcC,SAAU,CAAA,CAAE,EACrC,CAAEP,QAASQ,EAAWD,SAAU,OAAO,EACvC,CAAEP,QAASS,EAAoBF,SAAUX,CAAM,EAC/C,CAAEI,QAASU,EAAkBR,SAAUS,CAAe,CAAE,EAG9D,yCAbWjB,EAAc,sBAAdA,CAAc,CAAA,oBAArB,IAAOA,EAAPkB,SAAOlB,CAAc,GAAA", "names": ["init_esm2015", "GlobalHttpExceptionHandller", "constructor", "router", "authService", "routeStrategyFactory", "intercept", "req", "next", "handle", "pipe", "catchError", "error", "HttpErrorResponse", "doHandleUnauthorized", "throwError", "status", "logout", "createStrategy", "redirect", "\u0275\u0275inject", "Router", "AuthService", "RouteStrategyFactory", "factory", "\u0275fac", "_GlobalHttpExceptionHandller", "RequestInterceptor", "constructor", "auth", "intercept", "request", "next", "token", "userId", "userCredentials", "getUserCredential", "currentTenant", "getCurrentTenant", "serviceCredentials", "getServiceCredential", "requestClone", "Authorization", "UserId", "key", "headers", "append", "handle", "clone", "setHeaders", "\u0275\u0275inject", "AppContext", "factory", "\u0275fac", "_RequestInterceptor", "CustomPaginator", "MatPaginatorIntl", "constructor", "itemsPerPageLabel", "firstPageLabel", "nextPageLabel", "previousPageLabel", "lastPageLabel", "getRangeLabel", "page", "pageSize", "length", "Math", "max", "startIndex", "endIndex", "min", "__ngFactoryType__", "factory", "\u0275fac", "_CustomPaginator", "ProviderModule", "forRoot", "config", "toastConfig", "ngModule", "providers", "provide", "HTTP_INTERCEPTORS", "useClass", "GlobalHttpExceptionHandller", "multi", "RequestInterceptor", "MatDialogRef", "useValue", "LOCALE_ID", "TOAST_CONFIG_TOKEN", "MatPaginatorIntl", "CustomPaginator", "_ProviderModule"] }