routes + Base style scaffolding

master
Chakib Benziane 5 years ago
parent 314e3b7624
commit 6b74f86164

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width">
<title></title>
</head>
<body>
<body class="avenir bg-white">
<div id="app">
</div>

@ -19,8 +19,10 @@
"dependencies": {
"babel-polyfill": "^6.26.0",
"qrcode": "^1.3.3",
"tachyons": "4.10.0",
"vue": "^2.6.8",
"vue-hot-reload-api": "^2.3.3"
"vue-hot-reload-api": "^2.3.3",
"vue-router": "^3.0.2"
},
"alias": {
"vue": "./node_modules/vue/dist/vue.common.js"

@ -1,87 +1,31 @@
<template>
<div id="app">
<upload></upload>
<pay :uploadId="uploadId" :status="status" :invoice="invoice"></pay>
<download-link v-if="uploadId && paid" :id="uploadId"></download-link>
<div id="app" class="flex flex-column items-center">
<div id="logo" class="w-100 flex justify-center items-end">
<span class="logo-titla f1 lh-title tracked">BIT4SAT</span>
</div>
<div class="main h-100 w-100 flex mt5 items-start justify-center">
<router-view />
</div>
</div>
</template>
<script charset="utf-8">
import Upload from './Upload.vue';
import Pay from './Pay.vue';
import DownloadLink from './DownloadLink.vue';
import GetWorker from './workerInterface.js';
import { lastSession } from './api.js';
const Worker = GetWorker('main');
export default {
name: 'app',
data() {
return {
uploadId: 0,
invoice: {},
status: {},
}
},
mounted (){
let self = this;
this.worker = Worker;
// listen to worker events
this.worker.listenTo('upload-invoice', (e) => {
console.log("received invoice ", e.data)
self.invoice = e.data.invoice;
self.uploadId = e.data.upload_id;
self.status = e.data.status;
})
this.worker.listenTo('payment-received', (e)=>{
console.log('pay received', e.data)
this.invoice = e.data.invoice;
this.status = e.data.status;
})
// Get last session uploadId if it exists
lastSession()
.then((data) => {
// If upload id is unpaid
if (data.uploadId !== 0){
this.invoice = data.invoice;
this.uploadId = data.uploadId;
this.status = data.status;
if (this.invoice.status === 'unpaid') {
console.log("last session unpaid")
</script>
// start waiting for the payment status
this.worker.post({
msg: 'watch-payment',
uploadId: this.uploadId
})
}
}
})
<style>
#app {
height: 100vh;
}
},
computed: {
paid() {
return this.invoice.status == 'paid';
},
},
components: {
Upload,
Pay,
DownloadLink,
}
#logo {
height: 35%;
color: #FF725C;
font-style: italic;
font-weight: bolder;
text-shadow: 2px 3px #444, -2px -2px #444;
}
</script>
<style>
.unpaid {
background-color: pink;
}

@ -0,0 +1,104 @@
<template>
<div id="home">
<upload></upload>
<!--<pay :uploadId="uploadId" :status="status" :invoice="invoice"></pay>-->
<!--<download-link v-if="uploadId && paid" :id="uploadId"></download-link>-->
</div>
</template>
<script charset="utf-8">
import Upload from './Upload.vue';
import Pay from './Pay.vue';
import DownloadLink from './DownloadLink.vue';
import GetWorker from './workerInterface.js';
import { lastSession } from './api.js';
const Worker = GetWorker('main');
export default {
name: 'app',
data() {
return {
uploadId: 0,
invoice: {},
status: {},
}
},
mounted (){
let self = this;
this.worker = Worker;
// listen to worker events
this.worker.listenTo('upload-invoice', (e) => {
console.log("received invoice ", e.data)
self.invoice = e.data.invoice;
self.uploadId = e.data.upload_id;
self.status = e.data.status;
})
this.worker.listenTo('payment-received', (e)=>{
console.log('pay received', e.data)
this.invoice = e.data.invoice;
this.status = e.data.status;
})
// Get last session uploadId if it exists
lastSession()
.then((data) => {
// If upload id is unpaid
if (data.uploadId !== 0){
this.invoice = data.invoice;
this.uploadId = data.uploadId;
this.status = data.status;
if (this.invoice.status === 'unpaid') {
console.log("last session unpaid")
// start waiting for the payment status
this.worker.post({
msg: 'watch-payment',
uploadId: this.uploadId
})
}
}
})
},
computed: {
paid() {
return this.invoice.status == 'paid';
},
},
components: {
Upload,
Pay,
DownloadLink,
}
}
</script>
<style>
.unpaid {
background-color: pink;
}
.expired {
background-color: yellow;
}
.paid {
background-color: lightgreen;
}
.last-upload {
background: cyan;
}
.dl-link{
color: #d33b00
}
</style>

