@molecule/app-status-summary-angular

Feature · status-summary · App (browser) · v1.1.2 · Apache-2.0

Status-page summary: component grid with operational/degraded/outage badges + incident list

npm install @molecule/app-status-summary-angular

npm · Source on GitHub

How it works

@molecule/app-status-summary-angular is a ready-made status-summary feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { Component } from '@angular/core'
import { StatusSummary } from '@molecule/app-status-summary-angular'

@Component({
  selector: 'app-status-page',
  standalone: true,
  imports: [StatusSummary],
  template: `
    <div
      mol-status-summary
      [groups]="[
        {
          id: 'api',
          name: 'API',
          components: [
            { id: 'rest', name: 'REST API', status: 'operational' },
            { id: 'ws', name: 'WebSockets', status: 'degraded' },
          ],
        },
      ]"
    >
      <span slot="header">Last updated: 2 min ago</span>
    </div>
  `,
})
export class StatusPage {}

Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular

Reference

Angular status-page summary — the counterpart of @molecule/app-status-summary-react: the same props and the same DOM for the same input.

Exports <StatusSummary> — a grouped component list with colored operational / degraded / outage badges and an overall banner derived from the worst child status — plus the ComponentStatus, StatusComponent, StatusGroup and StatusSummaryProps types.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { StatusSummary } from '@molecule/app-status-summary-angular'

@Component({
  selector: 'app-status-page',
  standalone: true,
  imports: [StatusSummary],
  template: `
    <div
      mol-status-summary
      [groups]="[
        {
          id: 'api',
          name: 'API',
          components: [
            { id: 'rest', name: 'REST API', status: 'operational' },
            { id: 'ws', name: 'WebSockets', status: 'degraded' },
          ],
        },
      ]"
    >
      <span slot="header">Last updated: 2 min ago</span>
    </div>
  `,
})
export class StatusPage {}

Type

feature

Installation

npm install @molecule/app-status-summary-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

StatusComponent

A single monitored component with its current health status.

interface StatusComponent {
  /** Stable identifier, used as the rendered list key. */
  id: string
  /** Component name — text or an `ng-template` reference. */
  name: StatusSummaryNode
  /** Current health status. */
  status: ComponentStatus
  /** Optional sub-label (SLA %, region, etc.) — text or an `ng-template` reference. */
  subtitle?: StatusSummaryNode
}

StatusGroup

A named group of related StatusComponent entries.

interface StatusGroup {
  /** Stable identifier, used as the rendered section key. */
  id: string
  /** Group name — text or an `ng-template` reference. */
  name: StatusSummaryNode
  /** The components in this group. */
  components: StatusComponent[]
}

StatusSummaryProps

Props accepted by StatusSummary — the same props @molecule/app-status-summary-react accepts. The node props (header, footer) are projected content in Angular (an input cannot carry a node), so they are typed unknown: pass them in the host template ([slot=header] / [slot=footer]), not as values.

interface StatusSummaryProps {
  /** Grouped components. */
  groups: StatusGroup[]
  /** Overall summary label (auto-derived if omitted). */
  overallStatus?: ComponentStatus
  /** Header content (last updated time, subscribe button), projected as `[slot=header]`. */
  header?: unknown
  /** Below-the-grid content (incident list), projected as `[slot=footer]`. */
  footer?: unknown
  /** Extra classes. */
  className?: string
}

Types

ComponentStatus

Union of possible component health states.

type ComponentStatus =
  'operational' | 'degraded' | 'partial-outage' | 'major-outage' | 'maintenance'

Classes

StatusSummary

StatusSummary component.

Status-page summary — grouped component list with colored badges and an overall banner derived from the worst child status. The host IS the outer <div> (div[mol-status-summary]), matching React's root exactly. The header and footer are projected content ([slot=header], [slot=footer]) so consumers retain full control over the banner stamp and the incident list. Node-valued group / component names are ng-template references rendered through NgTemplateOutlet; text fields render as text.

