Skip to content

Commit

Permalink
feat: add a dynamic breadcrumb on each pages, personal user page, use…
Browse files Browse the repository at this point in the history
… of i18n plugin
  • Loading branch information
Vincent59 committed Mar 7, 2023
1 parent 8c6848d commit 5037445
Show file tree
Hide file tree
Showing 17 changed files with 4,397 additions and 3,789 deletions.
7,821 changes: 4,091 additions & 3,730 deletions code/web-ui/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions code/web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"sharp": "^0.26.3",
"vue": "2.5.17",
"vue-cookies": "^1.7.4",
"vue-i18n": "^8.28.2",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.1",
"vue-virtual-scroller": "^0.12.2",
Expand Down
5 changes: 4 additions & 1 deletion code/web-ui/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@
<div id="app" :class="isFramed ? 'isFramed' : ''">
<top-menu data-nrt="topMenu" v-if='!isFramed && isLoggedInPage' style="position: fixed; top: 0; left: 0; width: 100%; z-index: 1000;"></top-menu>
<div class="layout-content">
<breadcrumb />
<router-view></router-view>
</div>
</div>
</template>

<script>
import topMenu from './components/top-menu.vue'
import breadcrumb from './components/breadcrumb.vue'

export default {
name: 'app',

components: {
topMenu
topMenu,
breadcrumb
},

computed: {
Expand Down
Binary file modified code/web-ui/src/assets/auditor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified code/web-ui/src/assets/super_admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions code/web-ui/src/components/breadcrumb.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<template>
<Breadcrumb class="breadcrumbLink">
<BreadcrumbItem to="/">Home</BreadcrumbItem>
<BreadcrumbItem v-if="getBack.path" :to="getBack.path">{{ getBack.meta.title }}</BreadcrumbItem>
<BreadcrumbItem v-if="actualPath.path">{{ actualPath.meta.title }}</BreadcrumbItem>
</Breadcrumb>
</template>

<script>
export default {
data () {
return {
previousPath: [],
actualPath: []
}
},
computed: {
getBack () {
if (!this.actualPath.path?.includes(this.previousPath.name)) {
this.previousPath = []
}
return this.previousPath
}
},
watch: {
'$route' (to, from) {
this.actualPath = to
if (from.name) {
this.previousPath = from
}
}
}
}
</script>
25 changes: 8 additions & 17 deletions code/web-ui/src/components/top-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@
</div>

<div id="helps">
<Tooltip v-if="isLoggedIn" class="user-avatar top-right-nav" placement="bottom">
<div class="user-picture" :style="{ backgroundImage: `url(${user.pictureUrl})` }">
<div v-if="isLoggedIn" class="top-right-nav" placement="bottom" @click="$router.push({ name: 'management-profile', params: { myProfile: 'me'} })">
<div class="user-avatar" :style="{ backgroundImage: `url(${user.pictureUrl})` }">
<span v-if="isAdmin">
<img src="../assets/super_admin.png" width="20" height="20" alt="User role">
<img src="../assets/super_admin.png" width="23" height="22" alt="User role">
</span>
<span v-if="isAuditor">
<img src="../assets/auditor.png" width="20" height="20" alt="User role">
<img src="../assets/auditor.png" width="23" height="22" alt="User role">
</span>
</div>
<div slot="content">
<!-- <div slot="content">
<p v-if="providerName">Connected via <strong>{{providerName}}</strong></p>
<p v-if="user && user.profile">> Profile: <strong>{{user.profile}}</strong></p>
<p v-if="user && user.login">> Login: <strong>{{user.login}}</strong></p>
<p v-if="user && user.firstName && user.lastName">> Name: <strong>{{user.firstName + " " + user.lastName}}</strong></p>
<p v-if="user && user.email">> Email: <strong>{{user.email}}</strong></p>
</div>
</Tooltip>
</div> -->
</div>
<!-- Keep the same width as logo+select: this is to center the menu when space is available -->
<!-- No space between items -->
<Dropdown trigger="click" class="top-right-nav" placement="bottom-end">
Expand Down Expand Up @@ -592,16 +592,12 @@
margin-right: 4px;
}

.user-avatar .user-picture {
.user-avatar {
background-size: cover;
width: 35px;
height: 35px;
border-radius: 100px;
}

.user-avatar img {
margin-right: 15px;
border-radius: 100px;
position: relative;
}

Expand All @@ -610,9 +606,4 @@
left: 21px;
top: 18px;
}

.user-avatar span img {
background-color: #ffffff;
padding: 2px;
}
</style>
13 changes: 13 additions & 0 deletions code/web-ui/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"profile": {
"SCOPED_USER": "Scoped user",
"SUPER_ADMIN": "Super admin",
"AUDITOR": "Auditor"
},

"role": {
"MEMBER": "Member",
"ADMIN": "Admin",
"MAINTAINER": "Maintainer"
}
}
11 changes: 11 additions & 0 deletions code/web-ui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import configurationPlugin from '@/config'
import VueCookies from 'vue-cookies'

