diff --git a/admin/src/components/CreationTransactionListFormular.vue b/admin/src/components/CreationTransactionListFormular.vue index 4073a315a..fcf984ea9 100644 --- a/admin/src/components/CreationTransactionListFormular.vue +++ b/admin/src/components/CreationTransactionListFormular.vue @@ -5,55 +5,40 @@ diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index e92c451b1..4c8f2bb67 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -125,7 +125,10 @@ :dateLastSend="$moment().subtract(1, 'month').format('dddd, DD.MMMM.YYYY HH:mm')," /> - + Order, { nullable: true }) order?: Order + + @Field(() => Boolean, { nullable: true }) + onlyCreations?: boolean + + @Field(() => Int, { nullable: true }) + userId?: number } diff --git a/backend/src/graphql/model/UserAdmin.ts b/backend/src/graphql/model/UserAdmin.ts index 5e7d7f684..befc203a5 100644 --- a/backend/src/graphql/model/UserAdmin.ts +++ b/backend/src/graphql/model/UserAdmin.ts @@ -2,6 +2,9 @@ import { ObjectType, Field } from 'type-graphql' @ObjectType() export class UserAdmin { + @Field(() => Number) + userId: number + @Field(() => String) email: string diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index fb596870a..31c720716 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -29,6 +29,7 @@ export class AdminResolver { const adminUsers = await Promise.all( users.map(async (user) => { const adminUser = new UserAdmin() + adminUser.userId = user.id adminUser.firstName = user.firstName adminUser.lastName = user.lastName adminUser.email = user.email diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index b2f4b4db5..40e29cfe6 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -340,6 +340,7 @@ async function listTransactions( pageSize: number, order: Order, user: dbUser, + onlyCreations: boolean, ): Promise { let limit = pageSize let offset = 0 @@ -379,6 +380,14 @@ async function listTransactions( const transactionList = new TransactionList() transactionList.count = userTransactionsCount + if (onlyCreations) { + console.log('before filtering', transactions) + transactions = transactions.filter((transaction) => { + console.log('In filter', transaction) + return transaction.type === 'creation' + }) + console.log('after filtering', transactions) + } transactionList.transactions = transactions return transactionList } @@ -469,14 +478,33 @@ export class TransactionResolver { @Authorized([RIGHTS.TRANSACTION_LIST]) @Query(() => TransactionList) async transactionList( - @Args() { currentPage = 1, pageSize = 25, order = Order.DESC }: Paginated, + @Args() + { + currentPage = 1, + pageSize = 25, + order = Order.DESC, + onlyCreations = false, + userId, + }: Paginated, @Ctx() context: any, ): Promise { // load user const userRepository = getCustomRepository(UserRepository) - const userEntity = await userRepository.findByPubkeyHex(context.pubKey) + let userEntity: dbUser | undefined + if (userId) { + console.log('Find by id, ', userId) + userEntity = await userRepository.findOneOrFail({ id: userId }) + } else { + userEntity = await userRepository.findByPubkeyHex(context.pubKey) + } - const transactions = await listTransactions(currentPage, pageSize, order, userEntity) + const transactions = await listTransactions( + currentPage, + pageSize, + order, + userEntity, + onlyCreations, + ) // get gdt sum const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index d867e14ad..c6d5a36c3 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -47,8 +47,18 @@ export const logout = gql` ` export const transactionsQuery = gql` - query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) { - transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) { + query( + $currentPage: Int = 1 + $pageSize: Int = 25 + $order: Order = DESC + $onlyCreations: Boolean = false + ) { + transactionList( + currentPage: $currentPage + pageSize: $pageSize + order: $order + onlyCreations: $onlyCreations + ) { gdtSum count balance