import { Component } from '@angular/core' ; import { Inject } from '@angular/core' ; import { ZipkinService } from './../zipkin/zipkin' ; import * as moment from 'moment' ; @ Component ( { selector : 'searchbox' , template : require ( './searchbox.component.html' ) } ) export class SearchBoxComponent { customTime : boolean ; limit : number ; minDuration : number ; startDate : Date ; endDate : Date ; serviceName : string ; constructor ( @ Inject ( ZipkinService ) private zipkin ) { this . limit = 10 ; this . minDuration = 0 ; this . startDate = moment ( ) . toDate ( ) ; this . endDate = moment ( ) . subtract ( 1 , 'day' ) . toDate ( ) ; this . zipkin . getServices ( ) ; this . load ( ) ; } load ( ) { let minDuration = this . minDuration == 0 ? '' : this . minDuration ; let limit = this . limit ; this . zipkin . getTraces ( this . serviceName , this . startDate , this . endDate , limit , minDuration ) ; } updateTimeRange ( value ) { if ( value === 'custom' ) { this . customTime = true ; } else { this . customTime = false ; } } find ( serviceName , timerange , minDuration , limit , startDate , startTime , endDate , endTime ) { if ( timerange === 'custom' ) { } else { this . startDate = moment ( ) . toDate ( ) ; this . endDate = moment ( ) . subtract ( timerange , 'minutes' ) . toDate ( ) ; } this . serviceName = serviceName ; this . limit = + limit ; this . minDuration = + minDuration ; this . load ( ) ; } formatTime ( date ) { return moment ( date ) . format ( 'HH:mm' ) ; } formatDate ( date ) { return moment ( date ) . format ( 'YYYY-MM-DD' ) ; } }