@Component({
  selector: 'div[mol-status-summary]',
  standalone: true,
  imports: [NgTemplateOutlet],
  inputs: ['groups', 'overallStatus', 'className'],
  host: {
    '[class]': 'classes()',
  },
  // prettier-ignore
  template: `<div [class]="bannerClasses()" [style]="bannerStyle()"><span [class]="labelClasses()">{{ overallLabel() }}</span><ng-content select="[slot=header]"></ng-content></div>@for (group of groups; track group.id) {<section [class]="sectionClasses()"><h3 [class]="groupNameClasses()">@if (isNode(group.name)) {<ng-container [ngTemplateOutlet]="group.name" />}@else {<ng-container>{{ textOf(group.name) }}</ng-container>}</h3><ul [class]="listClasses()">@for (component of group.components; track component.id) {<li [class]="rowClasses()"><div><span [class]="componentNameClasses()">@if (isNode(component.name)) {<ng-container [ngTemplateOutlet]="component.name" />}@else {<ng-container>{{ textOf(component.name) }}</ng-container>}</span>@if (component.subtitle) {<span [class]="subtitleClasses()">@if (isNode(component.subtitle)) {<ng-container [ngTemplateOutlet]="component.subtitle" />}@else {<ng-container>{{ textOf(component.subtitle) }}</ng-container>}</span>}</div><span [class]="badgeClasses(component.status)" [style]="badgeStyle()">{{ statusLabel(component.status) }}</span></li>}</ul></section>}<ng-content select="[slot=footer]"></ng-content>`,
})
export class StatusSummary {
  /** Grouped components. */
  groups: StatusGroup[] = []
  /** Overall summary label (auto-derived at read time when omitted). */
  overallStatus?: ComponentStatus
  /** Extra classes on the outer `<div>`. */
  className?: string

  /**
   * Reactive translation, read in the injection context. Its `t` reads the
   * locale, so every label re-renders on a locale switch.
   */
  private readonly i18n = useTranslation()

  /**
   * The current class map.
   * @returns The UIClassMap.
   */
  cm(): UIClassMap {
    return getClassMap()
  }

  /**
   * The wrapper's class list (`cm.stack(4)` + `className`).
   * @returns The class string.
   */
  classes(): string {
    const cm = this.cm()
    return cm.cn(cm.stack(4), this.className)
  }

  /**
   * The banner's class list (flex row + padding + the overall status's tone
   * fill with the theme's inverse text on it).
   * @returns The class string.
   */
  bannerClasses(): string {
    const cm = this.cm()
    return cm.cn(
      cm.flex({ align: 'center', justify: 'between', gap: 'md' }),
      cm.sp('p', 3),
      cm.bgTone(STATUS_TONE[this.overall()]),
      cm.textOnTone,
    )
  }

