blob: 07293f937c454b9c0060e4836d73e0e35fe25558 [file] [log] [blame]
Pablo Gamito06102a22020-07-23 14:25:24 +01001<!-- Copyright (C) 2020 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 <span>
Pablo Gamito84c82dc2020-09-29 20:18:05 +020017 <span class="key">{{ key }} </span>
Pablo Gamito06102a22020-07-23 14:25:24 +010018 <span v-if="value">: </span>
19 <span class="value" v-if="value" :class="[valueClass]">{{ value }}</span>
20 </span>
21</template>
22<script>
23export default {
24 name: 'PropertiesTreeElement',
Pablo Gamito84c82dc2020-09-29 20:18:05 +020025 props: ['item', 'simplify-names'],
Pablo Gamito06102a22020-07-23 14:25:24 +010026 computed: {
27 key() {
28 if (!this.item.children || this.item.children.length === 0) {
Pablo Gamito84c82dc2020-09-29 20:18:05 +020029 return this.item.name.split(': ')[0];
Pablo Gamito06102a22020-07-23 14:25:24 +010030 }
31
32 return this.item.name;
33 },
34 value() {
35 if (!this.item.children || this.item.children.length === 0) {
Pablo Gamito84c82dc2020-09-29 20:18:05 +020036 return this.item.name.split(': ').slice(1).join(': ');
Pablo Gamito06102a22020-07-23 14:25:24 +010037 }
38
39 return null;
40 },
41 valueClass() {
42 if (!this.value) {
43 return null;
44 }
45
Pablo Gamito84c82dc2020-09-29 20:18:05 +020046 if (this.value == 'null') {
47 return 'null';
Pablo Gamito06102a22020-07-23 14:25:24 +010048 }
49
Pablo Gamito84c82dc2020-09-29 20:18:05 +020050 if (this.value == 'true') {
51 return 'true';
Pablo Gamito06102a22020-07-23 14:25:24 +010052 }
53
Pablo Gamito84c82dc2020-09-29 20:18:05 +020054 if (this.value == 'false') {
55 return 'false';
Pablo Gamito06102a22020-07-23 14:25:24 +010056 }
57
58 if (!isNaN(this.value)) {
Pablo Gamito84c82dc2020-09-29 20:18:05 +020059 return 'number';
Pablo Gamito06102a22020-07-23 14:25:24 +010060 }
Pablo Gamito84c82dc2020-09-29 20:18:05 +020061 },
62 },
63};
Pablo Gamito06102a22020-07-23 14:25:24 +010064</script>
65<style scoped>
66.key {
67 color: #4b4b4b;
68}
69.value {
70 color: #8A2BE2;
71}
72.value.null {
73 color: #e1e1e1;
74}
75.value.number {
76 color: #4c75fd;
77}
78.value.true {
79 color: #2ECC40;
80}
81.value.false {
82 color: #FF4136;
83}
Pablo Gamito84c82dc2020-09-29 20:18:05 +020084</style>