Skip to content

Commit

Permalink
Added option to upload multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
WassimG committed Jan 24, 2024
1 parent 14eac21 commit 61976cb
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" type="image/png" href="img/favicon.ico"/>
<link rel="shortcut icon" type="image/png" href="public/favicon.ico"/>
<title>Prosit</title>
</head>
<body>
Expand Down
31 changes: 28 additions & 3 deletions ui/src/components/MQR.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,39 @@
</Info>



<v-stepper-step :complete="step > 1" step="1">
Search Engine
<small>select the search engine used for searching your data.</small>
</v-stepper-step>
<v-stepper-content step="1">
<v-card flat>
<div v-if="modelIntensityList.length>0">
Intensity prediction model
<v-radio-group v-model="modelIntensityName" column>
<v-radio color='primary'
v-for="f in modelIntensityList"
:key="f.name"
:label="f.name"
:value="f.name"
></v-radio>
</v-radio-group>
</div>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn small color="primary" @click="step = 2" :disabled="!doneUploads">next<v-icon>chevron_right</v-icon></v-btn>
</v-card-actions>
</v-card>
</v-stepper-content>

<v-stepper-step :complete="step > 1" step="1">
Upload Files
<small>msms.txt and RAW file.</small>
</v-stepper-step>
<v-stepper-content step="1">

<Upload filetype="msms.txt" filesuffix=".txt" :taskid="taskid" hinttext="MaxQuant's msms.txt from a finished search. Note, amino acid U or O are not supported."></Upload>
<Upload filetype="RAW" filesuffix=".RAW,.raw" v-bind:sizelimit=2000 :taskid="taskid" hinttext="RAW file that was searched (restricted to Thermo Fisher HCD Orbitrap). File size is limited to 2GB."></Upload>
<MultiUpload filetype="RAW" filesuffix=".RAW,.raw,.zip" v-bind:sizelimit=6000 :taskid="taskid" hinttext="RAW file that was searched."></MultiUpload>

