User/rework
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
Vue.component("User", {
|
||||
template: `
|
||||
<tt-card>
|
||||
<tt-table :data="window['TT_CONFIG']['USERS']" :config="UserTableConfig">
|
||||
<template v-slot:top-buttons>
|
||||
<tt-button @click="window.location = window['TT_CONFIG']['ADD_URL']"
|
||||
additional-class="btn-primary"
|
||||
text="Vorbestellkampagne hinzuf\xfcgen"
|
||||
icon="fas fa-plus"/>
|
||||
</template>
|
||||
|
||||
<template v-slot:actions="{ row: user }">
|
||||
<div class="d-flex justify-content-center" style="gap: 4px">
|
||||
<tt-button @click="window.location = window['TT_CONFIG']['EDIT_URL'] + '?id=' + user.id"
|
||||
additional-class="btn-outline-primary"
|
||||
sm
|
||||
icon="far fa-edit"
|
||||
title="Bearbeiten"/>
|
||||
|
||||
<tt-button @click="window.location = window['TT_CONFIG']['IMPERSONATE_URL'] + '?username=' + user.username"
|
||||
additional-class="btn-outline-secondary"
|
||||
sm
|
||||
title="Impersonate"
|
||||
icon="far fa-user-secret"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
</tt-table>
|
||||
</tt-card>
|
||||
`, data: () => ({
|
||||
window: window, UserTableConfig: {
|
||||
key: "UserTable",
|
||||
tableHeader: "Benutzer",
|
||||
defaultPageSize: 25,
|
||||
headers: [{text: "Username", key: "username", class: "text-center", sortable: false, priority: 20},
|
||||
{text: "Name", key: "name", class: "text-center", sortable: false, priority: 18},
|
||||
{text: "Firma", key: "address", class: "text-center", priority: 19},
|
||||
{text: "E-Mail", key: "email", priority: 14},
|
||||
{text: "Tel. Nr.", key: "mobile", priority: 17, filter: false, sortable: false},
|
||||
{
|
||||
text: "2FA", key: "twofactor", class: "text-center", priority: 16, filter: 'iconSelect', sortable: false,
|
||||
filterOptions: [{value: "N/A", text: "N/A", icon: "fa fa-exclamation-triangle text-danger"},
|
||||
{value: "Mail", text: "Mail", icon: "fa-light fa-envelope text-primary"},
|
||||
{value: "SMS", text: "SMS", icon: "fa-light fa-mobile-retro text-info"}]
|
||||
},
|
||||
{
|
||||
text: "Admin", key: "isAdmin", class: "text-center", priority: 13, filter: 'iconSelect', sortable: false,
|
||||
filterOptions: [{value: true, text: "Ist Admin", icon: "fa-regular fa-circle-check text-success"},
|
||||
{value: false, text: "Ist kein Admin", icon: "fa-regular fa-circle-xmark text-danger"}]
|
||||
},
|
||||
{
|
||||
text: "Techniker", key: "isTechnician", class: "text-center", priority: 12, filter: 'iconSelect', sortable: false,
|
||||
filterOptions: [{value: true, text: "Ist Techniker", icon: "fa-regular fa-circle-check text-success"},
|
||||
{value: false, text: "Ist kein Techniker", icon: "fa-regular fa-circle-xmark text-danger"}],
|
||||
},
|
||||
{
|
||||
text: "Aktiv", key: "isActive", class: "text-center", priority: 12, filter: 'iconSelect', sortable: false,
|
||||
filterOptions: [{value: "1", text: "Ist Aktiv", icon: "fa-regular fa-circle-check text-success"},
|
||||
{value: "0", text: "Ist nicht aktiv", icon: "fa-regular fa-circle-xmark text-danger"}],
|
||||
},
|
||||
{text: "Aktionen", key: "actions", class: "text-center", sortable: false, priority: 21, filter: false}]
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -49,7 +49,7 @@ Vue.component('tt-icon-select', {
|
||||
<div class="form-group tt-select" style="user-select: none;margin-bottom: 0; margin-top: 6px">
|
||||
<div class="dropdown" :class="{'show': isOpen}">
|
||||
<i v-if="selectedOption !== null" :class="selectedOption.icon" style="font-size: 18px; cursor: pointer" ref="selectedIcon"></i>
|
||||
<span v-else style="cursor: pointer" ref="selectedIcon">Alle<i class="fas fa-caret-down"></i></span>
|
||||
<span v-else style="cursor: pointer" ref="selectedIcon">Alle<i class="ml-1 fas fa-caret-down"></i></span>
|
||||
<div style="display: grid; justify-items: center;" ref="select">
|
||||
<div class="dropdown-menu" :class="{'show': isOpen}" style="min-width: unset !important;">
|
||||
<a class="dropdown-item text-center" href="#" @click.prevent="selectOption(null)">Alle</a>
|
||||
|
||||
@@ -48,8 +48,12 @@ Vue.component('tt-table-pagination', {
|
||||
}
|
||||
return pages.length === 0 ? [1] : pages;
|
||||
}, pageInfoText() {
|
||||
const start = Math.min(this.pagination.page * this.pagination.per_page - this.pagination.per_page + 1, this.pagination.total_rows);
|
||||
const end = Math.min(this.pagination.page * this.pagination.per_page, this.pagination.total_rows);
|
||||
let start = Math.max(this.pagination.filtered_available, Math.min(
|
||||
this.pagination.page * this.pagination.per_page - this.pagination.per_page + 1,
|
||||
this.pagination.total_rows
|
||||
));
|
||||
const end = Math.min(this.pagination.page * this.pagination.per_page, this.pagination.filtered_available);
|
||||
if (start > end) start = end;
|
||||
|
||||
if (!this.pagination.filtered_available) this.pagination.filtered_available = this.pagination.total_rows;
|
||||
|
||||
@@ -86,7 +90,7 @@ Vue.component('tt-table-pagination', {
|
||||
v-on:click.prevent="fetchRows(pageNumber)">{{ pageNumber }}</a>
|
||||
</li>
|
||||
<li class="page-item tt-table-page-item"
|
||||
v-bind:class="{ disabled: pagination.page === pagination.total_pages }">
|
||||
v-bind:class="{ disabled: pagination.page === pagination.total_pages || pagination.total_pages <= 1 }">
|
||||
<a class="page-link" href="#" v-on:click.prevent="fetchRows(pagination.total_pages)"
|
||||
aria-label="Last">
|
||||
<span aria-hidden="true">»</span>
|
||||
@@ -205,6 +209,7 @@ Vue.component('tt-table', {
|
||||
|
||||
|
||||
</span>
|
||||
<span v-else-if="column.filter === 'select'">{{ columns[key].filterOptions.find(option => option.value.toString() === row[key].toString())?.text }}</span>
|
||||
<span v-else-if="key === 'create'">{{ window.moment(row[key] * 1000).format('DD.MM.YYYY HH:mm:ss') }}</span>
|
||||
<span v-else-if="row[key] !== null"
|
||||
v-html="(column.prefix) + (row[key] === null || typeof row[key] === 'undefined' ? '' : row[key]?.toString()?.replace('\\\\n', '<br>')) + (column.suffix )"></span>
|
||||
@@ -229,6 +234,7 @@ Vue.component('tt-table', {
|
||||
.isValid() ? moment.unix(row[key]).format('DD.MM.YYYY HH:mm') : moment(row[key])
|
||||
.format('DD.MM.YYYY HH:mm')) : ''
|
||||
}}</span>
|
||||
<span v-else-if="column.filter === 'select'">{{ columns[key].filterOptions.find(option => option.value.toString() === row[key].toString())?.text }}</span>
|
||||
<span v-else-if="key === 'create'">{{ window.moment(row[key] * 1000).format('DD.MM.YYYY HH:mm:ss') }}</span>
|
||||
<i v-else-if="column.filter === 'iconSelect'"
|
||||
:title="columns[key].filterOptions.find(option => option.value.toString() === row[key].toString())?.text"
|
||||
@@ -772,7 +778,8 @@ Vue.component('tt-table', {
|
||||
});
|
||||
|
||||
}
|
||||
// console.timeEnd('Filtering and pagination');
|
||||
// set page to current page or 1 if page is not set or 0 or less or over max pages
|
||||
if (this.pagination.page < 1) this.pagination.page = 1;
|
||||
return output;
|
||||
}, visibleRows() {
|
||||
if (!this.rawRows || this.ssr === true) return null;
|
||||
|
||||
Reference in New Issue
Block a user