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