<v-card flat>
<v-card-actions>
Expand Down Expand Up @@ -131,11 +156,12 @@ import axios from 'axios'
import Upload from '@/components/Upload.vue'
import Submit from '@/components/Submit.vue'
import Info from '@/components/Info.vue'
import MultiUpload from '@/components/MultiUpload.vue'
export default {
props: ['taskid'],
components: { Upload, Submit, Info },
components: { Upload, Submit,MultiUpload, Info },
data () {
return {
step: 1,
Expand Down Expand Up @@ -171,7 +197,6 @@ export default {
let modelIntensityLists = response.data.models.intensities;
let modelIRTLists = response.data.models.iRT;
this.modelIRTList = [];
//modelIRTList = response.data.models.iRT;
this.modelIntensityList = [];
for (let i = 0; i < modelIntensityLists.length; i++){
//if(modelIntensityLists[i].enabled.rescoring)
Expand Down
194 changes: 194 additions & 0 deletions ui/src/components/MultiUpload.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<template>
<v-container>
<v-text-field
readonly
:hint='hinttext'
persistent-hint
@click="$refs.upload.$el.lastChild.click()"
v-model="filetype"
class='ma-0'>
<v-tooltip top slot='prepend'>
<v-btn slot='activator' fab small color='primary' @click.native="$refs.upload.$el.lastChild.click()">
<v-icon>cloud_upload</v-icon>
</v-btn>
{{this.filetype}}
</v-tooltip>
</v-text-field>
<div v-for="file in files" :key="file.id">
<v-text-field
readonly
loading
@click="$refs.upload.$el.lastChild.click()"
@click:clear="remove(file)"
v-model="file.name"
append-outer-icon="clear"
@click:append-outer="remove(file)"
class='ma-0'>
<v-progress-linear
color="accent"
height="3"
slot="progress"
:value="file.progress"
></v-progress-linear>
</v-text-field>
</div>
<v-btn small :disabled='getNumFilesWaitingForUpload() == 0' v-if="!$refs.upload || !$refs.upload.active" @click.prevent="$refs.upload.active = true">
<v-icon small class="fa fa-arrow-up" aria-hidden="true"></v-icon>&nbsp;
Start Upload
</v-btn>
<v-btn small v-else @click.prevent="stopUpload()">
<v-icon small class="fa fa-stop" aria-hidden="true"></v-icon>&nbsp;
Stop Upload
</v-btn>
<file-upload
class="btn btn-primary"
:custom-action="uploadFile"
:extensions="filesuffix"
:accept='filesuffix'
:multiple="true"
:size="sizelimit*1024*1024"
v-model="files"
@input-filter="inputFilter"
@input-file="inputFile"
:data="{type: filetype}"
ref="upload">
</file-upload>
</v-container>
</template>

<script>
import FileUpload from 'vue-upload-component'
import axios from 'axios'
import store from '@/store'
export default {
components: {
FileUpload,
},
props: {
'filetype': String,
'hinttext': String,
'filesuffix': String,
'sizelimit': {
type: Number,
default: -1
}
},
data() {
return {
files: [],
filename: this.filetype,
progress: 0,
baseurl: process.env.VUE_APP_API_URL + '/prosit/api/upload.xsjs',
requesttoken: axios.CancelToken.source()
}
},
methods: {
remove(file) {
this.$refs.upload.remove(file)
this.checkNumUploadFiles()
},
stopUpload() {
this.requesttoken.cancel();
this.resetUpload()
},
resetUpload() {
this.$refs.upload.active = false
},
checkNumUploadFiles() {
var count = 0
this.files.forEach(function (f) {
if (f.success) {
count += 1
}
})
if (count == 0) {
store.commit('reportUpload', {fileType: this.filetype, isSuccessful: false});
}
},
getNumFilesWaitingForUpload() {
var count = 0
this.files.forEach(function (f) {
if (!f.success) {
count += 1
}
})
return count
},
inputFilter(newFile, oldFile, prevent) {
if (newFile && !oldFile) {
// Before adding a file
// Filter system files or hide files
if (/(\/|^)(Thumbs\.db|desktop\.ini|\..+)$/.test(newFile.name)) {
return prevent()
}
// Filter php html js file
if (/\.(php5?|html?|jsx?)$/i.test(newFile.name)) {
return prevent()
}
}
},
inputFile(newFile, oldFile) {
if (newFile && !oldFile) {
// add
//console.log('add', newFile)
store.commit('reportUpload', {fileType: this.filetype, isSuccessful: false});
}
if (newFile && oldFile) {
// update
//console.log('update', newFile, oldFile)
// on upload abort
if (!newFile.active && oldFile.active && newFile.progress != 100) {
newFile.progress = 0
newFile.success = false
}
}
if (!newFile && oldFile) {
// remove
//console.log('remove', oldFile)
}
},
async uploadFile(file) {
this.requesttoken.cancel();
file.progress = 0;
this.file = file;
this.filename = this.file.name;
let formData = new FormData();
formData.set('type', this.filetype);
formData.append('file', this.file.file);
this.requesttoken = axios.CancelToken.source();
await axios.post(
this.baseurl,
formData,
{
params: { datasetId: this.$store.state.taskID },
headers: { 'Content-Type': 'multipart/form-data' },
onUploadProgress: ( progressEvent ) => {
file.progress = parseInt( Math.round( ( progressEvent.loaded * 100 ) / progressEvent.total ) );
},
cancelToken: this.requesttoken.token
}
).then(() => {
// success
if (this.getNumFilesWaitingForUpload() == 1) {
store.commit('reportUpload', {fileType: this.filetype, isSuccessful: true});
}
}).catch(() =>{
// error
alert('Something went wrong. Please reload the page and try again (respectfully).')
this.resetUpload()
});
},
}
}
</script>
Binary file removed ui/static/favicon.png
Binary file not shown.

0 comments on commit 61976cb

Please sign in to comment.