Skip to content

Commit

Permalink
Merge branch 'main' into docs/generic
Browse files Browse the repository at this point in the history
  • Loading branch information
tmberthold authored Aug 27, 2024
2 parents 2350242 + e7f6354 commit 246d073
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CheckFreeCaasUsageRequest,
ConnectorDetailDto,
ConnectorOverviewResult,
ConnectorStatusDto,
ConnectorTypeDto,
CreateCaasRequest,
CreateConnectorRequest,
Expand All @@ -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';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -266,6 +269,7 @@ export const createOwnConnector = (
managementUrl: request.managementUrl,
status: status,
});

return {
id: randomId,
changedDate: new Date(),
Expand All @@ -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,
Expand Down Expand Up @@ -334,6 +339,8 @@ export const createProvidedConnector = (
)?.name;

const randomId = generateRandomId(clientOrganizationId);
updateConnectorStatus(randomId);

TEST_CONNECTORS.push({
connectorId: randomId,
organizationId: clientOrganizationId,
Expand Down Expand Up @@ -370,6 +377,8 @@ export const createProvidedConnectorWithJwks = (
)?.name;

const randomId = generateRandomId(clientOrganizationId);
updateConnectorStatus(randomId);

TEST_CONNECTORS.push({
connectorId: randomId,
organizationId: clientOrganizationId,
Expand Down Expand Up @@ -426,3 +435,22 @@ const generateRandomId = (organizationId: string): string => {
return result;
}
};

const updateConnector = (
connectorId: string,
patcher: Patcher<ConnectorDetailDto> = () => ({}),
): 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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -45,6 +46,19 @@ export class AuthorityConnectorDetailPageStateImpl {
);
}

@Action(RefreshConnectorSilent)
onRefreshConnectorSilent(
ctx: StateContext<AuthorityConnectorDetailPageState>,
): Observable<never> {
return this.apiService.getConnector(ctx.getState().connectorId).pipe(
catchError(() => EMPTY),
tap((connector) =>
this.connectorRefreshed(ctx, Fetched.ready(connector)),
),
ignoreElements(),
);
}

private connectorRefreshed(
ctx: StateContext<AuthorityConnectorDetailPageState>,
connector: Fetched<ConnectorDetailDto>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {Injectable} from '@angular/core';
import {EMPTY, Observable} from 'rxjs';
import {
catchError,
filter,
finalize,
ignoreElements,
Expand All @@ -32,6 +33,7 @@ import {
CloseConnectorDetail,
DeleteConnector,
GetConnectors,
GetConnectorsSilent,
ShowConnectorDetail,
} from './authority-connector-list-page-actions';
import {
Expand Down Expand Up @@ -69,6 +71,23 @@ export class AuthorityConnectorListPageStateImpl {
);
}

@Action(GetConnectorsSilent)
onGetConnectorsSilent(
ctx: StateContext<AuthorityConnectorListPageState>,
): Observable<never> {
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<AuthorityConnectorListPageState>,
newConnectors: Fetched<ConnectorOverviewEntryDto[]>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -48,6 +49,22 @@ export class ParticipantOwnConnectorDetailPageStateImpl {
);
}

@Action(RefreshConnectorSilent, {cancelUncompleted: true})
onRefreshConnectorSilent(
ctx: StateContext<ParticipantOwnConnectorDetailPageState>,
action: RefreshConnector,
): Observable<never> {
return this.apiService
.getOwnOrganizationConnectorDetails(ctx.getState().connectorId)
.pipe(
catchError(() => EMPTY),
tap((connector) => {
this.connectorRefreshed(ctx, Fetched.ready(connector));
}),
ignoreElements(),
);
}

private connectorRefreshed(
ctx: StateContext<ParticipantOwnConnectorDetailPageState>,
connector: Fetched<ConnectorDetailDto>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import {Injectable} from '@angular/core';
import {EMPTY, Observable} from 'rxjs';
import {
catchError,
filter,
finalize,
ignoreElements,
Expand All @@ -32,6 +33,7 @@ import {
CloseConnectorDetail,
DeleteOwnConnector,
GetOwnOrganizationConnectors,
GetOwnOrganizationConnectorsSilent,
ShowConnectorDetail,
} from './participant-own-connector-list-page-actions';
import {
Expand Down Expand Up @@ -69,6 +71,23 @@ export class ParticipantOwnConnectorListPageStateImpl {
);
}

@Action(GetOwnOrganizationConnectorsSilent)
onGetOwnOrganizationConnectorsSilent(
ctx: StateContext<ParticipantOwnConnectorListPageState>,
): Observable<never> {
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<ParticipantOwnConnectorListPageState>,
newConnectors: Fetched<ConnectorOverviewEntryDto[]>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
Loading

0 comments on commit 246d073

Please sign in to comment.