Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 1 | <!-- 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 Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 17 | <span class="key">{{ key }} </span> |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 18 | <span v-if="value">: </span> |
| 19 | <span class="value" v-if="value" :class="[valueClass]">{{ value }}</span> |
| 20 | </span> |
| 21 | </template> |
| 22 | <script> |
| 23 | export default { |
| 24 | name: 'PropertiesTreeElement', |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 25 | props: ['item', 'simplify-names'], |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 26 | computed: { |
| 27 | key() { |
| 28 | if (!this.item.children || this.item.children.length === 0) { |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 29 | return this.item.name.split(': ')[0]; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | return this.item.name; |
| 33 | }, |
| 34 | value() { |
| 35 | if (!this.item.children || this.item.children.length === 0) { |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 36 | return this.item.name.split(': ').slice(1).join(': '); |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | return null; |
| 40 | }, |
| 41 | valueClass() { |
| 42 | if (!this.value) { |
| 43 | return null; |
| 44 | } |
| 45 | |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 46 | if (this.value == 'null') { |
| 47 | return 'null'; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 50 | if (this.value == 'true') { |
| 51 | return 'true'; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 54 | if (this.value == 'false') { |
| 55 | return 'false'; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | if (!isNaN(this.value)) { |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 59 | return 'number'; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 60 | } |
Pablo Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 61 | }, |
| 62 | }, |
| 63 | }; |
Pablo Gamito | 06102a2 | 2020-07-23 14:25:24 +0100 | [diff] [blame] | 64 | </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 Gamito | 84c82dc | 2020-09-29 20:18:05 +0200 | [diff] [blame] | 84 | </style> |