From e7f6354b8213b7fdc88189fb304e38a359873085 Mon Sep 17 00:00:00 2001 From: Ilia Orlov <66363651+illfixit@users.noreply.github.com> Date: Tue, 27 Aug 2024 12:05:19 +0200 Subject: [PATCH] Automatic status refresh on connector page (#271) --- CHANGELOG.md | 2 ++ .../api/fake-backend/impl/fake-connectors.ts | 30 ++++++++++++++++++- ...thority-connector-detail-page.component.ts | 2 -- ...authority-connector-detail-page-actions.ts | 4 +++ ...hority-connector-detail-page-state-impl.ts | 18 +++++++++-- ...authority-connector-list-page.component.ts | 13 +++++++- .../authority-connector-list-page-actions.ts | 4 +++ ...uthority-connector-list-page-state-impl.ts | 19 ++++++++++++ ...ipant-own-connector-detail-page-actions.ts | 4 +++ ...nt-own-connector-detail-page-state-impl.ts | 21 +++++++++++-- ...ipant-own-connector-list-page.component.ts | 13 +++++++- ...icipant-own-connector-list-page-actions.ts | 4 +++ ...pant-own-connector-list-page-state-impl.ts | 19 ++++++++++++ .../state/sp-connector-detail-page-actions.ts | 5 ++++ .../sp-connector-detail-page-state-impl.ts | 20 +++++++++++-- .../sp-connector-list-page.component.ts | 12 +++++++- .../state/sp-connector-list-page-actions.ts | 4 +++ .../sp-connector-list-page-state-impl.ts | 19 ++++++++++++ 18 files changed, 201 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd35371f9..4640b0b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). #### Patch +- Added auto refresh for pages with connectors every 30 seconds + ### Known issues ### Deployment Migration Notes diff --git a/authority-portal-frontend/src/app/core/api/fake-backend/impl/fake-connectors.ts b/authority-portal-frontend/src/app/core/api/fake-backend/impl/fake-connectors.ts index 9b8996e19..1a47850a0 100644 --- a/authority-portal-frontend/src/app/core/api/fake-backend/impl/fake-connectors.ts +++ b/authority-portal-frontend/src/app/core/api/fake-backend/impl/fake-connectors.ts @@ -15,6 +15,7 @@ import { CheckFreeCaasUsageRequest, ConnectorDetailDto, ConnectorOverviewResult, + ConnectorStatusDto, ConnectorTypeDto, CreateCaasRequest, CreateConnectorRequest, @@ -26,6 +27,7 @@ import { ProvidedConnectorOverviewEntryDto, ProvidedConnectorOverviewResult, } from '@sovity.de/authority-portal-client'; +import {Patcher, patchObj} from 'src/app/core/utils/object-utils'; import {fakeEnv} from './fake-environments'; import {TEST_ORGANIZATIONS} from './fake-organizations'; import {getUserInfo} from './fake-users'; @@ -59,7 +61,7 @@ export let TEST_CONNECTORS: ConnectorDetailDto[] = [ frontendUrl: 'https://xample.test1/connector', endpointUrl: 'https://xample.test1/connector/api/dsp', managementUrl: 'https://xample.test1/connector/api/management', - status: 'DEAD', + status: 'OFFLINE', }, { connectorId: 'MDSL1111AA.AP42I3L', @@ -250,6 +252,7 @@ export const createOwnConnector = ( const organizationName = getUserInfo().organizationName; const randomId = generateRandomId(organizationId); const status = 'OFFLINE'; + updateConnectorStatus(randomId); TEST_CONNECTORS.push({ connectorId: randomId, @@ -266,6 +269,7 @@ export const createOwnConnector = ( managementUrl: request.managementUrl, status: status, }); + return { id: randomId, changedDate: new Date(), @@ -282,6 +286,7 @@ export const createCaas = ( const organizationName = getUserInfo().organizationName; const randomId = generateRandomId(organizationId); const status = 'INIT'; + updateConnectorStatus(randomId); TEST_CONNECTORS.push({ connectorId: randomId, @@ -334,6 +339,8 @@ export const createProvidedConnector = ( )?.name; const randomId = generateRandomId(clientOrganizationId); + updateConnectorStatus(randomId); + TEST_CONNECTORS.push({ connectorId: randomId, organizationId: clientOrganizationId, @@ -370,6 +377,8 @@ export const createProvidedConnectorWithJwks = ( )?.name; const randomId = generateRandomId(clientOrganizationId); + updateConnectorStatus(randomId); + TEST_CONNECTORS.push({ connectorId: randomId, organizationId: clientOrganizationId, @@ -426,3 +435,22 @@ const generateRandomId = (organizationId: string): string => { return result; } }; + +const updateConnector = ( + connectorId: string, + patcher: Patcher = () => ({}), +): void => { + TEST_CONNECTORS = TEST_CONNECTORS.map((it) => + it.connectorId === connectorId ? patchObj(it, patcher) : it, + ); +}; + +const updateConnectorStatus = ( + connectorId: string, + status: ConnectorStatusDto = 'ONLINE', + timeout: number = 5000, +): void => { + setTimeout(() => { + updateConnector(connectorId, () => ({status})); + }, timeout); +}; diff --git a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/authority-connector-detail-page/authority-connector-detail-page.component.ts b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/authority-connector-detail-page/authority-connector-detail-page.component.ts index 6af534329..7d3811730 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/authority-connector-detail-page/authority-connector-detail-page.component.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/authority-connector-detail-page/authority-connector-detail-page.component.ts @@ -10,7 +10,6 @@ * Contributors: * sovity GmbH - initial implementation */ -import {Clipboard} from '@angular/cdk/clipboard'; import {Component, HostBinding, Inject, OnDestroy, OnInit} from '@angular/core'; import {Subject, takeUntil} from 'rxjs'; import {Store} from '@ngxs/store'; @@ -20,7 +19,6 @@ import { UserRoleDto, } from '@sovity.de/authority-portal-client'; import {GlobalStateUtils} from 'src/app/core/global-state/global-state-utils'; -import {ClipboardUtils} from 'src/app/core/utils/clipboard-utils'; import { getConnectorStatusText, getConnectorsTypeClasses, diff --git a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-actions.ts b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-actions.ts index 369cd775a..3f6d25380 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-actions.ts @@ -21,3 +21,7 @@ export class SetConnectorId { export class RefreshConnector { static readonly type = `[${tag}] Refresh Connector`; } + +export class RefreshConnectorSilent { + static readonly type = `[${tag}] Refresh Connector (silent)`; +} diff --git a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-state-impl.ts b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-state-impl.ts index 4a2c1028d..61f7200fa 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-detail-page/state/authority-connector-detail-page-state-impl.ts @@ -11,14 +11,15 @@ * sovity GmbH - initial implementation */ import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs'; -import {ignoreElements, tap} from 'rxjs/operators'; +import {EMPTY, Observable} from 'rxjs'; +import {catchError, ignoreElements, tap} from 'rxjs/operators'; import {Action, State, StateContext} from '@ngxs/store'; import {ConnectorDetailDto} from '@sovity.de/authority-portal-client'; import {ApiService} from 'src/app/core/api/api.service'; import {Fetched} from 'src/app/core/utils/fetched'; import { RefreshConnector, + RefreshConnectorSilent, SetConnectorId, } from './authority-connector-detail-page-actions'; import { @@ -45,6 +46,19 @@ export class AuthorityConnectorDetailPageStateImpl { ); } + @Action(RefreshConnectorSilent) + onRefreshConnectorSilent( + ctx: StateContext, + ): Observable { + return this.apiService.getConnector(ctx.getState().connectorId).pipe( + catchError(() => EMPTY), + tap((connector) => + this.connectorRefreshed(ctx, Fetched.ready(connector)), + ), + ignoreElements(), + ); + } + private connectorRefreshed( ctx: StateContext, connector: Fetched, diff --git a/authority-portal-frontend/src/app/pages/authority-connector-list-page/authority-connector-list-page/authority-connector-list-page.component.ts b/authority-portal-frontend/src/app/pages/authority-connector-list-page/authority-connector-list-page/authority-connector-list-page.component.ts index 9f81295aa..505395e75 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-list-page/authority-connector-list-page/authority-connector-list-page.component.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-list-page/authority-connector-list-page/authority-connector-list-page.component.ts @@ -11,7 +11,7 @@ * sovity GmbH - initial implementation */ import {Component, OnDestroy, OnInit} from '@angular/core'; -import {Subject} from 'rxjs'; +import {Subject, interval} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; import {Store} from '@ngxs/store'; import {ConnectorOverviewEntryDto} from '@sovity.de/authority-portal-client'; @@ -27,9 +27,11 @@ import { SlideOverConfig, } from 'src/app/shared/common/slide-over/slide-over.model'; import {AuthorityConnectorDetailPageComponent} from '../../authority-connector-detail-page/authority-connector-detail-page/authority-connector-detail-page.component'; +import {RefreshConnectorSilent} from '../../authority-connector-detail-page/state/authority-connector-detail-page-actions'; import { CloseConnectorDetail, GetConnectors, + GetConnectorsSilent, ShowConnectorDetail, } from '../state/authority-connector-list-page-actions'; import { @@ -98,6 +100,15 @@ export class AuthorityConnectorListPageComponent implements OnInit, OnDestroy { refresh() { this.store.dispatch(GetConnectors); + + interval(30000) + .pipe(takeUntil(this.ngOnDestroy$)) + .subscribe(() => { + this.store.dispatch(GetConnectorsSilent); + if (this.showDetail) { + this.store.dispatch(RefreshConnectorSilent); + } + }); } private startListeningToState() { diff --git a/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-actions.ts b/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-actions.ts index 06e69f045..fbb5886d6 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-actions.ts @@ -17,6 +17,10 @@ export class GetConnectors { static readonly type = `[${tag}] Get Connectors`; } +export class GetConnectorsSilent { + static readonly type = `[${tag}] Get Connectors (silent)`; +} + export class ShowConnectorDetail { static readonly type = `[${tag}] Show Connector Details Slider`; } diff --git a/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-state-impl.ts b/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-state-impl.ts index 7cd46a4ee..11e635740 100644 --- a/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/authority-connector-list-page/state/authority-connector-list-page-state-impl.ts @@ -13,6 +13,7 @@ import {Injectable} from '@angular/core'; import {EMPTY, Observable} from 'rxjs'; import { + catchError, filter, finalize, ignoreElements, @@ -32,6 +33,7 @@ import { CloseConnectorDetail, DeleteConnector, GetConnectors, + GetConnectorsSilent, ShowConnectorDetail, } from './authority-connector-list-page-actions'; import { @@ -69,6 +71,23 @@ export class AuthorityConnectorListPageStateImpl { ); } + @Action(GetConnectorsSilent) + onGetConnectorsSilent( + ctx: StateContext, + ): Observable { + return this.globalStateUtils.getDeploymentEnvironmentId().pipe( + switchMap((deploymentEnvironmentId) => + this.apiService.getAllConnectors(deploymentEnvironmentId), + ), + map((result) => result.connectors), + catchError((error) => EMPTY), + tap((connectors) => + this.connectorsRefreshed(ctx, Fetched.ready(connectors)), + ), + ignoreElements(), + ); + } + private connectorsRefreshed( ctx: StateContext, newConnectors: Fetched, diff --git a/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-actions.ts b/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-actions.ts index a37a9b7f3..7ee9bae81 100644 --- a/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-actions.ts @@ -21,3 +21,7 @@ export class SetConnectorId { export class RefreshConnector { static readonly type = `[${tag}] Refresh Connector`; } + +export class RefreshConnectorSilent { + static readonly type = `[${tag}] Refresh Connector (silent)`; +} diff --git a/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-state-impl.ts b/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-state-impl.ts index 2e8c09c89..b1ce398ff 100644 --- a/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/participant-own-connector-detail-page/state/participant-own-connector-detail-page-state-impl.ts @@ -11,14 +11,15 @@ * sovity GmbH - initial implementation */ import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs'; -import {ignoreElements, tap} from 'rxjs/operators'; +import {EMPTY, Observable} from 'rxjs'; +import {catchError, ignoreElements, tap} from 'rxjs/operators'; import {Action, State, StateContext} from '@ngxs/store'; import {ConnectorDetailDto} from '@sovity.de/authority-portal-client'; import {ApiService} from 'src/app/core/api/api.service'; import {Fetched} from 'src/app/core/utils/fetched'; import { RefreshConnector, + RefreshConnectorSilent, SetConnectorId, } from './participant-own-connector-detail-page-actions'; import { @@ -48,6 +49,22 @@ export class ParticipantOwnConnectorDetailPageStateImpl { ); } + @Action(RefreshConnectorSilent, {cancelUncompleted: true}) + onRefreshConnectorSilent( + ctx: StateContext, + action: RefreshConnector, + ): Observable { + return this.apiService + .getOwnOrganizationConnectorDetails(ctx.getState().connectorId) + .pipe( + catchError(() => EMPTY), + tap((connector) => { + this.connectorRefreshed(ctx, Fetched.ready(connector)); + }), + ignoreElements(), + ); + } + private connectorRefreshed( ctx: StateContext, connector: Fetched, diff --git a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/participant-own-connector-list-page/participant-own-connector-list-page.component.ts b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/participant-own-connector-list-page/participant-own-connector-list-page.component.ts index ad168f963..739653842 100644 --- a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/participant-own-connector-list-page/participant-own-connector-list-page.component.ts +++ b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/participant-own-connector-list-page/participant-own-connector-list-page.component.ts @@ -12,7 +12,7 @@ */ import {Component, OnDestroy, OnInit} from '@angular/core'; import {Router} from '@angular/router'; -import {Subject} from 'rxjs'; +import {Subject, interval} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; import {Store} from '@ngxs/store'; import { @@ -31,9 +31,11 @@ import { SlideOverConfig, } from 'src/app/shared/common/slide-over/slide-over.model'; import {ParticipantOwnConnectorDetailPageComponent} from '../../participant-own-connector-detail-page/participant-own-connector-detail-page/participant-own-connector-detail-page.component'; +import {RefreshConnectorSilent} from '../../participant-own-connector-detail-page/state/participant-own-connector-detail-page-actions'; import { CloseConnectorDetail, GetOwnOrganizationConnectors, + GetOwnOrganizationConnectorsSilent, ShowConnectorDetail, } from '../state/participant-own-connector-list-page-actions'; import { @@ -114,6 +116,15 @@ export class ParticipantOwnConnectorListPageComponent refresh() { this.store.dispatch(GetOwnOrganizationConnectors); + + interval(30000) + .pipe(takeUntil(this.ngOnDestroy$)) + .subscribe(() => { + this.store.dispatch(GetOwnOrganizationConnectorsSilent); + if (this.state.showDetail) { + this.store.dispatch(RefreshConnectorSilent); + } + }); } private startListeningToState() { diff --git a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-actions.ts b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-actions.ts index bdf3633d1..ee9f4bc0f 100644 --- a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-actions.ts @@ -17,6 +17,10 @@ export class GetOwnOrganizationConnectors { static readonly type = `[${tag}] Get Own Organization Connectors`; } +export class GetOwnOrganizationConnectorsSilent { + static readonly type = `[${tag}] Get Own Organization Connectors (silent)`; +} + export class DeleteOwnConnector { static readonly type = `[${tag}] Delete Own Connector`; constructor(public connectorId: string) {} diff --git a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-state-impl.ts b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-state-impl.ts index 4bb05bcfe..3490337d4 100644 --- a/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/participant-own-connector-list-page/state/participant-own-connector-list-page-state-impl.ts @@ -13,6 +13,7 @@ import {Injectable} from '@angular/core'; import {EMPTY, Observable} from 'rxjs'; import { + catchError, filter, finalize, ignoreElements, @@ -32,6 +33,7 @@ import { CloseConnectorDetail, DeleteOwnConnector, GetOwnOrganizationConnectors, + GetOwnOrganizationConnectorsSilent, ShowConnectorDetail, } from './participant-own-connector-list-page-actions'; import { @@ -69,6 +71,23 @@ export class ParticipantOwnConnectorListPageStateImpl { ); } + @Action(GetOwnOrganizationConnectorsSilent) + onGetOwnOrganizationConnectorsSilent( + ctx: StateContext, + ): Observable { + return this.globalStateUtils.getDeploymentEnvironmentId().pipe( + switchMap((deploymentEnvironmentId) => + this.apiService.getOwnOrganizationConnectors(deploymentEnvironmentId), + ), + map((result) => result.connectors), + catchError(() => EMPTY), + tap((connectors) => { + this.connectorsRefreshed(ctx, Fetched.ready(connectors)); + }), + ignoreElements(), + ); + } + private connectorsRefreshed( ctx: StateContext, newConnectors: Fetched, diff --git a/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-actions.ts b/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-actions.ts index 7ff3756b1..c91504d1d 100644 --- a/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-actions.ts @@ -18,6 +18,11 @@ export class RefreshConnector { constructor(public connectorId: string) {} } +export class RefreshConnectorSilent { + static readonly type = `[${tag}] Refresh Connector (silent)`; + constructor(public connectorId: string) {} +} + export class SetConnectorId { static readonly type = `[${tag}] Set Connector Id`; constructor(public connectorId: string) {} diff --git a/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-state-impl.ts b/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-state-impl.ts index 77d41cdf3..e2a430d48 100644 --- a/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/sp-connector-detail-page/state/sp-connector-detail-page-state-impl.ts @@ -11,14 +11,15 @@ * sovity GmbH - initial implementation */ import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs'; -import {ignoreElements, tap} from 'rxjs/operators'; +import {EMPTY, Observable} from 'rxjs'; +import {catchError, ignoreElements, tap} from 'rxjs/operators'; import {Action, State, StateContext} from '@ngxs/store'; import {ConnectorDetailDto} from '@sovity.de/authority-portal-client'; import {ApiService} from 'src/app/core/api/api.service'; import {Fetched} from 'src/app/core/utils/fetched'; import { RefreshConnector, + RefreshConnectorSilent, SetConnectorId, } from './sp-connector-detail-page-actions'; import { @@ -47,6 +48,21 @@ export class SpConnectorDetailPageStateImpl { ); } + @Action(RefreshConnectorSilent, {cancelUncompleted: true}) + onRefreshConnectorSilent( + ctx: StateContext, + ): Observable { + return this.apiService + .getProvidedConnectorDetails(ctx.getState().connectorId) + .pipe( + catchError(() => EMPTY), + tap((connector) => + this.connectorRefreshed(ctx, Fetched.ready(connector)), + ), + ignoreElements(), + ); + } + private connectorRefreshed( ctx: StateContext, diff --git a/authority-portal-frontend/src/app/pages/sp-connector-list-page/sp-connector-list-page/sp-connector-list-page.component.ts b/authority-portal-frontend/src/app/pages/sp-connector-list-page/sp-connector-list-page/sp-connector-list-page.component.ts index 86d6923b2..6211dd6a9 100644 --- a/authority-portal-frontend/src/app/pages/sp-connector-list-page/sp-connector-list-page/sp-connector-list-page.component.ts +++ b/authority-portal-frontend/src/app/pages/sp-connector-list-page/sp-connector-list-page/sp-connector-list-page.component.ts @@ -12,7 +12,7 @@ */ import {Component, OnDestroy, OnInit} from '@angular/core'; import {Router} from '@angular/router'; -import {Subject} from 'rxjs'; +import {Subject, interval} from 'rxjs'; import {takeUntil} from 'rxjs/operators'; import {Store} from '@ngxs/store'; import { @@ -31,9 +31,11 @@ import { SlideOverConfig, } from 'src/app/shared/common/slide-over/slide-over.model'; import {SpConnectorDetailPageComponent} from '../../sp-connector-detail-page/sp-connector-detail-page/sp-connector-detail-page.component'; +import {RefreshConnectorSilent} from '../../sp-connector-detail-page/state/sp-connector-detail-page-actions'; import { CloseConnectorDetail, GetProvidedConnectors, + GetProvidedConnectorsSilent, ShowConnectorDetail, } from '../state/sp-connector-list-page-actions'; import { @@ -114,6 +116,14 @@ export class SpConnectorListPageComponent implements OnInit, OnDestroy { refresh() { this.store.dispatch(GetProvidedConnectors); + interval(3000) + .pipe(takeUntil(this.ngOnDestroy$)) + .subscribe(() => { + this.store.dispatch(GetProvidedConnectorsSilent); + if (this.showDetail) { + this.store.dispatch(RefreshConnectorSilent); + } + }); } startListeningToState() { diff --git a/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-actions.ts b/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-actions.ts index 120d4a8fc..07a0c6aec 100644 --- a/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-actions.ts +++ b/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-actions.ts @@ -17,6 +17,10 @@ export class GetProvidedConnectors { static readonly type = `[${tag}] Get Provided Connectors`; } +export class GetProvidedConnectorsSilent { + static readonly type = `[${tag}] Get Provided Connectors (silent)`; +} + export class DeleteProvidedConnector { static readonly type = `[${tag}] Delete Provided Connector`; constructor(public connectorId: string) {} diff --git a/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-state-impl.ts b/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-state-impl.ts index 1169a9ca1..4f3204384 100644 --- a/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-state-impl.ts +++ b/authority-portal-frontend/src/app/pages/sp-connector-list-page/state/sp-connector-list-page-state-impl.ts @@ -13,6 +13,7 @@ import {Injectable} from '@angular/core'; import {EMPTY, Observable} from 'rxjs'; import { + catchError, filter, finalize, ignoreElements, @@ -32,6 +33,7 @@ import { CloseConnectorDetail, DeleteProvidedConnector, GetProvidedConnectors, + GetProvidedConnectorsSilent, ShowConnectorDetail, } from './sp-connector-list-page-actions'; import { @@ -69,6 +71,23 @@ export class SpConnectorListPageStateImpl { ); } + @Action(GetProvidedConnectorsSilent) + onGetProvidedConnectorsSilent( + ctx: StateContext, + ): Observable { + return this.globalStateUtils.getDeploymentEnvironmentId().pipe( + switchMap((deploymentEnvironmentId) => + this.apiService.getProvidedConnectors(deploymentEnvironmentId), + ), + map((result) => result.connectors), + catchError(() => EMPTY), + tap((connectors) => + this.connectorsRefreshed(ctx, Fetched.ready(connectors)), + ), + ignoreElements(), + ); + } + private connectorsRefreshed( ctx: StateContext, newConnectors: Fetched,