File

src/app/modules/public/module/offline/components/info-card/info-card.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(connectionService: ConnectionService, resourceService: ResourceService, activatedRoute: ActivatedRoute, telemetryService: TelemetryService, router: Router)
Parameters :
Name Type Optional
connectionService ConnectionService No
resourceService ResourceService No
activatedRoute ActivatedRoute No
telemetryService TelemetryService No
router Router No

Inputs

showCpuLoadWarning
Type : boolean
Default value : false
showMinRamWarning
Type : boolean
Default value : false
text
Type : any

Outputs

navigate
Type : EventEmitter

Methods

handleRoute
handleRoute()
Returns : void
isBrowsePage
isBrowsePage()
Returns : any
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
setTelemetryData
setTelemetryData()
Returns : void

Properties

Public activatedRoute
Type : ActivatedRoute
isConnected
Public resourceService
Type : ResourceService
Public router
Type : Router
Public telemetryService
Type : TelemetryService
Public unsubscribe$
Default value : new Subject<void>()
import { TelemetryService } from '@sunbird/telemetry';
import { takeUntil } from 'rxjs/operators';
import { Router, ActivatedRoute } from '@angular/router';
import { ResourceService, ConnectionService } from '@sunbird/shared';
import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core';
import { Subject } from 'rxjs';
import * as _ from 'lodash-es';

@Component({
  selector: 'app-info-card',
  templateUrl: './info-card.component.html',
  styleUrls: ['./info-card.component.scss']
})
export class InfoCardComponent implements OnInit, OnDestroy {

  @Input() text: any;
  @Input() showMinRamWarning = false;
  @Input() showCpuLoadWarning = false;
  isConnected;
  @Output() navigate = new EventEmitter();
  public unsubscribe$ = new Subject<void>();
  constructor(private connectionService: ConnectionService,
    public resourceService: ResourceService,
    public activatedRoute: ActivatedRoute,
    public telemetryService: TelemetryService,
    public router: Router) { }

   ngOnInit() {
    this.connectionService.monitor().pipe(takeUntil(this.unsubscribe$)).subscribe(isConnected => {
      this.isConnected = isConnected;
    });
  }

  isBrowsePage() {
    return  _.includes(this.router.url, 'browse');
  }
  handleRoute() {
    this.navigate.emit();
    this.setTelemetryData();
  }

  ngOnDestroy() {
    this.unsubscribe$.next();
    this.unsubscribe$.complete();
  }
  setTelemetryData() {
    const interactData = {
      context: {
        env: _.get(this.activatedRoute.snapshot.data.telemetry, 'env') || 'browse',
        cdata: []
      },
      edata: {
        id: 'navigate-' + _.kebabCase(_.get(this.text, 'linkName')),
        type: 'click',
        pageid: _.get(this.activatedRoute.snapshot.data.telemetry, 'pageid')
      }
    };
    this.telemetryService.interact(interactData);
  }

}
<div class="info-container d-flex flex-jc-start flex-ai-center p-16 sb-bg-color-white my-16"
  *ngIf="isConnected && isBrowsePage()">
  <div class="d-flex">
    <div class="info-container__icon">
      <img src="../../assets/images/information.svg" width="22px" height="22px">
    </div>
    <div class="fs-0-785 ml-16 text-left">{{text?.msg}}
      <a href="#" class="info-container__label font-weight-bold" tabindex="0" (click)="handleRoute()">{{text?.linkName}}</a></div>
  </div>
</div>

<div class="info-container d-flex flex-jc-start flex-ai-center p-16 sb-bg-color-white my-16" *ngIf="showMinRamWarning">
  <div class="d-flex">
    <div class="info-container__icon">
      <img src="../../assets/images/alert.svg" width="22px" height="22px">
    </div>
    <div class="fs-0-785 ml-16 text-left">{{resourceService?.frmelmnts?.lbl?.desktop?.lowMemory}}</div>
  </div>
</div>

<div class="info-container d-flex flex-jc-start flex-ai-center p-16 sb-bg-color-white my-16" *ngIf="showCpuLoadWarning">
  <div class="d-flex">
    <div class="info-container__icon">
      <img src="../../assets/images/alert.svg" width="22px" height="22px" alt="Cpu load warning">
    </div>
    <div class="fs-0-785 ml-16 text-left">{{resourceService?.frmelmnts?.lbl?.maxCpuLoadWaring}}</div>
  </div>
</div>

./info-card.component.scss

@use "@project-sunbird/sb-styles/assets/mixins/mixins" as *;

.info-container{
    width: 100%;
    padding:1.5rem ;
    box-shadow: 0px calculateRem(5px) calculateRem(10px) 0px rgba(var(--rc-rgba-black), 0.12);

    &__label{
        &:hover{
            text-decoration: underline;
        }   
    }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""