import { Injectable } from '@angular/core' ; import { AngularFireDatabase } from 'angularfire2/database' ; import * as firebase from 'firebase/app' ; @ Injectable ( ) export class ProfileService { public driverProfile : any ; public userProfile : any ; public activityProfile : any ; public dashboardProfile : any ; public ActiveDriverProfile : any ; public ItemProfile : any ; public userFeed : any ; public driverFeed : any ; public subitemProfile : any ; constructor ( public af ) { this . dashboardProfile = firebase . database ( ) . ref ( `DashboardSettings` ) ; this . driverProfile = firebase . database ( ) . ref ( `driverProfile` ) ; this . userFeed = firebase . database ( ) . ref ( `DashboardSettings/user/complains` ) ; this . driverFeed = firebase . database ( ) . ref ( `DashboardSettings/driver/complains` ) ; this . userProfile = firebase . database ( ) . ref ( `userProfile` ) ; this . activityProfile = firebase . database ( ) . ref ( `Customer` ) ; this . ActiveDriverProfile = firebase . database ( ) . ref ( `Drivers` ) ; this . ItemProfile = firebase . database ( ) . ref ( `ItemProfile` ) ; this . subitemProfile = firebase . database ( ) . ref ( `ItemProfile/Stuffs` ) ; } getActivityProfile ( ) { return this . activityProfile ; } getItemProfile ( id ) { return this . ItemProfile . child ( id ) ; } getDriverProfile ( id ) { return this . driverProfile . child ( id ) ; } _getDriverProfile ( ) { return this . driverProfile ; } getUserProfile ( id ) { return this . userProfile . child ( id ) ; } _getUserProfile ( ) { return this . userProfile ; } _getFeedUserProfile ( ) { return this . userFeed ; } getFeedUserProfile ( id ) { return this . userFeed . child ( id ) ; } getFeedDriverProfile ( id ) { return this . driverFeed . child ( id ) ; } _getFeedDriverProfile ( ) { return this . driverFeed ; } ChangeItem ( id , idi ) { return firebase . database ( ) . ref ( `ItemProfile/${ id }/Stuffs/${ idi }` ) ; } ChangeMainItem ( id ) { return firebase . database ( ) . ref ( `ItemProfile/${ id }/` ) ; } getInnerItem ( id ) { return firebase . database ( ) . ref ( `ItemProfile/${ id }/Stuffs` ) ; } getSecondaryItem ( id , subid ) { return firebase . database ( ) . ref ( `ItemProfile/${ id }/Stuffs/${ subid }` ) ; } getDashboardProfile ( ) { return this . dashboardProfile ; } getActiveDriverProfile ( ) { return this . ActiveDriverProfile ; } updateState ( id ) { return this . driverProfile . child ( id ) . update ( { active_state : true } ) ; } }