src/modules/app-data/components/app-data.component.ts
Component to display all the data concerning the current user session including the following info:
OnInit
changeDetection | ChangeDetectionStrategy.OnPush |
encapsulation | ViewEncapsulation.None |
host | { |
selector | stark-app-data |
templateUrl | ./app-data.component.html |
Properties |
|
Methods |
|
Inputs |
Public
constructor(logger: StarkLoggingService, renderer: Renderer2, elementRef: ElementRef)
|
||||||||||||||||
Class constructor
Parameters :
|
mode | |
Type : StarkAppDataComponentMode
|
|
Default value : "dropdown"
|
|
The mode in which the component should be displayed. Default: |
color | |
Type : string
|
|
Inherited from
AbstractStarkUiComponent
|
|
Defined in
AbstractStarkUiComponent:16
|
|
Color theme |
Public ngOnInit |
ngOnInit()
|
Inherited from
AbstractStarkUiComponent
|
Defined in
AbstractStarkUiComponent:55
|
Component lifecycle hook
Returns :
void
|
Public logger |
Type : StarkLoggingService
|
Decorators :
@Inject(STARK_LOGGING_SERVICE)
|
- The `StarkLoggingService` instance of the application.
|
import { ChangeDetectionStrategy, Component, ElementRef, Inject, Input, OnInit, Renderer2, ViewEncapsulation } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { AbstractStarkUiComponent } from "@nationalbankbelgium/stark-ui/src/internal-common";
/**
* @ignore
*/
const componentName = "stark-app-data";
/**
* Modes in which the {@link StarkAppDataComponent} can be displayed
*/
export type StarkAppDataComponentMode = "dropdown" | "menu";
/**
* Component to display all the data concerning the current user session including the following info:
* - User full name + profile.
* - Last access date of the user.
* - App version + Environment (PROD, DEV, etc...).
*/
@Component({
selector: "stark-app-data",
templateUrl: "./app-data.component.html",
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: componentName
}
})
export class StarkAppDataComponent extends AbstractStarkUiComponent implements OnInit {
/**
* The mode in which the component should be displayed.
*
* Default: `"dropdown"`
*/
@Input() public mode?: StarkAppDataComponentMode = "dropdown";
/**
* Class constructor
* @param logger - The `StarkLoggingService` instance of the application.
* @param renderer - Angular `Renderer2` wrapper for DOM manipulations.
* @param elementRef - Reference to the DOM element where this component is attached to.
*/
public constructor(
@Inject(STARK_LOGGING_SERVICE) public logger: StarkLoggingService,
renderer: Renderer2,
elementRef: ElementRef
) {
super(renderer, elementRef);
}
/**
* Component lifecycle hook
*/
public override ngOnInit(): void {
super.ngOnInit();
this.logger.debug(componentName + ": controller initialized");
}
}
<!-- the projected detail content should be put in an ng-template so that it can be rendered multiple times in this template -->
<!-- solution taken from https://github.com/angular/angular/issues/22972#issuecomment-407358396 -->
<ng-template #appDataDetail>
<div class="stark-app-data-detail" (click)="$event.stopPropagation()">
<ng-content select=".detail-slot"></ng-content>
</div>
</ng-template>
<div *ngIf="mode === 'dropdown'" class="stark-app-data dropdown">
<div class="stark-app-data-summary">
<ng-content select=".summary-slot"></ng-content>
</div>
<button
mat-icon-button
aria-label="Application Data"
#dropdownDetailTrigger="matMenuTrigger"
[matMenuTriggerFor]="dropdownDetail"
[class.is-open]="dropdownDetailTrigger.menuOpen"
mat-button
>
<mat-icon svgIcon="menu-down"></mat-icon>
</button>
<mat-menu #dropdownDetail="matMenu" xPosition="before" yPosition="below" class="stark-app-data dropdown-detail">
<ng-template matMenuContent>
<ng-container *ngTemplateOutlet="appDataDetail"></ng-container>
</ng-template>
</mat-menu>
</div>
<div *ngIf="mode === 'menu'" class="stark-app-data menu">
<button
mat-button
mat-icon-button
aria-label="Application Data"
[matMenuTriggerFor]="menuDetail"
[matTooltip]="'STARK.ICONS.APP_DATA' | translate"
>
<mat-icon svgIcon="dots-vertical"></mat-icon>
</button>
<mat-menu #menuDetail="matMenu" yPosition="below" class="stark-app-data menu-detail">
<ng-template matMenuContent>
<ng-container *ngTemplateOutlet="appDataDetail"></ng-container>
</ng-template>
</mat-menu>
</div>