Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
47 changes: 44 additions & 3 deletions src/views/import/ImportGeno.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@
{{upload.file.name}}
</div>
</div>
<FileSelector v-model="upload.file"
v-bind:fileTypes="['.vcf']">
</FileSelector>
<FileSelector
v-bind:key="fileSelectorKey"
v-bind:value="upload.file"
v-bind:fileTypes="['.vcf']"
v-on:input="handleFileSelected"
/>
</div>
</div>
</template>
Expand Down Expand Up @@ -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({});

Expand All @@ -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();
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading