Commit a0cc0c0d authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

Merge branch '139-improve-download' into 'dev'

Resolve "Improve download of csv and fasta"

Closes #139 and #134

See merge request !61
parents f9aca3b8 3250418d
Pipeline #32864 passed with stages
in 3 minutes and 33 seconds
......@@ -6,7 +6,7 @@
</v-toolbar>
<v-alert
v-if="notFound"
:value="true"
:value="notFound"
type="warning"
>
<v-layout align-center>
......@@ -14,7 +14,7 @@
<v-spacer/>
<router-link to="/">redirect to home page</router-link>
<v-icon small class="ml-1">fa-home</v-icon>
</v-layout>
</v-layout>
</v-alert>
<v-card v-else class="blue-grey lighten-5">
......
<div class="genes">
<template v-for="(item, index) in downloadAlerts">
<v-alert
:value="item.value"
:type="item.type"
icon="fas fa-download"
transition="slide-y-transition"
>
<v-layout align-center>
<v-spacer/>
{{ item.text }}
<v-spacer/>
<v-flex md8>
<v-progress-linear
v-if="item.progressBar"
indeterminate
height="2"
color="primary"
></v-progress-linear>
</v-flex>
<v-spacer/>
</v-layout>
</v-alert>
</template>
<v-layout row wrap>
<v-flex xs12>
<v-toolbar
......@@ -188,8 +211,17 @@
</v-card>
</v-expansion-panel-content>
</v-expansion-panel>
<!-- Table : Alert for backend error -->
<v-alert
v-if="listGenesError"
:value="listGenesError"
type="warning"
>
<v-layout align-center>
Could not retrieve gene list from the server.
</v-layout>
</v-alert>
<!-- Table -->
<v-card flat id="tablegenes" v-if="!loadTable">
<v-speed-dial
v-model="fab"
......
......@@ -34,6 +34,10 @@ export default {
downloadFastaReady: true,
downloadCSVReady: true,
fab: false,
// Error handlers
listGenesError: false,
fastaError: false,
csvError: false,
};
},
computed: {
......@@ -142,6 +146,52 @@ export default {
return 'right';
}
return 'left';
},
fileName() {
if (this.searchGeneName) {
return this.searchGeneName;
}
var basename = "metagenedb";
if (this.geneSource && this.geneSource != 'all') {
basename = `${basename}_${this.geneSource}`;
}
if (this.filterGeneLength) {
basename = `${basename}_${this.geneLengthFilterRange[0]}bp-${this.geneLengthFilterRange[1]}bp`;
}
if (this.functionID){
basename = `${basename}_function-${this.functionID}`;
}
if (this.taxChoice) {
var taxName = this.taxChoice.replace(/ /g,"_");
basename = `${basename}_${this.taxLevel}-${taxName}`;
}
return basename;
},
downloadAlerts() {
return [
{
value: this.loadingFastaDownload,
text: "Downloading sequences (.fasta)...",
type: "info",
progressBar: true,
},
{
value: this.loadingCSVDownload,
text: "Downloading metadata (.csv)...",
type: "info",
progressBar: true,
},
{
value: this.fastaError,
text: "Could not download sequences (.fasta).",
type: "error",
},
{
value: this.csvError,
text: "Could not download metadata (.csv).",
type: "error"
},
]
}
},
mounted() {
......@@ -158,8 +208,12 @@ export default {
})
return taxLevelsFormatted;
},
getGenes() {
resetGeneListFlags() {
this.requestDone = false;
this.listGenesError = false;
},
getGenes() {
this.resetGeneListFlags();
axios.get('/api/catalog/v1/genes', {
params: this.qParams,
headers: {
......@@ -200,6 +254,7 @@ export default {
})
.catch((error) => {
console.error(error);
this.listGenesError = true;
this.requestDone = true;
});
},
......@@ -211,8 +266,12 @@ export default {
document.body.appendChild(link)
link.click()
},
downloadFasta() {
resetFastaFlags() {
this.downloadFastaReady = false;
this.fastaError = false;
},
downloadFasta() {
this.resetFastaFlags();
var qParams = {};
Object.assign(qParams, this.qParams);
qParams.fasta = "true";
......@@ -226,15 +285,20 @@ export default {
})
.then((response) => {
this.downloadFastaReady = true;
this.forceFileDownload(response, 'metagenedb_sequences.fasta');
this.forceFileDownload(response, `${this.fileName}.fasta`);
})
.catch((error) => {
console.error(error);
this.downloadReady = true;
this.fastaError = true;
this.downloadFastaReady = true;
});
},
downloadMetadataCSV() {
resetCsvFlags() {
this.downloadCSVReady = false;
this.csvError = false;
},
downloadMetadataCSV() {
this.resetCsvFlags();
var qParams = {};
Object.assign(qParams, this.qParams);
qParams.csv = "true";
......@@ -248,11 +312,12 @@ export default {
})
.then((response) => {
this.downloadCSVReady = true;
this.forceFileDownload(response, 'metagenedb_metadata.csv');
this.forceFileDownload(response, `${this.fileName}.csv`);
})
.catch((error) => {
console.error(error);
this.downloadReady = true;
this.csvError = true;
this.downloadCSVReady = true;
});
},
emptyGeneInformationFilter() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment