Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix routing to appropriate CF view after connecting/disconnecting an endpoint #2660

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { createBasicStoreModule } from '../../../test-framework/store-test-helper';
import { PaginationMonitorFactory } from '../../../shared/monitors/pagination-monitor.factory';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CloudFoundryService } from '../../../shared/data-services/cloud-foundry.service';

describe('CloudFoundryComponent', () => {
let component: CloudFoundryComponent;
Expand All @@ -19,7 +20,7 @@ describe('CloudFoundryComponent', () => {
TestBed.configureTestingModule({
declarations: [CloudFoundryComponent],
imports: [...BaseTestModules, BrowserAnimationsModule],
providers: [PaginationMonitorFactory, generateTestCfServiceProvider()]
providers: [PaginationMonitorFactory, CloudFoundryService, generateTestCfServiceProvider()]
}).compileComponents();
})
);
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { endpointSchemaKey, entityFactory } from '../../../store/helpers/entity-
import { APIResource, EntityInfo } from '../../../store/types/api.types';
import { EndpointModel } from '../../../store/types/endpoint.types';
import { getFullEndpointApiUrl } from '../../endpoints/endpoint-helpers';
import { CloudFoundryService } from '../../../shared/data-services/cloud-foundry.service';

export interface MetricsEndpointProvider {
provider: EndpointModel;
Expand All @@ -29,7 +30,7 @@ export class MetricsService {
private paginationMonitorFactory: PaginationMonitorFactory
) {
this.endpointsMonitor = this.paginationMonitorFactory.create(
'endpoint-list',
CloudFoundryService.EndpointList,
entityFactory(endpointSchemaKey)
);

Expand Down
13 changes: 6 additions & 7 deletions src/frontend/app/shared/data-services/cloud-foundry.service.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
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 {
static EndpointList = 'endpoint-list';
hasRegisteredCFEndpoints$: Observable<boolean>;
hasConnectedCFEndpoints$: Observable<boolean>;
connectedCFEndpoints$: Observable<EndpointModel[]>;
Expand All @@ -23,10 +24,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, CloudFoundryService.EndpointList, entityFactory(endpointSchemaKey));

this.cFEndpoints$ = this.cfEndpointsMonitor.currentPage$.pipe(
map(endpoints => endpoints.filter(e => e.cnsi_type === 'cf'))
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/app/store/actions/endpoint.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Action } from '@ngrx/store';
import { endpointSchemaKey } from '../helpers/entity-factory';
import { EndpointModel, EndpointType, INewlyConnectedEndpointInfo } from '../types/endpoint.types';
import { PaginatedAction } from '../types/pagination.types';
import { CloudFoundryService } from '../../shared/data-services/cloud-foundry.service';

export const GET_ENDPOINTS = '[Endpoints] Get all';
export const GET_ENDPOINTS_START = '[Endpoints] Get all start';
Expand Down Expand Up @@ -54,7 +55,7 @@ export interface AuthParamsToken {
export type AuthParams = AuthParamsUsernamePassword | AuthParamsToken;

export class GetAllEndpoints implements PaginatedAction {
public static storeKey = 'endpoint-list';
public static storeKey = CloudFoundryService.EndpointList;
constructor(public login = false) { }
entityKey = endpointSchemaKey;
paginationKey = GetAllEndpoints.storeKey;
Expand Down
9 changes: 4 additions & 5 deletions src/frontend/app/store/effects/endpoint.effects.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

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

import { Actions, Effect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { catchError, mergeMap } from 'rxjs/operators';

import { BrowserStandardEncoder } from '../../helper';
import {
Expand All @@ -16,6 +14,7 @@ import {
DISCONNECT_ENDPOINTS_FAILED,
DISCONNECT_ENDPOINTS_SUCCESS,
DisconnectEndpoint,
EndpointActionComplete,
GetAllEndpointsSuccess,
REGISTER_ENDPOINTS,
REGISTER_ENDPOINTS_FAILED,
Expand All @@ -25,7 +24,6 @@ import {
UNREGISTER_ENDPOINTS_FAILED,
UNREGISTER_ENDPOINTS_SUCCESS,
UnregisterEndpoint,
EndpointActionComplete,
} from '../actions/endpoint.actions';
import { ClearPaginationOfEntity } from '../actions/pagination.actions';
import { GET_SYSTEM_INFO_SUCCESS, GetSystemInfo, GetSystemSuccess } from '../actions/system.actions';
Expand All @@ -40,6 +38,7 @@ import {
WrapperRequestActionSuccess,
} from '../types/request.types';


@Injectable()
export class EndpointsEffect {

Expand Down