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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 14x 14x 14x 14x 3x 14x 4x 10x 14x 9x 14x 9x 12x 9x 9x 9x 9x 1x 14x | /** * Copyright (c) Siemens 2016 - 2025 * SPDX-License-Identifier: MIT */ import { A11yModule } from '@angular/cdk/a11y'; import { CommonModule } from '@angular/common'; import { booleanAttribute, ChangeDetectionStrategy, Component, computed, inject, input, output } from '@angular/core'; import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router'; import { addIcons, elementCancel, elementDown2, SiIconComponent } from '@siemens/element-ng/icon'; import { SiLinkModule } from '@siemens/element-ng/link'; import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate'; import { SiApplicationHeaderComponent } from '../si-application-header.component'; import { SiLaunchpadAppComponent } from './si-launchpad-app.component'; import { App, AppCategory } from './si-launchpad.model'; export interface FavoriteChangeEvent { app: App; favorite: boolean; } @Component({ selector: 'si-launchpad-factory', imports: [ A11yModule, CommonModule, SiLinkModule, SiTranslatePipe, SiLaunchpadAppComponent, SiIconComponent, RouterLinkActive, RouterLink ], templateUrl: './si-launchpad-factory.component.html', styleUrl: './si-launchpad-factory.component.scss', changeDetection: ChangeDetectionStrategy.OnPush }) export class SiLaunchpadFactoryComponent { /** * Text to close the launchpad. Needed for a11y. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.CLOSE:Close launchpad`) * ``` */ readonly closeText = input(t(() => $localize`:@@SI_LAUNCHPAD.CLOSE:Close launchpad`)); /** * Title of the launchpad. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.TITLE:Launchpad`) * ``` */ readonly titleText = input(t(() => $localize`:@@SI_LAUNCHPAD.TITLE:Launchpad`)); /** * Subtitle of the launchpad. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.SUBTITLE:Access all your apps`) * ``` */ readonly subtitleText = input(t(() => $localize`:@@SI_LAUNCHPAD.SUBTITLE:Access all your apps`)); /** All app items shown in the launchpad. */ readonly apps = input.required<App[] | AppCategory[]>(); /** * Allow the user to select favorite apps which will then be displayed at the top. * * @defaultValue false */ readonly enableFavorites = input(false, { transform: booleanAttribute }); /** * Title of the favorite apps section. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.FAVORITE_APPS:Favorite apps`) * ``` */ readonly favoriteAppsText = input( t(() => $localize`:@@SI_LAUNCHPAD.FAVORITE_APPS:Favorite apps`) ); /** * Title of the show more apps button. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.SHOW_MORE:Show more`) * ``` */ readonly showMoreAppsText = input(t(() => $localize`:@@SI_LAUNCHPAD.SHOW_MORE:Show more`)); /** * Title of the show less apps button. * * @defaultValue * ``` * t(() => $localize`:@@SI_LAUNCHPAD.SHOW_LESS:Show less`) * ``` */ readonly showLessAppsText = input(t(() => $localize`:@@SI_LAUNCHPAD.SHOW_LESS:Show less`)); readonly favoriteChange = output<FavoriteChangeEvent>(); protected showAllApps = false; protected readonly categories = computed(() => { const apps = this.apps(); const favorites = this.favorites(); const categories: AppCategory[] = []; if (this.enableFavorites() && this.hasFavorites()) { categories.push({ name: this.favoriteAppsText(), apps: favorites }); } if (this.isCategories(apps)) { categories.push(...apps); } else { categories.push({ name: '', apps: [...apps] }); } return categories; }); protected readonly favorites = computed(() => this.apps() .flatMap(app => ('apps' in app ? app.apps : (app as App))) .filter(app => app.favorite) ); protected readonly hasFavorites = computed(() => this.favorites().length > 0); protected readonly icons = addIcons({ elementDown2, elementCancel }); protected readonly activatedRoute = inject(ActivatedRoute, { optional: true }); private header = inject(SiApplicationHeaderComponent); protected closeLaunchpad(): void { this.header.closeLaunchpad(); } protected toggleFavorite(app: App, favorite: boolean): void { this.favoriteChange.emit({ app, favorite }); } protected escape(): void { this.closeLaunchpad(); } protected isCategories(items: App[] | AppCategory[]): items is AppCategory[] { return items.some(item => 'apps' in item); } } |