From 09427e2fe1952c12d20cc500209109dc8e962852 Mon Sep 17 00:00:00 2001 From: marwanehcine Date: Sat, 2 Dec 2023 15:48:28 +0100 Subject: [PATCH] adding alert message for user when password will expire --- README.md | 49 +++++++++++++++++------------------------------ src/auth.ts | 6 ++++++ src/header.ce.vue | 12 ++++++++++-- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 28c6eab..6ea8d87 100644 --- a/README.md +++ b/README.md @@ -12,47 +12,34 @@ To include it in an existing application: 1. add a `script` tag pointing to the JS file: - ```html - - ``` +```html + +``` 2. include the header component: - ```html - - ``` +```html + +``` Note: unlike with iframes there is no need to specify a height, the component will decide of its own size and "push" the content around accordingly. Iframe can still be set with defining `legacy-url` attribute, style can also be set with `legacy-style` attribute : - ```html - - ``` - -Attributes available : -| Attribute | Description | Example | For host | For legacy | -|---------------|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|----------|-----------| -| lang | Used to force header language (default value : en) | `` | v | | -| active-app | Use this attribute to set the active class in menu | `` | v | v | -| logo-url | Use this attribute to set the logo for the new header (not legacy one). | `` | v | | -| legacy-header | Use this attribute to enable the legacy header `iframe` tag. Needs `legacy-url`. | `` | | v | -| legacy-url | Legacy URL: if set, activates iframe with src attribute pointing to this URL. Needs `legacy-header`. | `` | | v | -| style | adds this style to iframe or host tag (if legacy url is not used) | `` | v | v | -| stylesheet | allow to add stylesheet for new header | `` | v | | - -3. Optional : Override default colors with `stylesheet` attribute : - -```css -header { - --georchestra-primary: #124885; - --georchestra-secondary: #83532b; - --georchestra-primary-light: #12488540; - --georchestra-secondary-light: #83532b40; - } +```html + ``` -Note: It's important to target the `header` tag here to override the css variables, because of the shadow DOM. +Attributes available : + +| Attribute | Description | Example | For host | For legacy | +| ------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -------- | ---------- | +| lang | Used to force header language (default value : en) | `` | v | | +| active-app | Use this attribute to set the active class in menu | `` | v | v | +| logo-url | Use this attribute to set the logo for the new header (not legacy one). | `` | v | | +| legacy-header | Use this attribute to enable the legacy header `iframe` tag. Needs `legacy-url`. | `` | | v | +| legacy-url | Legacy URL: if set, activates iframe with src attribute pointing to this URL. Needs `legacy-header`. | `` | | v | +| style | adds this style to iframe or host tag (if legacy url is not used) | `` | v | v | ## Development diff --git a/src/auth.ts b/src/auth.ts index 4923847..c511592 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -16,12 +16,16 @@ interface WhoAmIResponse { GeorchestraUser: { roles: KNOWN_ROLES[] username: string + ldapWarn: boolean + ldapRemainingDays: string } } export interface User { username: string anonymous: boolean + warned: boolean + remainingDays: string adminRoles: AdminRoles | null } @@ -41,6 +45,8 @@ export async function getUserDetails(): Promise { const roles = user.roles return { username: user.username, + warned: user.ldapWarn, + remainingDays: user.ldapRemainingDays, anonymous: roles.indexOf('ROLE_ANONYMOUS') > -1, adminRoles: getAdminRoles(roles), } diff --git a/src/header.ce.vue b/src/header.ce.vue index ac1a3ed..9f06e23 100644 --- a/src/header.ce.vue +++ b/src/header.ce.vue @@ -31,6 +31,8 @@ const state = reactive({ const isAnonymous = computed(() => !state.user || state.user.anonymous) const isAdmin = computed(() => state.user?.adminRoles?.admin) +const isWarned = computed(() => state.user?.warned) +const remainingDays = computed(() => state.user?.remainingDays) const adminRoles = computed(() => state.user?.adminRoles) const loginUrl = computed(() => { @@ -50,8 +52,7 @@ onMounted(() => { 'eng' getUserDetails().then(user => { state.user = user - - if (user?.adminRoles?.superUser) { + if (user?.adminRoles?.admin) { getPlatformInfos().then( platformInfos => (state.platformInfos = platformInfos) ) @@ -170,6 +171,13 @@ onMounted(() => { + + {{ t('remaining_days_msg_part1') }} {{ remainingDays }} + {{ t('remaining_days_msg_part2') }} + {{ + t('remaining_days_msg_part3') + }}