All checks were successful
Build Quasar SPA and Go Backend for memberApp / build-spa (push) Successful in 2m20s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, .exe, windows) (push) Successful in 5m27s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, , linux) (push) Successful in 5m32s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm, 6, , linux) (push) Successful in 5m28s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm64, , linux) (push) Successful in 5m29s
87 lines
1.8 KiB
TypeScript
87 lines
1.8 KiB
TypeScript
import { appApi } from 'src/boot/axios';
|
|
import { ref, computed } from 'vue';
|
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
|
import { i18n } from 'boot/lang';
|
|
import type { Users } from 'src/vueLib/models/users';
|
|
|
|
export function useUserTable() {
|
|
const users = ref<Users>([]);
|
|
|
|
const pagination = ref({
|
|
sortBy: 'user',
|
|
descending: false,
|
|
page: 1,
|
|
rowsPerPage: 10,
|
|
});
|
|
|
|
const columns = computed(() => [
|
|
{
|
|
name: 'id',
|
|
align: 'left' as const,
|
|
label: 'Id',
|
|
field: 'id',
|
|
sortable: true,
|
|
style: 'width: 50px; max-width: 50px;',
|
|
},
|
|
{
|
|
name: 'user',
|
|
align: 'left' as const,
|
|
label: i18n.global.t('user'),
|
|
field: 'user',
|
|
sortable: true,
|
|
},
|
|
{
|
|
name: 'email',
|
|
align: 'left' as const,
|
|
label: i18n.global.t('email'),
|
|
field: 'email',
|
|
sortable: true,
|
|
},
|
|
{
|
|
name: 'role',
|
|
align: 'left' as const,
|
|
label: i18n.global.t('role'),
|
|
field: 'role',
|
|
sortable: true,
|
|
style: 'width: 120px; max-width: 120px;',
|
|
},
|
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
|
]);
|
|
|
|
const { NotifyResponse } = useNotify();
|
|
|
|
const loading = ref(false);
|
|
|
|
//updates user list from database
|
|
function updateUsers() {
|
|
loading.value = true;
|
|
appApi
|
|
.get('users')
|
|
.then((resp) => {
|
|
if (resp.data === null) {
|
|
users.value = [];
|
|
return;
|
|
}
|
|
users.value = resp.data as Users;
|
|
if (users.value === null) {
|
|
users.value = [];
|
|
return;
|
|
}
|
|
})
|
|
|
|
.catch((err) => {
|
|
NotifyResponse(err, 'error');
|
|
})
|
|
.finally(() => {
|
|
loading.value = false;
|
|
});
|
|
}
|
|
return {
|
|
users,
|
|
pagination,
|
|
columns,
|
|
loading,
|
|
updateUsers,
|
|
};
|
|
}
|