mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-27 02:30:39 +00:00
Merge remote-tracking branch 'origin/master' into filepreview
# Conflicts: # .env.example # package-lock.json # package.json # public/js/main.js # public/mix-manifest.json # resources/js/App.vue # resources/js/helpers.js # resources/js/i18n/lang/en.json # resources/js/i18n/lang/sk.json # resources/js/store/modules/fileFunctions.js # resources/js/views/Shared/SharedPage.vue
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<WidgetWrapper :icon="icon" :title="title">
|
||||
<DatatableWrapper v-if="users" :paginator="false" :columns="columns" :data="users" class="table table-users">
|
||||
<template scope="{ row }">
|
||||
<DatatableWrapper @init="isLoading = false" api="/api/dashboard/new-users" :paginator="false" :columns="columns" class="table table-users">
|
||||
<template slot-scope="{ row }">
|
||||
<tr>
|
||||
<td style="width: 300px">
|
||||
<router-link :to="{name: 'UserDetail', params: {id: row.data.id}}">
|
||||
@@ -65,27 +65,26 @@
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
users: undefined,
|
||||
columns: [
|
||||
{
|
||||
label: this.$t('admin_page_user.table.name'),
|
||||
field: 'data.attributes.name',
|
||||
sortable: true
|
||||
field: 'name',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
label: this.$t('admin_page_user.table.role'),
|
||||
field: 'data.attributes.role',
|
||||
sortable: true
|
||||
field: 'role',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
label: this.$t('admin_page_user.table.storage_used'),
|
||||
field: 'relationships.storage.data.attributes.used',
|
||||
sortable: true
|
||||
field: 'used',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
label: this.$t('admin_page_user.table.created_at'),
|
||||
field: 'data.attributes.created_at_formatted',
|
||||
sortable: true
|
||||
field: 'created_at',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
label: this.$t('admin_page_user.table.action'),
|
||||
@@ -107,13 +106,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
axios.get('/api/dashboard/new-users')
|
||||
.then(response => {
|
||||
this.users = response.data.data
|
||||
this.isLoading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="action-button">
|
||||
<FontAwesomeIcon class="icon" :icon="icon" />
|
||||
<x-icon size="12" class="icon" v-if="icon === 'x'"></x-icon>
|
||||
<edit-2-icon size="12" class="icon" v-if="icon === 'pencil-alt'"></edit-2-icon>
|
||||
<span class="label">
|
||||
<slot></slot>
|
||||
</span>
|
||||
@@ -8,9 +9,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Edit2Icon, XIcon } from 'vue-feather-icons'
|
||||
|
||||
export default {
|
||||
name: 'ActionButton',
|
||||
props: ['icon'],
|
||||
components: {
|
||||
Edit2Icon,
|
||||
XIcon,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -23,18 +30,17 @@
|
||||
|
||||
.label {
|
||||
@include font-size(12);
|
||||
color: $theme;
|
||||
font-weight: 600;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.icon {
|
||||
@include font-size(10);
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
margin-right: 2px;
|
||||
|
||||
path {
|
||||
fill: $theme;
|
||||
path, circle, line {
|
||||
stroke: $theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<div class="select-box">
|
||||
<div class="box-item"
|
||||
:class="{'selected': item.value === input}"
|
||||
@click="getSelectedValue(item)"
|
||||
v-for="(item, i) in data" :key="i"
|
||||
>
|
||||
<span class="box-value">{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SelectBoxInput',
|
||||
props: [
|
||||
'data',
|
||||
'value',
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
input: undefined,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getSelectedValue(item) {
|
||||
if (! this.input || this.input !== item.value)
|
||||
this.input = item.value
|
||||
else
|
||||
this.input = undefined
|
||||
|
||||
this.$emit('input', this.input)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.value)
|
||||
this.input = this.value
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@assets/vue-file-manager/_variables';
|
||||
@import '@assets/vue-file-manager/_mixins';
|
||||
@import "@assets/vue-file-manager/_inapp-forms.scss";
|
||||
@import "@assets/vue-file-manager/_forms.scss";
|
||||
|
||||
.select-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.box-item {
|
||||
margin-bottom: 10px;
|
||||
padding: 12px 4px;
|
||||
text-align: center;
|
||||
background: $light_background;
|
||||
border-radius: 8px;
|
||||
font-weight: 700;
|
||||
border: 2px solid $light_background;
|
||||
cursor: pointer;
|
||||
flex-direction: column;
|
||||
flex-basis: 55px;
|
||||
|
||||
.box-value {
|
||||
@include font-size(15);
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: rgba($theme, .1);
|
||||
border-color: $theme;
|
||||
|
||||
.box-value {
|
||||
color: $theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 960px) {
|
||||
.select-box {
|
||||
|
||||
.box-item {
|
||||
flex-basis: calc(34% - 10px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.select-box {
|
||||
|
||||
.box-item {
|
||||
border-color: $dark_mode_border_color;
|
||||
background: $dark_mode_foreground;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div class="page-tab">
|
||||
<div id="loader" v-if="isLoading">
|
||||
<div id="loader" v-show="isLoading">
|
||||
<Spinner></Spinner>
|
||||
</div>
|
||||
<slot v-if="! isLoading"></slot>
|
||||
<slot v-show="! isLoading"></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -32,6 +32,18 @@
|
||||
<input v-model="shareOptions.password" :class="{'is-error': errors[0]}" type="text" :placeholder="$t('page_sign_in.placeholder_password')">
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
|
||||
<!--More options-->
|
||||
<div class="more-options" v-if="isMoreOptions">
|
||||
|
||||
<!--Set expiration-->
|
||||
<div class="input-wrapper">
|
||||
<label class="input-label">{{ $t('shared_form.label_expiration') }}:</label>
|
||||
<SelectBoxInput v-model="shareOptions.expiration" :data="expirationList" class="box"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ActionButton @click.native="moreOptions" :icon="isMoreOptions ? 'x' : 'pencil-alt'">{{ moreOptionsTitle }}</ActionButton>
|
||||
</ValidationObserver>
|
||||
|
||||
<!--Copy generated link-->
|
||||
@@ -66,6 +78,7 @@
|
||||
|
||||
<script>
|
||||
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
|
||||
import SelectBoxInput from '@/components/Others/Forms/SelectBoxInput'
|
||||
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
|
||||
import PopupActions from '@/components/Others/Popup/PopupActions'
|
||||
import PopupContent from '@/components/Others/Popup/PopupContent'
|
||||
@@ -73,6 +86,7 @@
|
||||
import SwitchInput from '@/components/Others/Forms/SwitchInput'
|
||||
import SelectInput from '@/components/Others/Forms/SelectInput'
|
||||
import ThumbnailItem from '@/components/Others/ThumbnailItem'
|
||||
import ActionButton from '@/components/Others/ActionButton'
|
||||
import CopyInput from '@/components/Others/Forms/CopyInput'
|
||||
import ButtonBase from '@/components/FilesView/ButtonBase'
|
||||
import {required} from 'vee-validate/dist/rules'
|
||||
@@ -85,7 +99,9 @@
|
||||
components: {
|
||||
ValidationProvider,
|
||||
ValidationObserver,
|
||||
SelectBoxInput,
|
||||
ThumbnailItem,
|
||||
ActionButton,
|
||||
PopupWrapper,
|
||||
PopupActions,
|
||||
PopupContent,
|
||||
@@ -97,7 +113,10 @@
|
||||
required,
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permissionOptions']),
|
||||
...mapGetters([
|
||||
'permissionOptions',
|
||||
'expirationList',
|
||||
]),
|
||||
itemTypeTitle() {
|
||||
return this.pickedItem && this.pickedItem.type === 'folder' ? this.$t('types.folder') : this.$t('types.file')
|
||||
},
|
||||
@@ -106,12 +125,16 @@
|
||||
},
|
||||
submitButtonText() {
|
||||
return this.isGeneratedShared ? this.$t('shared_form.button_done') : this.$t('shared_form.button_generate')
|
||||
},
|
||||
moreOptionsTitle() {
|
||||
return this.isMoreOptions ? this.$t('shared_form.button_close_options') : this.$t('shared_form.button_more_options')
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
shareOptions: {
|
||||
isPassword: false,
|
||||
expiration: undefined,
|
||||
password: undefined,
|
||||
permission: undefined,
|
||||
type: undefined,
|
||||
@@ -121,9 +144,16 @@
|
||||
shareLink: undefined,
|
||||
isGeneratedShared: false,
|
||||
isLoading: false,
|
||||
isMoreOptions: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
moreOptions() {
|
||||
this.isMoreOptions = ! this.isMoreOptions
|
||||
|
||||
if (! this.isMoreOptions)
|
||||
this.shareOptions.expiration = undefined
|
||||
},
|
||||
async submitShareOptions() {
|
||||
|
||||
// If shared was generated, then close popup
|
||||
@@ -185,10 +215,12 @@
|
||||
permission: undefined,
|
||||
password: undefined,
|
||||
isPassword: false,
|
||||
expiration: undefined,
|
||||
type: undefined,
|
||||
unique_id: undefined,
|
||||
}
|
||||
this.isGeneratedShared = false
|
||||
this.isMoreOptions = false
|
||||
this.shareLink = undefined
|
||||
}, 150)
|
||||
})
|
||||
@@ -200,6 +232,10 @@
|
||||
@import "@assets/vue-file-manager/_inapp-forms.scss";
|
||||
@import '@assets/vue-file-manager/_forms';
|
||||
|
||||
.more-options {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
|
||||
&.password {
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<label class="input-label">{{ $t('shared_form.label_password_protection') }}:</label>
|
||||
<SwitchInput v-model="shareOptions.isProtected" :state="shareOptions.isProtected" class="switch"/>
|
||||
</div>
|
||||
<ActionButton v-if="(pickedItem.shared.protected && canChangePassword) && shareOptions.isProtected" @click.native="changePassword" icon="pencil-alt">{{ $t('popup_share_edit.change_pass') }}</ActionButton>
|
||||
<ActionButton v-if="(pickedItem.shared.protected && canChangePassword) && shareOptions.isProtected" @click.native="changePassword" class="change-password">{{ $t('popup_share_edit.change_pass') }}</ActionButton>
|
||||
</div>
|
||||
|
||||
<!--Set password-->
|
||||
@@ -40,6 +40,18 @@
|
||||
<span class="error-message" v-if="errors[0]">{{ errors[0] }}</span>
|
||||
</ValidationProvider>
|
||||
|
||||
<!--More options-->
|
||||
<div class="more-options" v-if="isMoreOptions">
|
||||
|
||||
<!--Set expiration-->
|
||||
<div class="input-wrapper">
|
||||
<label class="input-label">{{ $t('shared_form.label_expiration') }}:</label>
|
||||
<SelectBoxInput v-model="shareOptions.expiration" :data="expirationList" :value="shareOptions.expiration" class="box"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ActionButton @click.native="moreOptions" :icon="isMoreOptions || shareOptions.expiration ? 'x' : 'pencil-alt'">{{ moreOptionsTitle }}</ActionButton>
|
||||
|
||||
</ValidationObserver>
|
||||
|
||||
</PopupContent>
|
||||
@@ -68,6 +80,7 @@
|
||||
|
||||
<script>
|
||||
import {ValidationProvider, ValidationObserver} from 'vee-validate/dist/vee-validate.full'
|
||||
import SelectBoxInput from '@/components/Others/Forms/SelectBoxInput'
|
||||
import PopupWrapper from '@/components/Others/Popup/PopupWrapper'
|
||||
import PopupActions from '@/components/Others/Popup/PopupActions'
|
||||
import PopupContent from '@/components/Others/Popup/PopupContent'
|
||||
@@ -88,6 +101,7 @@
|
||||
components: {
|
||||
ValidationProvider,
|
||||
ValidationObserver,
|
||||
SelectBoxInput,
|
||||
ThumbnailItem,
|
||||
ActionButton,
|
||||
PopupWrapper,
|
||||
@@ -101,7 +115,12 @@
|
||||
required,
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['user', 'permissionOptions', 'currentFolder']),
|
||||
...mapGetters([
|
||||
'permissionOptions',
|
||||
'expirationList',
|
||||
'currentFolder',
|
||||
'user',
|
||||
]),
|
||||
isFolder() {
|
||||
return this.pickedItem && this.pickedItem.type === 'folder'
|
||||
},
|
||||
@@ -114,18 +133,28 @@
|
||||
isSharedLocation() {
|
||||
return this.currentFolder && this.currentFolder.location === 'shared'
|
||||
},
|
||||
moreOptionsTitle() {
|
||||
return this.isMoreOptions ? this.$t('shared_form.button_close_options') : this.$t('shared_form.button_more_options')
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isConfirmedDestroy: false,
|
||||
canChangePassword: false,
|
||||
shareOptions: undefined,
|
||||
pickedItem: undefined,
|
||||
isLoading: false,
|
||||
isMoreOptions: false,
|
||||
isDeleting: false,
|
||||
canChangePassword: false,
|
||||
isConfirmedDestroy: false,
|
||||
isLoading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
moreOptions() {
|
||||
this.isMoreOptions = ! this.isMoreOptions
|
||||
|
||||
if (! this.isMoreOptions)
|
||||
this.shareOptions.expiration = undefined
|
||||
},
|
||||
changePassword() {
|
||||
this.canChangePassword = false
|
||||
},
|
||||
@@ -142,7 +171,9 @@
|
||||
|
||||
// Send delete request
|
||||
axios
|
||||
.delete('/api/share/' + this.pickedItem.shared.token)
|
||||
.post('/api/share/' + this.pickedItem.shared.token, {
|
||||
_method: 'delete'
|
||||
})
|
||||
.then(() => {
|
||||
// Remove item from file browser
|
||||
if ( this.isSharedLocation ) {
|
||||
@@ -182,24 +213,25 @@
|
||||
|
||||
// Send request to get share link
|
||||
axios
|
||||
.patch('/api/share/' + this.shareOptions.token, {
|
||||
.post('/api/share/' + this.shareOptions.token, {
|
||||
permission: this.shareOptions.permission,
|
||||
protected: this.shareOptions.isProtected,
|
||||
expiration: this.shareOptions.expiration,
|
||||
password: this.shareOptions.password ? this.shareOptions.password : undefined,
|
||||
_method: 'patch'
|
||||
})
|
||||
.then(response => {
|
||||
|
||||
// End loading
|
||||
this.isLoading = false
|
||||
|
||||
// Update shared data
|
||||
this.$store.commit('UPDATE_SHARED_ITEM', response.data.data.attributes)
|
||||
|
||||
events.$emit('popup:close')
|
||||
})
|
||||
.catch(error => {
|
||||
.catch(() => {
|
||||
|
||||
// todo: catch errors
|
||||
this.$isSomethingWrong()
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
// End loading
|
||||
this.isLoading = false
|
||||
@@ -219,11 +251,15 @@
|
||||
// Store shared options
|
||||
this.shareOptions = {
|
||||
token: args.item.shared.token,
|
||||
expiration: args.item.shared.expire_in,
|
||||
isProtected: args.item.shared.protected,
|
||||
permission: args.item.shared.permission,
|
||||
password: undefined,
|
||||
}
|
||||
|
||||
if (args.item.shared.expire_in)
|
||||
this.isMoreOptions = true
|
||||
|
||||
this.canChangePassword = args.item.shared.protected
|
||||
})
|
||||
|
||||
@@ -253,6 +289,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.change-password {
|
||||
opacity: 0.7;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.item-thumbnail {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@@ -4,410 +4,489 @@
|
||||
<thead class="table-header">
|
||||
<tr>
|
||||
<th
|
||||
v-for="(column, index) in columns"
|
||||
@click="sort(column.field, column.sortable, index)"
|
||||
:key="index"
|
||||
:class="{ sortable: column.sortable }"
|
||||
v-if="! column.hidden"
|
||||
v-for="(column, index) in columns"
|
||||
@click="sort(column.field, column.sortable)"
|
||||
:key="index"
|
||||
:class="{ 'sortable': column.sortable }"
|
||||
v-if="! column.hidden"
|
||||
>
|
||||
<span>{{ column.label }}</span>
|
||||
|
||||
<chevron-up-icon v-if="false" :class="{ 'arrow-down': filter.sort === 'ASC' }" size="14" class="filter-arrow"></chevron-up-icon>
|
||||
<chevron-up-icon v-if="column.sortable" :class="{ 'arrow-down': filter.sort === 'ASC' }" size="14" class="filter-arrow"></chevron-up-icon>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="table-body">
|
||||
<slot v-for="row in visibleData" :row="row">
|
||||
<slot v-for="row in data.data" :row="row">
|
||||
<DatatableCell :data="row" :key="row.id"/>
|
||||
</slot>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<div v-if="hasData && paginator" class="paginator-wrapper">
|
||||
<ul v-if="chunks.length > 1" class="pagination">
|
||||
<li class="page-item">
|
||||
<a
|
||||
@click="goToPage(pageIndex - 1)"
|
||||
class="page-link"
|
||||
:class="{ disabled: pageIndex == 0 }"
|
||||
>
|
||||
|
||||
<slot v-if="! isLoading && ! hasData" name="empty-page"></slot>
|
||||
|
||||
<div v-if="paginator && hasData" class="paginator-wrapper">
|
||||
|
||||
<!--Show if there is only 6 pages-->
|
||||
<ul v-if="data.meta.total > 20 && data.meta.last_page <= 6" class="pagination">
|
||||
|
||||
<!--Go previous icon-->
|
||||
<li class="page-item previous">
|
||||
<a @click="goToPage(pageIndex - 1)" class="page-link" :class="{ disabled: pageIndex == 0 }">
|
||||
<chevron-left-icon size="14" class="icon"></chevron-left-icon>
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
v-for="(row, index) in chunks"
|
||||
:key="index"
|
||||
class="page-item"
|
||||
@click="goToPage(index)"
|
||||
>
|
||||
<a
|
||||
class="page-link"
|
||||
:class="{ active: pageIndex == index }">
|
||||
{{ index + 1 }}
|
||||
|
||||
<li v-for="(page, index) in 6" :key="index" class="page-item" @click="goToPage(page)">
|
||||
<a class="page-link" :class="{ active: pageIndex === page }">
|
||||
{{ page }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item">
|
||||
<a
|
||||
@click="goToPage(pageIndex + 1)"
|
||||
class="page-link"
|
||||
:class="{ disabled: pageIndex + 1 == chunks.length }"
|
||||
>
|
||||
|
||||
<!--Go next icon-->
|
||||
<li class="page-item next">
|
||||
<a @click="goToPage(pageIndex + 1)" class="page-link" :class="{ disabled: pageIndex + 1 == data.meta.last_page }">
|
||||
<chevron-right-icon size="14" class="icon"></chevron-right-icon>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<span class="paginator-info">{{ $t('datatable.paginate_info', {visible: visibleData.length, total: data.length}) }}</span>
|
||||
|
||||
<!--Show if there is more than 6 pages-->
|
||||
<ul v-if="data.meta.total > 20 && data.meta.last_page > 6" class="pagination">
|
||||
|
||||
<!--Go previous icon-->
|
||||
<li class="page-item previous">
|
||||
<a @click="goToPage(pageIndex - 1)" class="page-link" :class="{ disabled: pageIndex == 0 }">
|
||||
<chevron-left-icon size="14" class="icon"></chevron-left-icon>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!--Show first Page-->
|
||||
<li class="page-item" v-if="pageIndex >= 5" @click="goToPage(1)">
|
||||
<a class="page-link">
|
||||
1
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li v-if="pageIndex < 5" v-for="(page, index) in 5" :key="index" class="page-item" @click="goToPage(page)">
|
||||
<a class="page-link" :class="{ active: pageIndex === page }">
|
||||
{{ page }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="page-item" v-if="pageIndex >= 5">
|
||||
<a class="page-link">...</a>
|
||||
</li>
|
||||
|
||||
<!--Floated Pages-->
|
||||
<li v-if="pageIndex >= 5 && pageIndex < (data.meta.last_page - 3)" v-for="(page, index) in floatPages" :key="index" class="page-item" @click="goToPage(page)">
|
||||
<a class="page-link" :class="{ active: pageIndex === page }">
|
||||
{{ page }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="page-item" v-if="pageIndex < (data.meta.last_page - 3)">
|
||||
<a class="page-link">...</a>
|
||||
</li>
|
||||
|
||||
<li v-if="pageIndex > (data.meta.last_page - 4)" v-for="(page, index) in 5" :key="index" class="page-item" @click="goToPage(data.meta.last_page - (4 - index))">
|
||||
<a class="page-link" :class="{ active: pageIndex === (data.meta.last_page - (4 - index)) }">
|
||||
{{ data.meta.last_page - (4 - index) }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!--Show last page-->
|
||||
<li class="page-item" v-if="pageIndex < (data.meta.last_page - 3)" @click="goToPage(data.meta.last_page)">
|
||||
<a class="page-link">
|
||||
{{ data.meta.last_page }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!--Go next icon-->
|
||||
<li class="page-item next">
|
||||
<a @click="goToPage(pageIndex + 1)" class="page-link" :class="{ disabled: pageIndex + 1 == data.meta.last_page }">
|
||||
<chevron-right-icon size="14" class="icon"></chevron-right-icon>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<span class="paginator-info">{{ $t('datatable.paginate_info', {visible: data.meta.per_page, total: data.meta.total}) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ChevronUpIcon, ChevronLeftIcon, ChevronRightIcon } from 'vue-feather-icons'
|
||||
import DatatableCell from '@/components/Others/Tables/DatatableCell'
|
||||
import {chunk, sortBy} from 'lodash'
|
||||
import {ChevronUpIcon, ChevronLeftIcon, ChevronRightIcon} from 'vue-feather-icons'
|
||||
import DatatableCell from '@/components/Others/Tables/DatatableCell'
|
||||
import {chunk, sortBy} from 'lodash'
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
props: ['columns', 'data', 'scope', 'paginator'],
|
||||
components: {
|
||||
ChevronRightIcon,
|
||||
ChevronLeftIcon,
|
||||
DatatableCell,
|
||||
ChevronUpIcon,
|
||||
export default {
|
||||
name: 'DatatableWrapper',
|
||||
props: [
|
||||
'columns', 'scope', 'paginator', 'api', 'tableData'
|
||||
],
|
||||
components: {
|
||||
ChevronRightIcon,
|
||||
ChevronLeftIcon,
|
||||
DatatableCell,
|
||||
ChevronUpIcon,
|
||||
},
|
||||
computed: {
|
||||
hasData() {
|
||||
return this.data && this.data.data && this.data.data.length > 0
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
items_per_view: 20,
|
||||
pageIndex: 0,
|
||||
paginatorVisible: true,
|
||||
chunks: [],
|
||||
filter: {
|
||||
sort: 'DESC',
|
||||
field: undefined,
|
||||
index: undefined,
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goToPage(index) {
|
||||
if (index == this.chunks.length || index == -1) return
|
||||
|
||||
// Update page index
|
||||
this.pageIndex = index
|
||||
},
|
||||
sort(field, sortable, index) {
|
||||
|
||||
// Prevent sortable if is disabled
|
||||
if (!sortable) return
|
||||
|
||||
// Set filter
|
||||
this.filter.field = field
|
||||
this.filter.index = index
|
||||
|
||||
// Set sorting direction
|
||||
if (this.filter.sort === 'DESC') {
|
||||
this.filter.sort = 'ASC'
|
||||
} else if (this.filter.sort === 'ASC') {
|
||||
this.filter.sort = 'DESC'
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hasData() {
|
||||
|
||||
return this.data.length > 0 ? true : false
|
||||
},
|
||||
visibleData() {
|
||||
|
||||
// Prefent errors when data is empty
|
||||
if (!this.hasData) return
|
||||
|
||||
// Reconfigure data
|
||||
if (this.filter.field) {
|
||||
|
||||
// Set chunks with sorting
|
||||
if (this.filter.sort === 'DESC') {
|
||||
|
||||
// DESC
|
||||
this.chunks = chunk(sortBy(this.data, this.filter.field), this.items_per_view)
|
||||
} else {
|
||||
|
||||
// ASC
|
||||
this.chunks = chunk(sortBy(this.data, this.filter.field).reverse(), this.items_per_view)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Get data to chunks
|
||||
this.chunks = chunk(this.data, this.items_per_view)
|
||||
}
|
||||
|
||||
// Return chunks
|
||||
return this.chunks[this.pageIndex]
|
||||
floatPages() {
|
||||
return [(this.pageIndex - 1), this.pageIndex, (this.pageIndex + 1)];
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
data: undefined,
|
||||
isLoading: true,
|
||||
pageIndex: 1,
|
||||
filter: {
|
||||
sort: 'DESC',
|
||||
field: undefined,
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goToPage(index) {
|
||||
if (index > this.data.meta.last_page || index === 0) return
|
||||
|
||||
this.pageIndex = index
|
||||
|
||||
this.getPage(index)
|
||||
},
|
||||
sort(field, sortable) {
|
||||
|
||||
// Prevent sortable if is disabled
|
||||
if (!sortable) return
|
||||
|
||||
// Set filter
|
||||
this.filter.field = field
|
||||
|
||||
// Set sorting direction
|
||||
if (this.filter.sort === 'DESC') {
|
||||
this.filter.sort = 'ASC'
|
||||
} else if (this.filter.sort === 'ASC') {
|
||||
this.filter.sort = 'DESC'
|
||||
}
|
||||
|
||||
this.getPage(this.pageIndex)
|
||||
},
|
||||
getPage(page) {
|
||||
|
||||
// Get api URI
|
||||
this.URI = this.api;
|
||||
|
||||
// Set page index
|
||||
if (this.paginator)
|
||||
this.URI = this.URI + '?page=' + page
|
||||
|
||||
// Add filder URI if is defined sorting
|
||||
if (this.filter.field)
|
||||
|
||||
this.URI = this.URI + (this.paginator ? '&' : '?') + 'sort=' + this.filter.field + '&direction=' + this.filter.sort
|
||||
|
||||
this.isLoading = true
|
||||
|
||||
// Get data
|
||||
axios.get(this.URI)
|
||||
.then(response => {
|
||||
this.data = response.data
|
||||
this.$emit('data', response.data)
|
||||
|
||||
})
|
||||
.catch(() => this.$isSomethingWrong())
|
||||
.finally(() => {
|
||||
this.$emit('init', true)
|
||||
this.isLoading = false
|
||||
}
|
||||
)
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.api)
|
||||
this.getPage(this.pageIndex)
|
||||
|
||||
if (this.tableData)
|
||||
this.data = this.tableData,
|
||||
this.isLoading = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@assets/vue-file-manager/_variables';
|
||||
@import '@assets/vue-file-manager/_mixins';
|
||||
@import '@assets/vue-file-manager/_variables';
|
||||
@import '@assets/vue-file-manager/_mixins';
|
||||
|
||||
.datatable {
|
||||
height: 100%;
|
||||
}
|
||||
.datatable {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.table-row {
|
||||
@include transition;
|
||||
}
|
||||
.table-row {
|
||||
@include transition;
|
||||
}
|
||||
|
||||
.table-row-enter,
|
||||
.table-row-leave-to {
|
||||
opacity: 0;
|
||||
@include transform(translateY(-100%));
|
||||
}
|
||||
.table-row-enter,
|
||||
.table-row-leave-to {
|
||||
opacity: 0;
|
||||
@include transform(translateY(-100%));
|
||||
}
|
||||
|
||||
.table-row-leave-active {
|
||||
position: absolute;
|
||||
}
|
||||
.table-row-leave-active {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.table {
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
overflow-x: auto;
|
||||
|
||||
tr {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
overflow-x: auto;
|
||||
|
||||
td, th {
|
||||
&:first-child {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
padding-right: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.table-header {
|
||||
margin-bottom: 10px;
|
||||
|
||||
tr {
|
||||
width: 100%;
|
||||
|
||||
td, th {
|
||||
&:first-child {
|
||||
padding-left: 15px;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
|
||||
span {
|
||||
color: $theme;
|
||||
font-weight: 700;
|
||||
@include font-size(12);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&.sortable {
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
.filter-arrow {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
padding-right: 15px;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.filter-arrow {
|
||||
vertical-align: middle;
|
||||
margin-left: 8px;
|
||||
@include transition;
|
||||
opacity: 0;
|
||||
|
||||
path {
|
||||
fill: $text-muted;
|
||||
}
|
||||
|
||||
&.arrow-down {
|
||||
@include transform(rotate(180deg));
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 13px;
|
||||
color: $text-muted;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.table-body {
|
||||
tr {
|
||||
border-radius: 8px;
|
||||
//border-bottom: 1px solid #f5f5f5;
|
||||
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
}
|
||||
|
||||
td, th {
|
||||
padding: 12px;
|
||||
|
||||
&:last-child {
|
||||
button {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span, a.page-link {
|
||||
@include font-size(15);
|
||||
font-weight: 700;
|
||||
padding: 10px 35px 10px 0;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
.page-item {
|
||||
padding: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.page-link {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: block;
|
||||
color: $text;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
line-height: 2.4;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
@include transition(0.15s);
|
||||
|
||||
.icon {
|
||||
vertical-align: middle;
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
background: $light_background;
|
||||
color: $text;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: $text;
|
||||
background: $light_background;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
|
||||
svg path {
|
||||
fill: $text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.paginator-wrapper {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 40px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.paginator-info {
|
||||
font-size: 13px;
|
||||
color: $text-muted;
|
||||
}
|
||||
}
|
||||
|
||||
.user-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
|
||||
img {
|
||||
width: 45px;
|
||||
margin-right: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 690px) {
|
||||
.paginator-wrapper {
|
||||
display: block;
|
||||
text-align: center;
|
||||
|
||||
.paginator-info {
|
||||
margin-top: 10px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
||||
.table {
|
||||
|
||||
.table-header {
|
||||
margin-bottom: 10px;
|
||||
|
||||
tr {
|
||||
td, th {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
|
||||
span {
|
||||
color: $theme;
|
||||
font-weight: 700;
|
||||
@include font-size(12);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&.sortable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.filter-arrow {
|
||||
vertical-align: middle;
|
||||
margin-left: 8px;
|
||||
@include transition;
|
||||
|
||||
path {
|
||||
fill: $text-muted;
|
||||
}
|
||||
|
||||
&.arrow-down {
|
||||
@include transform(rotate(180deg));
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 13px;
|
||||
color: $text-muted;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.table-body {
|
||||
tr {
|
||||
border-radius: 8px;
|
||||
//border-bottom: 1px solid #f5f5f5;
|
||||
|
||||
tr, th {
|
||||
&:hover {
|
||||
background: $light_background;
|
||||
}
|
||||
|
||||
td, th {
|
||||
padding: 12px;
|
||||
|
||||
&:last-child {
|
||||
button {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span, a.page-link {
|
||||
@include font-size(15);
|
||||
font-weight: 700;
|
||||
padding: 10px 35px 10px 0;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
.page-item {
|
||||
padding: 3px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.page-link {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: block;
|
||||
color: $text;
|
||||
border-radius: 6px;
|
||||
text-align: center;
|
||||
line-height: 2.4;
|
||||
font-weight: bold;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
@include transition(0.15s);
|
||||
|
||||
.icon {
|
||||
vertical-align: middle;
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
background: $light_background;
|
||||
color: $text;
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: $text;
|
||||
background: $light_background;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
|
||||
svg path {
|
||||
fill: $text-muted;
|
||||
background: $dark_mode_foreground;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.paginator-wrapper {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 40px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.paginator-info {
|
||||
font-size: 13px;
|
||||
color: $text-muted;
|
||||
color: $dark_mode_text_secondary;
|
||||
}
|
||||
}
|
||||
|
||||
.user-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
.pagination {
|
||||
|
||||
img {
|
||||
width: 45px;
|
||||
margin-right: 22px;
|
||||
}
|
||||
}
|
||||
.page-link {
|
||||
color: $dark_mode_text_secondary;
|
||||
|
||||
@media only screen and (max-width: 690px) {
|
||||
.paginator-wrapper {
|
||||
display: block;
|
||||
text-align: center;
|
||||
|
||||
.paginator-info {
|
||||
margin-top: 10px;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
||||
.table {
|
||||
|
||||
.table-header {
|
||||
|
||||
tr {
|
||||
td, th {
|
||||
|
||||
span {
|
||||
color: $theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
svg polyline {
|
||||
stroke: $dark_mode_text_primary;
|
||||
}
|
||||
|
||||
.table-body {
|
||||
tr, th {
|
||||
&:hover {
|
||||
background: $dark_mode_foreground;
|
||||
}
|
||||
}
|
||||
&:hover:not(.disabled) {
|
||||
color: $theme;
|
||||
background: rgba($theme, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.paginator-wrapper {
|
||||
|
||||
.paginator-info {
|
||||
color: $dark_mode_text_secondary;
|
||||
&.active {
|
||||
color: $theme;
|
||||
background: rgba($theme, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
|
||||
.page-link {
|
||||
color: $dark_mode_text_secondary;
|
||||
&.disabled {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
|
||||
svg polyline {
|
||||
stroke: $dark_mode_text_primary;
|
||||
}
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
color: $theme;
|
||||
background: rgba($theme, 0.1);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: $theme;
|
||||
background: rgba($theme, 0.1);
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
|
||||
svg polyline {
|
||||
stroke: $dark_mode_text_secondary;
|
||||
}
|
||||
stroke: $dark_mode_text_secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -124,7 +124,6 @@
|
||||
@import '@assets/vue-file-manager/_mixins';
|
||||
|
||||
.menu-bar {
|
||||
//background: linear-gradient(180deg, rgba(246, 245, 241, 0.8) 0%, rgba(243, 244, 246, 0.8) 100%);
|
||||
background: $light_background;
|
||||
user-select: none;
|
||||
padding-top: 25px;
|
||||
|
||||
Reference in New Issue
Block a user