Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 11x 11x 19x 19x 19x 17x 17x 17x 17x 17x | /**
* Copyright (c) Siemens 2016 - 2025
* SPDX-License-Identifier: MIT
*/
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { SiDashboardCardComponent } from './si-dashboard-card.component';
@Injectable()
export class SiDashboardService {
private cards = new BehaviorSubject<SiDashboardCardComponent[]>([]);
/**
* Subject containing the current dashboard cards as a list.
*
* @defaultValue this.cards.asObservable()
*/
readonly cards$ = this.cards.asObservable();
/**
* Registers a new dashboard card.
*/
register(card: SiDashboardCardComponent): void {
const nextCards = this.cards.value;
nextCards.push(card);
this.cards.next(nextCards);
}
/**
* Removes a registered dashboard card.
*/
unregister(card: SiDashboardCardComponent): void {
const nextCards = this.cards.value;
const index = nextCards.indexOf(card);
if (index > -1) {
nextCards.splice(index, 1);
this.cards.next(nextCards);
}
}
}
|