From d1eed231588eabf0f75e0f16795f3eb8cd525420 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Fri, 26 Apr 2019 12:23:58 +0200 Subject: [PATCH] last_email_sent display and resend email --- .../users/user-repository.service.ts | 14 +++++++++++ client/src/app/shared/models/users/user.ts | 2 +- .../user-detail/user-detail.component.html | 15 ++++++++++++ .../user-detail/user-detail.component.ts | 23 +++++++++++++++++++ .../user-list/user-list.component.html | 15 +++++++++++- .../user-list/user-list.component.scss | 4 ++++ .../user-list/user-list.component.ts | 15 +++++++++++- 7 files changed, 85 insertions(+), 3 deletions(-) diff --git a/client/src/app/core/repositories/users/user-repository.service.ts b/client/src/app/core/repositories/users/user-repository.service.ts index 998aacbc1..82bf80d16 100644 --- a/client/src/app/core/repositories/users/user-repository.service.ts +++ b/client/src/app/core/repositories/users/user-repository.service.ts @@ -339,4 +339,18 @@ export class UserRepositoryService extends BaseRepository { } }); } + + /** + * Get the date of the last invitation email. + * + * @param user + * @returns a localized string representation of the date/time the last email was sent; + * or an empty string + */ + public lastSentEmailTimeString(user: ViewUser): string { + if (!user.user || !user.user.last_email_send) { + return ''; + } + return new Date(user.user.last_email_send).toLocaleString(this.translate.currentLang); + } } diff --git a/client/src/app/shared/models/users/user.ts b/client/src/app/shared/models/users/user.ts index 2bc87fe08..afaecb200 100644 --- a/client/src/app/shared/models/users/user.ts +++ b/client/src/app/shared/models/users/user.ts @@ -27,7 +27,7 @@ export class User extends BaseModel { public is_present: boolean; public is_committee: boolean; public email: string; - public last_email_send?: string; + public last_email_send?: string; // ISO datetime string public comment: string; public is_active: boolean; public default_password: string; diff --git a/client/src/app/site/users/components/user-detail/user-detail.component.html b/client/src/app/site/users/components/user-detail/user-detail.component.html index 1d6d653e3..dc07ee93e 100644 --- a/client/src/app/site/users/components/user-detail/user-detail.component.html +++ b/client/src/app/site/users/components/user-detail/user-detail.component.html @@ -31,11 +31,17 @@ security Change password + + +
+ +
+
+

+ Last email sent +

+ {{ getEmailSentTime() }} +
+
diff --git a/client/src/app/site/users/components/user-detail/user-detail.component.ts b/client/src/app/site/users/components/user-detail/user-detail.component.ts index 54fd763cc..f271687ba 100644 --- a/client/src/app/site/users/components/user-detail/user-detail.component.ts +++ b/client/src/app/site/users/components/user-detail/user-detail.component.ts @@ -430,4 +430,27 @@ export class UserDetailComponent extends BaseViewComponent implements OnInit { public sanitizedText(text: string): SafeHtml { return this.sanitizer.bypassSecurityTrustHtml(text); } + + /** + * (Re)- send an invitation email for this user after confirmation + */ + public async sendInvitationEmail(): Promise { + const title = this.translate.instant('Sending an invitation email'); + const content = this.translate.instant('Are you sure you want to send an invitation email to the user?'); + if (await this.promptService.open(title, content)) { + this.repo.sendInvitationEmail([this.user]).then(this.raiseError, this.raiseError); + } + } + + /** + * Fetches a localized string for the time the last email was sent. + * + * @returns a translated string with either the localized date/time; of 'No email sent' + */ + public getEmailSentTime(): string { + if (!this.user.is_last_email_send) { + return this.translate.instant('No email sent'); + } + return this.repo.lastSentEmailTimeString(this.user); + } } diff --git a/client/src/app/site/users/components/user-list/user-list.component.html b/client/src/app/site/users/components/user-list/user-list.component.html index 6c5c2a2b0..fc9198ebe 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.html +++ b/client/src/app/site/users/components/user-list/user-list.component.html @@ -44,7 +44,7 @@ Name - {{ user.full_name }} + {{ user.short_name }} @@ -75,6 +75,19 @@ + + + + +
+ + mail + +
+
+
+ Presence diff --git a/client/src/app/site/users/components/user-list/user-list.component.scss b/client/src/app/site/users/components/user-list/user-list.component.scss index ec57d2863..1fd7b68cd 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.scss +++ b/client/src/app/site/users/components/user-list/user-list.component.scss @@ -33,6 +33,10 @@ } } +.infoCell { + max-width: 25px; +} + .presentCell { align-content: left; padding-right: 50px; diff --git a/client/src/app/site/users/components/user-list/user-list.component.ts b/client/src/app/site/users/components/user-list/user-list.component.ts index 731342c50..3a9d38b16 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.ts +++ b/client/src/app/site/users/components/user-list/user-list.component.ts @@ -365,6 +365,19 @@ export class UserListComponent extends ListViewBaseComponent imp } } + /** + * Get information about the last time an invitation email was sent to a user + * + * @param user + * @returns a string representation about the last time an email was sent to a user + */ + public getEmailSentTime(user: ViewUser): string { + if (!user.is_last_email_send) { + return this.translate.instant('No email sent'); + } + return this.repo.lastSentEmailTimeString(user); + } + /** * Handler for bulk setting new passwords. Needs multiSelect mode. */ @@ -393,7 +406,7 @@ export class UserListComponent extends ListViewBaseComponent imp columns = ['projector'].concat(columns); } if (this.operator.hasPerms('users.can_manage')) { - columns = columns.concat(['presence']); + columns = columns.concat(['infos', 'presence']); } if (this.isMultiSelect) { columns = ['selector'].concat(columns);