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} from '@angular/core'; 17import {PropertiesTreeNode} from 'viewers/common/ui_tree_utils'; 18import {treeNodePropertiesDataViewStyles} from 'viewers/components/styles/tree_node_data_view.styles'; 19 20@Component({ 21 selector: 'tree-node-properties-data-view', 22 template: ` 23 <p class="mat-body-1"> 24 {{ item.propertyKey }} 25 <ng-container *ngIf="item.propertyValue"> 26 :&ngsp; 27 <span [class]="[valueClass()]" class="value">{{ item.propertyValue }}</span> 28 </ng-container> 29 </p> 30 `, 31 styles: [treeNodePropertiesDataViewStyles], 32}) 33export class TreeNodePropertiesDataViewComponent { 34 @Input() item!: PropertiesTreeNode; 35 36 valueClass() { 37 if (!this.item.propertyValue) { 38 return null; 39 } 40 41 if (this.item.propertyValue === 'null') { 42 return 'null'; 43 } 44 45 if (this.item.propertyValue === 'true') { 46 return 'true'; 47 } 48 49 if (this.item.propertyValue === 'false') { 50 return 'false'; 51 } 52 53 if (!isNaN(Number(this.item.propertyValue))) { 54 return 'number'; 55 } 56 57 return null; 58 } 59} 60