  /** The banner label's class list. */
  labelClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('lg'), cm.fontWeight('bold'))
  }

  /** One group section's class list (`cm.stack(2)`). */
  sectionClasses(): string {
    return this.cm().stack(2)
  }

  /** One group heading's class list. */
  groupNameClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))
  }

  /** The component list's class list (`cm.stack(1)`). */
  listClasses(): string {
    return this.cm().stack(1)
  }

  /** One component row's class list (flex row, space between). */
  rowClasses(): string {
    const cm = this.cm()
    return cm.flex({ align: 'center', justify: 'between', gap: 'sm' })
  }

  /** One component name's class list. */
  componentNameClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('sm'), cm.fontWeight('medium'))
  }

  /** One component subtitle's class list. */
  subtitleClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.sp('ml', 2), cm.textSize('xs'))
  }

  /**
   * One status badge's class list (its status's tone fill with the theme's
   * inverse text on it).
   * @param status - The component's status.
   * @returns The class string.
   */
  badgeClasses(status: ComponentStatus): string {
    const cm = this.cm()
    return cm.cn(
      cm.sp('px', 2),
      cm.textSize('xs'),
      cm.fontWeight('semibold'),
      cm.bgTone(STATUS_TONE[status]),
      cm.textOnTone,
    )
  }

  /**
   * Every component status in the summary, in render order.
   * @returns The statuses.
   */
  allStatuses(): ComponentStatus[] {
    return this.groups.flatMap((group) => group.components.map((component) => component.status))
  }

  /**
   * The banner's status: React's `overallStatus ?? worst(allStatuses)`.
   * @returns The overall status.
   */
  overall(): ComponentStatus {
    if (this.overallStatus) return this.overallStatus
    const statuses = this.allStatuses()
    for (const status of SEVERITY_ORDER) {
      if (statuses.includes(status)) return status
    }
    return 'operational'
  }

  /**
   * The banner label, translated through the status's literal key.
   * @returns The label text.
   */
  overallLabel(): string {
    return this.statusLabel(this.overall())
  }

  /**
   * The label for one status, through its literal i18n key with the English
   * fallback (the same text the `common` locale bond's en.ts ships).
   * @param status - The component's status.
   * @returns The label text.
   */
  statusLabel(status: ComponentStatus): string {
    switch (status) {
      case 'operational':
        return this.i18n.t('status.operational', {}, { defaultValue: 'Operational' })
      case 'degraded':
        return this.i18n.t('status.degraded', {}, { defaultValue: 'Degraded performance' })
      case 'partial-outage':
        return this.i18n.t('status.partial-outage', {}, { defaultValue: 'Partial outage' })
      case 'major-outage':
        return this.i18n.t('status.major-outage', {}, { defaultValue: 'Major outage' })
      case 'maintenance':
        return this.i18n.t('status.maintenance', {}, { defaultValue: 'Under maintenance' })
    }
  }

  /**
   * The banner's rounded corners, in React's declaration order.
   * @returns The style declarations.
   */
  bannerStyle(): Record<string, string> {
    return { borderRadius: '8px' }
  }

  /**
   * One badge's rounded corners, in React's declaration order.
   * @returns The style declarations.
   */
  badgeStyle(): Record<string, string> {
    return { borderRadius: '4px' }
  }

  /**
   * Whether a field holds a node (an `ng-template` reference) rather than text.
   * @param value - The group or component field.
   * @returns True when it renders through a template outlet.
   */
  isNode(value: unknown): value is TemplateRef<unknown> {
    return value instanceof TemplateRef
  }

  /**
   * The text a field renders (React renders strings and numbers as text).
   * @param value - The group or component field.
   * @returns The text, or `''` for a node field.
   */
  textOf(value: unknown): string {
    return typeof value === 'string' || typeof value === 'number' ? String(value) : ''
  }
}

Injection Notes

Requirements

Peer dependencies:

  • @angular/common ^22.0.0
  • @angular/core ^22.0.0
  • @angular/platform-browser ^22.0.0
  • @molecule/app-angular ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.4.0
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common

  • @angular/core

  • @angular/platform-browser

  • @molecule/app-angular

  • @molecule/app-ui

  • @molecule/app-ui-angular

  • Must render inside the app's i18n provider and with a ClassMap bond wired (useTranslation() / getClassMap() throw otherwise).

  • When overallStatus is omitted the banner shows the WORST status found across all components (major-outage > partial-outage > degraded > maintenance > operational).

  • Status colors are a fixed hex palette applied via inline styles (green/yellow/orange/red/blue with white text) — they ignore the app theme and cannot be restyled via ClassMap; acceptable for status pages, but know they will not follow a rebrand.

  • Status labels use the status.operational … status.maintenance i18n keys, which the common locale bond ships in every language; the English fallbacks in code match its en.ts.

  • Node props are projected content: header and footer are selected by [slot=header] / [slot=footer]. Group and component names may be ng-template references or plain text.