2023-03-17 15:13:37 +00:00
|
|
|
<script setup lang="ts">
|
2023-03-03 15:54:28 +00:00
|
|
|
// import { Head, Link, useForm, usePage } from '@inertiajs/inertia-vue3';
|
|
|
|
import { Head, Link, useForm, usePage } from '@inertiajs/vue3';
|
2023-03-17 15:13:37 +00:00
|
|
|
import { ComputedRef } from 'vue';
|
2024-05-16 11:47:06 +00:00
|
|
|
import { mdiAccountKey, mdiPlus, mdiSquareEditOutline, mdiAlertBoxOutline, mdiTrashCan } from '@mdi/js';
|
2023-03-17 15:13:37 +00:00
|
|
|
import { computed } from 'vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
|
|
|
|
import SectionMain from '@/Components/SectionMain.vue';
|
|
|
|
import SectionTitleLineWithButton from '@/Components/SectionTitleLineWithButton.vue';
|
|
|
|
import BaseButton from '@/Components/BaseButton.vue';
|
|
|
|
import CardBox from '@/Components/CardBox.vue';
|
|
|
|
import BaseButtons from '@/Components/BaseButtons.vue';
|
|
|
|
import NotificationBar from '@/Components/NotificationBar.vue';
|
2024-10-31 10:02:36 +00:00
|
|
|
import Pagination from '@/Components/Pagination.vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
import Sort from '@/Components/Admin/Sort.vue';
|
|
|
|
import { stardust } from '@eidellev/adonis-stardust/client';
|
|
|
|
// import { Vue } from 'vue-facing-decorator';
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
users: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
can: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
// user: {
|
|
|
|
// type: Object,
|
|
|
|
// default: () => ({}),
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
|
|
|
|
// const search = computed(() => {
|
|
|
|
// return props.filters.search;
|
|
|
|
// });
|
|
|
|
|
2023-03-17 15:13:37 +00:00
|
|
|
const flash: ComputedRef<any> = computed(() => {
|
2023-03-03 15:54:28 +00:00
|
|
|
// let test = usePage();
|
|
|
|
// console.log(test);
|
|
|
|
return usePage().props.flash;
|
|
|
|
});
|
|
|
|
|
|
|
|
const form = useForm({
|
|
|
|
search: props.filters.search,
|
|
|
|
});
|
|
|
|
|
2024-05-16 11:47:06 +00:00
|
|
|
const formDelete = useForm({});
|
2023-03-03 15:54:28 +00:00
|
|
|
// async function destroy(id) {
|
2024-05-16 11:47:06 +00:00
|
|
|
const destroy = async (id: number) => {
|
|
|
|
if (confirm('Are you sure you want to delete?')) {
|
|
|
|
await formDelete.delete(stardust.route('settings.user.destroy', [id]));
|
|
|
|
}
|
|
|
|
};
|
2023-03-03 15:54:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<LayoutAuthenticated>
|
|
|
|
<Head title="Users" />
|
|
|
|
<SectionMain>
|
|
|
|
<SectionTitleLineWithButton :icon="mdiAccountKey" title="Tethys Users" main>
|
2023-10-31 14:38:43 +00:00
|
|
|
<BaseButton
|
|
|
|
v-if="can.create"
|
2023-12-15 16:17:33 +00:00
|
|
|
:route-name="stardust.route('settings.user.create')"
|
2023-10-31 14:38:43 +00:00
|
|
|
:icon="mdiPlus"
|
|
|
|
label="Add"
|
|
|
|
color="modern"
|
|
|
|
rounded-full
|
|
|
|
small
|
|
|
|
/>
|
2023-03-03 15:54:28 +00:00
|
|
|
</SectionTitleLineWithButton>
|
|
|
|
<!-- <label>{{ form.search }}</label> -->
|
|
|
|
<NotificationBar v-if="flash.message" color="success" :icon="mdiAlertBoxOutline">
|
|
|
|
{{ flash.message }}
|
|
|
|
</NotificationBar>
|
|
|
|
<!-- <NotificationBar color="success" :icon="mdiAlertBoxOutline">{{ users.meta }}</NotificationBar> -->
|
|
|
|
<CardBox class="mb-6" has-table>
|
2023-12-15 16:17:33 +00:00
|
|
|
<form @submit.prevent="form.get(stardust.route('settings.user.index'))">
|
2023-03-03 15:54:28 +00:00
|
|
|
<div class="py-2 flex">
|
|
|
|
<div class="flex pl-4">
|
2023-10-31 14:38:43 +00:00
|
|
|
<input
|
|
|
|
type="search"
|
|
|
|
v-model="form.search"
|
2023-03-03 15:54:28 +00:00
|
|
|
class="rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
2023-10-31 14:38:43 +00:00
|
|
|
placeholder="Search"
|
|
|
|
/>
|
|
|
|
<BaseButton label="Search" type="submit" color="modern" class="ml-4 inline-flex items-center px-4 py-2" />
|
2023-03-03 15:54:28 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</CardBox>
|
|
|
|
<!-- table -->
|
|
|
|
<CardBox class="mb-6" has-table>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
<Sort label="Login" attribute="login" :search="form.search" />
|
|
|
|
</th>
|
|
|
|
<th>
|
|
|
|
<Sort label="Email" attribute="email" :search="form.search" />
|
|
|
|
</th>
|
|
|
|
<th v-if="can.edit || can.delete">Actions</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<tr v-for="user in users.data" :key="user.id">
|
|
|
|
<td data-label="Login">
|
2023-10-31 14:38:43 +00:00
|
|
|
<Link
|
2023-12-15 16:17:33 +00:00
|
|
|
v-bind:href="stardust.route('settings.user.show', [user.id])"
|
2023-10-31 14:38:43 +00:00
|
|
|
class="no-underline hover:underline text-cyan-600 dark:text-cyan-400"
|
|
|
|
>
|
|
|
|
{{ user.login }}
|
2023-03-03 15:54:28 +00:00
|
|
|
</Link>
|
|
|
|
<!-- {{ user.id }} -->
|
|
|
|
</td>
|
|
|
|
<td data-label="Email">
|
|
|
|
{{ user.email }}
|
|
|
|
</td>
|
|
|
|
<td v-if="can.edit || can.delete" class="before:hidden lg:w-1 whitespace-nowrap">
|
|
|
|
<BaseButtons type="justify-start lg:justify-end" no-wrap>
|
|
|
|
<BaseButton
|
2023-10-31 14:38:43 +00:00
|
|
|
v-if="can.edit"
|
2023-12-15 16:17:33 +00:00
|
|
|
:route-name="stardust.route('settings.user.edit', [user.id])"
|
2023-10-31 14:38:43 +00:00
|
|
|
color="info"
|
|
|
|
:icon="mdiSquareEditOutline"
|
|
|
|
small
|
|
|
|
/>
|
2024-05-16 11:47:06 +00:00
|
|
|
<BaseButton v-if="can.delete" color="danger" :icon="mdiTrashCan" small @click="destroy(user.id)" />
|
2023-03-03 15:54:28 +00:00
|
|
|
</BaseButtons>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div class="py-4">
|
|
|
|
<Pagination v-bind:data="users.meta" />
|
|
|
|
<!-- <ul>
|
|
|
|
<li>
|
|
|
|
<a href="{{ users.page == 1 ? '#' : '?page=' + (users.page - 1) }}">Previous</a>
|
|
|
|
</li>
|
|
|
|
@each(page in ???)
|
|
|
|
<li>
|
|
|
|
<a href="?page={{ page }}">{{ page }}</a>
|
|
|
|
</li>
|
|
|
|
@endeach
|
|
|
|
<li>
|
|
|
|
<a href="{{ users.lastPage == users.page ? '#' : '?page=' + (users.page + 1) }}">Next</a>
|
|
|
|
</li>
|
|
|
|
</ul> -->
|
|
|
|
</div>
|
|
|
|
</CardBox>
|
|
|
|
</SectionMain>
|
|
|
|
</LayoutAuthenticated>
|
|
|
|
</template>
|