@ -1,16 +1,50 @@
<template>
<div id="upload">
<input v-on:change="fileChange($event)" type="file" multiple />
<p>selected {{fileCount}} files</p>
<ul>
<li v-bind:files="files" v-for="file in files">
{{ file.name }}
<ul>
<li>size: {{ file.size / 1000 }} kB </li>
<li>type: {{ file.type }} </li>
</ul>
</li>
</ul>
<div @dragenter.stop.prevent @dragover.stop.prevent @drop.stop.prevent="drop" id="upload" class="flex flex-column ph4 pv4 ba b--dashed bw2 b--light-red br4 bg-near-white mid-gray">
<div class="title f5 b lh-title ttu tc">drop files here to start</div>
<div class="or f6 mv2 tc">OR</div>
<form class="input-reset flex flex-column justify-center">
<!--hidden file input-->
<input id="fileInput" class="dn" v-on:change="fileChange($event)" type="file" multiple />
<button class="mb3" @click="chooseFiles" id="fileSelect">choose files</button>
<div class="options w-100 flex flex-row justify-between">
<input v-model.trim.number="amount" type="number">
<select v-model="selectedCurrency">
<option v-for="cur in currencies">{{cur}}</option>
</select>
</div>
<!--<p>selected {{fileCount}} files</p>-->
<!--<ul>-->
<!--<li v-bind:files="files" v-for="file in files"> -->
<!--{{ file.name }}-->
<!--<ul>-->
<!--<li>size: {{ file.size / 1000 }} kB </li>-->
<!--<li>type: {{ file.type }} </li>-->
<!--</ul>-->
<!--</li>-->
<!--</ul>-->
</form>
<div class="desc f6 pt2 b lh-copy measure-narrow gray tc">
<p>
If choose to setup a fee for your link, every download will
require a payment.
</p>
<p>You can redeem your payments at any time.</p>
</div>
</div>
</template>
@ -28,10 +62,30 @@ export default {
data(){
return {
fileCount: 0,
files: []
files: [],
currencies: ['EUR', 'USD', 'SAT', 'MSAT'],
amount: 100,
selectedCurrency: 'SAT'
}
},
mounted(){
this.fileInput = this.$el.querySelector('#fileInput')
},
methods: {
drop(event){
this.files=[]
const dt = event.dataTransfer;
this.fileCount = dt.files.length;
this.files = dt.files;
w.post({
msg: 'new-upload',
payload: [...this.files],
})
},
chooseFiles(event){
this.fileInput.click();
},
fileChange(event) {
// reset
this.files = []

@ -1,16 +1,42 @@
import 'tachyons';
import './styles/index.css';
import Vue from 'vue';
import Home from './Home.vue';
import App from './App.vue';
import GetWorker from './workerInterface.js';
import Router from 'vue-router';
window.app = new Vue({
el: '#app',
Vue.use(Router)
const router = new Router({
routes: [
{
path: '/',
name: 'home',
component: Home,
},
{
path:'/u/:uploadId',
name: 'upload',
//component:
}
]
})
//const router = new VueRouter({
//routes
//})
const app = new Vue({
template: '<App/>',
components: { App }
});
components: { App },
router: router
}).$mount('#app');
window.worker = GetWorker('main');
//window.worker = GetWorker('main');

@ -1,6 +1,10 @@
@import './variables.css';
body {
font-size: var(--test);
font-family:
}
body {
/*font-size: var(--test);*/
}

@ -5994,6 +5994,11 @@ table@^5.2.3:
slice-ansi "^2.1.0"
string-width "^3.0.0"
tachyons@4.10.0:
version "4.10.0"
resolved "https://registry.yarnpkg.com/tachyons/-/tachyons-4.10.0.tgz#87fa088e88d9759983f2a1b0efd01d767bbef87b"
integrity sha512-50KOizE6V9QB7LdQqVLsLw17dnBzxonC2JWhmbu8xnQYUoyqV+Gcx678NwVM+O8A7jljobtC6QMl/hc8UZOzAA==
tar@^4:
version "4.4.8"
resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d"
@ -6354,6 +6359,11 @@ vue-hot-reload-api@^2.3.3:
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.3.tgz#2756f46cb3258054c5f4723de8ae7e87302a1ccf"
integrity sha512-KmvZVtmM26BQOMK1rwUZsrqxEGeKiYSZGA7SNWE6uExx8UX/cj9hq2MRV/wWC3Cq6AoeDGk57rL9YMFRel/q+g==
vue-router@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-3.0.2.tgz#dedc67afe6c4e2bc25682c8b1c2a8c0d7c7e56be"
integrity sha512-opKtsxjp9eOcFWdp6xLQPLmRGgfM932Tl56U9chYTnoWqKxQ8M20N7AkdEbM5beUh6wICoFGYugAX9vQjyJLFg==
vue-template-compiler@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.9.tgz#26600415ff81a7a241aebc2d4e0abaa0f1a07915"

Loading…
Cancel
Save