1/*
2 * Copyright (C) 2023 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 */
16
17import {Component, Input, ViewChild} from '@angular/core';
18import {TraceType} from 'trace/trace_type';
19import {CollapsibleSections} from 'viewers/common/collapsible_sections';
20import {CollapsibleSectionType} from 'viewers/common/collapsible_section_type';
21import {LogComponent} from 'viewers/components/log_component';
22import {selectedElementStyle} from 'viewers/components/styles/selected_element.styles';
23import {viewerCardStyle} from 'viewers/components/styles/viewer_card.styles';
24import {UiData} from './ui_data';
25
26@Component({
27  selector: 'viewer-transitions',
28  template: `
29    <div class="card-grid">
30      <collapsed-sections
31        [class.empty]="sections.areAllSectionsExpanded()"
32        [sections]="sections"
33        (sectionChange)="sections.onCollapseStateChange($event, false)">
34      </collapsed-sections>
35
36      <log-view
37        class="log-view"
38        [selectedIndex]="inputData?.selectedIndex"
39        [scrollToIndex]="inputData?.scrollToIndex"
40        [currentIndex]="inputData?.currentIndex"
41        [entries]="inputData?.entries"
42        [headers]="inputData?.headers"
43        [traceType]="${TraceType.TRANSITION}"
44        [showTraceEntryTimes]="false"
45        [showCurrentTimeButton]="false">
46      </log-view>
47
48      <properties-view
49        class="properties-view"
50        [title]="propertiesTitle"
51        [propertiesTree]="inputData?.propertiesTree"
52        [traceType]="${TraceType.TRANSITION}"
53        [textFilter]="inputData?.propertiesFilter"
54        [isProtoDump]="false"
55        placeholderText="No current or selected transition."
56        (collapseButtonClicked)="sections.onCollapseStateChange(CollapsibleSectionType.PROPERTIES, true)"
57        [class.collapsed]="sections.isSectionCollapsed(CollapsibleSectionType.PROPERTIES)"></properties-view>
58    </div>
59  `,
60  styles: [
61    `
62      .properties-view {
63        flex: 1;
64      }
65    `,
66    selectedElementStyle,
67    viewerCardStyle,
68  ],
69})
70export class ViewerTransitionsComponent {
71  @Input() inputData: UiData | undefined;
72
73  @ViewChild(LogComponent)
74  logComponent?: LogComponent;
75
76  propertiesTitle = 'SELECTED TRANSITION';
77  CollapsibleSectionType = CollapsibleSectionType;
78  sections = new CollapsibleSections([
79    {
80      type: CollapsibleSectionType.PROPERTIES,
81      label: this.propertiesTitle,
82      isCollapsed: false,
83    },
84  ]);
85}
86