Skip to content

Commit 5754c33

Browse files
committed
reset UI
1 parent a6bd70d commit 5754c33

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/app/ngrx/reducer/redis-reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export function reducer(state = initialState, action) {
7575
const i = getInstanceById(action.payload.id, state);
7676
i.status = 'failed';
7777
i.working = false;
78+
i.selected = false;
79+
i.expanded = false;
7880
return state;
7981
}
8082
case RedisActions.RedisConnect: {

src/app/services/http-helper.service.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import * as _ from 'lodash';
55
import {environment} from '../../environments/environment';
66
import {catchError, delay} from 'rxjs/operators';
77
import {Store} from '@ngrx/store';
8+
import {MatDialog} from '@angular/material';
89

910
import {RedisConnectFailed} from '../ngrx/actions/redis-actions';
11+
import {CollapseCli} from '../ngrx/actions/cli-actions';
1012
import {REDIS_INSTANCES_KEY} from '../ngrx/reducer/redis-reducer';
1113
import {UtilService} from './util.service';
1214

@@ -20,7 +22,8 @@ export class HttpHelperService {
2022
constructor(
2123
private http: HttpClient,
2224
private util: UtilService,
23-
private _store: Store<any>
25+
private _store: Store<any>,
26+
private dialogService: MatDialog
2427
) { }
2528

2629
/**
@@ -63,11 +66,16 @@ export class HttpHelperService {
6366
const id = instance.id;
6467
const host = instance.serverModel.name;
6568
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}.`);
6772
this._store.dispatch(new RedisConnectFailed({id}));
73+
this._store.dispatch(new CollapseCli());
6874
}
75+
return of();
76+
} else {
77+
return throwError(error);
6978
}
70-
return throwError(error);
7179
}
7280

7381
/**

0 commit comments

Comments
 (0)