move user to red-domain
This commit is contained in:
parent
2abb881dae
commit
56618a5fdb
@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ProfileModel, UserService } from '@services/user.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { LanguageService } from '@i18n/language.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
@ -8,6 +8,7 @@ import { ConfigService } from '@services/config.service';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { languagesTranslations } from '../../translations/languages-translations';
|
||||
import { LoadingService } from '@iqser/common-ui';
|
||||
import { IProfile } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-user-profile-screen',
|
||||
@ -19,7 +20,7 @@ export class UserProfileScreenComponent implements OnInit {
|
||||
changePasswordUrl: any;
|
||||
translations = languagesTranslations;
|
||||
|
||||
private _profileModel: ProfileModel;
|
||||
private _profileModel: IProfile;
|
||||
|
||||
constructor(
|
||||
readonly permissionsService: PermissionsService,
|
||||
@ -77,7 +78,7 @@ export class UserProfileScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
if (this.profileChanged) {
|
||||
const value = this.formGroup.value as ProfileModel;
|
||||
const value = this.formGroup.value as IProfile;
|
||||
delete value.language;
|
||||
|
||||
await this._userService
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { isArray } from 'rxjs/internal-compatibility';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
|
||||
export class AnnotationPermissions {
|
||||
canUndo = true;
|
||||
|
||||
@ -4,7 +4,7 @@ import { AnnotationWrapper } from './annotation.wrapper';
|
||||
import { RedactionLogEntryWrapper } from './redaction-log-entry.wrapper';
|
||||
import { ViewMode } from './view-mode';
|
||||
import * as moment from 'moment';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
import { Dictionary } from '@models/dictionary';
|
||||
|
||||
export class AnnotationData {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import { Component, Inject, OnDestroy } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { DossierAttributeConfigTypes, FileAttributeConfigTypes } from '@redaction/red-ui-http';
|
||||
import { FileAttributeConfigTypes } from '@redaction/red-ui-http';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AutoUnsubscribe, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
|
||||
import { dossierAttributeTypesTranslations } from '../../translations/dossier-attribute-types-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { IDossierAttributeConfig } from '@red/domain';
|
||||
import { DossierAttributeConfigTypes, IDossierAttributeConfig } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
templateUrl: './add-edit-dossier-attribute-dialog.component.html',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-add-edit-user-dialog',
|
||||
|
||||
@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { LoadingService } from '@iqser/common-ui';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-reset-password',
|
||||
|
||||
@ -4,7 +4,7 @@ import { AdminDialogService } from '../../../services/admin-dialog.service';
|
||||
import { IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { rolesTranslations } from '../../../../../translations/roles-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
import { UserService } from '@services/user.service';
|
||||
|
||||
@Component({
|
||||
@ -85,7 +85,7 @@ export class UserDetailsComponent implements OnInit {
|
||||
...prev,
|
||||
[role]: [
|
||||
{
|
||||
value: this.user && this.user.roles.indexOf(role) !== -1,
|
||||
value: this.user && this.user.hasRole(role),
|
||||
disabled: this.shouldBeDisabled(role),
|
||||
},
|
||||
],
|
||||
|
||||
@ -17,7 +17,7 @@ import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { rolesTranslations } from '../../../../translations/roles-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
templateUrl: './user-listing-screen.component.html',
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DossierAttributeConfigType } from '@redaction/red-ui-http';
|
||||
import { DossierAttributeConfigType } from '@red/domain';
|
||||
|
||||
export const dossierAttributeTypesTranslations: { [key in DossierAttributeConfigType]: string } = {
|
||||
TEXT: _('dossier-attribute-types.text'),
|
||||
|
||||
@ -7,9 +7,8 @@ import { UserService } from '@services/user.service';
|
||||
import { FilterService, Toaster } from '@iqser/common-ui';
|
||||
import { fileStatusTranslations } from '../../../../translations/file-status-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { User } from '@models/user';
|
||||
import { DossierAttributeWithValue, IDossierRequest, User } from '@red/domain';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { DossierAttributeWithValue, IDossierRequest } from '@red/domain';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-dossier-details',
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { Injectable, TemplateRef } from '@angular/core';
|
||||
import { ButtonConfig, IFilterGroup, keyChecker, NestedFilter, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { Dossier, User } from '@red/domain';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { UserPreferenceService } from '@services/user-preference.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { User } from '@models/user';
|
||||
import { fileStatusTranslations } from '../../translations/file-status-translations';
|
||||
import {
|
||||
annotationFilterChecker,
|
||||
|
||||
@ -41,10 +41,9 @@ import { fileStatusTranslations } from '../../translations/file-status-translati
|
||||
import { handleFilterDelta } from '@utils/filter-utils';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { FileActionsComponent } from '../../shared/components/file-actions/file-actions.component';
|
||||
import { User } from '@models/user';
|
||||
import { Dossier, User } from '@red/domain';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { Dossier } from '@red/domain';
|
||||
import { FileManagementService } from '../../shared/services/file-management.service';
|
||||
import Annotation = Core.Annotations.Annotation;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
import { List } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { AutoUnsubscribe } from '@iqser/common-ui';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { NamePipeOptions } from '@shared/pipes/name.pipe';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { User } from '@models/user';
|
||||
import { User } from '@red/domain';
|
||||
|
||||
function getInitials(name: string) {
|
||||
if (name.toLowerCase() === 'system') {
|
||||
@ -15,11 +15,6 @@ function getInitials(name: string) {
|
||||
.join('');
|
||||
}
|
||||
|
||||
function isSystemUser(user: User | string) {
|
||||
const userId = typeof user === 'string' ? user : user.id;
|
||||
return userId.toLowerCase() === 'system';
|
||||
}
|
||||
|
||||
export interface NamePipeOptions {
|
||||
showYou?: boolean;
|
||||
showInitials?: boolean;
|
||||
|
||||
@ -1,22 +1,14 @@
|
||||
import { Inject, Injectable, Injector } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import jwt_decode from 'jwt-decode';
|
||||
import { CreateUserRequest, IUser, ResetPasswordRequest, UpdateMyProfileRequest, UpdateProfileRequest } from '@redaction/red-ui-http';
|
||||
import { CreateUserRequest, ResetPasswordRequest } from '@redaction/red-ui-http';
|
||||
import { wipeCaches } from '@redaction/red-cache';
|
||||
import { BASE_HREF } from '../tokens';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { User } from '@models/user';
|
||||
import { IMyProfileUpdateRequest, IProfileUpdateRequest, IUser, User } from '@red/domain';
|
||||
import { EntitiesService, List, mapEach, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
export interface ProfileModel {
|
||||
username?: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
language: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@ -77,7 +69,7 @@ export class UserService extends EntitiesService<User, IUser> {
|
||||
hasAnyRole(requiredRoles: string[], user = this.currentUser): boolean {
|
||||
if (requiredRoles?.length > 0) {
|
||||
for (const role of requiredRoles) {
|
||||
if (user.roles.indexOf(role) >= 0) {
|
||||
if (user.hasRole(role)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -94,12 +86,12 @@ export class UserService extends EntitiesService<User, IUser> {
|
||||
}
|
||||
|
||||
@Validate()
|
||||
updateProfile(@RequiredParam() body: UpdateProfileRequest, @RequiredParam() userId: string) {
|
||||
updateProfile(@RequiredParam() body: IProfileUpdateRequest, @RequiredParam() userId: string) {
|
||||
return this._post<unknown>(body, `${this._defaultModelPath}/profile/${userId}`);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
updateMyProfile(@RequiredParam() body: UpdateMyProfileRequest) {
|
||||
updateMyProfile(@RequiredParam() body: IMyProfileUpdateRequest) {
|
||||
return this._post<unknown>(body, `${this._defaultModelPath}/my-profile`);
|
||||
}
|
||||
|
||||
|
||||
@ -2,3 +2,4 @@ export * from './lib/dossiers';
|
||||
export * from './lib/search';
|
||||
export * from './lib/shared/types';
|
||||
export * from './lib/dossier-attributes';
|
||||
export * from './lib/users';
|
||||
|
||||
5
libs/red-domain/src/lib/users/index.ts
Normal file
5
libs/red-domain/src/lib/users/index.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export * from './user.model';
|
||||
export * from './user.interface';
|
||||
export * from './my-profile-update.request';
|
||||
export * from './profile-update.request';
|
||||
export * from './profile.interface';
|
||||
14
libs/red-domain/src/lib/users/my-profile-update.request.ts
Normal file
14
libs/red-domain/src/lib/users/my-profile-update.request.ts
Normal file
@ -0,0 +1,14 @@
|
||||
export interface IMyProfileUpdateRequest {
|
||||
/**
|
||||
* Email of user.
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* First name of user.
|
||||
*/
|
||||
firstName?: string;
|
||||
/**
|
||||
* Last name of user.
|
||||
*/
|
||||
lastName?: string;
|
||||
}
|
||||
@ -9,18 +9,12 @@
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { IMyProfileUpdateRequest } from './my-profile-update.request';
|
||||
import { List } from '@iqser/common-ui';
|
||||
|
||||
export interface UpdateMyProfileRequest {
|
||||
export interface IProfileUpdateRequest extends IMyProfileUpdateRequest {
|
||||
/**
|
||||
* Email of user.
|
||||
* Roles.
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* First name of user.
|
||||
*/
|
||||
firstName?: string;
|
||||
/**
|
||||
* Last name of user.
|
||||
*/
|
||||
lastName?: string;
|
||||
roles?: List;
|
||||
}
|
||||
7
libs/red-domain/src/lib/users/profile.interface.ts
Normal file
7
libs/red-domain/src/lib/users/profile.interface.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export interface IProfile {
|
||||
username?: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
language: string;
|
||||
}
|
||||
15
libs/red-domain/src/lib/users/user.interface.ts
Normal file
15
libs/red-domain/src/lib/users/user.interface.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Object containing information of user and roles.
|
||||
*/
|
||||
import { IProfileUpdateRequest } from './profile-update.request';
|
||||
|
||||
export interface IUser extends IProfileUpdateRequest {
|
||||
/**
|
||||
* Id of user.
|
||||
*/
|
||||
readonly userId?: string;
|
||||
/**
|
||||
* Username for login.
|
||||
*/
|
||||
readonly username?: string;
|
||||
}
|
||||
@ -1,20 +1,20 @@
|
||||
import { IUser } from '@redaction/red-ui-http';
|
||||
import { IListable, List } from '@iqser/common-ui';
|
||||
import { KeycloakProfile } from 'keycloak-js';
|
||||
import { IUser } from './user.interface';
|
||||
|
||||
export class User implements IUser, IListable {
|
||||
readonly email: string;
|
||||
readonly username: string;
|
||||
readonly email?: string;
|
||||
readonly username?: string;
|
||||
readonly firstName?: string;
|
||||
readonly lastName?: string;
|
||||
readonly name: string;
|
||||
readonly name?: string;
|
||||
readonly searchKey: string;
|
||||
|
||||
readonly isActive = this.roles.length > 0;
|
||||
readonly isManager = this.roles.indexOf('RED_MANAGER') >= 0;
|
||||
readonly isUserAdmin = this.roles.indexOf('RED_USER_ADMIN') >= 0;
|
||||
readonly isUser = this.roles.indexOf('RED_USER') >= 0;
|
||||
readonly isAdmin = this.roles.indexOf('RED_ADMIN') >= 0;
|
||||
readonly isManager = this.hasRole('RED_MANAGER');
|
||||
readonly isUserAdmin = this.hasRole('RED_USER_ADMIN');
|
||||
readonly isUser = this.hasRole('RED_USER');
|
||||
readonly isAdmin = this.hasRole('RED_ADMIN');
|
||||
readonly hasAnyREDRoles = this.isUser || this.isManager || this.isAdmin || this.isUserAdmin;
|
||||
|
||||
constructor(user: KeycloakProfile | IUser, readonly roles: List, readonly id: string) {
|
||||
@ -23,6 +23,10 @@ export class User implements IUser, IListable {
|
||||
this.firstName = user.firstName;
|
||||
this.lastName = user.lastName;
|
||||
this.name = this.firstName && this.lastName ? `${this.firstName} ${this.lastName}` : this.username;
|
||||
this.searchKey = this.name + this.username + this.email;
|
||||
this.searchKey = `${this.name}${this.username}${this.email}`;
|
||||
}
|
||||
|
||||
hasRole(role: string): boolean {
|
||||
return this.roles.indexOf(role) >= 0;
|
||||
}
|
||||
}
|
||||
@ -52,13 +52,8 @@ export * from './rules';
|
||||
export * from './smtp-configuration';
|
||||
export * from './sectionGrid';
|
||||
export * from './sectionRectangle';
|
||||
export * from './updateMyProfileRequest';
|
||||
export * from './updateProfileRequest';
|
||||
export * from './updateDictionary';
|
||||
export * from './user';
|
||||
export * from './viewedPage';
|
||||
export * from './viewedPages';
|
||||
export * from './viewedPagesRequest';
|
||||
export * from './watermarkModel';
|
||||
export { DossierAttributeConfigType } from '../../../../red-domain/src/lib/dossier-attributes/types';
|
||||
export { DossierAttributeConfigTypes } from '../../../../red-domain/src/lib/dossier-attributes/types';
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
/**
|
||||
* API Documentation for Redaction Gateway
|
||||
* Description for redaction
|
||||
*
|
||||
* OpenAPI spec version: 1.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
export interface UpdateProfileRequest {
|
||||
/**
|
||||
* Email of user.
|
||||
*/
|
||||
email?: string;
|
||||
/**
|
||||
* First name of user.
|
||||
*/
|
||||
firstName?: string;
|
||||
/**
|
||||
* Last name of user.
|
||||
*/
|
||||
lastName?: string;
|
||||
/**
|
||||
* Roles.
|
||||
*/
|
||||
roles?: Array<string>;
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* API Documentation for Redaction Gateway
|
||||
* Description for redaction
|
||||
*
|
||||
* OpenAPI spec version: 1.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object containing information of user and roles.
|
||||
*/
|
||||
export interface IUser {
|
||||
/**
|
||||
* Email of user.
|
||||
*/
|
||||
readonly email: string;
|
||||
/**
|
||||
* First name of user.
|
||||
*/
|
||||
readonly firstName?: string;
|
||||
/**
|
||||
* Last name of user.
|
||||
*/
|
||||
readonly lastName?: string;
|
||||
/**
|
||||
* The list of RED_* roles.
|
||||
*/
|
||||
readonly roles?: readonly string[];
|
||||
/**
|
||||
* Id of user.
|
||||
*/
|
||||
readonly userId?: string;
|
||||
/**
|
||||
* Username for login.
|
||||
*/
|
||||
readonly username?: string;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user