@@ -350,7 +350,7 @@ export class AgentConfiguration extends PureComponent<
350
350
} )
351
351
}
352
352
353
- public onClickTableRowCall = async ( host : string , ip : string ) => {
353
+ public onClickTableRowCall = ( host : string , ip : string ) => {
354
354
if ( this . state . focusedHost === host ) return
355
355
const {
356
356
notify,
@@ -376,59 +376,69 @@ export class AgentConfiguration extends PureComponent<
376
376
host
377
377
)
378
378
379
- getLocalFileReadPromise . then ( ( { data} ) => {
380
- const hostData = data . return [ 0 ] [ host ]
381
- const hostLocalFileReadData = hostData . substring (
382
- 0 ,
383
- hostData . lastIndexOf ( '\n' )
384
- )
385
- const configObj = TOML . parse ( hostLocalFileReadData )
386
- const agent : any = _ . get ( configObj , 'agent' )
379
+ getLocalFileReadPromise
380
+ . then ( ( { data} ) => {
381
+ const hostData = data . return [ 0 ] [ host ]
382
+ const hostLocalFileReadData = hostData . substring (
383
+ 0 ,
384
+ hostData . lastIndexOf ( '\n' )
385
+ )
386
+ const configObj = TOML . parse ( hostLocalFileReadData )
387
+ const agent : any = _ . get ( configObj , 'agent' )
387
388
388
- let isChanged = false
389
+ let isChanged = false
389
390
390
- if ( agent . hostname !== host ) {
391
- notify ( notifyAgentConfigHostNameChanged ( agent . hostname , host ) )
392
- _ . set ( agent , 'hostname' , host )
393
- isChanged = true
394
- }
391
+ if ( agent . hostname !== host ) {
392
+ notify ( notifyAgentConfigHostNameChanged ( agent . hostname , host ) )
393
+ _ . set ( agent , 'hostname' , host )
394
+ isChanged = true
395
+ }
395
396
396
- this . setState ( {
397
- configScript : TOML . stringify ( configObj ) ,
398
- isGetLocalStorage : isChanged ,
399
- isApplyBtnDisabled : isChanged ? ! isChanged : true ,
400
- collectorConfigStatus : RemoteDataState . Done ,
401
- configPageStatus : RemoteDataState . Done ,
402
- selectedOrg : this . DEFAULT_DROPDOWN_TEXT ,
397
+ this . setState ( {
398
+ configScript : TOML . stringify ( configObj ) ,
399
+ isGetLocalStorage : isChanged ,
400
+ isApplyBtnDisabled : isChanged ? ! isChanged : true ,
401
+ collectorConfigStatus : RemoteDataState . Done ,
402
+ configPageStatus : RemoteDataState . Done ,
403
+ selectedOrg : this . DEFAULT_DROPDOWN_TEXT ,
404
+ } )
405
+ } )
406
+ . catch ( error => {
407
+ console . error ( error )
403
408
} )
404
- } )
405
409
406
410
const getLocalServiceGetRunningPromise = getLocalServiceGetRunning (
407
411
saltMasterUrl ,
408
412
saltMasterToken ,
409
413
host
410
414
)
411
415
412
- getLocalServiceGetRunningPromise . then ( ( { data} ) => {
413
- const { defaultService} = this . state
414
- const getServiceRunning = defaultService
415
- . filter ( m => data . return [ 0 ] [ host ] . includes ( m ) )
416
- . map ( sMeasure => ( {
417
- name : sMeasure ,
418
- isActivity : false ,
419
- } ) )
420
-
421
- const getDefaultMeasure = this . defaultMeasurementsData . map ( dMeasure => ( {
422
- name : dMeasure ,
423
- isActivity : false ,
424
- } ) )
416
+ getLocalServiceGetRunningPromise
417
+ . then ( ( { data} ) => {
418
+ const { defaultService} = this . state
419
+ const getServiceRunning = defaultService
420
+ . filter ( m => data . return [ 0 ] [ host ] . includes ( m ) )
421
+ . map ( sMeasure => ( {
422
+ name : sMeasure ,
423
+ isActivity : false ,
424
+ } ) )
425
425
426
- this . setState ( {
427
- serviceMeasurements : getServiceRunning ,
428
- defaultMeasurements : getDefaultMeasure ,
429
- measurementsStatus : RemoteDataState . Done ,
426
+ const getDefaultMeasure = this . defaultMeasurementsData . map (
427
+ dMeasure => ( {
428
+ name : dMeasure ,
429
+ isActivity : false ,
430
+ } )
431
+ )
432
+
433
+ this . setState ( {
434
+ serviceMeasurements : getServiceRunning ,
435
+ defaultMeasurements : getDefaultMeasure ,
436
+ measurementsStatus : RemoteDataState . Done ,
437
+ } )
438
+ } )
439
+ . catch ( error => {
440
+ console . error ( error )
430
441
} )
431
- } )
432
442
}
433
443
434
444
public onClickActionCall = async ( host : string , isRunning : boolean ) => {
@@ -763,7 +773,7 @@ export class AgentConfiguration extends PureComponent<
763
773
)
764
774
}
765
775
766
- private handleFocusedServiceMeasure = ( {
776
+ private handleFocusedServiceMeasure = async ( {
767
777
clickPosition,
768
778
_thisProps,
769
779
} : {
@@ -801,24 +811,25 @@ export class AgentConfiguration extends PureComponent<
801
811
? ( serviceMeasurements [ idx ] . isActivity = true )
802
812
: ( serviceMeasurements [ idx ] . isActivity = false )
803
813
804
- const getRunnerSaltCmdTelegrafPromise = getRunnerSaltCmdTelegraf (
805
- saltMasterUrl ,
806
- saltMasterToken ,
807
- measureName
808
- )
809
-
810
- getRunnerSaltCmdTelegrafPromise . then ( ( { data} ) => {
814
+ try {
815
+ const { data} = await getRunnerSaltCmdTelegraf (
816
+ saltMasterUrl ,
817
+ saltMasterToken ,
818
+ measureName
819
+ )
811
820
this . setState ( {
812
821
serviceMeasurements : [ ...mapServiceMeasurements ] ,
813
822
defaultMeasurements : [ ...mapDefaultMeasurements ] ,
814
823
focusedMeasure : measureName ,
815
824
focusedMeasurePosition : clickPosition ,
816
825
description : data . return [ 0 ] ,
817
826
} )
818
- } )
827
+ } catch ( error ) {
828
+ console . error ( error )
829
+ }
819
830
}
820
831
821
- private handleFocusedDefaultMeasure = ( {
832
+ private handleFocusedDefaultMeasure = async ( {
822
833
clickPosition,
823
834
_thisProps,
824
835
} : {
@@ -856,21 +867,22 @@ export class AgentConfiguration extends PureComponent<
856
867
description : globalSetting ,
857
868
} )
858
869
} else {
859
- const getRunnerSaltCmdTelegrafPromise = getRunnerSaltCmdTelegraf (
860
- saltMasterUrl ,
861
- saltMasterToken ,
862
- name
863
- )
864
-
865
- getRunnerSaltCmdTelegrafPromise . then ( ( { data} ) => {
870
+ try {
871
+ const { data} = await getRunnerSaltCmdTelegraf (
872
+ saltMasterUrl ,
873
+ saltMasterToken ,
874
+ name
875
+ )
866
876
this . setState ( {
867
877
defaultMeasurements : [ ...mapDefaultMeasurements ] ,
868
878
serviceMeasurements : [ ...mapServiceMeasurements ] ,
869
879
focusedMeasure : name ,
870
880
focusedMeasurePosition : clickPosition ,
871
881
description : data . return [ 0 ] ,
872
882
} )
873
- } )
883
+ } catch ( error ) {
884
+ console . error ( error )
885
+ }
874
886
}
875
887
}
876
888
0 commit comments