{"version":3,"file":"export-progress-modal-afa3e91d.js","sources":["../../../app/javascript/common/helpers/progress.ts","../../../app/javascript/common/components/export/export-progress-title-block.vue","../../../app/javascript/common/components/export/export-progress-title-block.vue?vue&type=template&lang.js","../../../app/javascript/common/components/export/export-progress-modal.vue","../../../app/javascript/common/components/export/export-progress-modal.vue?vue&type=template&lang.js"],"sourcesContent":["import moment from 'moment'\n\ntype ProgressMessage = { value: number, max: number } | { progress_value: number, progress_max: number }\n\n/**\n * Use in conjunction with ActionCable and our convention of sending progress updates on long-running processes\n * @example progress = {progress_value: 7, progress_max: 10, mode: 'some string'}\n */\nexport default class Progress {\n endTime: number = null\n max: number = 0\n startTime: number = null\n value: number = 0\n\n /**\n * @return [number] in milliseconds, rounded up to nearest second\n */\n get eta(): number {\n if (!this.startTime) return null\n\n const elapsedMS = Date.now() - this.startTime\n const msPerValue = elapsedMS / this.value\n const valueRemaining = this.max - this.value\n return Math.ceil(msPerValue * valueRemaining / 1000) * 1000\n }\n\n get isProgressing(): boolean {\n return Boolean(this.startTime) && !Boolean(this.endTime)\n }\n\n /**\n * @return [number] 0 - 100 assuming valid +value+ and +max+ being 0 or positive with +value+ < +max+\n */\n get percent(): number {\n if (!this.max) return 0\n\n return this.value / this.max * 100\n }\n\n formatETA(format: string): string {\n if (!this.eta) return ''\n return moment.utc(this.eta).format(format)\n }\n\n formatPercent({ decimal }: { decimal?: number }): string {\n decimal = decimal ?? 0\n return this.percent.toFixed(decimal)\n }\n\n start(progress: ProgressMessage): void {\n this.startTime = null\n this.endTime = null\n this.update(progress)\n }\n\n stop(): void {\n this.endTime = Date.now()\n }\n\n update(progress: ProgressMessage): void {\n if (!this.startTime) this.startTime = Date.now()\n\n if ('value' in progress) {\n this.value = progress.value ?? 0\n this.max = progress.max ?? 0\n } else {\n this.value = progress.progress_value ?? 0\n this.max = progress.progress_max ?? 0\n }\n }\n}\n","\n {{title}}Export for
\n
{{title}}
\n1\" class=\"text-grey text-base-i mb-0-i underline\">\n Attempt #{{lastBroadcast.tries}}\n
\nTime remaining: {{progressETAMessage}}
\nCompletion: {{progressPercentMessage}}
\nFile is exporting. We will notify you when it's complete.
\n{{failMsg}}
\n{{failTimeDisplay}}
\n1\" class=\"text-grey text-base-i mb-0-i underline\">\n Attempt #{{lastBroadcast.tries}}\n
\nTime remaining: {{progressETAMessage}}
\nCompletion: {{progressPercentMessage}}
\nFile is exporting. We will notify you when it's complete.
\n{{failMsg}}
\n{{failTimeDisplay}}
\n