{"version":3,"file":"DownloadAllDistributions.vue.mjs","sources":["../../../lib/datasetDetails/distributions/DownloadAllDistributions.vue"],"sourcesContent":["<template>\n  <div v-if=\"getDistributions.length > 1 && getCatalog.is_part_of  !== 'erpd'\" class=\"dsd-download-all-distributions-button\">\n    <pv-button v-if=\"isLoadingAllDistributionFiles\" :small=\"small\" :rounded=\"true\" :primary=\"primary\" :download=\"true\"\n            class=\"download-all-btn\"\n    >\n      <div class=\"loading-spinner\"></div>\n      {{ $t('message.datasetDetails.datasets.downloadAll') }}\n    </pv-button>\n    <pv-button v-else class=\"download-all-btn\" :small=\"small\" :rounded=\"true\" :primary=\"primary\" :download=\"true\" :action=\"openRessourceAccessPopup\">\n      {{ $t('message.datasetDetails.datasets.downloadAll') }}\n    </pv-button>\n    <div class=\"modal fade\" data-backdrop=\"static\" data-keyboard=\"false\" id=\"downloadAllModal\" ref=\"downloadAllModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"download progress\" aria-hidden=\"true\">\n      <div class=\"modal-dialog\" role=\"document\">\n        <div class=\"modal-content\">\n          <div class=\"modal-header\">\n            <h3 class=\"modal-title\">{{ $t('message.datasetDetails.datasets.modal.downloadProgress') }}</h3>\n<!--            <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">-->\n<!--              <span aria-hidden=\"true\">&times;</span>-->\n<!--            </button>-->\n          </div>\n          <div class=\"modal-body\">\n            <div class=\"progress\">\n              <div class=\"progress-bar\" role=\"progressbar\" :style=\"{width: `${downloadProgress}%`}\" :aria-valuenow=\"downloadProgress\" aria-valuemin=\"0\" aria-valuemax=\"100\"></div>\n            </div>\n            <div>\n              {{ $t('message.datasetDetails.datasets.modal.downloadingFiles') }} {{ downloadedFilesCounter.toLocaleString('fi') }}/{{getDistributions.length.toLocaleString('fi')}}\n            </div>\n            <div class=\"d-flex justify-content-between align-items-center\">\n              <div>{{ $t('message.datasetDetails.datasets.modal.notDownloaded') }} {{ failedDownloads.toLocaleString('fi') }}</div>\n              <i class=\"material-icons help-icon\" data-toggle=\"tooltip\" data-placement=\"bottom\" :title=\"$t('message.datasetDetails.datasets.modal.notDownloadedTooltip')\">help</i>\n            </div>\n            <div class=\"d-flex justify-content-between align-items-center\">\n              <div>{{ $t('message.datasetDetails.datasets.modal.zipNumberOfFiles', { number: numberOfFilesToZip.toLocaleString('fi') }) }}\n                <span v-if=\"isLoadingAllDistributionFiles && numberOfFilesToZip > 0\">\n                  {{ $t('message.datasetDetails.datasets.modal.coupleOfMinutes') }}\n                </span> <span v-else-if=\"isLoadingAllDistributionFiles\">\n                  {{ $t('message.datasetDetails.datasets.modal.waitingForDownload')}}\n                </span>\n              </div>\n              <div v-if=\"isGeneratingZip\" class=\"spinner-grow text-primary\" role=\"status\">\n                <span class=\"sr-only\">Loading...</span>\n              </div>\n              <i v-else-if=\"isGeneratingZipDone\" class=\"material-icons check-icon\">check_circle</i>\n            </div>\n          </div>\n          <div class=\"modal-footer\">\n<!--            <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">{{ $t('message.datasetDetails.datasets.modal.close') }}</button>-->\n            <button v-if=\"!downloadAllSuccess && !downloadAllError\" type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\" @click=\"cancelDownloadAll(cancelDownloadAllAxiosRequestSource)\">\n              {{ $t('message.datasetDetails.datasets.modal.cancel') }}\n            </button>\n            <button v-if=\"downloadAllError\" type=\"button\" class=\"btn btn-danger\" @click=\"trackAndDownloadAllDistributions()\">{{ $t('message.datasetDetails.datasets.modal.error') }}</button>\n            <button v-else-if=\"downloadAllSuccess\" type=\"button\" class=\"btn btn-success\" data-dismiss=\"modal\">{{ $t('message.datasetDetails.datasets.modal.okay') }}</button>\n          </div>\n        </div>\n      </div>\n    </div>\n  </div>\n</template>\n\n<script>\nimport { mapGetters } from \"vuex\";\nimport { onUnmounted } from 'vue';\nimport { useRouter } from 'vue-router';\n\nimport {has, isNil} from \"lodash\";\nimport axios from \"axios\";\nimport { saveAs } from 'file-saver';\nimport $ from \"jquery\";\nimport { getTranslationFor } from \"../../utils/helpers\";\n\n\nexport default {\n  name: \"DownloadAllDistributions\",\n  props: [\n    'getDistributionDescription',\n    'getDistributionTitle',\n    'openModal',\n    'isUrlInvalid',\n    'showDownloadUrls',\n    'primary',\n    'small'\n  ],\n  computed: {\n    ...mapGetters('datasetDetails', [\n      'getDistributions',\n      'getTitle',\n      'getCatalog',\n      'getLanguages'\n    ]),\n    files() {\n      const cutFormatEnding = string => (string.lastIndexOf('.') !== -1 ? string.substring(0, string.lastIndexOf('.')) : string);\n      const getFormat = (distribution) => {\n        if (has(distribution, 'format.id') && !isNil(distribution.format.id)) {\n          const type = distribution.format.id;\n          return type.lastIndexOf('.') === -1 ? type.toLowerCase() : type.substring(type.lastIndexOf('.') + 1, type.length).toLowerCase();\n        }\n        return '';\n      };\n      const getFileName = (distribution, i) =>\n        `${cutFormatEnding(this.getDistributionTitle(distribution)).substring(0, this.bulkDownload.MAX_FILE_TITLE_LENGTH)\n          .replace(/\\//g, ' ').trim()}-${i}`\n        || `${cutFormatEnding(this.getDistributionDescription(distribution)).substring(0, this.bulkDownload.MAX_FILE_TITLE_LENGTH)\n          .replace(/\\//g, ' ').trim()}-${i}`;\n      const getUrls = distribution => (this.showDownloadUrls(distribution) ?\n        { accessUrl: `${distribution.accessUrl[0]}`, downloadUrl: `${distribution.downloadUrls[0]}` }\n        : { accessUrl: `${distribution.accessUrl[0]}` });\n      const getFileNameForCSV = distribution => this.getDistributionTitle(distribution).replace(/,/g, '')\n        || this.getDistributionDescription(distribution).replace(/,/g, '');\n      const files = this.getDistributions\n        .map((distribution, i) => ({\n          title: getFileName(distribution, i + 1), ...getUrls(distribution), format: getFormat(distribution), csvReportTitle: getFileNameForCSV(distribution),\n        }));\n        return files\n    }\n  },\n  data() {\n    return {\n      downloadedFilesCounter: 0,\n      numberOfFilesToZip: 0,\n      downloadProgress: 0,\n      failedDownloads: 0,\n      isGeneratingZip: false,\n      isGeneratingZipDone: false,\n      isLoadingAllDistributionFiles: false,\n      cancelDownloadAllAxiosRequestSource: null,\n      isDownloadAllDistributionsCanceled: false,\n      downloadAllSuccess: false,\n      downloadAllError: false,\n      bulkDownload: {\n        MAX_FILE_TITLE_LENGTH: this.$env.content.datasetDetails.bulkDownload.MAX_FILE_TITLE_LENGTH,\n        TIMEOUT_MS: this.$env.content.datasetDetails.bulkDownload.TIMEOUT_MS,\n      }\n    }\n  },\n  methods: {\n    getTranslationFor,\n    async fetchDistributionFiles(zip, files, folder, getContentTypeFormat) {\n      const csvReportArray = [];\n      let csvReport = 'filename,status, issue_cause downloadURL, issue_cause accessURL\\n';\n      let csvDownloadURLIssue;\n      const problematicFormats = ['wms', 'wfs'];\n\n      const CancelToken = axios.CancelToken;\n      this.cancelDownloadAllAxiosRequestSource = CancelToken.source();\n      const axiosInstance = this.$bulkDownloadAxiosInstance;\n      const requestSettings = { responseType: 'blob', cancelToken: this.cancelDownloadAllAxiosRequestSource.token, timeout: this.bulkDownload.TIMEOUT_MS };\n\n      const promises = files.map(async (file) => {\n        const problematicFormat = problematicFormats.find(format => format === file.format);\n        if (!problematicFormat) {\n          let isRejected = true;\n          let responseData;\n          let fileFormat = file.format;\n\n          // try to download from download url\n          if (has(file, 'downloadUrl')) {\n            responseData = await axiosInstance.get(file.downloadUrl, requestSettings).then((responseDownloadUrl) => {\n              if (responseDownloadUrl.status === 200) {\n                isRejected = false;\n                if (!file.format.length > 0) fileFormat = getContentTypeFormat(responseDownloadUrl.headers['content-type']);\n                csvReportArray.push([file.csvReportTitle, 'delivered']);\n                return responseDownloadUrl.data;\n              }\n              return Promise.reject(new Error(responseDownloadUrl.statusText));\n            }).catch((error) => {\n              isRejected = true;\n              csvDownloadURLIssue = error;\n            });\n          } else csvDownloadURLIssue = 'no download url available';\n          if (this.isUrlInvalid(file.downloadUrl)) {\n            csvReportArray.push([file.csvReportTitle, 'issue', 'url is invalid']);\n          }\n          // try to download from access url\n          if (isRejected) {\n            responseData = await axiosInstance.get(file.accessUrl, requestSettings).then((responseAccessUrl) => {\n              if (responseAccessUrl.status === 200) {\n                isRejected = false;\n                if (file.format.length > 0) fileFormat = getContentTypeFormat(responseAccessUrl.headers['content-type']);\n                csvReportArray.push([file.csvReportTitle, 'delivered', csvDownloadURLIssue]);\n                return responseAccessUrl.data;\n              }\n              return Promise.reject(new Error(responseAccessUrl.statusText));\n            }).catch((error) => {\n              isRejected = true;\n              csvReportArray.push([file.csvReportTitle, 'issue', csvDownloadURLIssue, error]);\n            });\n          }\n          if (!isRejected) folder.file(`${file.title}.${fileFormat}`, responseData, { binary: true });\n          if (!this.isDownloadAllDistributionsCanceled) {\n            this.downloadedFilesCounter += 1;\n            this.downloadProgress = Math.floor(100 * this.downloadedFilesCounter / this.getDistributions.length);\n            if (isRejected) this.failedDownloads += 1;\n          } else {\n            this.downloadedFilesCounter = 0;\n            this.downloadProgress = 0;\n            this.failedDownloads = 0;\n          }\n        } else csvReportArray.push([file.csvReportTitle, 'issue', `We can't download ${problematicFormat} files using the download all button. Please try to download this file using the download button next to the file name.`]);\n      });\n\n      await Promise.all(promises);\n      csvReportArray.forEach((row) => {\n        csvReport += row.join(',');\n        csvReport += '\\n';\n      });\n      zip.file('file_report.csv', csvReport, { binary: true });\n    },\n    hideDownloadAllModal() {\n      $('#downloadAllModal').modal('hide');\n    },\n    generateAndSaveZip(zip, zipName) {\n      if (!this.isDownloadAllDistributionsCanceled) {\n        this.numberOfFilesToZip = Object.keys(zip.files).length;\n        this.isGeneratingZip = true;\n      }\n\n      class UserInterruptException {\n        constructor(message) {\n          this.message = message;\n          this.name = 'UserInterruptException';\n        }\n      }\n\n      zip.generateAsync({ type: 'blob', compression: 'DEFLATE' }, () => {\n        if (this.isDownloadAllDistributionsCanceled) throw new UserInterruptException('user canceled generate zip operation');\n      })\n        .then((blob) => {\n          this.isGeneratingZip = false;\n          this.isGeneratingZipDone = true;\n          this.isLoadingAllDistributionFiles = false;\n          this.downloadAllSuccess = true;\n          saveAs(blob, zipName);\n        })\n        .catch((e) => {\n          this.isGeneratingZip = false;\n          this.isDownloadAllDistributionsCanceled = false;\n          this.isLoadingAllDistributionFiles = false;\n          this.downloadAllError = true;\n          this.downloadedFilesCounter = 0;\n          this.downloadProgress = 0;\n          this.numberOfFilesToZip = 0;\n          console.warn(e); // eslint-disable-line\n        });\n\n      // works with chrome => to make it compatible to more browsers look here https://jimmywarting.github.io/StreamSaver.js/examples/saving-multiple-files.html open developer tools and find saving-multiple-files.html\n      // install stream saver and import it + script src=\"https://cdn.jsdelivr.net/npm/web-streams-polyfill@2.0.2/dist/ponyfill.min.js\"\n      // if we don't want to use his service worker we can configure something (I think we have to change the mitm url) => read the api https://jimmywarting.github.io/StreamSaver.js\n      // I think IE will never work with this solution\n      /* const writeStream = streamSaver.createWriteStream(zipName).getWriter();\n      zip.generateInternalStream({ type: 'uint8array', streamFiles: true })\n        .on('data', data => writeStream.write(data))\n        .on('error', err => console.error(err))\n        .on('end', () => writeStream.close())\n        .resume(); */\n    },\n    cancelDownloadAll(source) {\n      // stops axios operations\n      source.cancel('user canceled axios operation');\n      // stops zip operation\n      this.isDownloadAllDistributionsCanceled = true;\n    },\n    async trackAndDownloadAllDistributions() {\n      if (this.$piwik && this.$piwik.trackDownload) {\n        this.$piwik.trackDownload(\n          window.location.href,\n          {\n            files: JSON.stringify(this.files),\n            downloadAll: 'true',\n            format: 'all',\n          }\n        );\n      }\n      return await this.downloadAllDistributions();\n    },\n    async downloadAllDistributions() {\n      $('#downloadAllModal').modal('show');\n      this.downloadedFilesCounter = 0;\n      this.downloadProgress = 0;\n      this.failedDownloads = 0;\n      this.numberOfFilesToZip = 0;\n      this.isGeneratingZip = false;\n      this.isGeneratingZipDone = false;\n      this.isLoadingAllDistributionFiles = true;\n      this.isDownloadAllDistributionsCanceled = false;\n      this.downloadAllSuccess = false;\n      this.downloadAllError = false;\n      const getContentTypeFormat = (contentType) => {\n        const startIndex = contentType.lastIndexOf('/') + 1;\n        const endIndex = contentType.indexOf(';') !== -1 ? contentType.indexOf(';') : contentType.length;\n        return contentType.substring(startIndex, endIndex);\n      };\n\n      const {default: JSZip} = await import('jszip');\n      const zip = new JSZip();\n      const zipName = `${this.getTranslationFor(this.getTitle, this.$route.query.locale, this.getLanguages)}.zip`;\n      const folder = zip.folder(this.getTranslationFor(this.getCatalog.title, this.$route.query.locale, this.getLanguages));\n      await this.fetchDistributionFiles(zip, this.files, folder, getContentTypeFormat);\n      await this.generateAndSaveZip(zip, zipName);\n    },\n    // handle navigation to extern website (cancel bulk download and hide modal)\n    beforeWindowUnload(e) {\n      if (this.isLoadingAllDistributionFiles && !this.isDownloadAllDistributionsCanceled) {\n        e.preventDefault();\n        // Chrome requires returnValue to be set\n        e.returnValue = ''; // eslint-disable-line\n      }\n    },\n    openRessourceAccessPopup() {\n      // const modal = this.$refs.downloadAllModal;\n      // const modal = document.getElementById('externalAccess');\n      // console.log(\"openRessourceAccessPopup\", modal)\n      // modal.addEventListener('shown.bs.modal', function() {\n      //   console.log(\"CLOSING\");\n      // });\n      this.openModal(this.trackAndDownloadAllDistributions, true);\n    },\n    onClose(e) {\n      console.log(\"CLOSING\");\n    }\n  },\n  created() {\n    window.addEventListener('beforeunload', this.beforeWindowUnload);\n  },\n  // mounted() {\n  //   setTimeout(() => {\n  //     const modal = document.getElementById('externalAccess');\n  //     modal.addEventListener('click', function() {\n  //       console.log(\"CLOSING\");\n  //     });\n  //   })\n  // },\n  beforeUnmount() {\n    window.removeEventListener('beforeunload', this.beforeWindowUnload);\n    // const modal = this.$refs.downloadAllModal.$el;\n    // modal.removeEventListener('hide.bs.modal', this.onClose);\n  },\n  setup() {\n    const router = useRouter();\n\n    onUnmounted(() => {\n      router.beforeEach((to, from, next) => {\n        if (this.isLoadingAllDistributionFiles && !this.isDownloadAllDistributionsCanceled) {\n          const answer = window.confirm(this.$t('message.datasetDetails.datasets.leavePageWindow.text')); // eslint-disable-line\n          if (answer) {\n            // if modal is open we have to hide it when user tries to navigate back\n            this.hideDownloadAllModal();\n            this.cancelDownloadAll(this.cancelDownloadAllAxiosRequestSource);\n            next();\n          } else {\n            next(false);\n          }\n        } else {\n          this.hideDownloadAllModal();\n          next();\n        }\n      })();\n    })\n  },\n}\n</script>\n\n<style scoped>\n\n</style>\n"],"names":["_sfc_main","mapGetters","cutFormatEnding","string","getFormat","distribution","has","isNil","type","getFileName","i","getUrls","getFileNameForCSV","getTranslationFor","zip","files","folder","getContentTypeFormat","csvReportArray","csvReport","csvDownloadURLIssue","problematicFormats","CancelToken","axios","axiosInstance","requestSettings","promises","file","problematicFormat","format","isRejected","responseData","fileFormat","responseDownloadUrl","error","responseAccessUrl","row","$","zipName","UserInterruptException","message","blob","saveAs","e","source","contentType","startIndex","endIndex","JSZip","router","useRouter","onUnmounted","to","from","next","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_10","_hoisted_12","_hoisted_17","_ctx","_openBlock","_createElementBlock","_hoisted_1","$data","_createBlock","_component_pv_button","$props","_createElementVNode","_createTextVNode","$options","_hoisted_2","_hoisted_3","_toDisplayString","_hoisted_11","_hoisted_15","_cache","_hoisted_16","$event","_hoisted_18"],"mappings":";;;;;;;;;AAuEA,MAAKA,IAAU;AAAA,EACb,MAAM;AAAA,EACN,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACD,UAAU;AAAA,IACR,GAAGC,EAAW,kBAAkB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,QAAQ;AACN,YAAMC,IAAkB,CAAAC,MAAWA,EAAO,YAAY,GAAG,MAAM,KAAKA,EAAO,UAAU,GAAGA,EAAO,YAAY,GAAG,CAAC,IAAIA,GAC7GC,IAAY,CAACC,MAAiB;AAClC,YAAIC,EAAID,GAAc,WAAW,KAAK,CAACE,EAAMF,EAAa,OAAO,EAAE,GAAG;AACpE,gBAAMG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