WIP download start and keep dl invoice session
parent
53f37ff619
commit
4105c33e25
@ -1,25 +0,0 @@
|
||||
<template>
|
||||
<div class="download">
|
||||
<p>upload id: <span class="last-upload">{{ id }}</span></p>
|
||||
<p>download: <a :href="link" class="dl-link">{{link}}</a></p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
const baseDlPath = "/d/"
|
||||
|
||||
export default {
|
||||
props: ['id'],
|
||||
mounted(){
|
||||
|
||||
},
|
||||
computed:{
|
||||
link(){
|
||||
let linkTarget = baseDlPath + this.id
|
||||
|
||||
return new URL(linkTarget, window.location.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,69 @@
|
||||
<template>
|
||||
|
||||
<div id="download">
|
||||
<pay v-if="!error" :objectId="dlId" :invoice="invoice"></pay>
|
||||
<div v-if="error" class="f4 mv5 light-red ttu">{{errorMsg}}</div>
|
||||
<upload v-if="error"></upload>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapGetters } from 'vuex'
|
||||
import Pay from './Pay.vue';
|
||||
import Api from './api.js';
|
||||
import Upload from './Upload.vue';
|
||||
|
||||
|
||||
export default {
|
||||
name: 'DownloadView',
|
||||
props: ['dlId'],
|
||||
data(){
|
||||
return {
|
||||
error: false,
|
||||
errorMsg: "",
|
||||
}
|
||||
},
|
||||
created(){
|
||||
let self = this
|
||||
// Query for download invoice
|
||||
Api.download(this.dlId)
|
||||
|
||||
.then((res)=>{
|
||||
|
||||
if (res.status === 404){
|
||||
self.error = true
|
||||
self.errorMsg = "this link does not exist anymore"
|
||||
|
||||
// ask payment
|
||||
} else if ( res.status === 402) {
|
||||
res.json()
|
||||
.then((data)=>{
|
||||
this.$store.commit('setInvoice', data.invoice)
|
||||
this.$store.commit('setFiles', data.files)
|
||||
})
|
||||
.catch((e)=>{console.log(e)})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState({
|
||||
invoice: state => state.base.invoice,
|
||||
files: state => state.down.files,
|
||||
}),
|
||||
...mapGetters([
|
||||
'paid',
|
||||
'unpaid'
|
||||
]),
|
||||
downloadLink(){
|
||||
return 'TODO'
|
||||
},
|
||||
},
|
||||
components: {
|
||||
Pay,
|
||||
Upload,
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue