import { IMinemeldStatusService , IMinemeldStatus } from '../../app/services/status' ; export interface INodeDetailResolverService { registerClass ( classname , classdetails ) ; resolveNode ( nodename ) ; } export interface INodeDetailTab { icon : string ; tooltip : string ; state : string ; active : boolean ; } export interface INodeDetailClass { tabs : INodeDetailTab [ ] ; } export class NodeDetailResolver implements INodeDetailResolverService { mmstatus : IMinemeldStatusService ; $resource : angular . resource . IResourceService ; $q : angular . IQService ; $rootScope : angular . IRootScopeService ; nodeClasses : any = { } ; defaultClass : INodeDetailClass = { tabs : [ { icon : 'fa fa-circle-o' , tooltip : 'INFO' , state : 'nodedetail.info' , active : false } , { icon : 'fa fa-area-chart' , tooltip : 'STATS' , state : 'nodedetail.stats' , active : false } , { icon : 'fa fa-asterisk' , tooltip : 'GRAPH' , state : 'nodedetail.graph' , active : false } ] } ; ngInject constructor ( MinemeldStatusService , $resource , $q , $rootScope ) { this . mmstatus = MinemeldStatusService ; this . $resource = $resource ; this . $q = $q ; this . $rootScope = $rootScope ; } registerClass ( classname , classdetails ) { this . nodeClasses [ classname ] = classdetails ; } resolveNode ( nodename ) { return this . mmstatus . getStatus ( ) . then ( ( currentStatus ) => { var node = currentStatus [ nodename ] ; if ( this . nodeClasses . hasOwnProperty ( node . class ) ) { return this . nodeClasses [ node . class ] ; } return this . defaultClass ; } ) ; } }