import { Injectable } from '@angular/core' ; import { Observable , BehaviorSubject } from 'rxjs' ; import { HttpClient } from '@angular/common/http' ; import { ApiService } from '../api/api.service' ; @ Injectable ( ) export class SidebarService extends ApiService { private globalDSRoute = '/datasource' ; private _datasources = new BehaviorSubject < any > ( [ ] ) ; currentDatasources = this . _datasources . asObservable ( ) ; private _datasourcesDB = new BehaviorSubject < any > ( [ ] ) ; currentDatasourcesDB = this . _datasourcesDB . asObservable ( ) ; public toggleSideNav : boolean = false ; public hideSideNavSubj : BehaviorSubject < boolean > ; public menu : any [ ] = [ { title : 'Fuentes principales' , icon : 'mdi mdi-database' , submenu : [ ] } ] ; constructor ( protected http ) { super ( http ) ; this . hideSideNavSubj = new BehaviorSubject < boolean > ( false ) ; } getDataSourceNames ( ) { this . get ( this . globalDSRoute + '/names' ) . subscribe ( ( names ) => { this . _datasources . next ( names . ds ) ; } , err => console . log ( err ) ) ; } getDataSourceNamesForDashboard ( ) { this . get ( this . globalDSRoute + '/namesForDashboard' ) . subscribe ( ( names ) => { this . _datasourcesDB . next ( names . ds ) ; } , err => console . log ( err ) ) ; } getDataSources ( ) { return this . get ( this . globalDSRoute ) ; } setHideSideNav ( ) { this . toggleSideNav = ! this . toggleSideNav ; this . hideSideNavSubj . next ( this . toggleSideNav ) ; } setManualHideSideNav ( value ) { this . hideSideNavSubj . next ( value ) ; } getToggleSideNav ( ) { return this . hideSideNavSubj . asObservable ( ) ; } }