add index to import all user related views and modify some routes name

This commit is contained in:
Axolotle 2020-07-15 17:30:09 +02:00
parent ece6b3c41c
commit 1812ebbac8
5 changed files with 27 additions and 22 deletions

View file

@ -1,28 +1,27 @@
import Home from './views/Home' import Home from './views/Home'
import Login from './views/Login' import Login from './views/Login'
import Users from './views/Users' import { UserList, User } from './views/user'
import User from './views/User'
const routes = [ const routes = [
{ name: 'home', path: '/', component: Home }, { name: 'home', path: '/', component: Home },
{ name: 'login', path: '/login', component: Login, meta: { noAuth: true } }, { name: 'login', path: '/login', component: Login, meta: { noAuth: true } },
// Users routes
{ {
name: 'users', name: 'user-list',
path: '/users', path: '/users',
component: Users, component: UserList,
meta: { meta: { breadcrumb: [{ name: 'user-list', trad: 'users' }] }
breadcrumb: [{ name: 'users', trad: 'users' }]
}
}, },
{ {
name: 'user', name: 'user-info',
path: '/user/:name', path: '/user/:name',
component: User, component: User,
props: true, props: true,
meta: { meta: {
breadcrumb: [ breadcrumb: [
{ name: 'users', trad: 'users' }, { name: 'user-list', trad: 'users' },
{ name: 'user', param: 'name' } { name: 'user-info', param: 'name' }
] ]
} }
} }

View file

@ -1,7 +1,11 @@
<template> <template>
<div class="home"> <div class="home">
<b-list-group> <b-list-group>
<b-list-group-item v-for="item in menu" :key="item.id" :to="item.uri"> <b-list-group-item
v-for="item in menu"
:key="item.id"
:to="{name: item.routeName}"
>
<icon :iname="item.icon" class="lg" /> <icon :iname="item.icon" class="lg" />
<h2>{{ $t(item.translation) }}</h2> <h2>{{ $t(item.translation) }}</h2>
<icon iname="chevron-right" class="lg fs-sm ml-auto" /> <icon iname="chevron-right" class="lg fs-sm ml-auto" />
@ -16,14 +20,14 @@ export default {
data: () => { data: () => {
return { return {
menu: [ menu: [
{ id: 0, uri: '/users', icon: 'users', translation: 'users' }, { id: 0, routeName: 'user-list', icon: 'users', translation: 'users' },
{ id: 1, uri: '/domains', icon: 'globe', translation: 'domains' }, { id: 1, routeName: 'domains', icon: 'globe', translation: 'domains' },
{ id: 2, uri: '/apps', icon: 'cubes', translation: 'applications' }, { id: 2, routeName: 'apps', icon: 'cubes', translation: 'applications' },
{ id: 3, uri: '/update', icon: 'refresh', translation: 'system_update' }, { id: 3, routeName: 'update', icon: 'refresh', translation: 'system_update' },
{ id: 4, uri: '/services', icon: 'cog', translation: 'services' }, { id: 4, routeName: 'services', icon: 'cog', translation: 'services' },
{ id: 5, uri: '/tools', icon: 'wrench', translation: 'tools' }, { id: 5, routeName: 'tools', icon: 'wrench', translation: 'tools' },
{ id: 6, uri: '/diagnosis', icon: 'stethoscope', translation: 'diagnosis' }, { id: 6, routeName: 'diagnosis', icon: 'stethoscope', translation: 'diagnosis' },
{ id: 7, uri: '/backup', icon: 'archive', translation: 'backup' } { id: 7, routeName: 'backup', icon: 'archive', translation: 'backup' }
] ]
} }
} }

View file

@ -77,7 +77,7 @@ export default {
name: 'User', name: 'User',
props: { props: {
name: { name: {
type: Object, type: String,
required: true required: true
} }
}, },

View file

@ -12,7 +12,7 @@
<b-list-group-item <b-list-group-item
v-for="(user, index) in (users ? users : 3)" v-for="(user, index) in (users ? users : 3)"
:key="index" :key="index"
:to="users ? { name: 'user', params: { name: user.username }} : null" :to="users ? { name: 'user-info', params: { name: user.username }} : null"
class="d-flex justify-content-between align-items-center pr-0" class="d-flex justify-content-between align-items-center pr-0"
> >
<div> <div>
@ -35,7 +35,7 @@
import api from '@/helpers/api' import api from '@/helpers/api'
export default { export default {
name: 'Users', name: 'UserList',
data: function () { data: function () {
return { return {
users: undefined users: undefined

View file

@ -0,0 +1,2 @@
export { default as User } from './User'
export { default as UserList } from './UserList'