{"version":3,"sources":["src/app/shared/components/download-dialog/download-dialog.component.ts","src/app/shared/components/download-dialog/download-dialog.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnDestroy, ViewChild, inject } from '@angular/core'\nimport { InputDialogComponent, InputDialogStepComponent, StepState } from 'src/app/shared/components/input-dialog/input-dialog.component'\nimport { NgbProgressbar } from '@ng-bootstrap/ng-bootstrap'\nimport { SafePipe } from 'safe-pipe'\nimport { Store } from '@ngrx/store'\nimport { downloadArticlesRemote, downloadFinished, selectStatusState } from 'src/app/state'\nimport { BackEndService } from 'src/app/services/backend.service'\nimport { ToastService } from 'src/app/services/toast.service'\nimport { Dictionary } from '../filtering-search-component-base/filtering-search-types'\nimport { Subscription } from 'rxjs'\n\n\n@Component({\n selector: 'app-download-dialog',\n imports: [\n InputDialogComponent,\n InputDialogStepComponent,\n NgbProgressbar,\n SafePipe\n ],\n templateUrl: './download-dialog.component.html',\n styleUrl: './download-dialog.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class DownloadDialogComponent implements OnDestroy {\n @ViewChild('exportExcelDialog') excelExportDialogComponent: InputDialogComponent = {} as InputDialogComponent\n @Input() set action(action: Dictionary) {\n\n if (action['export']) {\n this.exportProgress = 50\n this.exportProgressMessage = ''\n this.excelExportDialogComponent.showModal()\n this.store.dispatch(downloadArticlesRemote({\n action\n }))\n this.downloadStartedHere = true\n }\n }\n\n public exportProgress = 0\n public exportProgressMessage: string = ''\n public exportDownloadURL: string = ''\n public downloadStartedHere = false\n\n public loading$\n\n private exportProgressRequest$ : null | Subscription = null\n\n private store = inject(Store)\n private searchService = inject(BackEndService)\n private toastService = inject(ToastService)\n private cdr = inject(ChangeDetectorRef)\n\n constructor() {\n this.loading$ = this.store.select(selectStatusState).subscribe(state => {\n if (state.loading && state.downloadID !== '' && this.downloadStartedHere) {\n let exportCheckCountDown = 180 * 4\n let interval = setInterval(\n () => {\n if (this.exportProgressRequest$ === null) {\n this.exportProgressRequest$ = this.searchService.downloadprogress(state.downloadID).subscribe(\n (res: any) => {\n this.exportProgressRequest$ = null\n this.exportProgressMessage = `${res?.response?.status} ${res.response.message}`\n this.exportProgress = res.response.progress\n if (this.exportProgress == 100) {\n this.exportProgressMessage = 'Download complete'\n this.exportDownloadURL = res.response.message.split(' ')[3]\n this.cdr.detectChanges()\n this.store.dispatch(downloadFinished())\n clearInterval(interval)\n this.downloadStartedHere = false\n this.excelExportDialogComponent.advanceToNextStep()\n this.toastService.show(`Click here if the file was not downloaded automatically.`, {\n header: 'Download complete',\n classname: 'bg-success',\n autohide: false,\n delay: 5000,\n })\n\n } else {\n exportCheckCountDown--\n if (exportCheckCountDown === 0) {\n this.store.dispatch(downloadFinished())\n clearInterval(interval)\n this.downloadStartedHere = false\n this.excelExportDialogComponent.advanceToNextStep()\n this.toastService.show(`Download failed`, {\n classname: 'bg-danger',\n autohide: false,\n delay: 5000,\n })\n }\n }\n }\n )\n }\n },\n 250)\n }\n })\n }\n\n ngOnDestroy(): void {\n this.exportProgressRequest$?.unsubscribe()\n this.loading$.unsubscribe()\n }\n}\n","\n \n

{{ exportProgressMessage }}

\n \n
\n
\n"],"names":["DownloadDialogComponent","excelExportDialogComponent","action","exportProgress","exportProgressMessage","showModal","store","dispatch","downloadArticlesRemote","downloadStartedHere","exportDownloadURL","loading$","exportProgressRequest$","inject","Store","searchService","BackEndService","toastService","ToastService","cdr","ChangeDetectorRef","constructor","select","selectStatusState","subscribe","state","loading","downloadID","exportCheckCountDown","interval","setInterval","downloadprogress","res","response","status","message","progress","split","detectChanges","downloadFinished","clearInterval","advanceToNextStep","show","header","classname","autohide","delay","ngOnDestroy","unsubscribe","selectors","viewQuery","rf","ctx","ɵɵelementStart","ɵɵtext","ɵɵelementEnd","ɵɵelement","ɵɵadvance","ɵɵtextInterpolate","ɵɵproperty","ɵɵpipeBind2","ɵɵsanitizeResourceUrl","InputDialogComponent","InputDialogStepComponent","NgbProgressbar","SafePipe","encapsulation","changeDet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