import { IMineMeldAPIService } from './minemeldapi' ; export interface IMinemeldMetricsService { getNodeType ( nodetype , options ? ) : angular . IPromise < any > ; getMinemeld ( options ? ) : angular . IPromise < any > ; getNode ( nodename , options ? ) ; } interface IMetricsParams { cf ? : string ; r ? : number ; dt ? : number ; } interface INTMetricsParams extends IMetricsParams { nodetype : string ; } interface INodeMetricsParams extends IMetricsParams { nodename : string ; } export class MinemeldMetricsService implements IMinemeldMetricsService { $state : angular . ui . IStateService ; MineMeldAPIService : IMineMeldAPIService ; ngInject constructor ( $state , MineMeldAPIService ) { this . $state = $state ; this . MineMeldAPIService = MineMeldAPIService ; } public getNodeType ( nodetype , options ? ) { var params = < INTMetricsParams > { nodetype : nodetype } ; var metricsNodeType ; if ( options ) { if ( options . cf ) { params . cf = options . cf ; } if ( options . dt ) { params . dt = options . dt ; } if ( options . r ) { params . r = options . r ; } } metricsNodeType = this . MineMeldAPIService . getAPIResource ( '/metrics/minemeld/:nodetype' , { } , { get : { method : 'GET' } } ) ; return metricsNodeType . get ( params ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return [ ] ; } ) ; } public getNode ( nodename , options ? ) { var params = < INodeMetricsParams > { nodename : nodename } ; var metricsNode ; if ( options ) { if ( options . cf ) { params . cf = options . cf ; } if ( options . dt ) { params . dt = options . dt ; } if ( options . r ) { params . r = options . r ; } } metricsNode = this . MineMeldAPIService . getAPIResource ( '/metrics/:nodename' , { } , { get : { method : 'GET' } } ) ; return metricsNode . get ( params ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return [ ] ; } ) ; } public getMinemeld ( options ? ) { var params = < IMetricsParams > { } ; var metricsMinemeld ; if ( options ) { if ( options . cf ) { params . cf = options . cf ; } if ( options . dt ) { params . dt = options . dt ; } if ( options . r ) { params . r = options . r ; } } metricsMinemeld = this . MineMeldAPIService . getAPIResource ( '/metrics/minemeld' , { } , { get : { method : 'GET' } } ) ; return metricsMinemeld . get ( params ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return [ ] ; } ) ; } }