2019-04-04 18:26:43 +00:00
|
|
|
<template>
|
2019-04-05 18:14:23 +00:00
|
|
|
<div id="upload-view" class="flex flex-column items-center justify-center">
|
2019-04-09 07:20:46 +00:00
|
|
|
<p v-show="!paid && !expired" class="dn f6 mb4 mid-gray">To avoid spam you are asked to make a one-time payment equivalent to the
|
|
|
|
fee you ask for your link</p>
|
|
|
|
|
|
|
|
<pay v-show="!paid" :objectId="uploadId" :invoice="invoice"></pay>
|
2019-04-04 18:26:43 +00:00
|
|
|
<div class="hr"></div>
|
2019-04-05 18:14:23 +00:00
|
|
|
|
|
|
|
<form id="accepted" class="flex flex-column mt5 w-100" v-if="accepted" >
|
|
|
|
<label for="adminToken" class="f7 db mb2">
|
|
|
|
<span class="normal b orange">Your admin token:</span>
|
|
|
|
</label>
|
|
|
|
|
2019-04-07 10:30:43 +00:00
|
|
|
<input class="input-reset f6 b ba b--black-20 pa2 mb2 db w-100 mid-gray" @click="selectCopy" id="adminToken" type="text" v-model="adminToken">
|
2019-04-05 18:14:23 +00:00
|
|
|
|
|
|
|
|
2019-04-07 10:30:43 +00:00
|
|
|
<label for="downloadLink" class="f7 db mb2 mt3">
|
2019-04-05 18:14:23 +00:00
|
|
|
<span class="normal b blue">Download link:</span>
|
|
|
|
</label>
|
2019-04-07 10:30:43 +00:00
|
|
|
<input class="input-reset f6 b ba b--black-20 pa2 mb2 db w-100 mid-gray" @click="selectCopy" id="downloadLink" type="text" v-model="downloadLink">
|
2019-04-05 18:14:23 +00:00
|
|
|
|
|
|
|
</form>
|
2019-04-04 18:26:43 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script charset="utf-8">
|
|
|
|
import { mapState, mapGetters } from 'vuex'
|
|
|
|
|
|
|
|
import Upload from './Upload.vue';
|
|
|
|
import Pay from './Pay.vue';
|
|
|
|
|
|
|
|
import GetWorker from './workerInterface.js';
|
|
|
|
import Api from './api.js';
|
|
|
|
|
|
|
|
const Worker = GetWorker('main');
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'UploadView',
|
|
|
|
data() {
|
|
|
|
return {
|
2019-04-05 18:14:23 +00:00
|
|
|
accepted: false,
|
|
|
|
adminToken: "",
|
|
|
|
downloadId: "",
|
2019-04-04 18:26:43 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
props: ['uploadId'],
|
2019-04-07 10:30:43 +00:00
|
|
|
created (){
|
2019-04-04 18:26:43 +00:00
|
|
|
let self = this;
|
|
|
|
this.worker = Worker;
|
|
|
|
|
|
|
|
|
|
|
|
// First check the status to get the invoice
|
|
|
|
Api.checkUploadStatus(this.uploadId)
|
2019-04-07 11:54:41 +00:00
|
|
|
.then((res)=>{
|
|
|
|
|
|
|
|
return res.json()
|
|
|
|
.then((data)=>{
|
|
|
|
this.$store.commit('setInvoice', data.invoice)
|
2019-04-04 18:26:43 +00:00
|
|
|
|
2019-04-07 11:54:41 +00:00
|
|
|
// Set upload metadata
|
|
|
|
this.$store.commit('setUpStatus', data.status)
|
2019-04-07 10:30:43 +00:00
|
|
|
|
2019-04-07 11:54:41 +00:00
|
|
|
return data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((err)=>{
|
|
|
|
console.error(err)
|
|
|
|
})
|
|
|
|
.then((data)=>{
|
2019-04-04 18:26:43 +00:00
|
|
|
|
2019-04-05 16:18:44 +00:00
|
|
|
// if payment required, poll for invoice paid
|
|
|
|
if (data.status.pay_status === 'waiting') {
|
2019-04-07 11:54:41 +00:00
|
|
|
Api.pollUploadStatus(self.uploadId)
|
|
|
|
.then((res)=>{ return res.json() })
|
2019-04-04 18:26:43 +00:00
|
|
|
.then((data)=>{
|
2019-04-07 11:54:41 +00:00
|
|
|
|
|
|
|
|
2019-04-04 18:26:43 +00:00
|
|
|
console.log(data)
|
2019-04-07 11:54:41 +00:00
|
|
|
self.$store.commit('setInvoice', data.invoice)
|
|
|
|
self.$store.commit('setUpStatus', data.status)
|
2019-04-04 18:26:43 +00:00
|
|
|
|
2019-04-05 18:14:23 +00:00
|
|
|
// if paid we get the admin/dl link
|
|
|
|
if (data.status.pay_status == 'paid' ){
|
2019-04-07 11:54:41 +00:00
|
|
|
self.accepted = true;
|
2019-04-05 18:14:23 +00:00
|
|
|
|
2019-04-07 11:54:41 +00:00
|
|
|
({ admin_token: self.adminToken,
|
|
|
|
download_id: self.downloadId } = data);
|
2019-04-05 18:14:23 +00:00
|
|
|
}
|
2019-04-04 18:26:43 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-04-05 18:14:23 +00:00
|
|
|
},
|
|
|
|
methods:{
|
2019-04-07 10:30:43 +00:00
|
|
|
selectCopy(ev){
|
2019-04-05 18:14:23 +00:00
|
|
|
ev.target.select()
|
|
|
|
document.execCommand('copy');
|
|
|
|
}
|
2019-04-04 18:26:43 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
status: state => state.upload.status,
|
2019-04-07 10:30:43 +00:00
|
|
|
invoice: state => state.base.invoice,
|
2019-04-04 18:26:43 +00:00
|
|
|
}),
|
2019-04-09 07:20:46 +00:00
|
|
|
...mapGetters([
|
|
|
|
'paid',
|
|
|
|
'expired',
|
|
|
|
]),
|
2019-04-05 18:14:23 +00:00
|
|
|
downloadLink(){
|
|
|
|
let loc = window.location;
|
|
|
|
return loc.host + '/d/' + this.downloadId
|
|
|
|
},
|
2019-04-04 18:26:43 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Upload,
|
|
|
|
Pay,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2019-04-05 18:14:23 +00:00
|
|
|
#upload-view{
|
|
|
|
min-width: var(--qrcode-width);
|
|
|
|
}
|
|
|
|
|
|
|
|
#accepted input:focus {
|
|
|
|
background: #fffceb;
|
|
|
|
}
|
|
|
|
|
|
|
|
input#adminToken::selection {
|
|
|
|
color: #ff6300;
|
|
|
|
}
|
|
|
|
|
|
|
|
input#downloadLink::selection {
|
|
|
|
color: #357Edd;;
|
|
|
|
}
|
|
|
|
|
2019-04-04 18:26:43 +00:00
|
|
|
</style>
|