All files / lib/fullscreen-message fullscreen-message.component.ts

89.18% Statements 99/111
100% Branches 11/11
62.5% Functions 5/8
89.18% Lines 99/111

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 1121x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x       1x 1x 1x 22x 22x 1x 1x 1x           1x 1x 1x         1x  
import {
  Component,
  ElementRef,
  Signal,
  computed,
  input,
  output,
  viewChild,
} from '@angular/core';
 
import { ActionEvent } from '../utils/event.types';
import {
  FocusableElementOwner,
  FormattedTextContent,
} from '../utils/util.types';
import { createWidgetKeySet } from '../utils/utilities';
 
export type FullscreenMessageContent = string | FormattedTextContent;
export type FullscreenMessageType =
  | 'peripheral-system'
  | 'authorization-error'
  | 'connection-error'
  | 'unknown-page'
  | 'generic-error'
  | 'ai-help-error';
 
@Component({
  selector: 'gc-fullscreen-message',
  templateUrl: './fullscreen-message.component.html',
  styleUrls: ['./fullscreen-message.component.css'],
  host: {
    '[class]': 'sizeClass()',
  },
  standalone: false,
})
export class FullscreenMessageComponent implements FocusableElementOwner {
  /** @ignore */
  protected get errorMessage(): boolean {
    return this.messageType() !== 'peripheral-system';
  }
 
  /**
   * Headline of the message
   */
  header = input.required<string>();
 
  /** The message(s) to show */
  description = input.required<string | readonly FullscreenMessageContent[]>();
 
  /** The request ID to show */
  requestID = input('');
 
  /** The label of the action button */
  actionLabel = input('Zurück zur Startseite');
 
  messageType = input<FullscreenMessageType>('generic-error');
 
  /**
   * Event delivered when action button is pressed
   */
  readonly onAction = output<ActionEvent>();
 
  /**
   * Control the size of the icon (allowing to embedded in page sections)
   */
  size = input<'default' | 'small'>('default');
 
  /** @ignore */
  protected sizeClass = computed(() => {
    return this.size() === 'small' ? 'gc-small' : 'gc-default';
  });
 
  /** @ignore */
  protected readonly _widgetKeys = createWidgetKeySet('gc-fullscreen-message');
  /** @ignore */
  protected readonly _maskIdCon = `${this._widgetKeys.baseKey}-maskCon`;
  /** @ignore */
  protected readonly _maskIdUnknown = `${this._widgetKeys.baseKey}-maskUnknown`;
 
  private headerElement: Signal<ElementRef<HTMLElement>> = viewChild.required(
    'headerElement',
    {
      read: ElementRef<HTMLElement>,
    },
  );
 
  focusChild(): boolean {
    this.headerElement().nativeElement.focus();
    return true;
  }
 
  /** @ignore */
  protected _isSingleValuedDescription() {
    return typeof this.description() === 'string';
  }
 
  /** @ignore */
  protected _multiValueDescription(): readonly FullscreenMessageContent[] {
    const description = this.description();
    return typeof description !== 'string'
      ? description
      : ['ERROR: single valued'];
  }
 
  /** @ignore */
  protected _isFormattedType(
    content: FullscreenMessageContent | string,
  ): content is Exclude<FullscreenMessageContent, string> {
    return typeof content !== 'string';
  }
}