import { INodeDetailResolverService } from '../../app/services/nodedetailresolver' ; import { IMinemeldConfigService } from '../../app/services/config' ; import { NodeDetailInfoController } from './nodedetail.info.controller' ; import { IMinemeldStatusService } from '../../app/services/status' ; import { IThrottleService } from '../../app/services/throttle' ; import { IConfirmService } from '../../app/services/confirm' ; ngInject function autofocusExportListConfig ( $stateProvider ) { $stateProvider . state ( 'nodedetail.autofocuselinfo' , { templateUrl : 'app/nodedetail/autofocusel.info.html' , controller : NodeDetailAutofocusELInfoController , controllerAs : 'nodedetailinfo' } ) ; } ngInject function autofocusELRegisterClass ( NodeDetailResolver ) { NodeDetailResolver . registerClass ( 'minemeld.ft.autofocus.ExportList' , { tabs : [ { icon : 'fa fa-circle-o' , tooltip : 'INFO' , state : 'nodedetail.autofocuselinfo' , 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 } ] } ) ; } class NodeDetailAutofocusELInfoController extends NodeDetailInfoController { MinemeldConfigService : IMinemeldConfigService ; ConfirmService : IConfirmService ; api_key : string ; label : string ; $modal : angular . ui . bootstrap . IModalService ; constructor ( toastr , $interval , MinemeldStatusService , moment , $scope , $compile , $state , $stateParams , MinemeldConfigService , $modal , $rootScope , ThrottleService , ConfirmService ) { this . MinemeldConfigService = MinemeldConfigService ; this . ConfirmService = ConfirmService ; this . $modal = $modal ; super ( toastr , $interval , MinemeldStatusService , moment , $scope , $compile , $state , $stateParams , $rootScope , ThrottleService ) ; this . loadSideConfig ( ) ; } flush ( ) { this . ConfirmService . show ( 'FLUSH INDICATORS' , 'Are you sure you want to flush indicators of ' + this . nodename + ' ?' ) . then ( ( result ) => { this . mmstatus . signal ( this . nodename , 'flush' ) . then ( ( result ) => { this . toastr . success ( 'FLUSH SCHEDULED. THIS MAY TAKE A WHILE' ) ; } , ( error ) => { this . toastr . error ( 'ERROR SCHEDULING FLUSH: ' + error . statusText ) ; } ) ; } ) ; } loadSideConfig ( ) { this . MinemeldConfigService . getDataFile ( this . nodename + '_side_config' ) . then ( ( result ) => { if ( ! result ) { return ; } if ( result . api_key ) { this . api_key = result . api_key ; } else { this . api_key = undefined ; } if ( result . label ) { this . label = result . label ; } else { this . label = undefined ; } } , ( error ) => { this . toastr . error ( 'ERROR RETRIEVING NODE SIDE CONFIG: ' + error . status ) ; this . api_key = undefined ; this . label = undefined ; } ) ; } saveSideConfig ( ) { var side_config = { } ; var hupnode = this . nodename ; if ( this . api_key ) { side_config . api_key = this . api_key ; } else { hupnode = undefined ; } if ( this . label ) { side_config . label = this . label ; } else { hupnode = undefined ; } return this . MinemeldConfigService . saveDataFile ( this . nodename + '_side_config' , side_config , hupnode ) ; } setAPIKey ( ) { var mi ; mi = this . $modal . open ( { templateUrl : 'app/nodedetail/autofocus.sak.modal.html' , controller : AutofocusSetAPIKeyController , controllerAs : 'vm' , bindToController : true , backdrop : 'static' , animation : false } ) ; mi . result . then ( ( result ) => { this . api_key = result . api_key ; return this . saveSideConfig ( ) . then ( ( result ) => { this . toastr . success ( 'API KEY SET' ) ; } , ( error ) => { this . toastr . error ( 'ERROR SETTING API KEY: ' + error . status ) ; } ) ; } ) ; } setLabel ( ) { var mi ; mi = this . $modal . open ( { templateUrl : 'app/nodedetail/autofocus.sl.modal.html' , controller : AutofocusSetLabelController , controllerAs : 'vm' , bindToController : true , backdrop : 'static' , animation : false , resolve : { label : ( ) => { return this . label ; } } } ) ; mi . result . then ( ( result ) => { this . label = result . label ; return this . saveSideConfig ( ) . then ( ( result ) => { this . toastr . success ( 'LABEL SET' ) ; } , ( error ) => { this . toastr . error ( 'ERROR SETTING LABEL: ' + error . status ) ; } ) ; } ) ; } } class AutofocusSetAPIKeyController { $modalInstance : angular . ui . bootstrap . IModalServiceInstance ; api_key : string ; api_key2 : string ; valid ( ) { if ( this . api_key !== this . api_key2 ) { angular . element ( '#fgAPIKey1' ) . addClass ( 'has-error' ) ; angular . element ( '#fgAPIKey2' ) . addClass ( 'has-error' ) ; return false ; } angular . element ( '#fgAPIKey1' ) . removeClass ( 'has-error' ) ; angular . element ( '#fgAPIKey2' ) . removeClass ( 'has-error' ) ; if ( ! this . api_key ) { return false ; } return true ; } ngInject constructor ( $modalInstance ) { this . $modalInstance = $modalInstance ; } save ( ) { var result = { } ; result . api_key = this . api_key ; this . $modalInstance . close ( result ) ; } cancel ( ) { this . $modalInstance . dismiss ( ) ; } } ; class AutofocusSetLabelController { $modalInstance : angular . ui . bootstrap . IModalServiceInstance ; label : string ; valid ( ) { if ( ! this . label ) { return false ; } return true ; } ngInject constructor ( $modalInstance , label ) { this . $modalInstance = $modalInstance ; this . label = label ; } save ( ) { var result = { } ; result . label = this . label ; this . $modalInstance . close ( result ) ; } cancel ( ) { this . $modalInstance . dismiss ( ) ; } } ; console . log ( 'Loading Autofocus ExportList' ) ; angular . module ( 'minemeldWebui' ) . config ( autofocusExportListConfig ) . run ( autofocusELRegisterClass ) ;