File

src/app/modules/groups/directive/activity-dashboard/activity-dashbord.directive.ts

Implements

OnInit

Metadata

Index

Properties
Methods
Inputs
HostListeners

Constructor

constructor(router: Router, groupService: GroupsService, activatedRoute: ActivatedRoute, ref: ElementRef, activityDashboardService: ActivityDashboardService)
Parameters :
Name Type Optional
router Router No
groupService GroupsService No
activatedRoute ActivatedRoute No
ref ElementRef No
activityDashboardService ActivityDashboardService No

Inputs

hierarchyData
Type : any

HostListeners

click
Arguments : '$event'

Methods

addTelemetry
addTelemetry(id, cdata, extra?, obj?)
Parameters :
Name Optional Description
id No
cdata No
extra Yes

?

obj Yes

?

Returns : void
navigateToActivityDashboard
navigateToActivityDashboard()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onClick
onClick(event)
Decorators :
@HostListener('click', ['$event'])
Parameters :
Name Optional
event No
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
Public activityDashboardService
Type : ActivityDashboardService
Public groupService
Type : GroupsService
Public ref
Type : ElementRef
Public router
Type : Router
import { Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import _ from 'lodash';
import { ACTIVITY_DASHBOARD, GROUP_DETAILS, MY_GROUPS } from '../../interfaces';
import { GroupsService } from '../../services/groups/groups.service';
import { ActivityDashboardService } from '../../../shared/services/activity-dashboard/activity-dashboard.service';

@Directive({
  selector: '[appActivityDashboard]'
})
export class ActivityDashboardDirective implements OnInit {
  @Input() hierarchyData: any;

  constructor(public router: Router,
    public groupService: GroupsService,
    public activatedRoute: ActivatedRoute,
    public ref: ElementRef,
    public activityDashboardService: ActivityDashboardService) { }

  @HostListener('click', ['$event'])
  onClick(event) {
    this.navigateToActivityDashboard();
  }

  ngOnInit() {
    const isAdded = this.activityDashboardService.isActivityAdded;
    (this.ref.nativeElement as HTMLButtonElement).style.display = isAdded ? 'block' : 'none';
  }
  /**
  * @description - navigate to groups activity dashboard page
  */
  navigateToActivityDashboard() {
    this.addTelemetry('activity-detail', [{ id: _.get(this.hierarchyData, 'identifier'), type: _.get(this.hierarchyData, 'primaryCategory') }]);
    this.router.navigate([`${MY_GROUPS}/${GROUP_DETAILS}`, _.get(this.groupService.groupData, 'id'), `${ACTIVITY_DASHBOARD}`, _.get(this.hierarchyData, 'identifier')],
      {
        state: {
          hierarchyData: this.hierarchyData,
        }
      });
  }

  /**
   * @param  {} id
   * @param  {} cdata
   * @param  {} extra?
   * @param  {} obj?
   */
  addTelemetry(id, cdata, extra?, obj?) {
    this.groupService.addTelemetry({ id, extra }, this.activatedRoute.snapshot, cdata, _.get(this.groupService.groupData, 'id'), obj);
  }
}

results matching ""

    No results matching ""