- Aktueller Stand: {{ balance.balance.toFixed(2) }} €
+ Aktueller Stand: {{ balance.balance ? balance.balance.toFixed(2) : "" }} €
gesperrt
diff --git a/src/components/BalanceTransfer.vue b/src/components/BalanceTransfer.vue
index d4429b8..1499fb1 100644
--- a/src/components/BalanceTransfer.vue
+++ b/src/components/BalanceTransfer.vue
@@ -1,60 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/pages/Admin.vue b/src/pages/Admin.vue
index eeab423..d4970cc 100644
--- a/src/pages/Admin.vue
+++ b/src/pages/Admin.vue
@@ -1,11 +1,90 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{ getName(props.row.userid) }}
+
+
+ {{ getLimit(props.row.userid) }}€
+
+
+
+
+
+ {{ getBalance(props.row.debit, props.row.credit) }}€
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -13,17 +92,27 @@
diff --git a/src/pages/Overview.vue b/src/pages/Overview.vue
index fc421dd..2797f43 100644
--- a/src/pages/Overview.vue
+++ b/src/pages/Overview.vue
@@ -17,8 +17,12 @@
binary-state-sort
@request="onRequest"
>
-
-
+
+
@@ -48,7 +52,7 @@ export default defineComponent({
void userStore.getUsers().then(() =>
onRequest({
pagination: pagination.value,
- filter: undefined
+ filter: undefined,
})
);
});
@@ -58,10 +62,10 @@ export default defineComponent({
const loading = ref(false);
const pagination = ref({
sortBy: 'time',
- descending: false,
+ descending: true,
page: 1,
- rowsPerPage: 3,
- rowsNumber: 10
+ rowsPerPage: 10,
+ rowsNumber: 10,
});
interface PaginationInterface {
@@ -85,7 +89,8 @@ export default defineComponent({
offset: startRow,
limit: fetchCount,
showCancelled: showCancelled.value,
- showReversals: false
+ showReversals: false,
+ descending,
});
// clear out existing data and add new
data.value.splice(0, data.value.length, ...result.transactions);
@@ -110,7 +115,7 @@ export default defineComponent({
field: 'time',
required: true,
sortable: true,
- format: (val: Date) => formatDateTime(new Date(val), true, true, true)
+ format: (val: Date) => formatDateTime(new Date(val), true, true, true),
},
{
name: 'type',
@@ -120,31 +125,18 @@ export default defineComponent({
else {
if (row.receiver_id == null) return 'Angeschrieben';
else {
- if (row.receiver_id === mainStore.currentUser.userid) return 'Bekommen von X';
- else return 'Gesendet an X';
+ if (row.receiver_id === mainStore.currentUser.userid)
+ return `Bekommen von ${getName(row.sender_id)}`;
+ else return `Gesendet an ${getName(row.receiver_id)}`;
}
}
- }
- },
- {
- name: 'text',
- label: 'Text',
- format: (_: undefined, row: FG.Transaction) => {
- if (row.sender_id == null) return 'Gutschrift';
- else {
- if (row.receiver_id == null) return 'Angeschrieben';
- else {
- if (row.receiver_id === mainStore.currentUser.userid) return 'Bekommen von X';
- else return 'Gesendet an X';
- }
- }
- }
+ },
},
{
name: 'amount',
label: 'Betrag',
field: 'amount',
- format: (val: number) => `${val.toFixed(2)}€`
+ format: (val: number) => `${val.toFixed(2)}€`,
},
{
name: 'author_id',
@@ -154,11 +146,15 @@ export default defineComponent({
const user = userStore.users.filter((x) => x.userid == val);
if (user.length > 0) return user[0].display_name;
else return val;
- }
- }
+ },
+ },
];
+ function getName(userid: string) {
+ return userStore.users.find((a) => a.userid === userid)?.display_name;
+ }
+
return { data, pagination, onRequest, loading, balance, columns, showCancelled };
- }
+ },
});
diff --git a/src/store.ts b/src/store.ts
index 6394acc..d997519 100644
--- a/src/store.ts
+++ b/src/store.ts
@@ -1,4 +1,4 @@
-import { api, useMainStore } from '@flaschengeist/api';
+import { api, useMainStore, useUserStore } from '@flaschengeist/api';
import { defineStore } from 'pinia';
import { AxiosResponse } from 'axios';
import { Notify } from 'quasar';
@@ -19,6 +19,11 @@ export interface TransactionsResponse {
count?: number;
}
+export interface UserLimit {
+ userid: string;
+ limit?: number;
+}
+
function fixTransaction(t: FG.Transaction) {
t.time = new Date(t.time);
}
@@ -31,10 +36,11 @@ export const useBalanceStore = defineStore({
shortcuts: [] as number[],
transactions: [] as FG.Transaction[],
_balances_dirty: 0,
+ user_limits: [] as Array,
}),
getters: {
- balance(): BalancesResponse | undefined {
+ balance() {
const mainStore = useMainStore();
return this.balances.find((v) => v.userid === mainStore.user?.userid);
},
@@ -58,9 +64,7 @@ export const useBalanceStore = defineStore({
async getShortcuts(force = false) {
if (force || this.shortcuts.length == 0) {
const mainStore = useMainStore();
- const { data } = await api.get(
- `/users/${mainStore.currentUser.userid}/balance/shortcuts`
- );
+ const { data } = await api.get(`/users/${mainStore.currentUser.userid}/balance/shortcuts`);
this.shortcuts = data;
}
},
@@ -74,11 +78,7 @@ export const useBalanceStore = defineStore({
},
async getBalances(force = false) {
- if (
- force ||
- this.balances.length == 0 ||
- new Date().getTime() - this._balances_dirty > 60000
- ) {
+ if (force || this.balances.length == 0 || new Date().getTime() - this._balances_dirty > 60000) {
const { data } = await api.get('/balance');
this.balances = data;
}
@@ -94,10 +94,7 @@ export const useBalanceStore = defineStore({
sender: sender?.userid,
});
fixTransaction(data);
- if (
- user.userid === mainStore.currentUser.userid ||
- sender?.userid === mainStore.currentUser.userid
- )
+ if (user.userid === mainStore.currentUser.userid || sender?.userid === mainStore.currentUser.userid)
this.transactions.push(data);
const f = this.balances.find((x) => x.userid === user.userid);
if (f) f.balance += amount;
@@ -134,14 +131,14 @@ export const useBalanceStore = defineStore({
to?: Date;
showReversals?: boolean;
showCancelled?: boolean;
+ descending?: boolean;
}
| undefined = undefined
) {
if (!filter) filter = { limit: 10 };
- const { data } = await api.get(
- `/users/${user.userid}/balance/transactions`,
- { params: filter }
- );
+ const { data } = await api.get(`/users/${user.userid}/balance/transactions`, {
+ params: filter,
+ });
data.transactions.forEach((t) => fixTransaction(t));
if (data.transactions) this.transactions.push(...data.transactions);
return data;
@@ -160,5 +157,32 @@ export const useBalanceStore = defineStore({
}
this._balances_dirty = 0;
},
+
+ async getLimits() {
+ const { data } = await api.get>('users/balance/limit');
+ this.user_limits = data;
+ },
+
+ async setLimits(limit: number) {
+ await api.put('users/balance/limit', { limit });
+ useUserStore().users.forEach((user) => {
+ const user_limit = this.user_limits.find((a) => a.userid === user.userid);
+ if (user_limit) {
+ user_limit.limit = limit;
+ } else {
+ this.user_limits.push({ userid: user.userid, limit });
+ }
+ });
+ },
+
+ async setLimit(limit: number, userid: string) {
+ await api.put(`users/${userid}/balance/limit`, { limit });
+ const user_limit = this.user_limits.find((a) => a.userid === userid);
+ if (user_limit) {
+ user_limit.limit = limit;
+ } else {
+ this.user_limits.push({ userid, limit });
+ }
+ },
},
});