{"version":3,"file":"repositoryService.js","sourceRoot":"","sources":["../../../../src/modules/services/applicationcore/repositoryService.ts"],"names":[],"mappings":"AAAA,IAAO,QAAQ,CAuGd;AAvGD,WAAO,QAAQ;IACX,IAAc,eAAe,CAoG5B;IApGD,WAAc,eAAe;QACzB;YAGI,2BAAoB,cAA0D,EAAU,GAA4C,EACxH,KAAsB,EAAU,QAA4B,EAAS,SAAuC;gBADpG,mBAAc,GAAd,cAAc,CAA4C;gBAAU,QAAG,GAAH,GAAG,CAAyC;gBACxH,UAAK,GAAL,KAAK,CAAiB;gBAAU,aAAQ,GAAR,QAAQ,CAAoB;gBAAS,cAAS,GAAT,SAAS,CAA8B;YACxH,CAAC;YAED,sCAAU,GAAV;gBACI,OAAO,IAAI,CAAC,SAAS,CAA6C,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,uBAAuB,CAAC,CAAC;YAClH,CAAC;YAED,mDAAuB,GAAvB,UAAwB,QAA6C;gBAArE,iBAwCC;gBAtCG,IAAI,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;gBAC9C,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBAExC,OAAO,IAAI,CAAC,KAAK,CAAC;oBACb,MAAM,EAAE,MAAM;oBACd,YAAY,EAAE,aAAa;oBAC3B,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,+BAA+B;oBACvD,IAAI,EAAE,QAAQ;iBACjB,CAAC,CAAC,IAAI,CAAC,UAAC,QAAQ;oBACb,IAAI,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,CAAC,CAAC;oBAC3F,IAAI,QAAQ,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC;oBAElE,IAAI,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC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AAK,CAAC,UAAC,aAAa;oBACnB,IAAI,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;oBAC5E,IAAI,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;oBACnD,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;oBAEhC,kDAAkD;oBAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAC,CAAgB;wBAChD,IAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAEhC,KAAI,CAAC,QAAQ,CAAC;4BACV,KAAI,CAAC,cAAc,CAAC,qBAAqB,CAA6C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;wBAC5G,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;oBAEH,kCAAkC;oBAClC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;YACP,CAAC;YAhGM,yBAAO,GAAG,CAAC,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAC,WAAW,CAAC,CAAC;YAiGhF,wBAAC;SAAA,AAlGD,IAkGC;QAlGY,iCAAiB,oBAkG7B,CAAA;IACL,CAAC,EApGa,eAAe,GAAf,wBAAe,KAAf,wBAAe,QAoG5B;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;AACnG,CAAC,EAvGM,QAAQ,KAAR,QAAQ,QAuGd","sourcesContent":["module services {\r\n export module applicationcore {\r\n export class repositoryService implements interfaces.applicationcore.IRepositoryService {\r\n static $inject = [\"generalService\", \"ENV\", \"$http\", \"$timeout\",\"$resource\"];\r\n\r\n constructor(private generalService: interfaces.applicationcore.IGeneralService, private ENV: interfaces.applicationcore.serverConfig,\r\n private $http: ng.IHttpService, private $timeout: ng.ITimeoutService,private $resource: ng.resource.IResourceService) {\r\n }\r\n\r\n EmailFiles(): ng.resource.IResourceClass {\r\n return this.$resource(this.ENV.DSP_URL + \"Repository/EmailFiles\");\r\n }\r\n\r\n downloadRepositoryFiles(fileKeys: interfaces.applicationcore.FileKeys) {\r\n \r\n var pdfDownload = document.createElement(\"a\");\r\n document.body.appendChild(pdfDownload);\r\n\r\n return this.$http({\r\n method: 'POST',\r\n responseType: 'arraybuffer',\r\n url: this.ENV.DSP_URL + 'Repository/GetRepositoryFiles',\r\n data: fileKeys\r\n }).then((response) => {\r\n var fileBlob = new Blob([response.data as BlobPart], { type: 'application/octet-stream' });\r\n var filename = response.headers()['x-filename'] || 'download.bin';\r\n\r\n if (navigator.appVersion.toString().indexOf('.NET') > 0) { // for IE browser\r\n window.navigator.msSaveBlob(fileBlob, filename);\r\n } else { // for other browsers\r\n var fileURL = window.URL.createObjectURL(fileBlob);\r\n pdfDownload.href = fileURL;\r\n pdfDownload.download = filename;\r\n pdfDownload.click();\r\n pdfDownload.remove();\r\n }\r\n }).catch((errorResponse) => {\r\n var fileBlob = new Blob([errorResponse.data], { type: 'application/json' });\r\n var fileURL = window.URL.createObjectURL(fileBlob);\r\n const reader = new FileReader();\r\n\r\n // This fires after the blob has been read/loaded.\r\n reader.addEventListener('loadend', (e: ProgressEvent) => {\r\n const text = e.target['result'];\r\n\r\n this.$timeout(() => {\r\n this.generalService.displayMessageHandler(JSON.parse(text));\r\n });\r\n });\r\n\r\n // Start reading the blob as text.\r\n reader.readAsText(fileBlob);\r\n });\r\n }\r\n\r\n downloadRepositoryFile(key: string, IsViewable?: boolean) {\r\n if (!IsViewable)\r\n {\r\n this.generalService.displayMessage(\"You are unable to view the document!\", Enum.EnumMessageType.Error);\r\n return;\r\n }\r\n\r\n var pdfDownload = document.createElement(\"a\");\r\n document.body.appendChild(pdfDownload);\r\n\r\n this.$http({\r\n method: 'GET',\r\n responseType: 'arraybuffer',\r\n url: this.ENV.DSP_URL + 'Repository/GetRepositoryFile?key=' + key\r\n }).then((response) => {\r\n var fileBlob = new Blob([response.data as BlobPart], { type: 'application/octet-stream' });\r\n var filename = response.headers()['x-filename'] || 'download.bin';\r\n\r\n if (navigator.appVersion.toString().indexOf('.NET') > 0) { // for IE browser\r\n window.navigator.msSaveBlob(fileBlob, filename);\r\n } else { // for other browsers\r\n var fileURL = window.URL.createObjectURL(fileBlob);\r\n pdfDownload.href = fileURL;\r\n pdfDownload.download = filename;\r\n pdfDownload.click();\r\n pdfDownload.remove();\r\n }\r\n }).catch((errorResponse) => {\r\n var fileBlob = new Blob([errorResponse.data], { type: 'application/json' });\r\n var fileURL = window.URL.createObjectURL(fileBlob);\r\n const reader = new FileReader();\r\n\r\n // This fires after the blob has been read/loaded.\r\n reader.addEventListener('loadend', (e: ProgressEvent) => {\r\n const text = e.target['result'];\r\n\r\n this.$timeout(() => {\r\n this.generalService.displayMessageHandler(JSON.parse(text));\r\n });\r\n });\r\n\r\n // Start reading the blob as text.\r\n reader.readAsText(fileBlob);\r\n });\r\n }\r\n }\r\n }\r\n angular.module(\"app\").service(\"repositoryService\", services.applicationcore.repositoryService);\r\n}"]}