File
Implements
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Outputs
|
|
showCpuLoadWarning
|
Type : boolean
|
Default value : false
|
|
showMinRamWarning
|
Type : boolean
|
Default value : false
|
|
Outputs
navigate
|
Type : EventEmitter
|
|
Methods
handleRoute
|
handleRoute()
|
|
|
isBrowsePage
|
isBrowsePage()
|
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
|
setTelemetryData
|
setTelemetryData()
|
|
|
Public
activatedRoute
|
Type : ActivatedRoute
|
|
Public
router
|
Type : Router
|
|
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>
@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 with directive