From 9bbfddad8c101c1a62aeab11be32a45b8bde40c7 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Thu, 19 Nov 2020 17:13:27 +0000 Subject: [PATCH] [Library | Trunk]: 1. Add compose email for invitation in monitor dashboard. 2. Add messages on invitation modals. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59921 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../users/dashboard-users.component.html | 2 +- dashboard/users/dashboard-users.component.ts | 2 ++ .../role-users/role-users.component.html | 13 ++++++++---- .../users/role-users/role-users.component.ts | 12 +++++++---- .../users/role-users/role-users.module.ts | 3 ++- services/user-registry.service.ts | 4 ++-- utils/email/composer.ts | 20 +++++++++++++++++++ utils/email/email.ts | 3 ++- 8 files changed, 46 insertions(+), 13 deletions(-) diff --git a/dashboard/users/dashboard-users.component.html b/dashboard/users/dashboard-users.component.html index 57617a32..201ab570 100644 --- a/dashboard/users/dashboard-users.component.html +++ b/dashboard/users/dashboard-users.component.html @@ -4,6 +4,6 @@
  • Members
  • - + diff --git a/dashboard/users/dashboard-users.component.ts b/dashboard/users/dashboard-users.component.ts index d7dfb635..3eebd5f6 100644 --- a/dashboard/users/dashboard-users.component.ts +++ b/dashboard/users/dashboard-users.component.ts @@ -16,6 +16,8 @@ export class DashboardUsersComponent implements OnInit{ public name: string; @Input() public link: string; + @Input() + public messages: Map<"member" | "manager", string> = null; public user: User; public tab: "manager" | "member" = 'manager'; diff --git a/dashboard/users/role-users/role-users.component.html b/dashboard/users/role-users/role-users.component.html index e18181b7..0b16f6be 100644 --- a/dashboard/users/role-users/role-users.component.html +++ b/dashboard/users/role-users/role-users.component.html @@ -55,7 +55,7 @@ {{(showActive) ? item.email : item}} -
    + -
    -
    +
    +
    +
    +
    +
    +
    +
    diff --git a/dashboard/users/role-users/role-users.component.ts b/dashboard/users/role-users/role-users.component.ts index e114b43f..21905b40 100644 --- a/dashboard/users/role-users/role-users.component.ts +++ b/dashboard/users/role-users/role-users.component.ts @@ -9,6 +9,7 @@ import {Session} from "../../../login/utils/helper.class"; import {UserManagementService} from "../../../services/user-management.service"; import {Router} from "@angular/router"; import {LoginErrorCodes} from "../../../login/utils/guardHelper.class"; +import {Composer} from "../../../utils/email/composer"; declare var UIkit; @@ -28,7 +29,10 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { public link: string; @Input() public isPortalAdmin: boolean = false; - @Input() role: "member" | "manager" = "manager"; + @Input() + public role: "member" | "manager" = "manager"; + @Input() + public messages: Map<"member" | "manager", string> = null; public active: any[]; public pending: any[]; public showActive: boolean = true; @@ -170,10 +174,10 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges { this.showActive = false; this.loadPending = true; let details = { - name: this.name, - link: this.link + link: this.link, + email: Composer.composeEmailForMonitorDashboard(this.name, this.invited.value, this.role) } - this.userRegistryService.invite(this.type, this.id, this.invited.value, details, this.role).subscribe(() => { + this.userRegistryService.invite(this.type, this.id, details, this.role).subscribe(() => { this.error = null; if (!this.pending.includes(this.invited.value)) { this.pending.push(this.invited.value); diff --git a/dashboard/users/role-users/role-users.module.ts b/dashboard/users/role-users/role-users.module.ts index 357579d6..a3d7af81 100644 --- a/dashboard/users/role-users/role-users.module.ts +++ b/dashboard/users/role-users/role-users.module.ts @@ -10,9 +10,10 @@ import {person_add, remove_circle_outline} from "../../../utils/icons/icons"; import {IconsModule} from "../../../utils/icons/icons.module"; import {InputModule} from "../../../sharedComponents/input/input.module"; import {PageContentModule} from "../../sharedComponents/page-content/page-content.module"; +import {SafeHtmlPipeModule} from "../../../utils/pipes/safeHTMLPipe.module"; @NgModule({ - imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule, IconsModule, InputModule, PageContentModule], + imports: [CommonModule, AlertModalModule, ReactiveFormsModule, LoadingModule, IconsModule, InputModule, PageContentModule, SafeHtmlPipeModule], declarations: [RoleUsersComponent], exports: [RoleUsersComponent], providers: [EmailService] diff --git a/services/user-registry.service.ts b/services/user-registry.service.ts index 640b5a61..6cff6d8b 100644 --- a/services/user-registry.service.ts +++ b/services/user-registry.service.ts @@ -37,9 +37,9 @@ export class UserRegistryService { encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + role + '/' + encodeURIComponent(email), CustomOptions.registryOptions()); } - public invite(type: string, id: string, email: string, details: any, role: "member" | "manager" = "manager"): Observable { + public invite(type: string, id: string, details: any, role: "member" | "manager" = "manager"): Observable { return this.http.post(properties.registryUrl + 'invite/' + - encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + role + '/' + encodeURIComponent(email), details, + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + role, details, CustomOptions.registryOptions()).pipe(map((response: any) => response.response)); } diff --git a/utils/email/composer.ts b/utils/email/composer.ts index 556472e2..c4fce04f 100644 --- a/utils/email/composer.ts +++ b/utils/email/composer.ts @@ -1,6 +1,7 @@ import {Email} from "./email"; import {Body} from "./body"; import {FormArray} from "@angular/forms"; +import {properties} from "../../../../environments/environment"; export class Composer { private static noteBodySize = "14px"; @@ -225,4 +226,23 @@ export class Composer { return email = {body: "", subject: this.subjectPrefix + communityTitle, recipients: []}; } + + public static composeEmailForMonitorDashboard(name: string, recipient: string, role: "manager" | "member") { + let email: Email = new Email(); + email.subject = 'OpenAIRE Monitor Dashboard | ' + name; + email.body = '

    Dear ((__user__)),

    ' + + '

    You have been invited to be a ' + role +' of the OpenAIRE Monitor Dashboard for the ' + name + '.

    ' + + '

    Click this URL and use the verification code below to accept the invitation.

    ' + + '

    The verification code is ((__code__)).

    ' + + (role === "manager"? + '

    As a manager of the OpenAIRE Monitor Dashboard, you will have access to the administration part of the dashboard, ' + + 'where you will be able to customize and manage the profile of the ' + name + '.

    ': + '

    As a member of the OpenAIRE Monitor Dashboard, you will have access to the restricted access areas of the profile for the ' + name + '.') + + '

    Please contact us at ' + properties.helpdeskEmail + + ' if you have any questions or concerns.

    ' + + '

    Kind Regards
    The OpenAIRE Team

    ' + + '

    OpenAIRE Monitor

    ' + email.recipient = recipient; + return email; + } } diff --git a/utils/email/email.ts b/utils/email/email.ts index 5c43f4c6..c27bc4f8 100644 --- a/utils/email/email.ts +++ b/utils/email/email.ts @@ -1,5 +1,6 @@ export class Email { body: string; subject: string; - recipients: string[]; + recipients?: string[]; + recipient?: string; }