mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
transaction list query in graphql, include decayStartBlock in model, transactionId optional
This commit is contained in:
parent
ac91c59a59
commit
572abb9e3f
@ -9,6 +9,7 @@ export class Decay {
|
||||
this.decayStart = json.decay_start
|
||||
this.decayEnd = json.decay_end
|
||||
this.decayDuration = json.decay_duration
|
||||
this.decayStartBlock = json.decay_start_block
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
@ -22,4 +23,7 @@ export class Decay {
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
decayDuration?: string
|
||||
|
||||
@Field(() => Int, { nullable: true })
|
||||
decayStartBlock?: number
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ export class Transaction {
|
||||
@Field(() => String)
|
||||
memo: string
|
||||
|
||||
@Field(() => Number)
|
||||
transactionId: number
|
||||
@Field(() => Number, { nullable: true })
|
||||
transactionId?: number
|
||||
|
||||
@Field({ nullable: true })
|
||||
name?: string
|
||||
|
||||
@ -10,6 +10,7 @@ export class TransactionResolver {
|
||||
async transactionList(
|
||||
@Args() { sessionId, firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput,
|
||||
): Promise<TransactionList> {
|
||||
|
||||
const result = await apiGet(
|
||||
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`,
|
||||
)
|
||||
|
||||
@ -19,16 +19,17 @@
|
||||
{{ $t('decay.last_transaction') }}
|
||||
</div>
|
||||
<div style="width: 60%">
|
||||
<div v-if="decay.decay_start_block > 0">
|
||||
{{ decay.decayStartBlock }}
|
||||
<div v-if="decay.decayStartBlock > 0">
|
||||
<div class="display-4">{{ $t('decay.Starting_block_decay') }}</div>
|
||||
<div>
|
||||
{{ $t('decay.decay_introduced') }} :
|
||||
{{ $d($moment.unix(decay.decay_start), 'long') }}
|
||||
{{ $d($moment.unix(decay.decayStart), 'long') }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
{{ $d($moment.unix(decay.decay_start), 'long') }}
|
||||
{{ $d($moment.unix(decay.decayStart), 'long') }}
|
||||
{{ $i18n.locale === 'de' ? 'Uhr' : '' }}
|
||||
</span>
|
||||
</div>
|
||||
@ -40,7 +41,7 @@
|
||||
{{ $t('decay.past_time') }}
|
||||
</div>
|
||||
<div style="width: 60%">
|
||||
<div v-if="decay.decay_start_block > 0">{{ $t('decay.since_introduction') }}</div>
|
||||
<div v-if="decay.decayStartBlock > 0">{{ $t('decay.since_introduction') }}</div>
|
||||
<span v-if="duration">
|
||||
<b v-if="duration.years > 0">{{ duration.years }} {{ $t('decay.year') }},</b>
|
||||
<b v-if="duration.months > 0">{{ duration.months }} {{ $t('decay.months') }},</b>
|
||||
@ -62,24 +63,24 @@ export default {
|
||||
props: {
|
||||
decay: {
|
||||
balance: '',
|
||||
decay_duration: '',
|
||||
decay_start: 0,
|
||||
decay_end: 0,
|
||||
decay_start_block: 0,
|
||||
decayDuration: '',
|
||||
decayStart: 0,
|
||||
decayEnd: 0,
|
||||
decayStartBlock: 0,
|
||||
},
|
||||
decaytyp: { type: String, default: '' },
|
||||
},
|
||||
computed: {
|
||||
decayStartBlockTextShort() {
|
||||
return this.decay.decay_start_block
|
||||
? ' - Startblock Decay am: ' + this.$d(this.$moment.unix(this.decay.decay_start_block))
|
||||
return this.decay.decayStartBlock
|
||||
? ' - Startblock Decay am: ' + this.$d(this.$moment.unix(this.decay.decayStartBlock))
|
||||
: ''
|
||||
},
|
||||
duration() {
|
||||
return this.$moment.duration(
|
||||
this.$moment
|
||||
.unix(new Date(this.decay.decay_end))
|
||||
.diff(this.$moment.unix(new Date(this.decay.decay_start))),
|
||||
.unix(new Date(this.decay.decayEnd))
|
||||
.diff(this.$moment.unix(new Date(this.decay.decayStart))),
|
||||
)._data
|
||||
},
|
||||
},
|
||||
|
||||
@ -20,3 +20,34 @@ export const logout = gql`
|
||||
logout(sessionId: $sessionId)
|
||||
}
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query($sessionId: Float!, $firstPage: Int = 1, $items: Int = 25, $order: String = "DESC") {
|
||||
transactionList(sessionId: $sessionId, firstPage: $firstPage, items: $items, order: $order) {
|
||||
gdtSum
|
||||
count
|
||||
balance
|
||||
decay
|
||||
decayDate
|
||||
transactions {
|
||||
type
|
||||
balance
|
||||
decayStart
|
||||
decayEnd
|
||||
decayDuration
|
||||
memo
|
||||
transactionId
|
||||
name
|
||||
email
|
||||
date
|
||||
decay {
|
||||
balance
|
||||
decayStart
|
||||
decayEnd
|
||||
decayDuration
|
||||
decayStartBlock
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@ -66,11 +66,9 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { logout } from '../../graphql/queries'
|
||||
|
||||
import { logout, transactionsQuery } from '../../graphql/queries'
|
||||
import ContentFooter from './ContentFooter.vue'
|
||||
import { FadeTransition } from 'vue2-transitions'
|
||||
import communityAPI from '../../apis/communityAPI'
|
||||
import VueQrcode from 'vue-qrcode'
|
||||
|
||||
export default {
|
||||
@ -105,22 +103,30 @@ export default {
|
||||
},
|
||||
async updateTransactions(pagination) {
|
||||
this.pending = true
|
||||
const result = await communityAPI.transactions(
|
||||
this.$store.state.sessionId,
|
||||
pagination.firstPage,
|
||||
pagination.items,
|
||||
)
|
||||
if (result.success) {
|
||||
this.GdtBalance = Number(result.result.data.gdtSum)
|
||||
this.transactions = result.result.data.transactions
|
||||
this.balance = Number(result.result.data.decay)
|
||||
this.bookedBalance = Number(result.result.data.balance)
|
||||
this.transactionCount = result.result.data.count
|
||||
this.pending = false
|
||||
} else {
|
||||
this.pending = true
|
||||
// what to do when loading balance fails?
|
||||
}
|
||||
this.$apollo
|
||||
.query({
|
||||
query: transactionsQuery,
|
||||
variables: {
|
||||
sessionId: this.$store.state.sessionId,
|
||||
firstPage: pagination.firstPage,
|
||||
items: pagination.items,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
const {
|
||||
data: { transactionList },
|
||||
} = result
|
||||
this.GdtBalance = Number(transactionList.gdtSum)
|
||||
this.transactions = transactionList.transactions
|
||||
this.balance = Number(transactionList.decay)
|
||||
this.bookedBalance = Number(transactionList.balance)
|
||||
this.transactionCount = transactionList.count
|
||||
this.pending = false
|
||||
})
|
||||
.catch(() => {
|
||||
this.pending = true
|
||||
// what to do when loading balance fails?
|
||||
})
|
||||
},
|
||||
updateBalance(ammount) {
|
||||
this.balance -= ammount
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
<div class="gdd-transaction-list">
|
||||
<b-list-group>
|
||||
<b-list-group-item
|
||||
v-for="{ decay, transaction_id, type, date, balance, name, memo } in transactions"
|
||||
:key="transaction_id"
|
||||
v-for="{ decay, transactionId, type, date, balance, name, memo } in transactions"
|
||||
:key="transactionId"
|
||||
:style="type === 'decay' ? 'background-color:#f1e0ae3d' : ''"
|
||||
>
|
||||
<!-- ROW Start -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user