All files / src/services si-grid.service.ts

100% Statements 8/8
77.77% Branches 7/9
100% Functions 3/3
100% Lines 5/5

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                  46x   46x   46x 28x       43x      
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { computed, Injectable, signal } from '@angular/core';
 
import { Widget } from '../model/widgets.model';
 
@Injectable()
export class SiGridService {
  /** @defaultValue [] */
  readonly widgetCatalog = signal<Widget[]>([]);
 
  private readonly widgetCatalogMap = computed(
    () => new Map(this.widgetCatalog().map(widget => [widget.id, widget]))
  );
 
  getWidget(id: string): Widget | undefined {
    return this.widgetCatalogMap().get(id);
  }
}