1/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import {Component, Input} from '@angular/core';
17import {Chip} from 'viewers/common/chip';
18import {UiHierarchyTreeNode} from 'viewers/common/ui_hierarchy_tree_node';
19import {hierarchyTreeNodeDataViewStyles} from 'viewers/components/styles/tree_node_data_view.styles';
20
21@Component({
22  selector: 'hierarchy-tree-node-data-view',
23  template: `
24    <span class="mat-body-1" *ngIf="node">
25      <span class="mat-body-2" *ngIf="node.heading()">{{ node.heading() }}</span>
26      <ng-container *ngIf="node.heading()">&ngsp;-&ngsp;</ng-container>
27      <span>{{ node.getDisplayName() }}</span>
28      <div *ngFor="let chip of node.getChips()" [class]="chipClass(chip)" [matTooltip]="chip.long">
29        {{ chip.short }}
30      </div>
31    </span>
32  `,
33  styles: [hierarchyTreeNodeDataViewStyles],
34})
35export class HierarchyTreeNodeDataViewComponent {
36  @Input() node?: UiHierarchyTreeNode;
37
38  chipClass(chip: Chip) {
39    return [
40      'tree-view-internal-chip',
41      'tree-view-chip',
42      'tree-view-chip' + '-' + (chip.type.toString() || 'default'),
43    ];
44  }
45}
46