mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
155 lines
4.5 KiB
Vue
Executable File
155 lines
4.5 KiB
Vue
Executable File
<template>
|
|
<div>
|
|
<navbar
|
|
class="main-navbar"
|
|
:balance="balance"
|
|
:visible="visible"
|
|
:pending="pending"
|
|
:elopageUri="elopageUri"
|
|
@set-visible="setVisible"
|
|
@admin="admin"
|
|
@logout="logout"
|
|
/>
|
|
<div class="content-gradido">
|
|
<div class="d-none d-sm-none d-md-none d-lg-flex shadow-lg gradido-width-300">
|
|
<sidebar class="main-sidebar" :elopageUri="elopageUri" @admin="admin" @logout="logout" />
|
|
</div>
|
|
|
|
<div class="main-page gradido-max-width" @click="visible = false">
|
|
<div class="main-content">
|
|
<fade-transition :duration="200" origin="center top" mode="out-in">
|
|
<router-view
|
|
ref="router-view"
|
|
:balance="balance"
|
|
:gdt-balance="GdtBalance"
|
|
:transactions="transactions"
|
|
:transactionCount="transactionCount"
|
|
:transactionLinkCount="transactionLinkCount"
|
|
:pending="pending"
|
|
:decayStartBlock="decayStartBlock"
|
|
@update-balance="updateBalance"
|
|
@update-transactions="updateTransactions"
|
|
></router-view>
|
|
</fade-transition>
|
|
</div>
|
|
<content-footer v-if="!$route.meta.hideFooter"></content-footer>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import Navbar from '@/components/Menu/Navbar.vue'
|
|
import Sidebar from '@/components/Menu/Sidebar.vue'
|
|
import { logout, transactionsQuery } from '@/graphql/queries'
|
|
import ContentFooter from '@/components/ContentFooter.vue'
|
|
import { FadeTransition } from 'vue2-transitions'
|
|
import CONFIG from '@/config'
|
|
|
|
export default {
|
|
components: {
|
|
Navbar,
|
|
Sidebar,
|
|
ContentFooter,
|
|
FadeTransition,
|
|
},
|
|
data() {
|
|
return {
|
|
logo: 'img/brand/green.png',
|
|
balance: 0,
|
|
GdtBalance: 0,
|
|
transactions: [],
|
|
bookedBalance: 0,
|
|
transactionCount: 0,
|
|
transactionLinkCount: 0,
|
|
pending: true,
|
|
visible: false,
|
|
decayStartBlock: new Date(),
|
|
}
|
|
},
|
|
methods: {
|
|
async logout() {
|
|
this.$apollo
|
|
.query({
|
|
query: logout,
|
|
})
|
|
.then(() => {
|
|
this.$store.dispatch('logout')
|
|
this.$router.push('/login')
|
|
})
|
|
.catch(() => {
|
|
this.$store.dispatch('logout')
|
|
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
|
|
})
|
|
},
|
|
async updateTransactions(pagination) {
|
|
this.pending = true
|
|
this.$apollo
|
|
.query({
|
|
query: transactionsQuery,
|
|
variables: {
|
|
currentPage: pagination.currentPage,
|
|
pageSize: pagination.pageSize,
|
|
},
|
|
fetchPolicy: 'network-only',
|
|
})
|
|
.then((result) => {
|
|
const {
|
|
data: { transactionList },
|
|
} = result
|
|
this.GdtBalance =
|
|
transactionList.balanceGDT === null ? null : Number(transactionList.balanceGDT)
|
|
this.transactions = transactionList.transactions
|
|
this.balance = Number(transactionList.balance)
|
|
this.transactionCount = transactionList.count
|
|
this.transactionLinkCount = transactionList.linkCount
|
|
this.decayStartBlock = new Date(transactionList.decayStartBlock)
|
|
this.pending = false
|
|
})
|
|
.catch((error) => {
|
|
this.pending = true
|
|
this.transactionCount = -1
|
|
this.toastError(error.message)
|
|
// what to do when loading balance fails?
|
|
})
|
|
},
|
|
updateBalance(ammount) {
|
|
this.balance -= ammount
|
|
},
|
|
admin() {
|
|
window.location.assign(CONFIG.ADMIN_AUTH_URL.replace('{token}', this.$store.state.token))
|
|
this.$store.dispatch('logout') // logout without redirect
|
|
},
|
|
setVisible(bool) {
|
|
this.visible = bool
|
|
},
|
|
},
|
|
computed: {
|
|
elopageUri() {
|
|
const pId = this.$store.state.publisherId
|
|
? this.$store.state.publisherId
|
|
: CONFIG.DEFAULT_PUBLISHER_ID
|
|
return encodeURI(
|
|
this.$store.state.hasElopage
|
|
? `https://elopage.com/s/gradido/sign_in?locale=${this.$i18n.locale}`
|
|
: `https://elopage.com/s/gradido/basic-de/payment?locale=${this.$i18n.locale}&prid=111&pid=${pId}&firstName=${this.$store.state.firstName}&lastName=${this.$store.state.lastName}&email=${this.$store.state.email}`,
|
|
)
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
<style>
|
|
.content-gradido {
|
|
display: inline-flex;
|
|
width: 100%;
|
|
height: 91%;
|
|
position: absolute;
|
|
}
|
|
.navbar-brand-img {
|
|
height: 2rem;
|
|
padding-left: 10px;
|
|
}
|
|
.bg-lightgrey {
|
|
background-color: #f0f0f0;
|
|
}
|
|
</style>
|