{ "version": 3, "sources": ["src/app/auth.monitor.ts"], "sourcesContent": ["import { Injectable, inject } from '@angular/core';\r\nimport { Router, ActivatedRouteSnapshot, CanActivateFn } from '@angular/router';\r\nimport * as Rx from 'rxjs';\r\nimport { HttpInterceptor, HttpEvent, HttpRequest, HttpErrorResponse, HttpHandler } from '@angular/common/http';\r\nimport { catchError } from 'rxjs/operators';\r\nimport { Title } from '@angular/platform-browser';\r\nimport { UserInfoService } from './user/user-info.service';\r\n\r\n@Injectable({providedIn: 'root'})\r\nclass AuthMonitorService {\r\n\tconstructor (\r\n\t\tprivate pageTitle: Title,\r\n\t\tprivate userInfo: UserInfoService,\r\n\t\tprivate router: Router\r\n\t) {}\r\n\r\n\tcanActivate (next: ActivatedRouteSnapshot): Rx.Observable | Promise | boolean \r\n\t{\r\n\t\tif (next.data[\"externalUrl\"] != null) {\r\n\t\t\tlet loc: string = next.data[\"externalUrl\"];\r\n\t\t\tif (next.queryParams != null) {\r\n\t\t\t\tlet vls: string[] = [];\r\n\t\t\t\tObject.keys(next.queryParams).forEach((key) => {\r\n\t\t\t\t\tvls.push(encodeURIComponent(key) + \"=\" + encodeURIComponent(next.queryParams[key]));\r\n\t\t\t\t});\r\n\t\t\t\tif (vls.length > 0) {\r\n\t\t\t\t\tloc += \"?\" + vls.join(\"&\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\twindow.location.href = loc;\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\telse {\r\n\t\t\tlet routeData = next.data;\r\n\t\t\tif (routeData[\"authenticate\"] && this.userInfo.isAnonymous()) {\r\n\t\t\t\tthis.router.navigateByUrl(\"/User/Login\");\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t//update page title\r\n\t\t\t\tthis.pageTitle.setTitle(routeData[\"routeName\"]);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport const AuthMonitor: CanActivateFn = (next: ActivatedRouteSnapshot) => {\r\n\treturn inject(AuthMonitorService).canActivate(next);\r\n}\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class MonitorHTTP implements HttpInterceptor {\r\n\tintercept(request: HttpRequest, next: HttpHandler): Rx.Observable> {\r\n\t\treturn next.handle(request)\r\n\t\t\t.pipe(\r\n\t\t\t\tcatchError((error: HttpErrorResponse) => {\r\n\t\t\t\t\t// 505, HttpVersionNotSupported / maintenance\r\n\t\t\t\t\tif (error.status === 505) {\r\n\t\t\t\t\t\twindow.location.href = \"assets/maintenance.html?tm=\" + Date.now();\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn Rx.throwError(() => error);\r\n\t\t\t\t})\r\n\t\t\t)\r\n\t}\r\n}\r\n"], "mappings": "mGASMA,GAAkB,IAAA,CADxB,MACMA,CAAkB,CACvBC,YACSC,EACAC,EACAC,EAAc,CAFd,KAAAF,UAAAA,EACA,KAAAC,SAAAA,EACA,KAAAC,OAAAA,CACN,CAEHC,YAAaC,EAA4B,CAExC,GAAIA,EAAKC,KAAK,aAAkB,KAAM,CACrC,IAAIC,EAAcF,EAAKC,KAAK,YAC5B,GAAID,EAAKG,aAAe,KAAM,CAC7B,IAAIC,EAAgB,CAAA,EACpBC,OAAOC,KAAKN,EAAKG,WAAW,EAAEI,QAASC,GAAO,CAC7CJ,EAAIK,KAAKC,mBAAmBF,CAAG,EAAI,IAAME,mBAAmBV,EAAKG,YAAYK,CAAG,CAAC,CAAC,CACnF,CAAC,EACGJ,EAAIO,OAAS,IAChBT,GAAO,IAAME,EAAIQ,KAAK,GAAG,EAE3B,CACAC,cAAOC,SAASC,KAAOb,EAChB,EACR,KACK,CACJ,IAAIc,EAAYhB,EAAKC,KACrB,OAAIe,EAAU,cAAmB,KAAKnB,SAASoB,YAAW,GACzD,KAAKnB,OAAOoB,cAAc,aAAa,EAChC,KAIP,KAAKtB,UAAUuB,SAASH,EAAU,SAAY,EACvC,GAET,CACD,iDAnCKtB,GAAkB0B,EAAAC,CAAA,EAAAD,EAAAE,CAAA,EAAAF,EAAAG,CAAA,CAAA,CAAA,CAAA,iCAAlB7B,EAAkB8B,QAAlB9B,EAAkB+B,UAAAC,WADC,MAAM,CAAA,CAAA,SACzBhC,CAAkB,GAAA,EAsCXiC,EAA8B3B,GACnC4B,EAAOlC,CAAkB,EAAEK,YAAYC,CAAI,EAItC6B,GAAW,IAAA,CAAlB,MAAOA,CAAW,CACvBC,UAAUC,EAA+B/B,EAAiB,CACzD,OAAOA,EAAKgC,OAAOD,CAAO,EACxBE,KACAC,EAAYC,IAEPA,EAAMC,SAAW,MACpBvB,OAAOC,SAASC,KAAO,8BAAgCsB,KAAKC,IAAG,GAEtDC,EAAW,IAAMJ,CAAK,EAChC,CAAC,CAEL,iDAZYN,EAAW,CAAA,iCAAXA,EAAWL,QAAXK,EAAWJ,UAAAC,WADE,MAAM,CAAA,CAAA,SACnBG,CAAW,GAAA", "names": ["AuthMonitorService", "constructor", "pageTitle", "userInfo", "router", "canActivate", "next", "data", "loc", "queryParams", "vls", "Object", "keys", "forEach", "key", "push", "encodeURIComponent", "length", "join", "window", "location", "href", "routeData", "isAnonymous", "navigateByUrl", "setTitle", "\u0275\u0275inject", "Title", "UserInfoService", "Router", "factory", "\u0275fac", "providedIn", "AuthMonitor", "inject", "MonitorHTTP", "intercept", "request", "handle", "pipe", "catchError", "error", "status", "Date", "now", "throwError"] }