show an animation to signify that the page is still loading

This commit is contained in:
j3d1 2024-11-05 23:25:44 +01:00
parent 767d34f8b7
commit 3a8fa8cdcf
4 changed files with 306 additions and 161 deletions

View file

@ -0,0 +1,133 @@
<template>
<div class="async-wrapper" :class="{ 'loaded': loaded }">
<div class="deferred">
<slot></slot>
</div>
<div class="loader-wrapper">
<div class="loader-ellipsis">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'AsyncLoader',
props: {
loaded: {
type: Boolean,
default: false
}
}
};
</script>
<style>
.async-wrapper {
position: relative;
}
.async-wrapper > .deferred {
width: 100%;
height: 100%;
display: none;
}
.async-wrapper.loaded > .deferred {
display: block;
}
.async-wrapper > .loader-wrapper {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis {
color: #17a2b8;
}
.async-wrapper.loaded > .loader-wrapper {
display: none;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis,
.async-wrapper > .loader-wrapper > .loader-ellipsis div {
box-sizing: border-box;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis div {
position: absolute;
top: 33.33333px;
width: 13.33333px;
height: 13.33333px;
border-radius: 50%;
background: currentColor;
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(1) {
left: 8px;
animation: loader-ellipsis1 0.6s infinite;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(2) {
left: 8px;
animation: loader-ellipsis2 0.6s infinite;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(3) {
left: 32px;
animation: loader-ellipsis2 0.6s infinite;
}
.async-wrapper > .loader-wrapper > .loader-ellipsis div:nth-child(4) {
left: 56px;
animation: loader-ellipsis3 0.6s infinite;
}
@keyframes loader-ellipsis1 {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes loader-ellipsis3 {
0% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
@keyframes loader-ellipsis2 {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(24px, 0);
}
}
</style>

View file

@ -1,77 +1,82 @@
<template> <template>
<div class="container-fluid px-xl-5 mt-3"> <AsyncLoader :loaded="loadedItems.length > 0">
<Modal title="Edit Item" v-if="editingItem" @close="closeEditingModal()"> <div class="container-fluid px-xl-5 mt-3">
<template #body> <Modal title="Edit Item" v-if="editingItem" @close="closeEditingModal()">
<EditItem <template #body>
:item="editingItem" <EditItem
badge="uid" :item="editingItem"
badge="uid"
/>
</template>
<template #buttons>
<button type="button" class="btn btn-secondary" @click="closeEditingModal()">Cancel</button>
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button>
</template>
</Modal>
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
<div class="row" v-if="layout === 'table'">
<div class="col-xl-8 offset-xl-2">
<Table
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
@itemActivated="openLightboxModalWith($event)"
>
<template #actions="{ item }">
<div class="btn-group">
<button class="btn btn-success"
@click.stop="confirm('return Item?') && markItemReturned(item)"
title="returned">
<font-awesome-icon icon="check"/>
</button>
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit">
<font-awesome-icon icon="edit"/>
</button>
<button class="btn btn-danger" @click.stop="confirm('delete Item?') && deleteItem(item)"
title="delete">
<font-awesome-icon icon="trash"/>
</button>
</div>
</template>
</Table>
</div>
</div>
<Cards
v-if="layout === 'cards'"
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)"
>
<AuthenticatedImage v-if="item.file" cached
:src="`/media/2/256/${item.file}/`"
class="card-img-top img-fluid"
/> />
</template> <div class="card-body">
<template #buttons> <h6 class="card-title">{{ item.description }}</h6>
<button type="button" class="btn btn-secondary" @click="closeEditingModal()">Cancel</button> <h6 class="card-subtitle text-secondary">uid: {{ item.uid }} box: {{ item.box }}</h6>
<button type="button" class="btn btn-success" @click="saveEditingItem()">Save Changes</button> <div class="row mx-auto mt-2">
</template>
</Modal>
<Lightbox v-if="lightboxHash" :hash="lightboxHash" @close="closeLightboxModal()"/>
<div class="row" v-if="layout === 'table'">
<div class="col-xl-8 offset-xl-2">
<Table
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
@itemActivated="openLightboxModalWith($event)"
>
<template #actions="{ item }">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-success" <button class="btn btn-outline-success"
@click.stop="confirm('return Item?') && markItemReturned(item)" title="returned"> @click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
<font-awesome-icon icon="check"/> <font-awesome-icon icon="check"/>
</button> </button>
<button class="btn btn-secondary" @click.stop="openEditingModalWith(item)" title="edit"> <button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)"
title="edit">
<font-awesome-icon icon="edit"/> <font-awesome-icon icon="edit"/>
</button> </button>
<button class="btn btn-danger" @click.stop="confirm('delete Item?') && deleteItem(item)" <button class="btn btn-outline-danger"
@click.stop="confirm('delete Item?') && deleteItem(item)"
title="delete"> title="delete">
<font-awesome-icon icon="trash"/> <font-awesome-icon icon="trash"/>
</button> </button>
</div> </div>
</template>
</Table>
</div>
</div>
<Cards
v-if="layout === 'cards'"
:columns="['uid', 'description', 'box']"
:items="loadedItems"
:keyName="'uid'"
v-slot="{ item }"
@itemActivated="openLightboxModalWith($event)"
>
<AuthenticatedImage v-if="item.file" cached
:src="`/media/2/256/${item.file}/`"
class="card-img-top img-fluid"
/>
<div class="card-body">
<h6 class="card-title">{{ item.description }}</h6>
<h6 class="card-subtitle text-secondary">uid: {{ item.uid }} box: {{ item.box }}</h6>
<div class="row mx-auto mt-2">
<div class="btn-group">
<button class="btn btn-outline-success"
@click.stop="confirm('return Item?') && markItemReturned(item)" title="returned">
<font-awesome-icon icon="check"/>
</button>
<button class="btn btn-outline-secondary" @click.stop="openEditingModalWith(item)" title="edit">
<font-awesome-icon icon="edit"/>
</button>
<button class="btn btn-outline-danger" @click.stop="confirm('delete Item?') && deleteItem(item)"
title="delete">
<font-awesome-icon icon="trash"/>
</button>
</div> </div>
</div> </div>
</div> </Cards>
</Cards> </div>
</div> </AsyncLoader>
</template> </template>
<script> <script>
@ -82,6 +87,7 @@ import EditItem from '@/components/EditItem';
import {mapActions, mapGetters, mapState} from 'vuex'; import {mapActions, mapGetters, mapState} from 'vuex';
import Lightbox from '../components/Lightbox'; import Lightbox from '../components/Lightbox';
import AuthenticatedImage from "@/components/AuthenticatedImage.vue"; import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
import AsyncLoader from "@/components/AsyncLoader.vue";
export default { export default {
name: 'Items', name: 'Items',
@ -89,7 +95,7 @@ export default {
lightboxHash: null, lightboxHash: null,
editingItem: null, editingItem: null,
}), }),
components: {AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem}, components: {AsyncLoader, AuthenticatedImage, Lightbox, Table, Cards, Modal, EditItem},
computed: { computed: {
...mapState(['loadedItems']), ...mapState(['loadedItems']),
...mapGetters(['layout']), ...mapGetters(['layout']),

View file

@ -1,74 +1,77 @@
<template> <template>
<div class="container-fluid px-xl-5 mt-3"> <AsyncLoader :loaded="ticket.id">
<div class="row"> <div class="container-fluid px-xl-5 mt-3">
<div class="col-xl-8 offset-xl-2"> <div class="row">
<div class="card bg-dark text-light mb-2" id="filters"> <div class="col-xl-8 offset-xl-2">
<div class="card-header"> <div class="card bg-dark text-light mb-2" id="filters">
<h3>Ticket #{{ ticket.id }} - {{ ticket.name }}</h3> <div class="card-header">
</div> <h3>Ticket #{{ ticket.id }} - {{ ticket.name }}</h3>
<Timeline :timeline="ticket.timeline" @sendMail="handleMail" @addComment="handleComment"/>
<div class="card-footer d-flex justify-content-between">
<button class="btn btn-secondary mr-2" @click="$router.go(-1)">Back</button>
<!--button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
<font-awesome-icon icon="trash"/>
Delete
</button-->
<div class="btn-group">
<select class="form-control" v-model="selected_assignee">
<option v-for="user in users" :value="user.username">{{ user.username }}</option>
</select>
<button class="form-control btn btn-success"
@click="assignTicket(ticket)"
:disabled="!selected_assignee || (selected_assignee == ticket.assigned_to)">
Assign&nbsp;Ticket
</button>
</div> </div>
<div class="btn-group"> <Timeline :timeline="ticket.timeline" @sendMail="handleMail" @addComment="handleComment"/>
<select class="form-control" v-model="selected_state"> <div class="card-footer d-flex justify-content-between">
<option v-for="status in state_options" :value="status.value">{{ <button class="btn btn-secondary mr-2" @click="$router.go(-1)">Back</button>
status.text <!--button class="btn btn-danger" @click="deleteItem({type: 'tickets', id: ticket.id})">
}} <font-awesome-icon icon="trash"/>
</option> Delete
</select> </button-->
<button class="form-control btn btn-success" <div class="btn-group">
@click="changeTicketStatus(ticket)" <select class="form-control" v-model="selected_assignee">
:disabled="(selected_state == ticket.state)"> <option v-for="user in users" :value="user.username">{{ user.username }}</option>
Change&nbsp;Status </select>
</button> <button class="form-control btn btn-success"
@click="assignTicket(ticket)"
:disabled="!selected_assignee || (selected_assignee == ticket.assigned_to)">
Assign&nbsp;Ticket
</button>
</div>
<div class="btn-group">
<select class="form-control" v-model="selected_state">
<option v-for="status in state_options" :value="status.value">{{
status.text
}}
</option>
</select>
<button class="form-control btn btn-success"
@click="changeTicketStatus(ticket)"
:disabled="(selected_state == ticket.state)">
Change&nbsp;Status
</button>
</div>
</div> </div>
</div> <div class="card-footer d-flex justify-content-between">
<div class="card-footer d-flex justify-content-between"> <ClipboardButton :payload="shippingEmail" class="btn btn-primary">
<ClipboardButton :payload="shippingEmail" class="btn btn-primary"> <font-awesome-icon icon="clipboard"/>
<font-awesome-icon icon="clipboard"/> Copy&nbsp;DHL&nbsp;contact&nbsp;to&nbsp;clipboard
Copy&nbsp;DHL&nbsp;contact&nbsp;to&nbsp;clipboard </ClipboardButton>
</ClipboardButton> <div class="btn-group">
<div class="btn-group"> <select class="form-control" v-model="shipping_voucher_type">
<select class="form-control" v-model="shipping_voucher_type"> <option v-for="type in availableShippingVoucherTypes.filter(t=>t.count>0)"
<option v-for="type in availableShippingVoucherTypes.filter(t=>t.count>0)" :value="type.id">{{ type.name }}
:value="type.id">{{ type.name }} </option>
</option> </select>
</select> <button class="form-control btn btn-success"
<button class="form-control btn btn-success" @click="claimShippingVoucher({ticket: ticket.id, shipping_voucher_type}).then(()=>shipping_voucher_type=null)"
@click="claimShippingVoucher({ticket: ticket.id, shipping_voucher_type}).then(()=>shipping_voucher_type=null)" :disabled="!shipping_voucher_type">
:disabled="!shipping_voucher_type"> Claim&nbsp;Shipping&nbsp;Voucher
Claim&nbsp;Shipping&nbsp;Voucher </button>
</button> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </AsyncLoader>
</template> </template>
<script> <script>
import {mapActions, mapGetters, mapState} from 'vuex'; import {mapActions, mapGetters, mapState} from 'vuex';
import Timeline from "@/components/Timeline.vue"; import Timeline from "@/components/Timeline.vue";
import ClipboardButton from "@/components/inputs/ClipboardButton.vue"; import ClipboardButton from "@/components/inputs/ClipboardButton.vue";
import AsyncLoader from "@/components/AsyncLoader.vue";
export default { export default {
name: 'Ticket', name: 'Ticket',
components: {ClipboardButton, Timeline}, components: {AsyncLoader, ClipboardButton, Timeline},
data() { data() {
return { return {
selected_state: null, selected_state: null,

View file

@ -1,51 +1,53 @@
<template> <template>
<div class="container-fluid px-xl-5 mt-3"> <AsyncLoader :loaded="tickets.length > 0">
<div class="row"> <div class="container-fluid px-xl-5 mt-3">
<div class="col-xl-8 offset-xl-2"> <div class="row">
<Table <div class="col-xl-8 offset-xl-2">
:columns="['id', 'name', 'state', 'last_activity', 'assigned_to']" <Table
:items="tickets" :columns="['id', 'name', 'state', 'last_activity', 'assigned_to', 'actions', 'actions2']"
:keyName="'id'" :items="tickets.map(formatTicket)"
v-if="layout === 'table'" :keyName="'id'"
> v-if="layout === 'table'"
<template #actions="{ item }"> >
<div class="btn-group"> <template v-slot:actions="{item}">
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view" <div class="btn-group">
@click.prevent="gotoDetail(item)"> <a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
<font-awesome-icon icon="eye"/> @click.prevent="gotoDetail(item)">
View <font-awesome-icon icon="eye"/>
</a> View
</div> </a>
</template> </div>
</Table> </template>
</Table>
</div>
</div> </div>
</div> <CollapsableCards v-if="layout === 'tasks'" :items="tickets"
<CollapsableCards v-if="layout === 'tasks'" :items="tickets" :columns="['id', 'name', 'last_activity', 'assigned_to']"
:columns="['id', 'name', 'last_activity', 'assigned_to']" :keyName="'state'" :sections="['pending_new', 'pending_open','pending_shipping',
:keyName="'state'" :sections="['pending_new', 'pending_open','pending_shipping',
'pending_physical_confirmation','pending_return','pending_postponed'].map(stateInfo)"> 'pending_physical_confirmation','pending_return','pending_postponed'].map(stateInfo)">
<template #section_header="{index, section, count}"> <template #section_header="{index, section, count}">
{{ section.text }} <span class="badge badge-light ml-1">{{ count }}</span> {{ section.text }} <span class="badge badge-light ml-1">{{ count }}</span>
</template> </template>
<template #section_body="{item}"> <template #section_body="{item}">
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.last_activity }}</td> <td>{{ item.last_activity }}</td>
<td>{{ item.assigned_to }}</td> <td>{{ item.assigned_to }}</td>
<td> <td>
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view" <a class="btn btn-primary" :href="'/'+ getEventSlug + '/ticket/' + item.id" title="view"
@click.prevent="gotoDetail(item)"> @click.prevent="gotoDetail(item)">
<font-awesome-icon icon="eye"/> <font-awesome-icon icon="eye"/>
View View
</a> </a>
</div> </div>
</td> </td>
</tr> </tr>
</template> </template>
</CollapsableCards> </CollapsableCards>
</div> </div>
</AsyncLoader>
</template> </template>
<script> <script>
@ -56,10 +58,11 @@ import {mapActions, mapGetters, mapState} from 'vuex';
import Lightbox from '../components/Lightbox'; import Lightbox from '../components/Lightbox';
import Table from '@/components/Table'; import Table from '@/components/Table';
import CollapsableCards from "@/components/CollapsableCards.vue"; import CollapsableCards from "@/components/CollapsableCards.vue";
import AsyncLoader from "@/components/AsyncLoader.vue";
export default { export default {
name: 'Tickets', name: 'Tickets',
components: {Lightbox, Table, Cards, Modal, EditItem, CollapsableCards}, components: {AsyncLoader, Lightbox, Table, Cards, Modal, EditItem, CollapsableCards},
computed: { computed: {
...mapState(['tickets']), ...mapState(['tickets']),
...mapGetters(['stateInfo', 'getEventSlug', 'layout']), ...mapGetters(['stateInfo', 'getEventSlug', 'layout']),