Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SIGPUBLIC
unantes-orientation-active
Commits
c1821120
Commit
c1821120
authored
Sep 27, 2021
by
Django Janny
Browse files
UNOTOPLYS-299 - Problème de droits sur onglet de la home
parent
e0c34877
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/webapp/app/main.ts
View file @
c1821120
...
...
@@ -25,7 +25,7 @@ const store = config.initVueXStore(Vue);
const
alertService
=
new
AlertService
(
store
);
const
translationService
=
new
TranslationService
(
store
,
i18n
);
const
accountService
=
new
AccountService
(
store
,
translationService
,
router
);
const
headerService
=
new
HeaderService
(
store
,
translationService
,
i18n
);
const
headerService
=
new
HeaderService
(
store
,
accountService
,
translationService
,
i18n
);
const
frontFormService
=
new
FrontFormService
(
store
,
router
,
alertService
,
translationService
,
i18n
);
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
...
...
src/main/webapp/app/services/account.service.ts
View file @
c1821120
...
...
@@ -88,4 +88,21 @@ export default class AccountService {
public
get
token
():
any
{
return
localStorage
.
getItem
(
'
jhi-authenticationToken
'
)
||
sessionStorage
.
getItem
(
'
jhi-authenticationToken
'
);
}
public
hasAuthoritiesForRoute
(
path
:
String
):
boolean
{
if
(
this
.
router
.
getRoutes
().
find
(
r
=>
r
.
path
===
path
)
&&
!
this
.
router
.
getRoutes
().
find
(
r
=>
r
.
path
===
path
).
meta
.
authorities
)
{
return
true
;
}
for
(
let
authority
of
this
.
userAuthorities
)
{
if
(
this
.
router
.
getRoutes
()
.
find
(
r
=>
r
.
path
===
path
)
?.
meta
?.
authorities
?.
includes
(
authority
)
)
{
return
true
;
}
}
return
false
;
}
}
src/main/webapp/app/shared/service/header-service.ts
View file @
c1821120
...
...
@@ -2,6 +2,7 @@ import { Store } from 'vuex';
import
axios
from
'
axios
'
;
import
VueI18n
from
'
vue-i18n
'
;
import
TranslationService
from
'
@/locale/translation.service
'
;
import
AccountService
from
'
@/services/account.service
'
;
const
filArianeBaseApiUrl
=
'
api/filariane
'
;
...
...
@@ -14,10 +15,41 @@ export default class HeaderService {
public
static
readonly
TAB_KEY_FORMS
=
'
forms
'
;
public
static
readonly
TAB_KEY_USERS
=
'
users
'
;
constructor
(
private
store
:
Store
<
any
>
,
private
translationService
:
TranslationService
,
private
i18n
:
VueI18n
)
{
constructor
(
private
store
:
Store
<
any
>
,
private
accountService
:
AccountService
,
private
translationService
:
TranslationService
,
private
i18n
:
VueI18n
)
{
this
.
translationService
.
refreshTranslation
(
this
.
store
.
getters
.
currentLanguage
);
}
public
updateTabsForHome
(
currentKey
:
string
):
void
{
let
tabs
=
[];
if
(
this
.
accountService
.
hasAuthoritiesForRoute
(
'
/admin/forms
'
))
{
tabs
.
push
({
title
:
this
.
i18n
.
t
(
'
onglets.forms
'
),
link
:
`/admin/forms`
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_FORMS
,
});
}
if
(
this
.
accountService
.
hasAuthoritiesForRoute
(
'
/admin/workspaces
'
))
{
tabs
.
push
({
title
:
this
.
i18n
.
t
(
'
onglets.workspaces
'
),
link
:
`/admin/workspaces`
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_WORKSPACES
,
});
}
if
(
this
.
accountService
.
hasAuthoritiesForRoute
(
'
/admin/user
'
))
{
tabs
.
push
({
title
:
this
.
i18n
.
t
(
'
onglets.utilisateurs
'
),
link
:
'
/admin/user
'
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_USERS
,
});
}
this
.
store
.
commit
(
'
tabs
'
,
tabs
);
}
public
updateTabsForWorkspaceId
(
workspaceId
:
number
,
currentKey
:
string
):
void
{
const
tabs
:
any
[]
=
[
{
...
...
@@ -81,25 +113,4 @@ export default class HeaderService {
this
.
store
.
commit
(
'
filArianeElements
'
,
res
.
data
);
});
}
public
updateTabsForHome
(
currentKey
:
string
):
void
{
let
tabs
=
[
{
title
:
this
.
i18n
.
t
(
'
onglets.forms
'
),
link
:
`/admin/forms`
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_FORMS
,
},
{
title
:
this
.
i18n
.
t
(
'
onglets.workspaces
'
),
link
:
`/admin/workspaces`
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_WORKSPACES
,
},
{
title
:
this
.
i18n
.
t
(
'
onglets.utilisateurs
'
),
link
:
'
/admin/user
'
,
isCurrent
:
currentKey
===
HeaderService
.
TAB_KEY_USERS
,
},
];
this
.
store
.
commit
(
'
tabs
'
,
tabs
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment