From c54345336c7dbd8c5ea170bb89c9e27a9911bca7 Mon Sep 17 00:00:00 2001 From: Keerthi Humsika Kattamudi Date: Thu, 23 Jul 2026 17:44:15 -0400 Subject: [PATCH] [BI-2967] BI-2967: Update the ImportGeno.vue file to handle the file size validation and updated the properties files as needed. --- .env.development | 1 + src/views/import/ImportGeno.vue | 47 ++++++++++++++++++++++++++++++--- vue.config.js | 1 + 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.env.development b/.env.development index 0f3dd2fa4..b1aa0d498 100644 --- a/.env.development +++ b/.env.development @@ -15,6 +15,7 @@ VUE_APP_LOG_LEVEL=${WEB_LOG_LEVEL} # The reference source VUE_APP_BI_REFERENCE_SOURCE=${BRAPI_REFERENCE_SOURCE} +VUE_APP_MAX_GENOTYPE_UPLOAD_MB=${MAX_GENOTYPE_UPLOAD_MB} # feature flags VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED=${BRAPI_VENDOR_SUBMISSION_ENABLED} diff --git a/src/views/import/ImportGeno.vue b/src/views/import/ImportGeno.vue index ff8615ab7..26480267c 100644 --- a/src/views/import/ImportGeno.vue +++ b/src/views/import/ImportGeno.vue @@ -68,9 +68,12 @@ {{upload.file.name}} - - + @@ -115,6 +118,8 @@ export default class ImportExperiment extends ProgramsBase { private importState: DataFormEventBusHandler = new DataFormEventBusHandler(); private currentImport?: ImportResponse = new ImportResponse({}); private systemImportTemplateId?: string; + private fileSelectorKey: number = 0; + private defaultMaxGenotypeUploadMb: number = 800; upload: Upload = new Upload({}); @@ -123,6 +128,36 @@ export default class ImportExperiment extends ProgramsBase { file: {required} } + private getMaxGenotypeUploadLimitMb(): number { + const configuredLimit = Number(process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB); + if (!Number.isFinite(configuredLimit) || configuredLimit <= 0) { + return this.defaultMaxGenotypeUploadMb; + } + return configuredLimit; + } + + private getMaxGenotypeUploadBytes(): number { + return this.getMaxGenotypeUploadLimitMb() * 1024 * 1024; + } + + private showMaxGenotypeUploadError() { + this.$emit( + 'show-error-notification', + `Uploaded file exceeds the maximum file size limit of ${this.getMaxGenotypeUploadLimitMb()} MB.` + ); + } + + handleFileSelected(file: File) { + if (file.size > this.getMaxGenotypeUploadBytes()) { + this.clearFile(); + this.fileSelectorKey += 1; + this.showMaxGenotypeUploadError(); + return; + } + + this.upload.file = file; + } + mounted() { this.loadSampleSubmissions(); this.getSystemImportTemplateMapping(); @@ -142,6 +177,12 @@ export default class ImportExperiment extends ProgramsBase { async save() { try { this.$store.commit( DEACTIVATE_ALL_NOTIFICATIONS ); + + if (this.upload.file!.size > this.getMaxGenotypeUploadBytes()) { + this.showMaxGenotypeUploadError(); + return; + } + this.currentImport = await GenoService.uploadData(this.activeProgram!.id!, this.upload.submissionId!, this.upload.file!); const response: ImportResponse = await this.getDataUpload(); if (response.progress!.statuscode == 500) { diff --git a/vue.config.js b/vue.config.js index eed14c1ff..196301ab5 100644 --- a/vue.config.js +++ b/vue.config.js @@ -27,6 +27,7 @@ process.env.VUE_APP_OPENID_LOGOUT_URL = process.env.VUE_APP_OPENID_LOGOUT_URL || process.env.VUE_APP_BI_API_V1_PATH = process.env.VUE_APP_BI_API_ROOT + "/v1"; process.env.VUE_APP_LOG_LEVEL = process.env.VUE_APP_LOG_LEVEL || 'error'; process.env.VUE_APP_BI_REFERENCE_SOURCE = process.env.VUE_APP_BI_REFERENCE_SOURCE || 'breedinginsight.org'; +process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB = process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB || '800'; process.env.VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED = ('true' === process.env.VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED); process.env.VUE_APP_ALTERNATE_AUTHENTICATION_ENABLED = ('true' === process.env.VUE_APP_ALTERNATE_AUTHENTICATION_ENABLED);