import { sanitizeUrl } from '@braintree/sanitize-url'
import VueI18n from 'vue-i18n'

Vue.config.devtools = true
Vue.use(Vue2Filters)
Expand All @@ -44,6 +45,7 @@ Vue.use(iView, { locale })
Vue.use(VueVirtualScroller)
Vue.use(configurationPlugin)
Vue.use(VueCookies)
Vue.use(VueI18n)
iView.LoadingBar.config({
color: '#FFEA28', // Yellowish
height: 3
Expand All @@ -59,6 +61,14 @@ const router = new VueRouter({
routes: routes
})

const i18n = new VueI18n({
locale: 'en',
fallbackLocale: 'en',
messages: {
en: require('./locales/en.json')
}
})

router.beforeEach(async (to, from, next) => {
await AuthenticationService.manageLoginRedirection(to, from, next)

Expand All @@ -85,6 +95,7 @@ new Vue({
el: '#app',
router,
store,
i18n,
beforeCreate () { this.$store.commit('initialiseStore') },
render: h => h(app)
})
Expand Down
13 changes: 11 additions & 2 deletions code/web-ui/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const routes = [
path: '/admin/projects-list',
name: 'projects-list',
meta: {
title: 'Admin Management'
title: 'Project list'
},
component: (resolve) => require(['./views/admin-management.vue'], resolve)
},
Expand Down Expand Up @@ -218,7 +218,7 @@ const routes = [
path: '/admin/projects-list/:projectCode/:projectName/:userRole?',
name: 'admin-project-details',
meta: {
title: 'Admin project details'
title: 'Project details'
},
component: (resolve) => require(['./views/admin-project-details.vue'], resolve)
},
Expand Down Expand Up @@ -314,6 +314,15 @@ const routes = [
},
component: (resolve) => require(['./views/management-settings.vue'], resolve)
},
{
path: '/profile/:myProfile',
name: 'management-profile',
beforeEnter: requireAuth,
meta: {
title: 'Profile'
},
component: (resolve) => require(['./views/management-profile.vue'], resolve)
},

// 403 redirect
{
Expand Down
4 changes: 0 additions & 4 deletions code/web-ui/src/styles/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ h2 {
position: absolute;
top: 30px;
left: 110px;
cursor: pointer;
font-weight: 800;
color: #747474;
}

/* DROPDOWNS */
Expand Down Expand Up @@ -568,7 +565,6 @@ pre code {
}

.adminTable .table-cta i {
float: right;
margin-right: 1rem;
cursor: pointer;
}
Expand Down
33 changes: 20 additions & 13 deletions code/web-ui/src/views/admin-management-groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<template>
<div class="tableContent">
<span class="breadcrumbLink" @click="$router.go(-1)">
<Icon type="md-home" />
list
</span>

<h1 v-if="this.groupInfo[0]" class="adminTitle">
{{ this.groupInfo[0].name }}
<p class="title-description"><strong>{{ this.groupInfo[0].description }}</strong></p>
</h1>

<Tabs class="adminTable" type="card" v-model="tab">
<Tabs class="adminTable" type="card" v-model="activeTab" :animated="false">
<TabPane label="Managers">
<table class="tab-content" aria-label="Group's management">
<thead>
Expand Down Expand Up @@ -58,7 +53,7 @@

<tbody v-for="member in groupInfo" :key="member.id">
<tr
v-for="(user, index) in member.users"
v-for="(user, index) in member.members"
:key="index"
:class="index % 2 !== 0 ? 'lightGrey' : 'darkGrey'"
>
Expand Down Expand Up @@ -95,13 +90,9 @@
</table>
</TabPane>

<template #extra>
<Button @click="handleTabsAdd" size="small">增加</Button>
</template>
<Button @click="addToGroup" size="small" slot="extra">Add {{ groupTabs[activeTab] }}</Button>
</Tabs>

<Button @click="handleTabsAdd" size="small">{{ groupTabs[this.tab] }}</Button>

<Modal
v-model="memberToAdd"
title="Add Group"
Expand Down Expand Up @@ -189,7 +180,7 @@
searchElement: '',
showError: false,
groupInfo: [],
tab: ''
activeTab: 0
}
},

Expand All @@ -200,6 +191,22 @@
.then((groups) => {
this.groupInfo = groups.body.filter(item => item.name === this.$route.params.groupName)
})
},

addToGroup () {
const update = this.groupTabs[this.activeTab]

switch (update) {
case 'Managers':
Vue.http
.put(api.paths.groupsMembersManagement('user1', this.groupInfo[0].id), api.REQUEST_OPTIONS)
.then(response => console.log(response))
break
case 'Users':
break
case 'Projects':
break
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<template>
<div>
<span class="breadcrumbLink" @click="$router.go(-1)">Members list</span>
<div>
<h1 class="adminTitle">{{ getMemberInfo.login }}'s projects</h1>
</div>
Expand Down
18 changes: 9 additions & 9 deletions code/web-ui/src/views/admin-management-members.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
<template>
<div>
<div class="tableContent">
<span class="breadcrumbLink" @click="$router.go(-1)">
<Icon type="md-home" />
list
</span>

<h1 class="adminTitle">{{ memberType }}</h1>

<div v-if="manageProject || isNotAuditor">
Expand Down Expand Up @@ -61,7 +56,7 @@
<div>
<div v-if="memberType !== 'Groups'" class="user-avatar">
<span v-if="member.pictureUrl" :style="getAvatar(member)" class="user-picture"></span>
<Avatar v-else class="user-picture">{{ getAvatar(member) }}</Avatar>
<Avatar v-else :style="generateRandomColor()">{{ getAvatar(member) }}</Avatar>
<p>{{ member.login }}</p>
</div>
<div v-else>
Expand All @@ -71,7 +66,7 @@
</td>

<td>
<p v-if="memberType === 'Members'">{{ member.profile }}</p>
<p v-if="memberType === 'Members'">{{ $t('profile.' + member.profile) }}</p>
<p v-else>{{ member.managers[0].login }}</p>
</td>

Expand All @@ -90,7 +85,7 @@
</span>
</td>

<td class="table-cta">
<td class="table-cta" align="right">
<Icon v-if="!isMe(member.login) && isNotAuditor && isManagerOf(member.scopes)" type="md-eye" size="24" @click="navTo(member)" />
</td>
</tr>
Expand Down Expand Up @@ -325,8 +320,13 @@
if (member.pictureUrl) {
return `backgroundImage: url("` + member.pictureUrl + `")`
} else if (member.login) {
return member.login.substring(0, 1)
return member.login.match(/(\b\S)?/g).join('').toUpperCase()
}
},

generateRandomColor () {
const randomColor = Math.floor(Math.random() * 16777215).toString(16)
return 'background-color: #' + randomColor + ';'
}
},

Expand Down
8 changes: 4 additions & 4 deletions code/web-ui/src/views/admin-management.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
<td>{{ project.creation_user }}</td>
<td>{{ project.update_date }}</td>
<td>{{ project.update_user }}</td>
<td v-if="isScopedUser">{{ project.currentUserRole }}</td>
<td v-if="isScopedUser">{{ $t('role.' + project.currentUserRole) }}</td>
<td>
<input type="radio" name="defaultProject" @change="changeDefaultProject(project)" :checked="(user.default_project && user.default_project === project.code)">
</td>
<td class="table-cta">
<Icon type="md-close-circle" size="24" @click="deleteProject(project.code)" :class="isAdminOnProject(project) ? '' : 'hidden'"/>
<Icon type="md-create" size="24" @click="openProjectUpdateModal(project)" :class="isAdminOnProject(project) ? '' : 'hidden'"/>
<td class="table-cta" align="right">
<Icon type="md-eye" size="24" @click="openProjectDetails(project)" :class="isDemoProject(project.code) ? 'hidden' : ''"/>
<Icon type="md-create" size="24" @click="openProjectUpdateModal(project)" :class="isAdminOnProject(project) ? '' : 'hidden'"/>
<Icon type="md-close-circle" size="24" @click="deleteProject(project.code)" :class="isAdminOnProject(project) ? '' : 'hidden'"/>
</td>
</tr>
</tbody>
Expand Down
Loading

0 comments on commit 5037445

Please sign in to comment.