1<!-- Copyright (C) 2019 The Android Open Source Project
2
3     Licensed under the Apache License, Version 2.0 (the "License");
4     you may not use this file except in compliance with the License.
5     You may obtain a copy of the License at
6
7          http://www.apache.org/licenses/LICENSE-2.0
8
9     Unless required by applicable law or agreed to in writing, software
10     distributed under the License is distributed on an "AS IS" BASIS,
11     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12     See the License for the specific language governing permissions and
13     limitations under the License.
14-->
15<template>
16  <md-card v-if="file">
17    <md-card-header>
18      <md-card-header-text>
19        <div class="md-title">
20          <md-icon>{{file.type.icon}}</md-icon> {{file.filename}}
21        </div>
22      </md-card-header-text>
23      <md-button :href="file.blobUrl" :download="file.filename" class="md-icon-button">
24        <md-icon>save_alt</md-icon>
25      </md-button>
26    </md-card-header>
27    <traceview v-if="isTrace" :store="store" :file="file" ref="view" />
28    <videoview v-if="isVideo" :file="file" ref="view" />
29    <logview v-if="isLog" :file="file" ref="view" />
30    <div v-if="!(isTrace || isVideo || isLog)">
31      <h1 class="bad">Unrecognized DataType</h1>
32    </div>
33  </md-card>
34</template>
35<script>
36import TraceView from './TraceView.vue'
37import VideoView from './VideoView.vue'
38import LogView from './LogView.vue'
39import { DATA_TYPES } from './decode.js'
40
41export default {
42  name: 'dataview',
43  data() {
44    return {}
45  },
46  methods: {
47    arrowUp() {
48      return this.$refs.view.arrowUp();
49    },
50    arrowDown() {
51      return this.$refs.view.arrowDown();
52    },
53  },
54  props: ['store', 'file'],
55  computed: {
56    isTrace() {
57      return this.file.type == DATA_TYPES.WINDOW_MANAGER ||
58          this.file.type == DATA_TYPES.SURFACE_FLINGER ||
59          this.file.type == DATA_TYPES.TRANSACTION ||
60          this.file.type == DATA_TYPES.WAYLAND ||
61          this.file.type == DATA_TYPES.SYSTEM_UI ||
62          this.file.type == DATA_TYPES.LAUNCHER
63    },
64    isVideo() {
65      return this.file.type == DATA_TYPES.SCREEN_RECORDING;
66    },
67    isLog() {
68      return this.file.type == DATA_TYPES.PROTO_LOG
69    }
70  },
71  components: {
72    'traceview': TraceView,
73    'videoview': VideoView,
74    'logview': LogView,
75  }
76}
77
78</script>
79<style>
80.bad {
81  margin: 1em 1em 1em 1em;
82  font-size: 4em;
83  color: red;
84}
85</style>
86