src/app/modules/groups/components/group-details/group-details.component.ts
OnInit
OnDestroy
selector | app-group-details |
styleUrls | ./group-details.component.scss |
templateUrl | ./group-details.component.html |
Properties |
Methods |
constructor(activatedRoute: ActivatedRoute, groupService: GroupsService, toasterService: ToasterService, router: Router, resourceService: ResourceService, userService: UserService, layoutService: LayoutService)
|
||||||||||||||||||||||||
Parameters :
|
addTelemetry | ||||||||||||
addTelemetry(id, extra?, edata?)
|
||||||||||||
Parameters :
Returns :
void
|
filterList |
filterList()
|
Returns :
void
|
getGroupData |
getGroupData()
|
Returns :
void
|
handleEvent |
handleEvent()
|
Returns :
void
|
initLayout |
initLayout()
|
Returns :
void
|
navigateToAddActivity |
navigateToAddActivity()
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
toggleActivityModal | ||||||
toggleActivityModal(visibility)
|
||||||
Parameters :
Returns :
void
|
toggleFtuModal | ||||||||
toggleFtuModal(visibility: boolean)
|
||||||||
Parameters :
Returns :
void
|
activityList |
Public ADD_ACTIVITY |
Default value : ADD_ACTIVITY
|
addActivityModal |
Decorators :
@ViewChild('addActivityModal')
|
config |
Type : IGroupMemberConfig
|
Default value : {
showMemberCount: true,
showSearchBox: true,
showAddMemberButton: true,
showMemberMenu: true
}
|
groupData |
Type : IGroupCard
|
Private groupId |
Type : string
|
isAdmin |
Default value : false
|
isLoader |
Default value : true
|
layoutConfiguration |
Type : any
|
Public layoutService |
Type : LayoutService
|
members |
Type : IGroupMember[]
|
Default value : []
|
Public resourceService |
Type : ResourceService
|
showActivityList |
Default value : false
|
showFilters |
Default value : false
|
showMemberPopup |
Default value : false
|
showModal |
Default value : false
|
telemetryImpression |
Type : IImpressionEventInput
|
Public unsubscribe$ |
Default value : new Subject<void>()
|
import { GroupEntityStatus, CsGroup } from '@project-sunbird/client-services/models/group';
import { UserService } from '@sunbird/core';
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ResourceService, ToasterService, LayoutService } from '@sunbird/shared';
import * as _ from 'lodash-es';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { GroupsService } from '../../services';
import { IGroupMemberConfig, IGroupCard, IGroupMember, ADD_ACTIVITY_CONTENT_TYPES } from '../../interfaces';
import { IImpressionEventInput } from '@sunbird/telemetry';
import { ADD_ACTIVITY, PAGE_LOADED} from '../../interfaces/telemetryConstants';
import { sessionKeys } from '../../../../modules/groups/interfaces/group';
@Component({
selector: 'app-group-details',
templateUrl: './group-details.component.html',
styleUrls: ['./group-details.component.scss']
})
export class GroupDetailsComponent implements OnInit, OnDestroy {
@ViewChild('addActivityModal') addActivityModal;
groupData: IGroupCard;
showModal = false;
private groupId: string;
public unsubscribe$ = new Subject<void>();
showActivityList = false;
showFilters = false;
telemetryImpression: IImpressionEventInput;
members: IGroupMember[] = [];
isLoader = true;
isAdmin = false;
layoutConfiguration: any;
activityList;
showMemberPopup = false;
public ADD_ACTIVITY = ADD_ACTIVITY;
config: IGroupMemberConfig = {
showMemberCount: true,
showSearchBox: true,
showAddMemberButton: true,
showMemberMenu: true
};
constructor(
private activatedRoute: ActivatedRoute,
private groupService: GroupsService,
private toasterService: ToasterService,
private router: Router,
public resourceService: ResourceService,
private userService: UserService,
public layoutService: LayoutService
) {
this.groupService = groupService;
}
ngOnInit() {
this.initLayout();
this.groupId = _.get(this.activatedRoute, 'snapshot.params.groupId');
this.getGroupData();
this.groupService.closeForm.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.getGroupData();
});
this.groupService.updateEvent.pipe(takeUntil(this.unsubscribe$)).subscribe((status: GroupEntityStatus) => {
this.groupData.active = this.groupService.updateGroupStatus(this.groupData, status);
});
this.telemetryImpression = this.groupService.getImpressionObject(this.activatedRoute.snapshot, this.router.url, {type: PAGE_LOADED});
}
initLayout() {
this.layoutConfiguration = this.layoutService.initlayoutConfig();
this.layoutService.switchableLayout().
pipe(takeUntil(this.unsubscribe$)).subscribe(layoutConfig => {
if (layoutConfig != null) {
this.layoutConfiguration = layoutConfig.layout;
}
});
}
getGroupData() {
this.isLoader = true;
this.groupService.getGroupById(this.groupId, true, true, true).pipe(takeUntil(this.unsubscribe$)).subscribe((groupData: CsGroup) => {
const user = _.find(_.get(groupData, 'members'), (m) => _.get(m, 'userId') === this.userService.userid);
if (!user || _.get(groupData, 'status') === 'inactive') {
this.groupService.goBack();
}
this.groupService.groupData = groupData;
sessionStorage.setItem(sessionKeys.GROUPDATA, JSON.stringify( groupData));
this.groupData = this.groupService.addGroupFields(groupData);
this.members = this.groupService.addFieldsToMember(this.groupData.members);
this.isAdmin = this.groupService.isCurrentUserAdmin;
this.isLoader = false;
const response = this.groupService.groupContentsByActivityType(false, groupData);
this.showActivityList = response.showList;
this.activityList = response.activities;
}, err => {
this.isLoader = false;
this.groupService.goBack();
this.toasterService.error(this.resourceService.messages.emsg.m002);
});
}
toggleActivityModal(visibility = false) {
this.showModal = visibility;
}
filterList() {
this.showFilters = true;
}
navigateToAddActivity() {
this.router.navigate([`${ADD_ACTIVITY_CONTENT_TYPES}`], {
relativeTo: this.activatedRoute,
queryParams: {
groupName: _.get(this.groupData, 'name'),
createdBy: _.capitalize(_.get(_.find(this.groupData['members'], {userId: this.groupData['createdBy']}), 'name'))
}
});
}
/**
* @description - To set the telemetry Intract event data
* @param {} edata? - it's an object to specify the type and subtype of edata
*/
addTelemetry (id, extra?, edata?) {
this.groupService.addTelemetry({id, extra, edata}, this.activatedRoute.snapshot, [], this.groupId);
}
toggleFtuModal(visibility: boolean = false) {
this.showMemberPopup = visibility;
}
handleEvent() {
this.groupService.emitActivateEvent('activate', 'activate-group' );
}
ngOnDestroy() {
this.unsubscribe$.next();
this.unsubscribe$.complete();
/* istanbul ignore else */
if (this.showModal && this.addActivityModal.deny) {
this.addActivityModal.deny();
}
}
}
<app-landing-section [textToDisplay]=""
[layoutConfiguration]="layoutConfiguration" [noTitle]="true"></app-landing-section>
<app-ftu-popup *ngIf="showMemberPopup" [showMemberPopup]="showMemberPopup" (close)="toggleFtuModal(false)">
</app-ftu-popup>
<div *ngIf="groupData && !isLoader" [ngClass]="layoutConfiguration ? 'sb-back-actionbar mt-0' : 'sb-bg-white cc-player__btn-back'" class="relative position mt-0">
<app-group-header class="w-100" [groupData]="groupData" (handleFtuModal)="showMemberPopup=!showMemberPopup"></app-group-header>
</div>
<div [ngClass]="layoutConfiguration ? 'sbt-center-container sbt-back-header sbt-mygroups-details' : 'sb-back-header'">
<div class="ui container" *ngIf="isLoader" >
<app-loader></app-loader>
</div>
<div *ngIf="groupData && !isLoader" [appTelemetryImpression]="telemetryImpression">
<div class="ui container">
<div class="sb-g mt-24 sbt-sb-g">
<div class="sb-g-col-xs-12 sb-g-col-md-9 sb-g-col-lg-9 sb-g-col-xxxl-12 ">
<div class="sb-pageSection sb-bg-color-white p-8">
<div class="sb-pageSection-header m-0">
<h4 class="sb-pageSection-title my-0 mx-8 sb-pagesection-activity">
{{resourceService?.frmelmnts?.lbl?.activities}}</h4>
<button type="button" class="sb-btn sb-btn-primary sb-btn-normal ml-auto" *ngIf="isAdmin && groupData?.active"
tabindex="0" (click)="navigateToAddActivity(); addTelemetry('add-activity', '', {type: ADD_ACTIVTY})">
<i class="plus icon" aria-hidden="true"></i>
{{resourceService?.frmelmnts?.btn?.addActivity}}
</button>
</div>
</div>
<div class="my-16 p-8 group-status" *ngIf="!groupData?.active">
<div class="fnormal group-status__label">
<img class="mr-8" src="assets/images/exclamation.svg" width="18px">
{{resourceService?.messages?.imsg?.m001}}
</div>
<button *ngIf="groupData?.isAdmin" class="sb-btn sb-btn-primary sb-btn-normal mt-8" type="button" tabindex="0" (click)="handleEvent()">{{resourceService?.frmelmnts?.lbl?.activategrp}}</button>
</div>
<app-add-activity *ngIf="!showActivityList"></app-add-activity>
<app-activity-list *ngIf="showActivityList" [groupData]="groupData" [activityList]="activityList"></app-activity-list>
</div>
<div class="sb-g-col-xs-12 sb-g-col-md-3 sb-g-col-lg-3 sb-g-col-xxxl-4 ">
<app-group-members [config]="config" [members]="members" [groupData]="groupData"></app-group-members>
</div>
</div>
</div>
</div>
</div>
<router-outlet></router-outlet>
./group-details.component.scss
@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;
@use "components/tabs" as *;
.sb-pagesection-activity{
font-size: calculateRem(18px);
}
.sb-pageSection-activity-title{
color: var(--primary-400);
}
.group-status{
border: calculateRem(1px) solid var(--rc-E08A20);
border-radius: calculateRem(4px);
background-color: var(--white);
&__label{
color: var(--rc-E08A20);
}
}