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