user management v1.6-alpha.1

This commit is contained in:
carodej
2020-05-27 10:22:33 +02:00
parent 143aca64dc
commit a76d1dec3b
54 changed files with 3489 additions and 535 deletions
@@ -27,6 +27,7 @@
border: 0;
padding: 10px 28px;
display: inline-block;
white-space: nowrap;
&:active {
transform: scale(0.95);
@@ -9,6 +9,7 @@
<settings-icon v-if="link.icon === 'settings'" size="17"></settings-icon>
<upload-cloud-icon v-if="link.icon === 'latest'" size="17"></upload-cloud-icon>
<user-icon v-if="link.icon === 'user'" size="17"></user-icon>
<users-icon v-if="link.icon === 'users'" size="17"></users-icon>
<lock-icon v-if="link.icon === 'lock'" size="17"></lock-icon>
</div>
<b class="menu-link">
@@ -28,6 +29,7 @@
Trash2Icon,
PowerIcon,
ShareIcon,
UsersIcon,
UserIcon,
LockIcon,
} from 'vue-feather-icons'
@@ -41,6 +43,7 @@
SettingsIcon,
Trash2Icon,
PowerIcon,
UsersIcon,
ShareIcon,
LockIcon,
UserIcon,
@@ -7,7 +7,7 @@
</div>
<!--Folder Title-->
<div class="location-name">{{ $router.currentRoute.meta.title }}</div>
<div class="location-name">{{ title }}</div>
<!--More Actions-->
<div @click="showMobileNavigation" class="mobile-menu">
@@ -26,6 +26,9 @@
export default {
name: 'MenuBar',
props: [
'title'
],
components: {
ChevronLeftIcon,
MenuIcon,
@@ -46,7 +49,7 @@
@import '@assets/vue-file-manager/_mixins';
.mobile-header {
padding: 10px 15px;
padding: 10px 0;
text-align: center;
background: white;
position: sticky;
@@ -0,0 +1,44 @@
<template>
<b class="color-label" :class="color">
<slot></slot>
</b>
</template>
<script>
export default {
name: 'ColorLabel',
props: ['color'],
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.color-label {
text-transform: capitalize;
@include font-size(12);
display: inline-block;
border-radius: 6px;
font-weight: 700;
padding: 4px 6px;
&.purple {
color: $purple;
background: rgba($purple, 0.1);
}
&.yellow {
color: $yellow;
background: rgba($yellow, 0.1);
}
}
@media only screen and (max-width: 1024px) {
}
@media (prefers-color-scheme: dark) {
}
</style>
@@ -84,6 +84,7 @@
.select {
position: relative;
user-select: none;
width: 100%;
}
.input-options {
@@ -0,0 +1,129 @@
<template>
<div class="setup-box" :class="theme">
<b class="title">{{ title }}</b>
<p class="description">{{ description }}</p>
<slot></slot>
</div>
</template>
<script>
export default {
name: 'SetupBox',
props: ['title', 'description', 'theme'],
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.setup-box {
padding: 20px;
border-radius: 8px;
.title {
@include font-size(19);
margin-bottom: 15px;
display: block;
//color: $theme;
}
.description {
@include font-size(15);
line-height: 1.5;
margin-bottom: 20px;
}
&.base {
background: $light_background;
}
&.danger {
background: $light_background;
.title {
color: $danger;
}
}
/deep/ .form {
margin-top: 20px;
&.block-form {
max-width: 450px;
.single-line-form {
display: flex;
.submit-button {
margin-left: 20px;
}
}
}
}
}
@media only screen and (max-width: 960px) {
.setup-box {
/deep/ .form {
&.block-form {
max-width: 100%;
}
input {
min-width: initial;
}
}
}
}
@media only screen and (max-width: 690px) {
.setup-box {
/deep/ .form.block-form {
.single-line-form {
display: block;
.submit-button {
margin-left: 0;
margin-top: 10px;
}
}
}
}
}
@media (prefers-color-scheme: dark) {
.setup-box {
&.base {
background: $dark_mode_foreground;
}
&.danger {
background: $dark_mode_foreground;
}
/deep/ input {
&[type='text'],
&[type='number'],
.input-area {
background: $dark_mode_background;
}
}
/deep/ .input-area {
background: $dark_mode_background;
}
}
}
</style>
@@ -1,16 +1,16 @@
<template>
<div class="mobile-main-navigation">
<div class="mobile-main-navigation" v-if="app">
<transition name="context-menu">
<nav v-if="isVisible" class="mobile-navigation">
<!--User Info-->
<div class="user-info">
<UserAvatar size="large" />
<UserAvatar size="large"/>
<UserHeadline/>
</div>
<!--Navigation-->
<MenuItemList :navigation="navigation" @menu="action" />
<MenuItemList :navigation="navigation" @menu="action"/>
</nav>
</transition>
<transition name="fade">
@@ -35,11 +35,8 @@
},
computed: {
...mapGetters(['app', 'homeDirectory']),
},
data() {
return {
isVisible: false,
navigation: [
navigation() {
return [
{
icon: 'hard-drive',
title: this.$t('menu.files'),
@@ -70,6 +67,12 @@
routeName: 'MobileSettings',
isVisible: true,
},
{
icon: 'users',
title: this.$t('menu.admin'),
routeName: 'Users',
isVisible: this.app.user.role === 'admin',
},
{
icon: 'power',
title: this.$t('menu.logout'),
@@ -77,6 +80,11 @@
isVisible: true,
},
]
},
},
data() {
return {
isVisible: false,
}
},
methods: {
@@ -0,0 +1,136 @@
<template>
<transition appear name="fade">
<li class="toastr-item" :class="item.type" v-show="isActive">
<div class="toastr-content-wrapper">
<span class="toastr-icon">
<check-icon v-if="item.type == 'success'" size="22"></check-icon>
<x-icon v-if="item.type == 'danger'" size="22"></x-icon>
</span>
<div class="toastr-content">
<p class="toastr-description">{{ item.message }}</p>
</div>
</div>
<div class="progressbar">
<span></span>
</div>
</li>
</transition>
</template>
<script>
import {XIcon, CheckIcon} from 'vue-feather-icons'
export default {
components: {
XIcon,
CheckIcon
},
props: ['item'],
data() {
return {
isActive: 0
}
},
created() {
this.isActive = 1
setTimeout(() => (this.isActive = 0), 5000)
}
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.fade-enter-active,
.fade-leave-active {
transition: 0.8s ease;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
@include transform(translateX(100%));
}
.toastr-content-wrapper {
display: flex;
align-items: center;
padding: 15px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}
.progressbar {
position: absolute;
bottom: 0;
left: 0;
right: 0;
opacity: 0.35;
span {
width: 0;
height: 3px;
display: block;
background: $theme;
animation: progressbar 5s linear;
}
}
@keyframes progressbar {
0% {
width: 0;
}
100% {
width: 100%;
}
}
.toastr-item {
max-width: 320px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
display: block;
border-radius: 8px;
.toastr-description {
@include font-size(15);
font-weight: bold;
}
.toastr-icon {
height: 42px;
width: 42px;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0;
font-size: 20px;
}
&.success {
background: $theme_light;
polyline {
stroke: $theme;
}
.toastr-description {
color: $theme;
}
}
&.danger {
background: rgba($danger, 0.1);
polyline {
stroke: $danger;
}
.toastr-description {
color: $danger;
}
}
}
</style>
@@ -0,0 +1,51 @@
<template>
<div id="toastr-wrapper">
<ToastrItem :item="item" v-for="(item, i) in notifications" :key="i"/>
</div>
</template>
<script>
import ToastrItem from '@/components/Others/Notifications/ToastrItem'
import {events} from "@/bus";
export default {
components: {
ToastrItem,
},
data() {
return {
notifications: []
}
},
created() {
events.$on('toaster', notification => this.notifications.push(notification))
}
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.toastr-list {
transition: all 5s ease;
display: inline-block;
}
.toastr-list-enter,
.toastr-list-leave-to {
opacity: 0;
transform: translateY(-100%);
}
.toastr-list-leave-active {
position: absolute;
}
#toastr-wrapper {
position: absolute;
right: 30px;
top: 30px;
z-index: 10;
}
</style>
@@ -16,7 +16,7 @@
export default {
name: 'PageHeader',
props: [
'title', 'description'
'title'
],
computed: {
...mapGetters(['appSize']),
@@ -44,9 +44,10 @@
align-items: center;
background: white;
z-index: 9;
max-width: 700px;
width: 100%;
margin: 20px auto 30px;
position: sticky;
top: 0;
padding: 20px 0;
.title {
@include font-size(18);
@@ -64,8 +65,6 @@
@media only screen and (max-width: 960px) {
.page-header {
padding: 20px 15px;
margin: 0;
.title {
@include font-size(18);
@@ -0,0 +1,58 @@
<template>
<tr class="table-row">
<td
class="table-cell"
v-for="(collumn, index) in normalizedColumns"
:key="index"
>
<span>{{ collumn }}</span>
</td>
</tr>
</template>
<script>
export default {
props: ['data'],
computed: {
normalizedColumns() {
// Remove ID from object
if (this.data['id']) delete this.data['id']
// Return object
return Object.values(this.data)
}
}
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.table-row {
border-radius: 8px;
&:hover {
background: $light_background;
}
.table-cell {
padding-top: 15px;
padding-bottom: 15px;
&:first-child {
padding-left: 15px;
}
&:last-child {
padding-right: 15px;
text-align: right;
}
span {
@include font-size(16);
font-weight: bold;
}
}
}
</style>
@@ -0,0 +1,397 @@
<template>
<div class="datatable">
<table v-if="hasData" class="table">
<thead class="table-header">
<tr>
<td
v-for="(column, index) in columns"
@click="sort(column.field, column.sortable, index)"
:key="index"
:class="{ sortable: column.sortable }"
>
<span>{{ column.label }}</span>
<chevron-up-icon v-if="false" :class="{ 'arrow-down': filter.sort === 'ASC' }" size="14" class="filter-arrow"></chevron-up-icon>
</td>
</tr>
</thead>
<tbody class="table-body">
<slot v-for="row in visibleData" :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 }"
>
<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 }}
</a>
</li>
<li class="page-item">
<a
@click="goToPage(pageIndex + 1)"
class="page-link"
:class="{ disabled: pageIndex + 1 == chunks.length }"
>
<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>
</div>
</div>
</template>
<script>
import { ChevronUpIcon, ChevronLeftIcon, ChevronRightIcon } from 'vue-feather-icons'
import DatatableCell from '@/components/Others/Tables/DatatableCell'
import {chunk, sortBy} from 'lodash'
export default {
props: ['columns', 'data', 'scope', 'paginator'],
components: {
ChevronRightIcon,
ChevronLeftIcon,
DatatableCell,
ChevronUpIcon,
},
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]
}
}
}
</script>
<style lang="scss" scoped>
@import '@assets/vue-file-manager/_variables';
@import '@assets/vue-file-manager/_mixins';
.datatable {
height: 100%;
}
.table-row {
@include transition;
}
.table-row-enter,
.table-row-leave-to {
opacity: 0;
@include transform(translateY(-100%));
}
.table-row-leave-active {
position: absolute;
}
.table {
width: 100%;
border-collapse: collapse;
tr {
width: 100%;
td {
&:first-child {
padding-left: 15px;
}
&:last-child {
padding-right: 15px;
text-align: right;
}
}
}
.table-header {
margin-bottom: 10px;
tr {
td {
padding-top: 10px;
padding-bottom: 10px;
span {
color: #AFAFAF;
font-weight: 700;
@include font-size(12);
}
&.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;
&:hover {
background: $light_background;
}
td {
padding-top: 12px;
padding-bottom: 12px;
&:last-child {
button {
margin-right: 0;
}
}
}
}
span, a.page-link {
@include font-size(15);
font-weight: 700;
padding: 10px 0;
display: block;
}
}
}
.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 (prefers-color-scheme: dark) {
.table {
.table-header {
tr {
td {
span {
color: $theme;
}
}
}
}
.table-body {
tr {
&:hover {
background: $dark_mode_foreground;
}
}
}
}
.paginator-wrapper {
.paginator-info {
color: $dark_mode_text_secondary;
}
}
.pagination {
.page-link {
color: $dark_mode_text_secondary;
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;
}
}
}
}
}
</style>
@@ -31,6 +31,12 @@
<settings-icon size="19"></settings-icon>
</div>
</router-link>
<router-link v-if="app.user.role === 'admin'" :to="{name: 'Users'}" :class="{'is-active': $isThisRoute($route, ['Users'])}" class="icon-navigation-item users">
<div class="button-icon">
<users-icon size="19"></users-icon>
</div>
</router-link>
</div>
<!--User avatar & Logout-->
@@ -51,6 +57,7 @@
HardDriveIcon,
SettingsIcon,
Trash2Icon,
UsersIcon,
PowerIcon,
ShareIcon,
} from 'vue-feather-icons'
@@ -64,6 +71,7 @@
Trash2Icon,
PowerIcon,
ShareIcon,
UsersIcon,
},
computed: {
...mapGetters(['app']),
@@ -167,6 +175,16 @@
}
}
}
&.users {
.button-icon {
background: rgba($pink, 0.1);
path, line, polyline, rect, circle {
stroke: $pink;
}
}
}
}
}