import { Component , OnInit } from '@angular/core' ; import { RenderFieldComponent } from '../../fields/components.fields' ; import { ObjectService } from '../../../services/object.service' ; import { RenderResult } from '../../../models/cmdb-render' ; import { TypeReference } from '../../../models/cmdb-type-reference' ; type TypeReferenceTemplate = { reference : TypeReference ; value : any ; } ; @ Component ( { selector : 'cmdb-ref-simple' , templateUrl : './ref-simple.component.html' , styleUrls : [ './ref-simple.component.scss' ] } ) export class RefSimpleComponent extends RenderFieldComponent implements OnInit { public refData : TypeReferenceTemplate = { reference : new TypeReference ( ) , value : null } ; constructor ( private objectService ) { super ( ) ; } public ngOnInit ( ) { if ( this . data && this . data . value && this . data . value !== 0 ) { if ( ! this . data . reference ) { this . objectService . getObject ( this . data . value ) . subscribe ( ( res ) => { console . log ( res ) ; this . refData = { reference : new TypeReference ( { type_id : res . type_information . type_id , object_id : res . object_information . object_id , icon : res . type_information . icon , type_label : res . type_information . type_label , summaries : res . summaries } ) , value : this . data . value , } ; } ) ; } else { this . refData = this . data ; } } else { this . refData = undefined ; } } }