From 9a5440eec56b10f28340b5ac1001b1158146ed5d Mon Sep 17 00:00:00 2001 From: vishnubansaltarento Date: Thu, 22 Aug 2024 16:38:46 +0530 Subject: [PATCH] update for mentorship changes --- .../avatar-photo/avatar-photo.component.html | 23 + .../avatar-photo/avatar-photo.component.scss | 200 +++++ .../avatar-photo/avatar-photo.component.ts | 94 ++ .../avatar-photo/avatar-photo.module.ts | 22 + .../routes/create-mdo/create-mdo.module.ts | 24 +- .../mentor-manage.component.html | 128 +++ .../mentor-manage.component.scss | 333 +++++++ .../mentor-manage.component.spec.ts | 25 + .../mentor-manage/mentor-manage.component.ts | 413 +++++++++ .../routes/users/users.component.html | 10 +- .../routes/users/users.component.ts | 19 +- .../create-mdo/search/search.component.html | 10 + .../create-mdo/search/search.component.scss | 71 ++ .../create-mdo/search/search.component.ts | 145 ++++ .../user-cards/user-card.component.html | 705 +++++++++++++++ .../user-cards/user-card.component.scss | 414 +++++++++ .../user-cards/user-card.component.ts | 818 ++++++++++++++++++ .../pipe-order-by/pipe-order-by.module.ts | 12 + .../pipes/pipe-order-by/pipe-order-by.pipe.ts | 10 + .../routes/home/services/loader.service.ts | 5 +- .../lib/routes/home/services/users.service.ts | 19 +- 21 files changed, 3485 insertions(+), 15 deletions(-) create mode 100644 project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.html create mode 100644 project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.scss create mode 100644 project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.ts create mode 100644 project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.module.ts create mode 100644 project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.html create mode 100644 project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.scss create mode 100644 project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.spec.ts create mode 100644 project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.ts create mode 100644 project/ws/app/src/lib/routes/create-mdo/search/search.component.html create mode 100644 project/ws/app/src/lib/routes/create-mdo/search/search.component.scss create mode 100644 project/ws/app/src/lib/routes/create-mdo/search/search.component.ts create mode 100644 project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.html create mode 100644 project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.scss create mode 100644 project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.ts create mode 100644 project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.module.ts create mode 100644 project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.pipe.ts diff --git a/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.html b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.html new file mode 100644 index 00000000..33785e5f --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.html @@ -0,0 +1,23 @@ +
+ + +
+ {{ userInitials }} +
+ + +
\ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.scss b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.scss new file mode 100644 index 00000000..2a469e43 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.scss @@ -0,0 +1,200 @@ +@import 'ws-common'; +@import 'ws-vars'; +@import 'ws-mixins'; + + +.circle-s { + border-radius: 10%; + width: 24px; + height: 24px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 10%; + width: 24px; + height: 24px; + } + + .initials { + color: #ffffff; + font-size: 10px; + line-height: 12px; + letter-spacing: 0.2625px; + } +} + +.circle-m { + border-radius: 10%; + width: 40px !important; + height: 40px !important; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 10%; + width: 40px; + height: 40px; + } + + .initials { + color: #ffffff; + font-size: 14px; + line-height: 19px; + letter-spacing: 0.2625px; + } +} + +.circle-l { + border-radius: 10%; + width: 80px; + height: 80px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 10%; + width: 80px; + height: 80px; + } + + .initials { + color: #ffffff; + font-size: 20px; + line-height: 19px; + letter-spacing: 0.2625px; + } +} + +.circle-xl { + border-radius: 10%; + width: 105px; + height: 105px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 10%; + width: 105px; + height: 105px; + } + + .initials { + color: #ffffff; + font-size: 20px; + line-height: 19px; + letter-spacing: 0.2625px; + } +} + +.circle-xxl { + border-radius: 10%; + width: 145px; + height: 145px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 10%; + width: 145px; + height: 145px; + } + + .initials { + color: #ffffff; + font-size: 20px; + line-height: 19px; + letter-spacing: 0.2625px; + } +} +.circle-l-xs{ + border-radius: 4px; + width: 24px; + height: 24px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 4px; + width: 24px; + height: 24px; + } + + .initials { + color: #ffffff; + font-size: $size-s; + line-height: $size-s; + letter-spacing: 0.2625px; + } +} +.circle-l-s { + border-radius: 4px; + width: 80px; + height: 80px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 4px; + width: 80px; + height: 80px; + } + + .initials { + color: #ffffff; + font-size: $size-l; + line-height: $size-l; + letter-spacing: 0.2625px; + } +} + +.circle-xl-s { + border-radius: 4px; + width: 152px; + height: 125px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 4px; + width: 152px; + height: 125px; + } + + .initials { + color: #ffffff; + font-size: $size-xl; + line-height: $size-xl; + letter-spacing: 0.2625px; + } +} + +.circle-xxl-s { + border-radius: 4px; + width: 276px; + height: 208px; + display: flex; + justify-content: center; + align-items: center; + + img { + border-radius: 4px; + width: 276px; + height: 208px; + } + + .initials { + color: #ffffff; + font-size: $size-xxl; + line-height: $size-xxl; + letter-spacing: 0.2625px; + } +} diff --git a/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.ts b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.ts new file mode 100644 index 00000000..1d2d4dee --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.component.ts @@ -0,0 +1,94 @@ +import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core' + +@Component({ + selector: 'ws-widget-avatar-photo', + templateUrl: './avatar-photo.component.html', + styleUrls: ['./avatar-photo.component.scss'], +}) +export class AvatarPhotoComponent implements OnInit, OnChanges { + @Input() datalen: any + + @Input() + public photoUrl!: string + + @Input() + public name!: string + @Input() public size = '' + @Input() randomColor = false + @Input() initials?: string + public showInitials = false + public circleColor!: string + random = Math.random().toString(36).slice(2) + + // public initials!: string + + private colors = [ + '#EB7181', // red + '#306933', // green + '#000000', // black + '#3670B2', // blue + '#4E9E87', + '#7E4C8D', + ] + + private randomcolors = [ + '#EB7181', // red + '#006400', // green + '#000000', // black + '#3670B2', // blue + '#4E9E87', + '#7E4C8D', + ] + + ngOnInit() { + if (!this.photoUrl) { + this.showInitials = true + if (!this.initials) { + this.createInititals() + } + if (this.datalen === 1) { + this.randomcolors = [ + '#006400', // green + ] + } + const randomIndex = Math.floor(Math.random() * Math.floor(this.colors.length)) + this.circleColor = this.colors[randomIndex] + if (this.randomColor) { + const randomIndex1 = Math.floor(Math.random() * Math.floor(this.randomcolors.length)) + this.circleColor = this.randomcolors[randomIndex1] + } + } + + } + ngOnChanges(change: SimpleChanges) { + if (change.name.currentValue !== change.name.previousValue && !change.name.firstChange) { + this.createInititals() + } + } + get userInitials() { + return this.initials + } + private createInititals(): void { + let initials = '' + const array = `${this.name} `.toString().split(' ') + if (array[0] !== 'undefined' && typeof array[1] !== 'undefined') { + initials += array[0].charAt(0) + initials += array[1].charAt(0) + } else { + for (let i = 0; i < this.name.length; i += 1) { + if (this.name.charAt(i) === ' ') { + continue + } + + if (this.name.charAt(i) === this.name.charAt(i)) { + initials += this.name.charAt(i) + + if (initials.length === 2) { + break + } + } + } + } + this.initials = initials.toUpperCase() + } +} diff --git a/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.module.ts b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.module.ts new file mode 100644 index 00000000..ccdc7525 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/avatar-photo/avatar-photo.module.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { RouterModule } from '@angular/router' +import { MatButtonModule, MatIconModule, MatMenuModule, MatRippleModule } from '@angular/material' +import { WidgetResolverModule } from '@sunbird-cb/resolver' +import { AvatarPhotoComponent } from './avatar-photo.component' + +@NgModule({ + declarations: [AvatarPhotoComponent], + imports: [ + CommonModule, + RouterModule, + MatButtonModule, + MatIconModule, + MatMenuModule, + MatRippleModule, + WidgetResolverModule, + ], + exports: [AvatarPhotoComponent], + entryComponents: [AvatarPhotoComponent], +}) +export class AvatarPhotoModule { } diff --git a/project/ws/app/src/lib/routes/create-mdo/create-mdo.module.ts b/project/ws/app/src/lib/routes/create-mdo/create-mdo.module.ts index d8223519..3337477f 100644 --- a/project/ws/app/src/lib/routes/create-mdo/create-mdo.module.ts +++ b/project/ws/app/src/lib/routes/create-mdo/create-mdo.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core' -import { CommonModule } from '@angular/common' +import { CommonModule, DatePipe } from '@angular/common' import { CreateMDORoutingModule } from './create-mdo-routing.module' import { HomeComponent } from './routes/home/home.component' import { BtnPageBackModuleAdmin, LeftMenuModule, GroupCheckboxModule, ScrollspyLeftMenuModule } from '@sunbird-cb/collection' @@ -7,22 +7,36 @@ import { HomeModule } from '../home/home.module' import { RouterModule } from '@angular/router' import { UsersComponent } from './routes/users/users.component' import { UsersService } from './services/users.service' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { + MatExpansionModule, MatSlideToggleModule, MatOptionModule, MatFormFieldModule, MatPaginatorModule, + MatSelectModule, MatChipsModule, MatDatepickerModule, MatAutocompleteModule, MatSidenavModule, MatIconModule, MatProgressSpinnerModule, + MatListModule, + MatRadioModule, + MatDialogModule, } from '@angular/material' import { MatCardModule } from '@angular/material/card' import { RolesAccessComponent } from '../access/routes/roles-access/roles-access.component' import { WidgetResolverModule } from '@sunbird-cb/resolver' import { UIAdminTableModule } from '../../head/ui-admin-table/ui-admin-table.module' +import { MentorManageComponent } from './mentor-manage/mentor-manage.component' +import { SearchComponent } from './search/search.component' +import { UserCardComponent } from './user-cards/user-card.component' +import { AvatarPhotoModule } from './avatar-photo/avatar-photo.module' +import { PipeOrderByModule } from '../home/pipes/pipe-order-by/pipe-order-by.module' +import { LoaderService } from '../home/services/loader.service' @NgModule({ - declarations: [HomeComponent, UsersComponent, RolesAccessComponent], + declarations: [HomeComponent, UsersComponent, RolesAccessComponent, MentorManageComponent, SearchComponent, UserCardComponent], imports: [CommonModule, CreateMDORoutingModule, BtnPageBackModuleAdmin, LeftMenuModule, WidgetResolverModule, MatSidenavModule, MatIconModule, MatProgressSpinnerModule, GroupCheckboxModule, HomeModule, RouterModule, UIAdminTableModule, MatCardModule, - ScrollspyLeftMenuModule], - exports: [UsersComponent, RolesAccessComponent], - providers: [UsersService], + ScrollspyLeftMenuModule, FormsModule, MatSelectModule, MatChipsModule, MatDatepickerModule, MatAutocompleteModule, + MatExpansionModule, MatSlideToggleModule, MatOptionModule, MatFormFieldModule, MatPaginatorModule, MatListModule, MatRadioModule, MatDialogModule, + ReactiveFormsModule, PipeOrderByModule, AvatarPhotoModule], + exports: [UsersComponent, RolesAccessComponent, MentorManageComponent, SearchComponent, UserCardComponent, AvatarPhotoModule], + providers: [UsersService, LoaderService, DatePipe], }) export class CreateMDOModule { } diff --git a/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.html b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.html new file mode 100644 index 00000000..786406c9 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.html @@ -0,0 +1,128 @@ +
+ + + + Users + + + +
+
Note:
+ +
+
+ error_outline +
+
+
+
+
+
+
+ play_circle +
+ Watch how it works +
+
+
+
+
+ + + + + + +
+ +
+ + +
+ +
+ +
+ + +
+ + + +
+
+
\ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.scss b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.scss new file mode 100644 index 00000000..f78c1235 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.scss @@ -0,0 +1,333 @@ +@import 'ws-common'; +@import 'ws-vars'; +@import 'ws-mixins'; + +.buton { + display: flex; + border: 1px solid; + flex: 1; + background: red; + align-content: center; + text-align: center; +} + +.flex-4 { + flex: 4; +} + +.mob { + @include breakpoint-xs { + bottom: 0 !important; + position: unset !important; + } +} + +.font-medium { + font-weight: 500 !important; +} + +.bottom-fix { + bottom: 1.5rem; + position: absolute; +} + +.view-more { + display: flex; + align-items: center; + text-align: center; + border: 1px solid; + + .icon { + $icon-size: 24px; + font-size: $icon-size; + width: $icon-size; + height: $icon-size; + border: 1px solid; + border-radius: 50%; + padding: 8px; + margin-bottom: 8px; + margin-right: $size-s; + } +} + +.view-all { + display: flex; + margin: 0 auto; + // border: 1px solid; + // font-weight: 500; + box-shadow: 0px 10px 30p; + /*#99999933*/ + border-radius: 8px; +} + + + +.text-box { + display: flex; + border: 1px solid; + flex: 3; + align-content: center; + text-align: center; +} + +.margin-fix { + @include breakpoint-xs { + margin: 0 $size-l 0 $size-l; + } + + @include breakpoint-s { + margin: 0 $size-l 0 $size-l; + } +} +::ng-deep.overlay { + display: none !important; +} +.overflow { + // @include breakpoint-xs { + // width: 10em; + // // outline: 1px solid #000; + // margin: 0 0 2em 0; + // text-overflow: ellipsis !important; + // /** + // * Required properties to achieve text-overflow + // */ + // white-space: nowrap; + // overflow: hidden; + // } + overflow: hidden; +} + +.custom { + + // height: 48px; + // max-height: 48px; + @include breakpoint-xs { + flex-direction: column; + } + + @include breakpoint-s { + flex-direction: column; + } +} + +.discuss-border { + border-radius: 4px; + /*.75rem;*/ + border: 1px solid #DEDFE0; + flex: 1; + // max-width: 500px; + /* border-color: #cecece;*/ +} + +.discuss .mat-form-field-wrapper { + padding-bottom: 0px; + + .mat-form-field-infix { + border-top-width: 5px !important; + padding: 0px; + padding-bottom: 5px; + } + +} + + +.flex-3 { + flex: 3; +} + +.filter { + .filter-option { + margin: $size-xs $size-m; + /* border-bottom: darkslateblue; */ + border-radius: 0; + border-bottom-width: 2px; + border-top-width: 0; + border-left-width: 0; + border-right-width: 0; + } +} + +.max-height-60 { + max-height: 60px; +} + +.height-48 { + max-height: 48px; +} + +.pagination { + justify-content: center; + flex-wrap: wrap; + margin-top: 0; + margin-bottom: 1rem; +} + +.pagination { + display: -ms-flexbox; + display: flex; + padding-left: 0; + list-style: none; + border-radius: .25rem; +} + +.page-item.active .page-link { + z-index: 1; + color: #fff; + background-color: #0074B6; + border-color: #0074B6; +} + +a:not([href]):not([tabindex]) { + color: inherit; + text-decoration: none; +} + +.page-link { + position: relative; + display: block; + padding: .5rem .75rem; + margin-left: -1px; + line-height: 1.25; + color: #0074B6; + background-color: #fff; + border: 1px solid #dee2e6; + + &.separator { + font-size: 20px; + } +} + +.page-item.disabled .page-link { + color: #6c757d; + pointer-events: none; + cursor: auto; + background-color: #fff; + border-color: #dee2e6; +} + +.container-balanced { + @extend %page-center; +} + +@media screen and (max-width: 1024px) { + .main-flex-box { + overflow: auto; +} +} + +.flex-3 { + flex: 3; +} + +.flex-update { + flex-direction: row; + + @include breakpoint-xs { + flex-direction: row; + } + + @include breakpoint-s { + flex-direction: row; + } +} + +.flex-custom { + display: flex; + + // @include breakpoint-xs { + flex-direction: column; + // } +} + +.flex-custom-m { + @include breakpoint-xs { + flex-direction: column; + } +} + +.example-header-image { + width: auto; + height: auto; +} + +.margin-0 { + margin: 0; +} + +.pad-4 { + padding: 0 0 0 $size-s; +} + +.mobile-margin { + @include breakpoint-xs { + margin-top: $size-s; + } +} + +.filter { + .filter-option { + margin: $size-s $size-s; + /* border-bottom: darkslateblue; */ + border-radius: 0; + border-bottom-width: 2px; + border-top-width: 0; + border-left-width: 0; + border-right-width: 0; + } + + .filter-option:first-child { + margin-left: 0; + } +} + +.recent-tabs { + box-shadow: none !important; + border-radius: unset; + background: inherit !important; +} + +.no-shadow { + box-shadow: none !important; +} + +.mat-card-title{ + // margin-left: -31px !important; + font-size: 20px !important; +} + +::ng-deep.mat-header-cell .mat-icon { + padding-left: 0.3em !important; +} + +.move-button{ + cursor: pointer; + height: auto; + border-radius: 4px; + border: none; + width: 60px; + // background: #0075b7!important; + // color: #fff!important; + //font-weight: 700; + font-family: Lato; + font-size: 14px; +} + +.reportsDemo { + .reportsDemoVideo { + width: 200px; + height: 140px; + border-radius: 5px; + background-color: #FDEAD5; + font-weight: 600; + pointer-events: all; + cursor: pointer; + + .video_icon { + font-size: 32px; + } + } + } +.no-border { + border: 0; + box-shadow: none !important; +} \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.spec.ts b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.spec.ts new file mode 100644 index 00000000..7949aaad --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing' + +import { MentorManageComponent } from './mentor-manage.component' + +describe('MentorManageComponent', () => { + let component: MentorManageComponent + let fixture: ComponentFixture + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MentorManageComponent], + }) + .compileComponents() + })) + + beforeEach(() => { + fixture = TestBed.createComponent(MentorManageComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.ts b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.ts new file mode 100644 index 00000000..27507b67 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/mentor-manage/mentor-manage.component.ts @@ -0,0 +1,413 @@ +import { Component, OnDestroy, OnInit } from '@angular/core' +import { MatDialog } from '@angular/material/dialog' +import { ActivatedRoute, Router } from '@angular/router' +/* tslint:disable */ +import _ from 'lodash' +/* tslint:enable */ +// import { environment } from 'src/environments/environment' +import { PageEvent } from '@angular/material' +import { EventService } from '@sunbird-cb/utils' +import { NsContent } from '@sunbird-cb/collection' +import { DomSanitizer, SafeHtml } from '@angular/platform-browser' +import { UsersService } from '../../../routes/home/services/users.service' +import { LoaderService } from '../../../routes/home/services/loader.service' +import { TelemetryEvents } from '../../../routes/home/routes/events/model/telemetry.event.model' +// import { ReportsVideoComponent } from '../reports-video/reports-video.component' + +@Component({ + selector: 'ws-app-mentor-manage', + templateUrl: './mentor-manage.component.html', + styleUrls: ['./mentor-manage.component.scss'], + /* tslint:disable */ + host: { class: 'flex flex-col' }, + /* tslint:enable */ +}) +export class MentorManageComponent implements OnInit, OnDestroy { + /* tslint:disable */ + Math: any + /* tslint:enable */ + currentFilter = 'verified' + // filterPath = '/app/home/users' + discussionList!: any + discussProfileData!: any + userDetails: any + location!: string | null + tabs: any + isLoading = false + // tabsData: NSProfileDataV2.IProfileTab[] + currentUser!: any + connectionRequests!: any[] + data: any = [] + usersData!: any + configSvc: any + mentorUsersData!: any[] + verifiedUsersData!: any[] + nonverifiedUsersData!: any[] + notmyuserUsersData!: any[] + + mentorUsersDataCount?: any | 0 + verifiedUsersDataCount?: any | 0 + content: NsContent.IContent = {} as NsContent.IContent + isMdoAdmin = false + + reportsNoteList: string[] = [] + + currentOffset = 0 + limit = 20 + pageIndex = 0 + searchQuery = '' + rootOrgId: any + currentUserStatus: any + filetrGroup = [] + filterDesignation = [] + filterRoles = [] + filterTags = [] + sortOrder: any + searchText = '' + filterFacets = [] + + constructor( + public dialog: MatDialog, + private route: ActivatedRoute, + private router: Router, + private events: EventService, + private loaderService: LoaderService, + private sanitizer: DomSanitizer, + // private configSvc: ConfigurationsService, + private usersService: UsersService + ) { + this.Math = Math + this.configSvc = this.route.parent && this.route.parent.snapshot.data.configService + this.currentUser = this.configSvc.userProfile && this.configSvc.userProfile.userId + this.currentUserStatus = this.configSvc.unMappedUser.profileDetails.profileStatus + + // this.usersData = _.get(this.route, 'snapshot.data.usersList.data') || {} + // this.filterData() + } + + ngOnDestroy() { + // if (this.tabs) { + // this.tabs.unsubscribe() + // } + // if (this.usersService.mentorList$) { + // this.usersService.mentorList$.unsubscribe() + // } + + } + ngOnInit() { + this.currentFilter = this.route.snapshot.params['tab'] || 'verified' + // this.rootOrgId = _.get(this.route.snapshot.parent, 'data.configService.unMappedUser.rootOrg.rootOrgId') + this.route.queryParams.subscribe(params => { + this.rootOrgId = params['roleId'] + // this.deparmentName = params['depatName'] + // this.currentDept = params['currentDept'] + }) + this.searchQuery = '' + if (this.configSvc.unMappedUser && this.configSvc.unMappedUser.roles) { + this.isMdoAdmin = this.configSvc.unMappedUser.roles.includes('MDO_ADMIN') + } + + this.usersService.mentorList$.subscribe(() => { + setTimeout(() => { + this.getAllVerifiedUsers('') + this.getMentorUsers('') + }, 1000) + + }) + // this.getNMUsers('') + this.getAllVerifiedUsers('') + this.getMentorUsers('') + // this.getNVUsers('') + + this.reportsNoteList = [ + `Easily create users individually or in bulk.`, + `Edit any user profile within your organization.`, + `Verified Users: Users with all their primary fields approved.`, + // tslint:disable-next-line: max-line-length + `Non-Verified Users: Users whose one or more primary fields are yet to be approved. You can help by reviewing and approving their requests.`, + `Not My User: Remove a user from your organization with a simple click.`, + ] + } + + sanitizeHtml(html: string): SafeHtml { + return this.sanitizer.bypassSecurityTrustHtml(html) + } + + openVideoPopup() { + // this.dialog.open(ReportsVideoComponent, { + // data: { + // videoLink: 'https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&mute=1', + // }, + // disableClose: true, + // width: '50%', + // height: '60%', + // panelClass: 'overflow-visable', + // }) + } + + filter(filter: string) { + this.currentFilter = filter + this.pageIndex = 0 + this.currentOffset = 0 + this.limit = 20 + this.searchQuery = '' + this.filterData(this.searchQuery) + } + + public tabTelemetry(label: string, index: number) { + const data: TelemetryEvents.ITelemetryTabData = { + label, + index, + } + this.events.handleTabTelemetry( + TelemetryEvents.EnumInteractSubTypes.USER_TAB, + data, + ) + } + + filterData(query: any) { + if (this.currentFilter === 'verified') { + this.getAllVerifiedUsers(query) + } else if (this.currentFilter === 'mentor') { + this.getMentorUsers(query) + } + } + + showEditUser(roles: any): boolean { + if (this.isMdoAdmin) { + if (roles && roles.length > 0) { + return true + // return (roles.includes('PUBLIC') && roles.length === 1) + } + // return false + } + return true + } + + // blockedUsers() { + // const blockedUsersData: any[] = [] + // if (this.usersData && this.usersData.content && this.usersData.content.length > 0) { + // _.filter(this.usersData.content, { isDeleted: false }).forEach((user: any) => { + // blockedUsersData.push({ + // fullname: user ? `${user.firstName}` : null, + // // fullname: user ? `${user.firstName} ${user.lastName}` : null, + // email: user.personalDetails && user.personalDetails.primaryEmail ? + // this.profileUtilSvc.emailTransform(user.personalDetails.primaryEmail) : this.profileUtilSvc.emailTransform(user.email), + // role: user.roles, + // userId: user.id, + // active: !user.isDeleted, + // blocked: user.blocked, + // roles: _.join(_.map(user.roleInfo, i => `
  • ${i}
  • `), ''), + // }) + // }) + // } + // return blockedUsersData + // } + + async getAllVerifiedUsers(query: any) { + this.loaderService.changeLoad.next(true) + let reqBody + const filtreq = { + rootOrgId: this.rootOrgId, + status: 1, + 'profileDetails.profileStatus': 'VERIFIED', + } + if (this.getFilterGroup(query) && this.getFilterGroup(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.group': this.getFilterGroup(query) }) + } + if (this.getFilterDesignation(query) && this.getFilterDesignation(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.designation': this.getFilterDesignation(query) }) + } + if (this.getFilterRoles(query) && this.getFilterRoles(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.role': this.getFilterRoles(query) }) + } + if (this.getFilterTags(query) && this.getFilterTags(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.tag': this.getFilterTags(query) }) + } + reqBody = { + request: { + filters: filtreq, + // facets: [ + // 'profileDetails.professionalDetails.group', + // 'profileDetails.professionalDetails.designation', + // 'profileDetails.additionalDetails.tag', + // ], + fields: [ + 'rootOrgId', + 'profileDetails', + 'userId', + 'roles', + ], + limit: this.limit, + offset: this.pageIndex, + query: this.getSearchText(query), + sort_by: this.getSortOrder(query), + }, + } + this.usersService.getAllUsersV3(reqBody).subscribe((data: any) => { + const allusersData = data + this.verifiedUsersData = allusersData.content + this.verifiedUsersDataCount = allusersData.count + this.filterFacets = allusersData.facets ? allusersData.facets : [] + + // const i = this.activeUsersData.findIndex((wf: any) => wf.userId === this.currentUser) + // if (i > -1) { + // this.activeUsersData.splice(i, 1) + // allusersData.count = allusersData.count - 1 + // } + + // if (this.notmyuserUsersDataCount && allusersData.count > this.notmyuserUsersDataCount) { + // this.activeUsersDataCount = allusersData.count - this.notmyuserUsersDataCount + // } + }) + } + async getMentorUsers(query: any) { + let reqBody + this.loaderService.changeLoad.next(true) + const filtreq = { + rootOrgId: this.rootOrgId, + 'roles.role': 'MENTOR', + 'profileDetails.profileStatus': 'VERIFIED', + } + if (this.getFilterGroup(query) && this.getFilterGroup(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.group': this.getFilterGroup(query) }) + } + if (this.getFilterDesignation(query) && this.getFilterDesignation(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.designation': this.getFilterDesignation(query) }) + } + if (this.getFilterRoles(query) && this.getFilterRoles(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.role': this.getFilterRoles(query) }) + } + if (this.getFilterTags(query) && this.getFilterTags(query) !== 'undefind') { + Object.assign(filtreq, { 'profileDetails.professionalDetails.tag': this.getFilterTags(query) }) + } + + reqBody = { + request: { + filters: filtreq, + // facets: [ + // 'profileDetails.professionalDetails.group', + // 'profileDetails.professionalDetails.designation', + // 'profileDetails.additionalDetails.tag', + // ], + fields: [ + 'rootOrgId', + 'profileDetails', + 'userId', + 'roles', + ], + limit: this.limit, + offset: this.pageIndex, + query: this.getSearchText(query), + sort_by: this.getSortOrder(query), + }, + } + this.usersService.getAllUsersV3(reqBody).subscribe((data: any) => { + const allusersData = data + this.mentorUsersData = allusersData.content + this.mentorUsersDataCount = allusersData.count + this.filterFacets = allusersData.facets ? allusersData.facets : [] + + // if (this.currentUserStatus === 'VERIFIED') { + // const i = this.verifiedUsersData.findIndex((wf: any) => wf.userId === this.currentUser) + // if (i > -1) { + // this.verifiedUsersData.splice(i, 1) + // this.verifiedUsersDataCount = this.verifiedUsersDataCount ? this.verifiedUsersDataCount - 1 : this.verifiedUsersDataCount + // } + // } + }) + } + + getFilterGroup(query: any) { + if (query && query.filters && (query.filters.group).length > 0) { + return query.filters.group + } + } + getFilterDesignation(query: any) { + if (query && query.filters && (query.filters.designation).length > 0) { + return query.filters.designation + } + } + getFilterRoles(query: any) { + if (query && query.filters && (query.filters.roles).length > 0) { + return query.filters.roles + } + } + getFilterTags(query: any) { + if (query && query.filters && (query.filters.tags.length > 0)) { + return query.filters.tags + } + } + getSearchText(query: any) { + return this.searchText = query && query.searchText ? query.searchText : '' + } + getSortOrder(query: any) { + let sortBy + if (query && query.sortOrder) { + sortBy = query.sortOrder + if (sortBy === 'alphabetical') { + return { firstName: 'asc' } + } + if (sortBy === 'oldest') { + return { createdDate: 'desc' } + } + if (sortBy === 'newest') { + return { createdDate: 'asc' } + } + } + return { firstName: 'asc' } + } + + clickHandler(event: any) { + switch (event.type) { + case 'createUser': + this.onCreateClick() + break + case 'upload': + this.onUploadClick() + break + } + } + + onCreateClick() { + this.router.navigate([`/app/users/create-user`]) + this.events.raiseInteractTelemetry( + { + type: TelemetryEvents.EnumInteractTypes.CLICK, + subType: TelemetryEvents.EnumInteractSubTypes.CREATE_BTN, + id: 'create-user-btn', + }, + {} + ) + } + + onUploadClick() { + this.filter('upload') + } + + onRoleClick(user: any) { + this.router.navigate([`/app/users/${user.userId}/details`]) + this.events.raiseInteractTelemetry( + { + type: TelemetryEvents.EnumInteractTypes.CLICK, + subType: TelemetryEvents.EnumInteractSubTypes.CARD_CONTENT, + id: TelemetryEvents.EnumIdtype.USER_ROW, + }, + { + id: user.userId, + type: TelemetryEvents.EnumIdtype.USER, + } + ) + } + + onEnterkySearch(enterValue: any) { + this.searchQuery = enterValue + this.filterData(this.searchQuery) + } + + onPaginateChange(event: PageEvent) { + this.pageIndex = event.pageIndex + this.limit = event.pageSize + this.filterData(this.searchQuery) + } +} diff --git a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html index d015636b..4fb2306a 100644 --- a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html +++ b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.html @@ -8,11 +8,13 @@
    - + - + +
    \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts index 9da6c848..884f7933 100644 --- a/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts +++ b/project/ws/app/src/lib/routes/create-mdo/routes/users/users.component.ts @@ -44,10 +44,10 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { } constructor(private usersSvc: UsersService, private router: Router, - private route: ActivatedRoute, - private profile: ProfileV2Service, - private profileUtilSvc: ProfileV2UtillService, - private usersService: UsersService) { + private route: ActivatedRoute, + private profile: ProfileV2Service, + private profileUtilSvc: ProfileV2UtillService, + private usersService: UsersService) { } ngOnInit() { this.tabsData = [ @@ -62,6 +62,12 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { key: 'rolesandaccess', render: true, enabled: true, + }, + { + name: 'Mentor Management', + key: 'mentormanage', + render: true, + enabled: true, }] const url = this.router.url.split('/') @@ -112,6 +118,8 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { this.currentTab = id if (this.currentTab === 'users') { this.getAllActiveUsersByDepartmentId(this.id) + } else if (this.currentTab === 'mentormanage') { + this.getMentorManage() } const el = document.getElementById(id) if (el != null) { @@ -247,4 +255,7 @@ export class UsersComponent implements OnInit, AfterViewInit, OnDestroy { }, state: { userData: event.row, updateButton: true }, }) } + getMentorManage() { + + } } diff --git a/project/ws/app/src/lib/routes/create-mdo/search/search.component.html b/project/ws/app/src/lib/routes/create-mdo/search/search.component.html new file mode 100644 index 00000000..716b27a4 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/search/search.component.html @@ -0,0 +1,10 @@ +
    + +
    \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/search/search.component.scss b/project/ws/app/src/lib/routes/create-mdo/search/search.component.scss new file mode 100644 index 00000000..c59c2a12 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/search/search.component.scss @@ -0,0 +1,71 @@ +.search { + width: 34%; + .rsearch { + position: relative; + } + + .search-icon { + position: absolute; + top: 15px; + font-size: 20px; + left: 10px; + } + + .sinput { + border-radius: 4px; + border: 1px solid #d5d0d0; + padding: 15px 36px; + font: 400 14px Lato; + } +} + +.filter-section span { + color: rgba(0, 0, 0, 0.87); + font-size: 16px; + font-weight: 600; +} +.apply-filter { + border: 1px solid #cccc; + padding: 4px 26px; +} + +.search-btn { + background: #1b4ca1 !important; + color: white !important; + font-family: 'Lato'; + font-weight: 700; + font-size: 14px; + border-radius: 4px; + min-width: 138px; +} + +.btn-disabled { + background: rgba(0, 0, 0, 0.16) !important; +} +.mat-button[disabled] { + opacity: 0.6 !important; +} + +.disable { + opacity: 0.3; + pointer-events: none; + cursor: none; +} + +.orangeicon-dialog { + color: #e99e38; + vertical-align: middle; + height: 45px !important; + font-size: 36px; +} + +.infoicon { + font-size: 18px !important; + width: 20px; + height: 20px; + vertical-align: bottom; + margin-left: 5px; +} +.blue-text { + color:#1B4CA1; +} \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/search/search.component.ts b/project/ws/app/src/lib/routes/create-mdo/search/search.component.ts new file mode 100644 index 00000000..6af2c314 --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/search/search.component.ts @@ -0,0 +1,145 @@ +import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core' +// import { ActivatedRoute } from '@angular/router' +/* tslint:disable */ +import _ from 'lodash' +/* tslint:enable */ +import { UsersService } from '../../../routes/home/services/users.service' +import { LoaderService } from '../../../routes/home/services/loader.service' +import { MatDialog } from '@angular/material' +@Component({ + selector: 'ws-app-searchuser', + templateUrl: './search.component.html', + styleUrls: ['./search.component.scss'], +}) +export class SearchComponent implements OnInit { + @Input() from: any = '' + @Input() isApprovals: any + @Input() showApproveALL: any + @Input() showBulkUpdate: any + @Input() disableApproveALL: any + @Input() currentFilter: any + @Input() filterFacetsData: any + @Input() forMentor: any = false + @Output() handleApiData = new EventEmitter() + @Output() handleapproveAll = new EventEmitter() + searchText = '' + filterVisibilityFlag = false + clearFilter = false + designationList: any[] = [] + pageIndex = 0 + pageSize = 20 + isContentLive = false + filtersList: any + sortOrder = '' + constructor( + // private route: ActivatedRoute, + private dialog: MatDialog, + private usersSvc: UsersService, + private loadingService: LoaderService + ) { } + + ngOnInit() { + // this.usersSvc.handleContentPageChange.subscribe((pageData: any) => { + // if (pageData) { + // this.pageIndex = pageData.pageIndex + // this.pageSize = pageData.pageSize + // // this.getContent() + // } + // }) + } + + hideFilter(event: any) { + switch (event.filter) { + case 'applyFilter': + this.applyFilters(event) + break + case 'clearFilter': + this.applyFilters(event) + break + case 'closeFilter': + break + } + + this.filterVisibilityFlag = false + + // if (this.document.getElementById('top-nav-bar')) { + // const ele: any = this.document.getElementById('top-nav-bar') + // ele.style.zIndex = '1000' + // } + } + + getContent(applyFilterObj?: any) { + this.loadingService.changeLoaderState(true) + if (applyFilterObj && Object.keys(applyFilterObj).length) { + this.searchText = '' + } + if (this.searchText) { + // this.tpdsSvc.clearFilter.next({ from: 'content', status: true }) + /* tslint:disable */ + applyFilterObj = {} + /* tslint:enable */ + } + const filterObj = { + request: { + filters: {}, + offset: this.pageIndex, + limit: this.pageSize, + query: (this.searchText) ? this.searchText : '', + sort_by: { lastUpdatedOn: 'desc' }, + fields: [], + }, + } + this.usersSvc.getAllValidUsers(filterObj).subscribe((res: any) => { + if (res) { + this.handleApiData.emit(true) + this.loadingService.changeLoaderState(false) + } + }) + } + + searchData(event: any) { + this.searchText = event.target.value + this.emitSearchRequest() + } + + sortData(sortOrder: string) { + this.sortOrder = sortOrder + this.emitSearchRequest() + } + + emitSearchRequest() { + const filterKeys = { + searchText: this.searchText, + filters: this.filtersList, + sortOrder: this.sortOrder, + } + this.handleApiData.emit(filterKeys) + } + + applyFilters(event: any) { + this.filtersList = event.filtersList + this.emitSearchRequest() + } + + resetPageIndex() { + this.pageIndex = 0 + this.pageSize = 20 + } + + approveAll() { + this.handleapproveAll.emit() + } + + confirmApproval(template: any) { + const dialog = this.dialog.open(template, { + width: '500px', + }) + dialog.afterClosed().subscribe((v: any) => { + if (v) { + this.handleapproveAll.emit() + } + }) + } + + sort() { } +} diff --git a/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.html b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.html new file mode 100644 index 00000000..00d9670c --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.html @@ -0,0 +1,705 @@ + +
    + + + +
    +
    + + + +
    +
    +
    +
    + + {{user?.profileDetails?.personalDetails?.firstname}} + + + {{user?.firstName}} + + +
    +
    + Verified + check_circle + + Non-verified + check_circle + Not my user + error + +
    +
    + Mentor + +
    +
    +
    {{user?.profileDetails && + user?.profileDetails?.professionalDetails + && + user?.profileDetails?.professionalDetails[0]?.designation ? + user?.profileDetails?.professionalDetails[0]?.designation : '-'}}
    +
    + Marked on: {{user?.profileDetails?.profileStatusUpdatedOn || ' NA'}}
    + +
    +
    + +
    +
    Mentor
    +
    +
    No  Yes +
    +
    +
    +
    + +
    +
    +
    + Primary Details info_outline +

    + Mark this user + as + non-verified +

    +

    + This is my + user +

    +
    +
    + + + + + {{g}} + + + + Group is mandatory + + + + check_circle + + cancel +
    +
    + + + + + {{designation?.name}} + + Other + + + + + check_circle + + cancel +
    +
    +
    +
    +
    + Other Details info_outline + +
    +
    + + + + + Please enter a valid employee Id + + +
    + +
    + + + + + Email is mandatory + + + Please enter a valid email + + +
    + +
    + + + +
    + +91 +
    + + + + + Please enter your mobile number + + + Please enter a valid 10 digit mobile number + + + + +
    +
    +
    +
    + + + + + + + + +
    + +
    + + + + + + + + + {{ option.name }} + + +
    + +
    + + + + + {{gender}} + + + + +
    +
    + +
    +
    + + + + + +
    + +
    + + + + +
    + +
    + + + + + {{ctg}} + + + + +
    +
    + +
    +
    + + +
    +
    + +
    +
    +
    + +
    +

    + + Only space and alphabets are supported + +

    + + + {{ tag }} + cancel + + + +
    +
    + +
    +
    + +
    + + + {{role.roleName}} + + +
    +
    + +
    + +
    +
      +
    • {{t}} +
    • +
    +
    +

    -

    +
    +
    + +
    + + +
    +
    +
    +
    + +
    + +
    +
    + Primary Details info_outline +
    +
    +
    + +

    {{user.profileDetails && user.profileDetails.professionalDetails && + user.profileDetails.professionalDetails[0].group ? + user.profileDetails.professionalDetails[0].group : '-'}} + + check_circle + + cancel +

    +
    +
    + +

    {{user.profileDetails && user.profileDetails.professionalDetails && + user.profileDetails.professionalDetails[0].designation ? + user.profileDetails.professionalDetails[0].designation : '-'}} + + check_circle + + cancel +

    +
    +
    +
    +
    +
    +
    + Other Details info_outline +
    + +
    +
    + +

    {{user.profileDetails && user.profileDetails.employmentDetails && + user.profileDetails.employmentDetails.employeeCode ? + user.profileDetails.employmentDetails.employeeCode : '-'}}

    +
    + +
    + +

    {{user.profileDetails && user.profileDetails.personalDetails ? + user.profileDetails.personalDetails.primaryEmail : '-'}}

    +
    + +
    + +

    +91 {{user.profileDetails && user.profileDetails.personalDetails ? + user.profileDetails.personalDetails.mobile : '-'}}

    +
    + +
    + +

    {{user.profileDetails && user.profileDetails.personalDetails && + user.profileDetails.personalDetails.gender ? + user.profileDetails.personalDetails.gender : '-'}}

    +
    +
    +
    +
    + +

    {{user.profileDetails && user.profileDetails.personalDetails && user.profileDetails.personalDetails.dob + ? user.profileDetails.personalDetails.dob + : '-'}}

    +
    + +
    + +

    {{user.profileDetails && user.profileDetails.personalDetails && + user.profileDetails.personalDetails.domicileMedium ? + user.profileDetails.personalDetails.domicileMedium : '-'}}

    +
    + +
    + +

    {{user.profileDetails && user.profileDetails.personalDetails && + user.profileDetails.personalDetails.category ? + user.profileDetails.personalDetails.category : '-'}}

    +
    + + +
    +
    +
    + +

    {{user.profileDetails && user.profileDetails.employmentDetails && + user.profileDetails.employmentDetails.pinCode ? + user.profileDetails.employmentDetails.pinCode : '-'}}

    +
    + +
    + +

    {{user.profileDetails && user.profileDetails.additionalProperties && + user.profileDetails.additionalProperties.externalSystemId ? + user.profileDetails.additionalProperties.externalSystemId : '-'}}

    +
    + +
    + +
    +
      +
    • {{t}}
    • +
    +
    +

    -

    +
    +
    +
    +
    + +
    +
      +
    • {{t}} +
    • +
    +
    +

    -

    +
    +
    +
    +
    +
    +
    + +
    +

    No users found

    +
    +
    + +
    + +
    + + +
    +

    Reason for rejection

    + + + + + + + + + +
    +
    + + +
    +

    Reason for rejection + edit_square +

    + +

    {{comment}}

    + + + +
    + + + + +
    +
    + + +
    + error_outline +
    + Are you sure you want to re-assign this user to your MDO? +
    +
    Note: The user will be shifted to non-verified tab
    +
    + + +
    +
    +
    + + +
    + error_outline +
    + Are you sure you want to update? +
    +
    + + +
    +
    +
    + + +
    + error_outline +
    + Are you sure you want to save changes? +
    +
    + + +
    +
    +
    + + +
    + error_outline +
    + Are you sure you want to cancel this transfer request? +
    +
    + + +
    +
    +
    + + +
    + error_outline +
    + {{memberAlertMessage}} +
    +
    + + +
    +
    +
    \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.scss b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.scss new file mode 100644 index 00000000..f218fc4a --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.scss @@ -0,0 +1,414 @@ +@import 'ws-common'; +@import 'ws-vars'; +@import 'ws-mixins'; + +.user-card.mat-expansion-panel { + margin-bottom: 1em !important; + box-shadow: none !important; + border: 1px solid #d5d5d5; + border-radius: 5px !important; + + .mat-expansion-panel-header { + padding: 10px 24px !important; + } + + .mat-content{ + display: block !important; + } + .width82 { + width: 82%; + } + .width88 { + width: 88%; + } + + .initialcircle { + vertical-align: text-bottom; + span { + background-color: #000000; + color: #ffffff; + display: block; + border-radius: 50%; + width: 40px; + height: 40px; + text-align: center; + line-height: 2.5; + } + } + + .status-label { + color: #fff; + font: 500 10px / 12px Lato; + padding: 4px 2px 4px 8px; + border-radius: 12px; + + .mat-icon { + width: 16px; + height: 16px; + vertical-align: middle; + font-size: 13px; + margin-left: 4px; + } + } + + .status-label.verified { + background: #1D8923; + } + .status-label.nonverified { + background: #D13924; + } + .status-label.notmyuser { + background: #e99e38; + } + + .verified-icon { + color: #1D8923; + vertical-align: sub; + } + .nonverified-icon { + color: #D13924; + vertical-align: sub; + } + .notmyuser-icon { + color: #e99e38; + vertical-align: sub; + } + + .button { + color: #1B4CA1; + border: 1px solid #1B4CA1; + padding: 2px 10px; + border-radius: 6px; + + .mat-icon { + font-size: 20px; + width: 20px; + height: 20px; + vertical-align: sub; + } + } +} + +::ng-deep .mat-expansion-panel-header { + min-height: 48px !important; + height: inherit !important; +} + +::ng-deep .mat-expansion-panel-header .mat-expansion-indicator::after { + content: "+"; + border: 0; + transform: none; + font-size: 24px !important; + padding: 6px !important; + } + +::ng-deep .mat-expansion-panel-header.mat-expanded .mat-expansion-indicator::after { + content: "-"; + font-size: 24px !important; + padding: 6px !important; +} +::ng-deep .initialcircle .circle-l { + border-radius: 50% !important; + width: 60px !important; + height: 60px !important; +} +::ng-deep .panel-body { + padding: 10px 0; + + .mat-radio-container { + width: 14px !important; + height: 14px !important; + } + .mat-radio-outer-circle, .mat-radio-inner-circle { + height: 16px !important; + width: 16px !important; + } +} +.mat-expanded { + border: 1px solid #1B4CA1 !important; +} + +.appr-text-field { + width: 80%; + border: 1px solid #DDDDDD; + border-radius: 4px; + padding: 9px; + font-family: 'Lato'; + font-size: 14px; + font-weight: 400; + font: 400 14px Lato; +} + +.form-label { + width: 100%; + padding-bottom: 10px; + margin-bottom: 0; + color: #000000; + display: block; + font: 600 13px/16px Lato; +} + +.view-text-label { + width: 100%; + padding-bottom: 10px; + margin-bottom: 0; + color: rgba(0, 0, 0, 0.6); + display: block; + font: 500 13px Lato; +} + +.infoicon { + font-size: 18px !important; + width: 20px; + height: 20px; + vertical-align: bottom; + margin-left: 5px; +} + +::ng-deep.mat-figure { + display: block !important; +} + +.roleslist { + padding-left: 0 !important; + margin: 0 !important; + li { + float: left; + margin: 0 16px 4px; + } +} + +.tagslist { + padding-left: 0 !important; + list-style-type: none !important; + margin: 0 !important; + li { + float: left; + margin: 0 4px 4px; + background: #e0e0e0; + padding: 2px 10px; + border-radius: 14px; + } +} + +.username { + width: 88%; +} + +// mat-selection-list.roles-list { +// // display: inline-flex; +// } + +label { + display: block; +} +.btn-success:disabled, +.btn-success[disabled] { + opacity: 0.6; +} + +.btn-danger { + height: 30px; + width: 30px +} + +.text_hint { + margin-top: -20px; + color: rgba($color: #000000, $alpha: .4); +} + +.left-input-div { + width: auto; + display: inline-flex; +} +.right-input-div { + // width: 14%; + display: inline-flex; + vertical-align: top; +} + +.btn-add-activity { + background: no-repeat padding-box #0074b6 !important; + border-radius: 4px; + box-sizing: border-box; + margin: 4px 16px 0 16px !important; + line-height: 28px; + height: 36px; +} + +.mat-chip-list { + margin-top: 2px; + display: flex; +} + +.roles-list { + list-style: none; + padding: 0; +} +::ng-deep .profile-box { + .mobile-country-code .mat-select-value { + text-overflow: inherit !important; + } + + .mat-select-arrow-wrapper { + transform: translateY(0%) !important; + } + + .mat-form-field-appearance-outline .mat-form-field-infix { + padding: 0 0 0.5em 0 !important; + width: 15em !important; + } + + .mat-form-field-disabled { + cursor: not-allowed !important; + pointer-events: none !important; + opacity: 0.8 !important; + } + .mat-list-base .mat-list-option { + border: 1px solid #dedede !important; + border-radius: 4px !important; + margin-right: 12px; + height: auto; + padding: 0.7em 0; + display: ruby; + height: 50px; + } + + .mat-form-field-disabled .mat-form-field-outline { + background-color: #ededed; + } + + .custominfo { + font-size: 18px; + height: 20px; + width: 20px; + vertical-align: middle; + margin-left: 1px; + } + + .customdob { + width: 16.5em !important; + .mat-form-field-flex { + height: 45px !important; + } + .mat-form-field-infix { + line-height: 0 !important; + } + } + .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb { + background-color: rgba(29, 137, 35) !important; + } + .mat-slide-toggle.mat-checked .mat-slide-toggle-bar { + background-color: rgba(29, 137, 35, 0.54) !important; + } +} + +// ::ng-deep .rejection-modal { +// .mat-dialog-container { +// padding: 0px !important; +// } +// } +.orangeicon { + color: #e99e38; + vertical-align: middle; + height: 30px !important; +} +.orangeicon-dialog { + color: #e99e38; + vertical-align: middle; + height: 45px !important; + font-size: 36px; +} +.editreasonicon { + vertical-align: middle; + color: #666 !important; +} +::ng-deep .mat-dialog-container { + //padding: 0 !important; + overflow: unset !important; +} + +.rejectdialog { + margin: -24px; + .mat-dialog-title { + background: #1b4ca1; + color: #fff; + padding: 1em 1em; + font: 500 18px/24px Montserrat !important; + } + .mat-dialog-content { + margin: 0 !important; + padding: 0 24px !important; + } + .mat-dialog-actions { + padding: 10px 24px !important; + margin-bottom: 0 !important; + } +} + +.blue-text { + color:#1B4CA1; +} + +.word-wrap { + word-wrap: break-word; +} + +.userName { + max-width: calc(100% - 100px); +} +.country-code { + padding: 6px 0; + text-align: center; + width: 46px; + height: 26px; + display: inline-block; + position: relative; + top: -2px; + border-radius: 4px; + border: 1px solid rgba(0, 0, 0, .14); + font-family: Lato; +} + +.black-color { + color: #212529; +} + +.gray-color { + color: color(0,0,0,0.6); +} + +.mentor-status-label { + color: #fff; + font-weight: 400 ; + font-size:14px ; + font-family:Lato; + padding: 3px 8px 3px 8px; + border-radius: 4px; +} + +.mentor-status-label.mentor { + background-color: #1B4CA1; +} + +.cancelbtn { + background-color: #fff !important; + border-radius: 4px; + margin-right: 16px; + color: #1B4CA1 !important; + width: 87px; + height: 47px; + border: 1px solid #1B4CA1; + cursor: pointer; +} + +.successbtn { + background-color: #1B4CA1 !important; + border-radius: 4px; + margin-right: 16px; + color: #fff !important; + width: 87px; + height: 47px; + border: 1px solid #1B4CA1; + cursor: pointer; +} \ No newline at end of file diff --git a/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.ts b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.ts new file mode 100644 index 00000000..ac8eb83a --- /dev/null +++ b/project/ws/app/src/lib/routes/create-mdo/user-cards/user-card.component.ts @@ -0,0 +1,818 @@ +import { + AfterViewChecked, + ChangeDetectorRef, + Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, + QueryList, TemplateRef, ViewChild, ViewChildren, +} from '@angular/core' +import { FormGroup, FormControl, Validators } from '@angular/forms' +import { UsersService } from '../../../routes/home/services/users.service' +import { + MatChipInputEvent, MatDialog, + MatExpansionPanel, MatPaginator, MatSnackBar, PageEvent, +} from '@angular/material' +import { COMMA, ENTER } from '@angular/cdk/keycodes' +// tslint:disable-next-line +import _ from 'lodash' +import { RolesService } from '../../../routes/home/services/roles.service' +import { ActivatedRoute } from '@angular/router' +import { Observable, Subscription } from 'rxjs' +import { debounceTime, distinctUntilChanged, map, startWith } from 'rxjs/operators' +// import { OtpService } from '../../../users/services/otp.service' +// import { ConfigurationsService } from '@sunbird-cb/utils' +// import { RejectionPopupComponent } from '../rejection-popup/rejection-popup.component' +import { EventService } from '@sunbird-cb/utils' +import { TelemetryEvents } from '../../../routes/home/routes/events/model/telemetry.event.model' +// import { DatePipe } from '@angular/common' + +// const EMAIL_PATTERN = /^[a-zA-Z0-9](\.?[a-zA-Z0-9_]+)*@[a-zA-Z0-9]*.[a-zA-Z]{2,}$/ +const EMAIL_PATTERN = /^[a-zA-Z0-9]+[a-zA-Z0-9._-]*[a-zA-Z0-9]+@[a-zA-Z0-9]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,4}$/ + +@Component({ + selector: 'ws-widget-user-card', + templateUrl: './user-card.component.html', + styleUrls: ['./user-card.component.scss'], + providers: [ + + ], +}) +export class UserCardComponent implements OnInit, OnChanges, AfterViewChecked { + @Input() userId: any + @Input() tableData: any + @Input() usersData: any + @Input() totalRecords: any + @Input() tabChangeIndex: any + @Input() currentFilter: any + @Input() isApprovals: any + @Input() handleApiData: any + @Input() activeTab: any + @Input() forMentor = false + @Output() paginationData = new EventEmitter() + @Output() searchByEnterKey = new EventEmitter() + @Output() disableButton = new EventEmitter() + @Output() updateList = new EventEmitter() + @ViewChildren(MatExpansionPanel) panels!: QueryList + + @ViewChild('rejectDialog', { static: false }) + rejectDialog!: TemplateRef + @ViewChild('updaterejectDialog', { static: false }) + updaterejectDialog!: TemplateRef + + @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator | any + + @ViewChild('toggleElement', { static: true }) ref!: ElementRef + + startIndex = 0 + lastIndex = 20 + pageSize = 20 + + // userStatus: any + rolesList: any = [] + rolesObject: any = [] + uniqueRoles: any = [] + public userRoles: Set = new Set() + orguserRoles: any = [] + isMdoAdmin = false + isMdoLeader = false + isBoth = false + updateUserDataForm: FormGroup + approveUserDataForm: FormGroup + designationsMeta: any = [] + groupsList: any = [] + selectedtags: any[] = [] + reqbody: any + isTagsEdited = false + separatorKeysCodes: number[] = [ENTER, COMMA] + namePatern = '^[a-zA-Z ]*$' + orgTypeList: any = [] + // public countryCodes: string[] = [] + masterLanguages: Observable | undefined + masterLanguagesEntries: any + genderList = ['Male', 'Female', 'Others'] + categoryList = ['General', 'OBC', 'SC', 'ST'] + // needApprovalList: any[] = [] + profileData: any[] = [] + userwfData!: any + comment = '' + listupdateFieldValues: any[] = [] + actionList: any = [] + + phoneNumberPattern = '^((\\+91-?)|0)?[0-9]{10}$' + emailRegix = `^[\\w\-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$` + pincodePattern = '(^[0-9]{6}$)' + yearPattern = '(^[0-9]{4}$)' + empIDPattern = `^[A-Za-z0-9]+$` + + userGroup: any + + otpSend = false + otpVerified = false + timerSubscription: Subscription | null = null + timeLeftforOTP = 0 + isMobileVerified = false + disableVerifyBtn = false + qpParam: any + department: any + approvalData: any + showeditText = false + today = new Date() + memberAlertMessage = '' + currentUserRole = '' + checked = false + isSPVAdmin = false + constructor(private usersSvc: UsersService, private roleservice: RolesService, + private dialog: MatDialog, + private route: ActivatedRoute, + private snackBar: MatSnackBar, + private events: EventService, + // private datePipe: DatePipe, + private cdr: ChangeDetectorRef) { + this.updateUserDataForm = new FormGroup({ + designation: new FormControl('', []), + group: new FormControl('', [Validators.required]), + employeeID: new FormControl('', [Validators.pattern(this.empIDPattern)]), + ehrmsID: new FormControl({ value: '', disabled: true }, []), + dob: new FormControl('', []), + primaryEmail: new FormControl('', [Validators.required, Validators.email, Validators.pattern(EMAIL_PATTERN)]), + // countryCode: new FormControl('+91', []), + mobile: new FormControl('', [Validators.required, Validators.pattern(this.phoneNumberPattern)]), + tags: new FormControl('', [Validators.pattern(this.namePatern)]), + roles: new FormControl('', [Validators.required]), + domicileMedium: new FormControl('', []), + gender: new FormControl('', []), + category: new FormControl('', []), + pincode: new FormControl('', []), + }) + + this.approveUserDataForm = new FormGroup({ + approveDesignation: new FormControl('', []), + approveGroup: new FormControl('', []), + }) + + const fullProfile = _.get(this.route, 'snapshot.parent.data.configService.userRoles') + // this.department = fullProfile.unMappedUser.rootOrgId + if (fullProfile) { + this.isSPVAdmin = fullProfile.has('spv_admin') + } + + if (this.usersData && this.usersData.length > 0) { + this.usersData = _.orderBy(this.usersData, item => item.firstName.toUpperCase(), ['asc']) + + // formatting profileStatusUpdatedOn value + this.usersData.forEach((u: any) => { + if (u.profileDetails.profileStatusUpdatedOn) { + const val = u.profileDetails.profileStatusUpdatedOn.split(' ') + u.profileDetails.profileStatusUpdatedOn = val[0] + } + }) + } + } + + enableUpdateButton(appData: any): boolean { + let enableBtn = true + if (appData.needApprovalList) { + appData.needApprovalList.forEach((field: any) => { + if (field.label === 'Group' && this.approveUserDataForm.controls.approveGroup.invalid) { + enableBtn = false + } + if (field.label === 'Designation' && this.approveUserDataForm.controls.approveDesignation.invalid) { + enableBtn = false + } + }) + } + return enableBtn + } + + ngOnInit() { + this.init() + } + + ngOnChanges() { + if (this.usersData) { + this.usersData = _.orderBy(this.usersData, item => { + if (item.profileDetails && item.profileDetails.personalDetails) { + return item.profileDetails.personalDetails.firstname ? + item.profileDetails.personalDetails.firstname.toUpperCase() : item.firstName.toUpperCase() + } + // tslint:disable-next-line + }, ['asc']) + } + } + + ngAfterViewChecked() { + this.cdr.detectChanges() + } + + // for approvals + async getUserMappedData(approvalData: any) { + approvalData.forEach((data: any) => { + if (data.userWorkflow && data.userWorkflow.userInfo) { + const id = data.userWorkflow.userInfo.wid + this.usersSvc.getUserById(id).subscribe((res: any) => { + if (res) { + data.user = res + if (this.currentFilter === 'transfers') { + data.enableToggle = res.profileDetails.profileStatus !== 'NOT-MY-USER' ? true : false + } + + if (data.user) { + if (data.needApprovalList && data.needApprovalList.length === 1) { + data.noneedApprovalList = [] + if (data.needApprovalList[0].feildName === 'group') { + const obj = { + label: 'Designation', + feildName: 'designation', + value: data.user.profileDetails.professionalDetails[0].designation || '', + } + data.noneedApprovalList.push(obj) + } + if (data.needApprovalList[0].feildName === 'designation') { + const obj = { + label: 'Group', + feildName: 'group', + value: data.user.profileDetails.professionalDetails[0].group || '', + } + data.noneedApprovalList.push(obj) + } + } + } + } + }) + } + }) + } + + async getFieldsMappedData(approvalData: any) { + approvalData.forEach((appdata: any) => { + if (appdata.userWorkflow.wfInfo && appdata.userWorkflow.wfInfo.length > 0) { + appdata.needApprovalList = [] + appdata.userWorkflow.wfInfo.forEach((wf: any) => { + if (typeof wf.updateFieldValues === 'string') { + const fields = JSON.parse(wf.updateFieldValues) + if (fields.length > 0) { + fields.forEach((field: any) => { + const labelKey = Object.keys(field.toValue)[0] + const feildNameObj = labelKey === 'designation' ? 'Designation' : 'Group' + if (labelKey === 'designation' || labelKey === 'group') { + appdata.needApprovalList.push( + Object.assign({ + wf, + feildName: labelKey, + label: feildNameObj, + value: field.toValue[labelKey], + fieldKey: field.fieldKey, + wfId: wf.wfId, + }) + ) + } + }) + } + } + }) + } + }) + } + + async init() { + // await this.loadCountryCodes() + await this.loadRoles() + } + + // async loadCountryCodes() { + // this.usersSvc.getMasterNationlity().subscribe((data: any) => { + // data.nationality.map((item: any) => { + // this.countryCodes.push(item.countryCode) + // }) + + // this.updateUserDataForm.patchValue({ + // countryCode: '+91', + // }) + // }, + // // tslint:disable-next-line + // (_err: any) => { + // }) + // } + + async loadRoles() { + this.roleservice.getAllRoles().subscribe((_data: any) => { + const parseRoledata = JSON.parse(_data.result.response.value) + this.orgTypeList = parseRoledata.orgTypeList + }) + } + + closeOtherPanels(openPanel: MatExpansionPanel) { + this.panels.forEach(panel => { + if (panel !== openPanel) { + panel.close() + } + }) + } + + otherDropDownChange(value: any, field: string) { + if (field === 'designation' && value !== 'Other') { + this.updateUserDataForm.controls['designation'].setValue(value) + } + } + + onChangesLanuage(): void { + // tslint:disable-next-line: no-non-null-assertion + this.masterLanguages = this.updateUserDataForm.get('domicileMedium')!.valueChanges + .pipe( + debounceTime(500), + distinctUntilChanged(), + startWith(''), + map((value: any) => typeof (value) === 'string' ? value : (value && value.name ? value.name : '')), + map((name: any) => name ? this.filterLanguage(name) : this.masterLanguagesEntries.slice()), + ) + } + + private filterLanguage(name: string) { + if (name) { + const filterValue = name.toLowerCase() + return this.masterLanguagesEntries.filter((option: any) => option.name.toLowerCase().includes(filterValue)) + } + return this.masterLanguagesEntries + } + + numericOnly(event: any): boolean { + const pattren = /^([0-9])$/ + const result = pattren.test(event.key) + return result + } + + onEditUser(user: any, pnael: any) { + let userval = user + this.usersSvc.getUserById(user.userId).subscribe((res: any) => { + if (res) { + userval = res + this.usersData.forEach((u: any) => { + if (u.userId === user.userId) { + u.enableEdit = true + userval.enableEdit = true + } else { + u.enableEdit = false + } + }) + + pnael.open() + this.setUserDetails(userval) + } + }) + } + + getApprovalUserData(user: any, data: any, openPanel: MatExpansionPanel) { + if (openPanel.expanded) { + user.enableEdit = false + this.approveUserDataForm.reset() + user.needApprovalList = [] + this.actionList = [] + this.comment = '' + this.getApprovalList(data) + } + } + + getUerData(user: any, openPanel: MatExpansionPanel, index: any) { + if (openPanel.expanded) { + user.enableEdit = false + const profileDataAll = user + + const profileData = profileDataAll.profileDetails + this.updateTags(profileData) + + this.usersSvc.getUserById(user.userId).subscribe((res: any) => { + if (res) { + // tslint:disable-next-line + user = res + // user.enableEdit = false + this.userRoles.clear() + this.mapRoles(user) + this.usersData[index] = user + } + }) + } + } + + mapRoles(user: any) { + if (this.orgTypeList && this.orgTypeList.length > 0) { + // New code for roles + for (let i = 0; i < this.orgTypeList.length; i += 1) { + if (this.orgTypeList[i].name === 'MDO') { + _.each(this.orgTypeList[i].roles, rolesObject => { + if (rolesObject !== 'MDO_LEADER') { + this.uniqueRoles.push({ + roleName: rolesObject, description: rolesObject, + }) + } + }) + } + } + this.uniqueRoles.forEach((role: any) => { + if (!this.rolesList.some((item: any) => item.roleName === role.roleName)) { + this.rolesList.push(role) + } + }) + const usrRoles = user.organisations[0] && user.organisations[0].roles + ? user.organisations[0].roles : [] + if (usrRoles.length > 0) { + this.updateUserDataForm.controls['roles'].setValue(usrRoles) + usrRoles.forEach((role: any) => { + this.orguserRoles.push(role) + this.userRoles.add(role) + // this.modifyUserRoles(role) + }) + } + } else { + this.loadRoles() + this.mapRoles(user) + } + } + + setUserDetails(user: any) { + if (user && user.profileDetails) { + this.updateUserDataForm.reset() + if (user.profileDetails.additionalProperties) { + if (user.profileDetails.additionalProperties.externalSystemId) { + this.updateUserDataForm.controls['ehrmsID'].setValue(user.profileDetails.additionalProperties.externalSystemId) + } + } + if (user.profileDetails.professionalDetails) { + if (user.profileDetails.professionalDetails[0].designation) { + this.updateUserDataForm.controls['designation'].setValue(user.profileDetails.professionalDetails[0].designation) + } + if (user.profileDetails.professionalDetails[0].group) { + this.updateUserDataForm.controls['group'].setValue(user.profileDetails.professionalDetails[0].group) + } + } + if (user.profileDetails.personalDetails) { + if (user.profileDetails.personalDetails.primaryEmail) { + this.updateUserDataForm.controls['primaryEmail'].setValue(user.profileDetails.personalDetails.primaryEmail) + } + if (user.profileDetails.personalDetails.mobile) { + this.updateUserDataForm.controls['mobile'].setValue(user.profileDetails.personalDetails.mobile) + } + if (user.profileDetails.personalDetails.gender) { + if (user.profileDetails.personalDetails.gender === 'FEMALE') { + this.updateUserDataForm.controls['gender'].setValue('Female') + } else if (user.profileDetails.personalDetails.gender === 'MALE') { + this.updateUserDataForm.controls['gender'].setValue('Male') + } else if (user.profileDetails.personalDetails.gender === 'OTHERS') { + this.updateUserDataForm.controls['gender'].setValue('Others') + } else { + this.updateUserDataForm.controls['gender'].setValue(user.profileDetails.personalDetails.gender) + } + } + if (user.profileDetails.personalDetails.dob) { + // this.updateUserDataForm.controls['dob'].setValue(user.profileDetails.personalDetails.dob) + this.updateUserDataForm.patchValue({ + dob: this.getDateFromText(user.profileDetails.personalDetails.dob), + }) + } + if (user.profileDetails.personalDetails.domicileMedium) { + this.updateUserDataForm.controls['domicileMedium'].setValue(user.profileDetails.personalDetails.domicileMedium) + } + if (user.profileDetails.personalDetails.category) { + this.updateUserDataForm.controls['category'].setValue(user.profileDetails.personalDetails.category) + } + // if (user.profileDetails.personalDetails.pinCode) { + // this.updateUserDataForm.controls['pincode'].setValue(user.profileDetails.personalDetails.pinCode) + // } + } + + if (user.profileDetails.employmentDetails) { + if (user.profileDetails.employmentDetails.pinCode) { + this.updateUserDataForm.controls['pincode'].setValue(user.profileDetails.employmentDetails.pinCode) + } + if (user.profileDetails.employmentDetails.employeeCode) { + this.updateUserDataForm.controls['employeeID'].setValue(user.profileDetails.employmentDetails.employeeCode) + } + } + this.mapRoles(user) + } + } + + private getDateFromText(dateString: string): any { + if (dateString) { + const sv: string[] = dateString.split('T') + if (sv && sv.length > 1) { + return sv[0] + } + const splitValues: string[] = dateString.split('-') + const [dd, mm, yyyy] = splitValues + const dateToBeConverted = dd.length !== 4 ? `${yyyy}-${mm}-${dd}` : `${dd}-${mm}-${yyyy}` + return new Date(dateToBeConverted) + } + return '' + } + + getUseravatarName(user: any) { + let name = '' + if (user && user.profileDetails && user.profileDetails.personalDetails) { + if (user.profileDetails.personalDetails.firstname) { + name = `${user.profileDetails.personalDetails.firstname}` + } + } else { + name = `${user.firstName}` + } + return name + } + + getApprovalList(approvalData: any) { + this.userwfData = approvalData + } + + cancelSubmit(user: any) { + this.updateUserDataForm.reset() + user.enableEdit = !user.enableEdit + } + + modifyUserRoles(role: string) { + if (this.userRoles.has(role)) { + this.userRoles.delete(role) + } else { + this.userRoles.add(role) + } + } + + updateTags(profileData: any) { + this.selectedtags = _.get(profileData, 'additionalProperties.tag') || [] + } + + addActivity(event: MatChipInputEvent) { + const input = event.input + const value = event.value as string + // if ((value && value.trim()) && this.updateUserDataForm.valid) { + if ((value && value.trim())) { + this.isTagsEdited = true + this.selectedtags.push(value) + } + if (input) { + input.value = '' + } + if (this.updateUserDataForm.get('tags')) { + // tslint:disable-next-line: no-non-null-assertion + this.updateUserDataForm.get('tags')!.setValue(null) + } + this.updateUserDataForm.controls['tags'].reset() + } + + removeActivity(interest: any) { + const index = this.selectedtags.indexOf(interest) + if (index >= 0) { + this.selectedtags.splice(index, 1) + this.isTagsEdited = true + } + } + + checkForChange(activityList: any) { + const newobj: any = [] + activityList.forEach((val: any) => { + const reqObj = { + name: val, + } + newobj.push(reqObj) + }) + } + + onChangePage(pe: PageEvent) { + this.startIndex = (pe.pageIndex) * pe.pageSize + this.lastIndex = pe.pageSize + this.paginationData.emit({ pageIndex: this.startIndex, pageSize: pe.pageSize }) + } + + onSearch(event: any) { + this.searchByEnterKey.emit(event) + } + + private openSnackbar(primaryMsg: string, duration: number = 5000) { + this.snackBar.open(primaryMsg, 'X', { + duration, + }) + } + /* tslint:disable */ + // for approval & rejection + onClickHandleWorkflow(field: any, action: string) { + field.action = action + const req = { + action, + comment: '', + state: 'SEND_FOR_APPROVAL', + userId: field.wf.userId, + applicationId: field.wf.applicationId, + actorUserId: this.userwfData.userInfo.wid, + wfId: field.wf.wfId, + serviceName: 'profile', + updateFieldValues: JSON.parse(field.wf.updateFieldValues), + } + if (action === 'APPROVE') { + // const index = this.actionList.indexOf(req.wfId) + const index = this.actionList.findIndex((x: any) => x.wfId === req.wfId) + if (index > -1) { + this.actionList[index] = req + } else { + this.actionList.push(req) + } + // this.onApproveOrRejectClick(req) + } else { + this.comment = '' + const dialogRef = this.dialog.open(this.rejectDialog, { + width: '770px', + }) + dialogRef.afterClosed().subscribe(result => { + if (result) { + // this.onApproveOrRejectClick(req) + req.comment = this.comment + field.comment = this.comment + // const index = this.actionList.indexOf(req.wfId) + const index = this.actionList.findIndex((x: any) => x.wfId === req.wfId) + if (index > -1) { + this.actionList[index] = req + } else { + this.actionList.push(req) + } + } else { + dialogRef.close() + } + }) + } + + this.events.raiseInteractTelemetry( + { + type: TelemetryEvents.EnumInteractTypes.CLICK, + subType: TelemetryEvents.EnumInteractSubTypes.BTN_CONTENT, + }, + { + id: field.wf.applicationId, + type: TelemetryEvents.EnumIdtype.APPLICATION, + } + ) + + // if (this.currentFilter === 'transfers' && appData !== undefined) { + // appData.needApprovalList.forEach((otherField: any) => { + // if (otherField.label !== field.label) { + // console.log('field', field) + // this.onClickHandleWorkflow(field, action) + // } + // }) + // if (field.label === 'Group') { + // const designationValue = action === 'APPROVE' ? 'approvedesg' : 'rejectdesg' + // this.approveUserDataForm.controls.approveDesignation.setValue(designationValue) + // } else { + // const groupValue = action === 'APPROVE' ? 'approvegroup' : 'rejectgroup' + // this.approveUserDataForm.controls.approveGroup.setValue(groupValue) + // } + // } + } + + onTransferSubmit(panel: any, appData: any) { + let orgReq = {} + appData.userWorkflow.wfInfo.forEach((wf: any) => { + const fields = JSON.parse(wf.updateFieldValues) + if (fields.length > 0) { + fields.forEach((field: any) => { + const labelKey = Object.keys(field.toValue)[0] + if (labelKey === 'name') { + orgReq = { + action: 'APPROVE', + actorUserId: wf.actorUUID, + applicationId: wf.applicationId, + serviceName: wf.serviceName, + state: 'SEND_FOR_APPROVAL', + updateFieldValues: fields, + userId: wf.userId, + wfId: wf.wfId, + } + } + }) + } + }) + + this.actionList.push(orgReq) + const datalength = this.actionList.length + this.actionList.forEach((req: any, index: any) => { + if (req.action === 'APPROVE') { + req.comment = '' + } + if (index === datalength - 1) { + panel.close() + this.comment = '' + setTimeout(() => { + this.openSnackbar('Request approved successfully') + this.updateList.emit() + // tslint:disable-next-line + }, 100) + } + if (this.approvalData.length === 0) { + this.disableButton.emit() + } + }) + + } + + updateRejection(field: any) { + this.comment = field.comment + const dialogRef = this.dialog.open(this.updaterejectDialog, { + width: '770px', + }) + dialogRef.afterClosed().subscribe(result => { + if (result) { + this.actionList.forEach((req: any) => { + if (req.wfId === field.wfId) { + req.comment = this.comment + field.comment = this.comment + this.showeditText = false + } + }) + } else { + dialogRef.close() + } + }) + } + + showedit() { + this.showeditText = true + } + + toggleMentor(template: any, event: any, user: any) { + if (event.checked) { + if (this.activeTab === 'mentor') { + this.memberAlertMessage = 'Assign this user as a mentor?' + } else { + this.memberAlertMessage = 'Assign this user as a mentor? The user will be moved to the Assigned Mentors Tab' + } + + } else { + if (this.activeTab === 'verified') { + this.memberAlertMessage = 'Remove this user from mentor role?' + } else { + this.memberAlertMessage = 'Remove this user from mentor role? The user will move to the Verified tab.' + } + + } + const dialog = this.dialog.open(template, { + width: '600px', + }) + dialog.afterClosed().subscribe((v: any) => { + if (v) { + this.saveMentorProfile(user, event) + } else { + event.source.checked = true + } + }) + } + + saveMentorProfile(user: any, event: any) { + const usrRoles = user.roles ? user.roles : [] + if (usrRoles.length > 0) { + user.roles.map((role: any) => { + if (role.role) { + this.userRoles.add(role.role) + } + }) + } + if (event.checked) { + this.userRoles.add('MENTOR') + } else { + this.userRoles.delete('MENTOR') + } + const dreq = { + request: { + organisationId: user.rootOrgId, + userId: user.userId, + roles: Array.from(this.userRoles), + }, + } + this.usersSvc.addUserToDepartmentMentor(dreq).subscribe(res => { + if (res) { + if (this.activeTab === 'mentor') { + this.usersSvc.mentorList$.next('mentor') + } else { + this.usersSvc.mentorList$.next('verified') + } + if (event.checked) { + this.snackBar.open('User Assigned as Mentor Successfully') + } else { + this.snackBar.open('User Removed from Mentor Role Successfully') + } + + } else { + if (event.checked) { + this.snackBar.open('Error While Assign User as a Mentor') + } else { + this.snackBar.open('Error While Removing User as a Mentor') + } + } + }) + } + + getUserRoles(user: any) { + let userRoles: any = [] + + user.roles.map((role: any) => { + userRoles.push(role.role) + }) + + if (userRoles.indexOf('MENTOR') > -1) { + return true + } + return false + } +} diff --git a/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.module.ts b/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.module.ts new file mode 100644 index 00000000..80846dc5 --- /dev/null +++ b/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { OrderByPipe } from './pipe-order-by.pipe' + +@NgModule({ + declarations: [OrderByPipe], + imports: [ + CommonModule, + ], + exports: [OrderByPipe], +}) +export class PipeOrderByModule { } diff --git a/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.pipe.ts b/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.pipe.ts new file mode 100644 index 00000000..0a8da21e --- /dev/null +++ b/project/ws/app/src/lib/routes/home/pipes/pipe-order-by/pipe-order-by.pipe.ts @@ -0,0 +1,10 @@ +import { Pipe, PipeTransform } from '@angular/core' +import { orderBy } from 'lodash' + +@Pipe({ + name: 'orderBy', +}) + +export class OrderByPipe implements PipeTransform { + transform = orderBy +} diff --git a/project/ws/app/src/lib/routes/home/services/loader.service.ts b/project/ws/app/src/lib/routes/home/services/loader.service.ts index 58154cda..cb71e19a 100644 --- a/project/ws/app/src/lib/routes/home/services/loader.service.ts +++ b/project/ws/app/src/lib/routes/home/services/loader.service.ts @@ -7,9 +7,12 @@ export class LoaderService { private doubleBack = new BehaviorSubject(false) currentState = this.doubleBack.asObservable() - + $currentState = this.changeLoad.asObservable() changeLoadState(state: boolean) { this.doubleBack.next(state) } + changeLoaderState(state: boolean) { + this.changeLoad.next(state) + } } diff --git a/project/ws/app/src/lib/routes/home/services/users.service.ts b/project/ws/app/src/lib/routes/home/services/users.service.ts index 5d90c0e6..b1abd16a 100644 --- a/project/ws/app/src/lib/routes/home/services/users.service.ts +++ b/project/ws/app/src/lib/routes/home/services/users.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { HttpClient } from '@angular/common/http' -import { Observable } from 'rxjs' +import { Observable, Subject } from 'rxjs' import { map, retry } from 'rxjs/operators' /* tslint:disable */ import _ from 'lodash' @@ -23,12 +23,15 @@ const API_END_POINTS = { NEW_USER_UN_BLOCK_API: '/apis/proxies/v8/user/v1/unblock', SEARCH_USER_TABLE: '/apis/proxies/v8/user/v1/search', ALL_USERS_BY_DEPARTMENT: '/apis/protected/v8/portal/spv/department', + GET_ALL_USERS_V3: '/apis/proxies/v8/user/v3/search', + ADD_USER_TO_DEPARTMENT_MENTOR: '/apis/proxies/v8/user/private/v1/assign/role', } @Injectable({ providedIn: 'root', }) export class UsersService { + mentorList$ = new Subject() constructor(private http: HttpClient) { } getUsersByDepartment(userId: string): Observable { return this.http.get(`${API_END_POINTS.ALL_USERS_BY_DEPARTMENT}/${userId}/?allUsers=true`) @@ -177,4 +180,18 @@ export class UsersService { return this.http.post(`${API_END_POINTS.SEARCH_USER_TABLE}`, reqBody) } + + getAllValidUsers(filter: object): Observable { + // console.log() + return this.http.post(`${API_END_POINTS.GET_ALL_USERS}`, filter).pipe(map(res => _.get(res, 'result.response'))) + } + + getAllUsersV3(filter: object): Observable { + // console.log() + return this.http.post(`${API_END_POINTS.GET_ALL_USERS_V3}`, filter).pipe(map(res => _.get(res, 'result.response'))) + } + + addUserToDepartmentMentor(req: any): Observable { + return this.http.post(`${API_END_POINTS.ADD_USER_TO_DEPARTMENT_MENTOR}`, req) + } }