import { Injectable } from '@angular/core' ; import { BreadcrumbItem } from './breadcrumb.model' ; import { BehaviorSubject } from 'rxjs' ; import { TypeService } from '../../../framework/services/type.service' ; import { ObjectService } from '../../../framework/services/object.service' ; import { RenderResult } from '../../../framework/models/cmdb-render' ; @ Injectable ( ) export class BreadcrumbService { public breadcrumbsSource : BehaviorSubject < BreadcrumbItem [ ] > ; constructor ( private typeService , private objService ) { this . breadcrumbsSource = new BehaviorSubject < BreadcrumbItem [ ] > ( [ ] ) ; } public store ( breadcrumbs ) { if ( breadcrumbs ) { const typeLabel = breadcrumbs . find ( x => x . label === 'Object Type List' ) ; if ( typeLabel && typeLabel . params . publicID !== undefined ) { this . typeService . getType ( typeLabel . params . publicID ) . subscribe ( type => typeLabel . label = type . label ) ; } const typeViewLabel = breadcrumbs . find ( x => x . label === 'Type View' ) ; if ( typeViewLabel && typeViewLabel . params . publicID !== undefined ) { typeViewLabel . label = 'View' ; this . objService . getObject ( breadcrumbs [ breadcrumbs . length - 1 ] . params . publicID ) . subscribe ( ( test ) => { breadcrumbs [ breadcrumbs . length - 2 ] . url = 'object/type/' + test . type_information . type_id ; breadcrumbs [ breadcrumbs . length - 2 ] . label = test . type_information . type_label ; } ) ; } this . breadcrumbsSource . next ( breadcrumbs ) ; } } public get ( ) { return this . breadcrumbsSource ; } }