Skip to content

Commit

Permalink
Fix CF Delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Irfan Habib committed Jul 6, 2018
1 parent 361899b commit 6b22a00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { CloudFoundryService } from '../../../shared/data-services/cloud-foundry
{
provide: ListConfig,
useClass: CFEndpointsListConfigService,
}]
},
CloudFoundryService
]
})
export class CloudFoundryComponent {
connectedEndpoints$: Observable<number>;
Expand Down
12 changes: 5 additions & 7 deletions src/frontend/app/shared/data-services/cloud-foundry.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map, publishReplay, refCount } from 'rxjs/operators';
import { map } from 'rxjs/operators';

import { PaginationMonitor } from '../monitors/pagination-monitor';
import { PaginationMonitorFactory } from '../monitors/pagination-monitor.factory';
import { AppState } from '../../store/app-state';
import { endpointSchemaKey, entityFactory } from '../../store/helpers/entity-factory';
import { APIResource, EntityInfo } from '../../store/types/api.types';
import { EndpointModel } from '../../store/types/endpoint.types';
import { PaginationMonitor } from '../monitors/pagination-monitor';
import { PaginationMonitorFactory } from '../monitors/pagination-monitor.factory';

@Injectable()
export class CloudFoundryService {
Expand All @@ -23,10 +23,8 @@ export class CloudFoundryService {
private store: Store<AppState>,
private paginationMonitorFactory: PaginationMonitorFactory
) {
this.cfEndpointsMonitor = this.paginationMonitorFactory.create(
'endpoint-list',
entityFactory(endpointSchemaKey)
);

this.cfEndpointsMonitor = new PaginationMonitor(store, 'endpoint-list', entityFactory(endpointSchemaKey));

this.cFEndpoints$ = this.cfEndpointsMonitor.currentPage$.pipe(
map(endpoints => endpoints.filter(e => e.cnsi_type === 'cf'))
Expand Down
13 changes: 11 additions & 2 deletions src/frontend/app/store/effects/endpoint.effects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {catchError, mergeMap } from 'rxjs/operators';
import {catchError, mergeMap, map, tap } from 'rxjs/operators';
import { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';

Expand Down Expand Up @@ -27,7 +27,7 @@ import {
UnregisterEndpoint,
EndpointActionComplete,
} from '../actions/endpoint.actions';
import { ClearPaginationOfEntity } from '../actions/pagination.actions';
import { ClearPaginationOfEntity, ResetPagination } from '../actions/pagination.actions';
import { GET_SYSTEM_INFO_SUCCESS, GetSystemInfo, GetSystemSuccess } from '../actions/system.actions';
import { AppState } from '../app-state';
import { ApiRequestTypes } from '../reducers/api-request-reducer/request-helpers';
Expand All @@ -38,14 +38,17 @@ import {
StartRequestAction,
WrapperRequestActionFailed,
WrapperRequestActionSuccess,
APISuccessOrFailedAction,
} from '../types/request.types';
import { endpointSchemaKey } from '../helpers/entity-factory';

@Injectable()
export class EndpointsEffect {

static connectingKey = 'connecting';
static disconnectingKey = 'disconnecting';
static registeringKey = 'registering';
static EndpointList = 'endpoint-list';

constructor(
private http: HttpClient,
Expand Down Expand Up @@ -132,6 +135,12 @@ export class EndpointsEffect {
);
}));

@Effect({dispatch: false}) resetEndpointsList$ = this.actions$.ofType<EndpointActionComplete>(
DISCONNECT_ENDPOINTS_SUCCESS, CONNECT_ENDPOINTS_SUCCESS).pipe(
tap(action => {
this.store.dispatch(new ResetPagination(endpointSchemaKey, EndpointsEffect.EndpointList));
}));

@Effect() unregister$ = this.actions$.ofType<UnregisterEndpoint>(UNREGISTER_ENDPOINTS).pipe(
mergeMap(action => {

Expand Down

0 comments on commit 6b22a00

Please sign in to comment.