-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NN-402 Added a function to window menu for exporting proteins as csv
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
frontend/src/components/toolbar/modules/ExportProteins.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<div class="tool-item"> | ||
<span v-on:click="export_proteins">Export proteins as .csv</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'ExportProteins', | ||
props:['gephi_data'], | ||
data() { | ||
return { | ||
} | ||
}, | ||
methods: { | ||
export_proteins() { | ||
var com = this; | ||
// export proteins as csv | ||
var csvTermsData = com.gephi_data.nodes; | ||
var terms_csv = 'name\tensembl\tcluster\tdescription\n'; | ||
csvTermsData.forEach(function(row) { | ||
terms_csv += row.attributes['Name'] + '\t' + row.attributes['Ensembl ID'] + '\t"' + row.attributes['Modularity Class'] + '"\t"' + row.attributes['Description'] +'"'; | ||
terms_csv += '\n'; | ||
}); | ||
//Create html element to hidden download csv file | ||
var hiddenElement = document.createElement('a'); | ||
hiddenElement.target = '_blank'; | ||
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(terms_csv); | ||
hiddenElement.download = 'Proteins.csv'; | ||
hiddenElement.click(); | ||
}, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters