@@ -5,8 +5,10 @@ import * as _ from 'lodash';
5
5
import { environment } from '../../environments/environment' ;
6
6
import { catchError , delay } from 'rxjs/operators' ;
7
7
import { Store } from '@ngrx/store' ;
8
+ import { MatDialog } from '@angular/material' ;
8
9
9
10
import { RedisConnectFailed } from '../ngrx/actions/redis-actions' ;
11
+ import { CollapseCli } from '../ngrx/actions/cli-actions' ;
10
12
import { REDIS_INSTANCES_KEY } from '../ngrx/reducer/redis-reducer' ;
11
13
import { UtilService } from './util.service' ;
12
14
@@ -20,7 +22,8 @@ export class HttpHelperService {
20
22
constructor (
21
23
private http : HttpClient ,
22
24
private util : UtilService ,
23
- private _store : Store < any >
25
+ private _store : Store < any > ,
26
+ private dialogService : MatDialog
24
27
) { }
25
28
26
29
/**
@@ -63,11 +66,16 @@ export class HttpHelperService {
63
66
const id = instance . id ;
64
67
const host = instance . serverModel . name ;
65
68
const port = instance . serverModel . port ;
66
- this . util . showMessage ( `Fail to connect Redis server at ${ host } :${ port } .` ) ;
69
+ // reset UI if redis connection fails
70
+ this . dialogService . closeAll ( ) ;
71
+ this . util . showMessage ( `Failed to connect Redis server at ${ host } :${ port } .` ) ;
67
72
this . _store . dispatch ( new RedisConnectFailed ( { id} ) ) ;
73
+ this . _store . dispatch ( new CollapseCli ( ) ) ;
68
74
}
75
+ return of ( ) ;
76
+ } else {
77
+ return throwError ( error ) ;
69
78
}
70
- return throwError ( error ) ;
71
79
}
72
80
73
81
/**
0 commit comments