bit4sat/web/src/App.vue

81 lines
2.1 KiB
Vue
Raw Normal View History

2019-03-23 17:01:49 +00:00
<template>
2019-04-04 10:45:34 +00:00
<div id="app" class="flex flex-column items-center">
<div id="logo" class="w-100 flex justify-center items-end">
<a href="/" class="logo-titla f1 lh-title tracked">BIT4SAT</a>
2019-04-04 10:45:34 +00:00
</div>
<div class="main h-100 w-100 flex mt4 items-start justify-center">
2019-04-04 10:45:34 +00:00
<router-view />
</div>
2019-03-23 17:01:49 +00:00
</div>
</template>
<script charset="utf-8">
import GetWorker from './workerInterface.js';
const Worker = GetWorker('main');
import { mapState, mapGetters } from 'vuex'
const dlUrlRegex = /d\/(\w+)\/?/
2019-04-09 07:20:46 +00:00
const adminUrlRegex = /r\/(\w+)\/?/
export default {
mounted(){
this.worker = Worker
// listen and route
this.worker.listenTo('upload-invoice', (e) => {
console.log("received invoice ", e.data)
this.$store.commit('setInvoice', e.data.invoice)
this.$store.commit('setUpStatus', e.data.status)
// if we are not on upload route go there
if ( this.$router.currentRoute.name !== 'upload' ) {
this.$router.push({name: 'upload', params: { uploadId: e.data.upload_id }})
}
})
// On load if the url is a download url route to download path
let loc = window.location
if (loc.pathname.match(dlUrlRegex)) {
let dlId = dlUrlRegex.exec(loc.pathname)[1]
history.replaceState("", `download ${dlId}`, '/' )
this.$router.replace({
name: 'download',
replace: true,
params: {dlId}
})
}
2019-04-09 07:20:46 +00:00
if (loc.pathname.match(adminUrlRegex)) {
let adminToken = adminUrlRegex.exec(loc.pathname)[1]
history.replaceState("", `admin`, '/' )
this.$router.replace({
name: 'admin',
replace: true,
params: {adminToken}
})
}
},
}
2019-04-04 10:45:34 +00:00
</script>
2019-04-02 13:53:00 +00:00
2019-04-04 10:45:34 +00:00
<style>
#app {
height: 100vh;
}
2019-04-02 13:53:00 +00:00
2019-04-04 10:45:34 +00:00
#logo {
height: 25%;
}
#logo a {
2019-04-04 10:45:34 +00:00
color: #FF725C;
font-style: italic;
font-weight: bolder;
text-shadow: 2px 3px #444, -2px -2px #444;
text-decoration: none;
2019-03-23 17:01:49 +00:00
}
2019-04-02 13:53:00 +00:00
</style>