diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html deleted file mode 100644 index 322dd97b4..000000000 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.scss b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.scss deleted file mode 100644 index 118317781..000000000 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.scss +++ /dev/null @@ -1,27 +0,0 @@ -//@use 'variables'; -//@use 'common-mixins'; -// -//.content-container { -// background-color: variables.$grey-2; -// justify-content: center; -// @include common-mixins.scroll-bar; -// overflow: auto; -//} -// -//.full-height { -// display: flex; -// flex-direction: row; -// position: absolute; -// bottom: 0; -// width: 100%; -// height: calc(100% + 50px); -// z-index: 1; -//} -// -//iframe { -// background: white; -// width: 500px; -// height: 500px; -// position: absolute; -// z-index: 100; -//} diff --git a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts b/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts deleted file mode 100644 index 47714ed5f..000000000 --- a/apps/red-ui/src/app/components/user-profile/user-profile-screen.component.ts +++ /dev/null @@ -1,116 +0,0 @@ -// import { Component, OnInit } from '@angular/core'; -// import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -// import { ProfileModel, UserService } from '@services/user.service'; -// import { PermissionsService } from '@services/permissions.service'; -// import { LanguageService } from '@i18n/language.service'; -// import { TranslateService } from '@ngx-translate/core'; -// import { UserControllerService } from '@redaction/red-ui-http'; -// import { ConfigService } from '@services/config.service'; -// import { DomSanitizer } from '@angular/platform-browser'; -// import { languagesTranslations } from '../../translations/languages-translations'; -// import { LoadingService } from '@iqser/common-ui'; -// -// @Component({ -// selector: 'redaction-user-profile-screen', -// templateUrl: './user-profile-screen.component.html', -// styleUrls: ['./user-profile-screen.component.scss'] -// }) -// export class UserProfileScreenComponent implements OnInit { -// formGroup: FormGroup; -// changePasswordUrl: any; -// translations = languagesTranslations; -// -// private _profileModel: ProfileModel; -// -// constructor( -// readonly permissionsService: PermissionsService, -// private readonly _formBuilder: FormBuilder, -// private readonly _userService: UserService, -// private readonly _configService: ConfigService, -// private readonly _userControllerService: UserControllerService, -// private readonly _languageService: LanguageService, -// private readonly _domSanitizer: DomSanitizer, -// private readonly _translateService: TranslateService, -// private readonly _loadingService: LoadingService -// ) { -// this._loadingService.start(); -// this.formGroup = this._formBuilder.group({ -// email: [undefined, [Validators.required, Validators.email]], -// firstName: [undefined], -// lastName: [undefined], -// language: [undefined] -// }); -// -// this.changePasswordUrl = this._domSanitizer.bypassSecurityTrustResourceUrl( -// this._configService.values.OAUTH_URL + '/account/password' -// ); -// } -// -// get languageChanged(): boolean { -// return this._profileModel['language'] !== this.formGroup.get('language').value; -// } -// -// get profileChanged(): boolean { -// const keys = Object.keys(this.formGroup.getRawValue()); -// keys.splice(keys.indexOf('language'), 1); -// -// for (const key of keys) { -// if (this._profileModel[key] !== this.formGroup.get(key).value) { -// return true; -// } -// } -// -// return false; -// } -// -// get languages(): string[] { -// return this._translateService.langs; -// } -// -// ngOnInit() { -// this._initializeForm(); -// } -// -// async save(): Promise { -// this._loadingService.start(); -// -// if (this.languageChanged) { -// await this._languageService.changeLanguage(this.formGroup.get('language').value); -// } -// -// if (this.profileChanged) { -// const value = this.formGroup.value as ProfileModel; -// delete value.language; -// -// await this._userControllerService -// .updateMyProfile({ -// ...value -// }) -// .toPromise(); -// -// await this._userService.loadCurrentUser(); -// await this._userService.loadAllUsers(); -// } -// -// this._initializeForm(); -// } -// -// private _initializeForm(): void { -// try { -// this._profileModel = { -// email: this._userService.currentUser.email, -// firstName: this._userService.currentUser.firstName, -// lastName: this._userService.currentUser.lastName, -// language: this._languageService.currentLanguage -// }; -// if (this._userService.currentUser.email) { -// // disable email if it's already set -// this.formGroup.get('email').disable(); -// } -// this.formGroup.patchValue(this._profileModel, { emitEvent: false }); -// } catch (e) { -// } finally { -// this._loadingService.stop(); -// } -// } -// } diff --git a/apps/red-ui/src/app/modules/account/account-routing.module.ts b/apps/red-ui/src/app/modules/account/account-routing.module.ts index 31d95beb4..b991d118d 100644 --- a/apps/red-ui/src/app/modules/account/account-routing.module.ts +++ b/apps/red-ui/src/app/modules/account/account-routing.module.ts @@ -4,8 +4,8 @@ import { CompositeRouteGuard } from '../../guards/composite-route.guard'; import { AuthGuard } from '../auth/auth.guard'; import { RedRoleGuard } from '../auth/red-role.guard'; import { AppStateGuard } from '../../state/app-state.guard'; -import { NotificationsScreenComponent } from './screens/notifications/notifications.component'; -import { UserProfileScreenComponent } from './screens/user-profile/user-profile.component'; +import { NotificationsScreenComponent } from './screens/notifications/notifications-screen.component'; +import { UserProfileScreenComponent } from './screens/user-profile/user-profile-screen.component'; const routes = [ { path: '', redirectTo: 'user-profile', pathMatch: 'full' }, diff --git a/apps/red-ui/src/app/modules/account/account.module.ts b/apps/red-ui/src/app/modules/account/account.module.ts index ab03c0314..b77ac676e 100644 --- a/apps/red-ui/src/app/modules/account/account.module.ts +++ b/apps/red-ui/src/app/modules/account/account.module.ts @@ -3,8 +3,8 @@ import { CommonModule } from '@angular/common'; import { SharedModule } from '../shared/shared.module'; import { AccountRoutingModule } from './account-routing.module'; import { AccountSideNavComponent } from './account-side-nav/account-side-nav.component'; -import { NotificationsScreenComponent } from './screens/notifications/notifications.component'; -import { UserProfileScreenComponent } from './screens/user-profile/user-profile.component'; +import { NotificationsScreenComponent } from './screens/notifications/notifications-screen.component'; +import { UserProfileScreenComponent } from './screens/user-profile/user-profile-screen.component'; const screens = [NotificationsScreenComponent, UserProfileScreenComponent]; diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.html b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html similarity index 69% rename from apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.html rename to apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html index 8a19b4a78..193232188 100644 --- a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.html +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.html @@ -4,9 +4,6 @@
-
diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.scss b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.scss similarity index 100% rename from apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.scss rename to apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.scss diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.ts b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts similarity index 57% rename from apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.ts rename to apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts index 586e58537..8f3846757 100644 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/notifications/notifications-screen.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'redaction-notifications-screen', - templateUrl: './notifications.component.html', - styleUrls: ['./notifications.component.scss'] + templateUrl: './notifications-screen.component.html', + styleUrls: ['./notifications-screen.component.scss'] }) export class NotificationsScreenComponent {} diff --git a/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.html b/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.html deleted file mode 100644 index 1d07a02f3..000000000 --- a/apps/red-ui/src/app/modules/account/screens/notifications/notifications.component.html +++ /dev/null @@ -1,34 +0,0 @@ -
-
- - - -
- -
-
- - - - - - - - -
-
-
-
diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.html b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.html new file mode 100644 index 000000000..77c930363 --- /dev/null +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.html @@ -0,0 +1,60 @@ +
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+ + + + {{ translations[language] | translate }} + + +
+
+
+ +
+ + + {{ 'user-profile-screen.actions.change-password' | translate }} +
+
+
+
+
+
+
diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.scss b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.scss new file mode 100644 index 000000000..a0f740599 --- /dev/null +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.scss @@ -0,0 +1,23 @@ +@use 'variables'; +@use 'common-mixins'; + +.dialog { + min-height: unset; +} + +.content-container { + background-color: variables.$grey-2; + justify-content: center; + @include common-mixins.scroll-bar; + overflow: auto; +} + +.full-height { + display: flex; + flex-direction: row; + position: absolute; + bottom: 0; + width: 100%; + height: calc(100% + 50px); + z-index: 1; +} diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.ts b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.ts new file mode 100644 index 000000000..98f8866d7 --- /dev/null +++ b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile-screen.component.ts @@ -0,0 +1,116 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { languagesTranslations } from '../../translations/languages-translations'; +import { ProfileModel, UserService } from '../../../../services/user.service'; +import { PermissionsService } from '../../../../services/permissions.service'; +import { ConfigService } from '../../../../services/config.service'; +import { UserControllerService } from '../../../../../../../../libs/red-ui-http/src'; +import { LanguageService } from '../../../../i18n/language.service'; +import { DomSanitizer } from '@angular/platform-browser'; +import { TranslateService } from '@ngx-translate/core'; +import { LoadingService } from '../../../../../../../../libs/common-ui/src'; + +@Component({ + selector: 'redaction-user-profile-screen', + templateUrl: './user-profile-screen.component.html', + styleUrls: ['./user-profile-screen.component.scss'] +}) +export class UserProfileScreenComponent implements OnInit { + formGroup: FormGroup; + changePasswordUrl: any; + translations = languagesTranslations; + + private _profileModel: ProfileModel; + + constructor( + readonly permissionsService: PermissionsService, + private readonly _formBuilder: FormBuilder, + private readonly _userService: UserService, + private readonly _configService: ConfigService, + private readonly _userControllerService: UserControllerService, + private readonly _languageService: LanguageService, + private readonly _domSanitizer: DomSanitizer, + private readonly _translateService: TranslateService, + private readonly _loadingService: LoadingService + ) { + this._loadingService.start(); + this.formGroup = this._formBuilder.group({ + email: [undefined, [Validators.required, Validators.email]], + firstName: [undefined], + lastName: [undefined], + language: [undefined] + }); + + this.changePasswordUrl = this._domSanitizer.bypassSecurityTrustResourceUrl( + this._configService.values.OAUTH_URL + '/account/password' + ); + } + + get languageChanged(): boolean { + return this._profileModel['language'] !== this.formGroup.get('language').value; + } + + get profileChanged(): boolean { + const keys = Object.keys(this.formGroup.getRawValue()); + keys.splice(keys.indexOf('language'), 1); + + for (const key of keys) { + if (this._profileModel[key] !== this.formGroup.get(key).value) { + return true; + } + } + + return false; + } + + get languages(): string[] { + return this._translateService.langs; + } + + ngOnInit() { + this._initializeForm(); + } + + async save(): Promise { + this._loadingService.start(); + + if (this.languageChanged) { + await this._languageService.changeLanguage(this.formGroup.get('language').value); + } + + if (this.profileChanged) { + const value = this.formGroup.value as ProfileModel; + delete value.language; + + await this._userControllerService + .updateMyProfile({ + ...value + }) + .toPromise(); + + await this._userService.loadCurrentUser(); + await this._userService.loadAllUsers(); + } + + this._initializeForm(); + } + + private _initializeForm(): void { + try { + this._profileModel = { + email: this._userService.currentUser.email, + firstName: this._userService.currentUser.firstName, + lastName: this._userService.currentUser.lastName, + language: this._languageService.currentLanguage + }; + if (this._userService.currentUser.email) { + // disable email if it's already set + this.formGroup.get('email').disable(); + } + this.formGroup.patchValue(this._profileModel, { emitEvent: false }); + } catch (e) { + } finally { + this._loadingService.stop(); + } + } +} diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.scss b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.ts b/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.ts deleted file mode 100644 index 97ebcd3f4..000000000 --- a/apps/red-ui/src/app/modules/account/screens/user-profile/user-profile.component.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'redaction-user-profile-screen', - templateUrl: './user-profile.component.html', - styleUrls: ['./user-profile.component.scss'] -}) -export class UserProfileScreenComponent {} diff --git a/apps/red-ui/src/app/translations/languages-translations.ts b/apps/red-ui/src/app/modules/account/translations/languages-translations.ts similarity index 100% rename from apps/red-ui/src/app/translations/languages-translations.ts rename to apps/red-ui/src/app/modules/account/translations/languages-translations.ts diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 2efc511c4..7c0e555b4 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1232,7 +1232,6 @@ "user-promoted-to-approver": "{user} promoted to approver in dossier: {dossierName}!", "user-removed-as-dossier-member": "{user} removed as a member of: {dossierName} !" }, - "notifications": "Notifications", "overwrite-files-dialog": { "options": { "cancel": "Cancel all uploads", @@ -1485,7 +1484,24 @@ } }, "user-management": "User Management", + "notifications": "Notifications", + "notifications-screen": { + "mark-as": "Mark as {type, select, read{read} unread{unread} other{}}", + "no-data": "You have no notifications." + }, "user-profile": "My Profile", + "user-profile-screen": { + "actions": { + "change-password": "Change Password", + "save": "Save profile" + }, + "form": { + "email": "Email", + "first-name": "First name", + "last-name": "Last name" + }, + "title": "Edit Profile" + }, "user-stats": { "chart": { "users": "Users in Workspace"