Skip to content

Commit

Permalink
feat: max active consuming contract agreements limit (#335)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Treier <richard.treier@sovity.de>
  • Loading branch information
AnurosePrakash and richardtreier committed Jul 4, 2023
1 parent 71153db commit 8fa3680
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 88 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ the detailed section referring to by linking pull requests or issues.

#### Added

- Enteprise Edition (Basic): Added support for consuming contract agreement
limits.

#### Changed

#### Removed
Expand Down
4 changes: 4 additions & 0 deletions fake-backend/json/connectorLimits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"numActiveConsumingContractAgreements": 2,
"maxActiveConsumingContractAgreements": 1
}
6 changes: 6 additions & 0 deletions fake-backend/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ app.get('/api/v1/data/wrapper/ui/pages/contract-agreement-page', (_, res) => {
res.json(contractAgreementPage);
});

// Connector Limits
const connectorLimits = json('json/connectorLimits.json');
app.get('/api/v1/data/wrapper/ee/connector-limits', (_, res) => {
res.json(connectorLimits);
});

// Broker API Wrapper
const brokerCatalogPage = json('json/brokerCatalogPage.json');
app.post('/api/v1/data/wrapper/broker/catalog-page', (_, res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
"
mat-raised-button
color="primary"
[matTooltip]="data.contractAgreement?.statusTooltipText ?? ''"
[disabled]="!data.contractAgreement?.canTransfer"
(click)="onTransferClick()">
Transfer
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,63 +236,72 @@ export class AssetPropertyGridGroupBuilder {
}

buildContractAgreementGroup(contractAgreement: ContractAgreementCardMapped) {
return {
groupLabel: 'Contract Agreement',
properties: [
{
icon: 'category',
label: 'Signed',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(
contractAgreement.contractSigningDate,
),
),
},
{
icon: 'category',
label: 'Valid From',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(
contractAgreement.contractStartDate,
),
),
},
{
icon: 'category',
label: 'Valid To',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(
contractAgreement.contractEndDate,
),
),
},
{
icon: 'policy',
label: 'Direction',
...this.propertyGridUtils.guessValue(contractAgreement.direction),
},
{
icon: 'link',
label: 'Other Connector Endpoint',
...this.propertyGridUtils.guessValue(
contractAgreement.counterPartyAddress,
),
},
{
icon: 'link',
label: 'Other Connector ID',
...this.propertyGridUtils.guessValue(
contractAgreement.counterPartyId,
let properties: PropertyGridField[] = [
{
icon: 'category',
label: 'Signed',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(
contractAgreement.contractSigningDate,
),
},
{
icon: 'category',
label: 'Contract Agreement ID',
...this.propertyGridUtils.guessValue(
contractAgreement.contractAgreementId,
),
},
{
icon: 'category',
label: 'Valid From',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(
contractAgreement.contractStartDate,
),
},
],
),
},
{
icon: 'category',
label: 'Valid To',
...this.propertyGridUtils.guessValue(
this.propertyGridUtils.formatDate(contractAgreement.contractEndDate),
),
},
{
icon: 'policy',
label: 'Direction',
...this.propertyGridUtils.guessValue(contractAgreement.direction),
},
{
icon: 'link',
label: 'Other Connector Endpoint',
...this.propertyGridUtils.guessValue(
contractAgreement.counterPartyAddress,
),
},
{
icon: 'link',
label: 'Other Connector ID',
...this.propertyGridUtils.guessValue(contractAgreement.counterPartyId),
},
{
icon: 'category',
label: 'Contract Agreement ID',
...this.propertyGridUtils.guessValue(
contractAgreement.contractAgreementId,
),
},
];

if (contractAgreement.isConsumingLimitsEnforced) {
properties.push({
icon: contractAgreement.canTransfer ? 'sync' : 'sync_disabled',
label: 'Status',
tooltip: contractAgreement.statusTooltipText,
textIconAfter: contractAgreement.statusTooltipText ? 'help' : null,
text: contractAgreement.statusText,
additionalClasses: 'text-warn',
});
}

return {
groupLabel: 'Contract Agreement',
properties,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ export interface PropertyGridField {
additionalClasses?: string;

copyButton?: boolean;
tooltip?: string | null;
textIconAfter?: string | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
class=""
emptyMessage="No properties."></empty-state>
<div
*ngFor="let prop of props"
*ngFor="let prop of props; trackBy: trackByIndex"
class="flex flex-row space-x-[10px] overflow-hidden"
[style.width]="'calc(100% / ' + columns + ' - ' + (columns - 1) * 10 + 'px)'">
<!-- Property Icon -->
<mat-icon
style="flex-shrink: 0; margin-top: 6px"
[matTooltip]="prop.tooltip!"
[attr.title]="prop.labelTitle"
>{{ prop.icon }}</mat-icon
>
<div class="flex flex-col">
<!-- Property Label -->
<div
class="uppercase text-slate text-sm break-all"
[matTooltip]="prop.tooltip!"
[attr.title]="prop.labelTitle">
{{ prop.label }}
</div>
Expand All @@ -41,12 +43,16 @@
>{{ prop.text }}</a
>

<!-- Property Value (Text) -->
<!-- Property Value (Text) with tooltip -->
<span
*ngIf="!(prop.url || prop.onclick)"
[matTooltip]="prop.tooltip!"
[ngClass]="prop.additionalClasses"
>{{ prop.text }}</span
>
>{{ prop.text }}
<mat-icon *ngIf="prop.textIconAfter" class="mat-icon-[12px]">
{{ prop.textIconAfter }}
</mat-icon>
</span>
</div>
<button
*ngIf="prop.copyButton"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, HostBinding, Input} from '@angular/core';
import {Component, HostBinding, Input, TrackByFunction} from '@angular/core';
import {PropertyGridField} from './property-grid-field';

@Component({
Expand All @@ -17,4 +17,6 @@ export class PropertyGridComponent {
@HostBinding('class.gap-[10px]')
@HostBinding('class.justify-start')
cls = true;

trackByIndex: TrackByFunction<any> = (index: number) => index;
}
4 changes: 4 additions & 0 deletions src/app/core/config/active-feature-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export class ActiveFeatureSet {
return this.has('mds-fields');
}

hasConnectorLimits(): boolean {
return this.has('connector-limits');
}

has(feature: EdcUiFeature): boolean {
return this.config.features.has(feature);
}
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/config/profiles/edc-ui-feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ export type EdcUiFeature =
| 'logout-button'

// Enables marketing for sovity in open-source variants
| 'open-source-marketing';
| 'open-source-marketing'

// Enterprise Edition specific attribute to view limits enforced on consuming contract agreements
| 'connector-limits';
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {EdcUiFeature} from '../edc-ui-feature';

export const ENTERPRISE_EDITION_FEATURES: EdcUiFeature[] = [
'sovity-zammad-integration',
'logout-button',
'connector-limits',
'sovity-zammad-integration',
];
5 changes: 5 additions & 0 deletions src/app/core/services/api/edc-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Observable, from} from 'rxjs';
import {
CatalogPageQuery,
CatalogPageResult,
ConnectorLimits,
ConnectorPageQuery,
ConnectorPageResult,
ContractAgreementPage,
Expand Down Expand Up @@ -31,6 +32,10 @@ export class EdcApiService {
return from(this.edcClient.useCaseApi.kpiEndpoint());
}

getEnterpriseEditionConnectorLimits(): Observable<ConnectorLimits> {
return from(this.edcClient.enterpriseEditionApi.connectorLimits());
}

brokerCatalog(
catalogPageQuery: CatalogPageQuery,
): Observable<CatalogPageResult> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck

/**
* EDC REST API
* All files merged by open api merger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class ContractAgreementCardMappedService {
isInProgress: contractAgreement.transferProcesses.some(
(it) => it.state.simplifiedState === 'RUNNING',
),
isConsumingLimitsEnforced: false,
statusText: '',
statusTooltipText: '',
canTransfer: true,
searchTargets: [
contractAgreement.contractAgreementId,
contractAgreement.counterPartyId,
Expand All @@ -43,4 +47,33 @@ export class ContractAgreementCardMappedService {
): ContractAgreementCardMapped[] {
return search(cards, searchText, (card) => card.searchTargets);
}

withEnforcedLimits(
maxConsumingContracts: number,
agreements: ContractAgreementCardMapped[],
): ContractAgreementCardMapped[] {
return agreements.map((it, index) => ({
...it,
isConsumingLimitsEnforced: true,
statusText: index < maxConsumingContracts ? 'Active' : 'Inactive',
statusTooltipText: this.getConsumingContractsInfoText(
index,
maxConsumingContracts,
),
canTransfer: index < maxConsumingContracts,
}));
}

private getConsumingContractsInfoText(
index: number,
maxConsumingContracts: number,
): string {
if (index >= maxConsumingContracts) {
return `This connector is licensed for a maximum number of ${maxConsumingContracts} consuming contract${
maxConsumingContracts == 1 ? '' : 's'
}. When negotiating new contracts, older contracts will be deactivated.`;
} else {
return '';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ export type ContractAgreementCardMapped = Omit<
> & {
asset: Asset;
isInProgress: boolean;
isConsumingLimitsEnforced: boolean;
statusText: string;
statusTooltipText: string;
canTransfer: boolean;
searchTargets: (string | null)[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
Validity
</div>
<div>
<date [date]="card.contractStartDate"></date> -
<date [date]="card.contractStartDate"></date>
-
<date [date]="card.contractEndDate"></date>
</div>
</div>
Expand All @@ -58,18 +59,33 @@
</div>
</div>
</div>
<!-- Counterparty Address -->
<div class="flex flex-col flex-grow">
<div class="text-slate text-sm uppercase tracking-wider">
Other Connector
<div class="flex flex-row space-x-[10px] justify-between">
<!-- Counterparty Address -->
<div class="flex flex-col">
<div class="text-slate text-sm uppercase">Other Connector</div>
<div>
<a
class="link break-all"
target="_blank"
[attr.href]="card.counterPartyAddress"
>{{ card.counterPartyAddress }}</a
>
</div>
</div>
<div>
<a
class="link"
target="_blank"
[attr.href]="card.counterPartyAddress"
>{{ card.counterPartyAddress }}</a
>
<!-- Status -->
<div
*ngIf="card.isConsumingLimitsEnforced"
class="flex flex-col"
[matTooltip]="card.statusTooltipText">
<div class="text-slate text-sm uppercase tracking-wider text-right">
Status
</div>
<div class="text-right" [class.text-warn]="!card.canTransfer">
{{ card.statusText }}
<mat-icon *ngIf="!card.canTransfer" class="mat-icon-[12px]">
help
</mat-icon>
</div>
</div>
</div>

Expand Down
Loading

0 comments on commit 8fa3680

Please sign in to comment.