fix: markdown styles, probe for policy-card-light
MODIFY
angular.json
angular.json
"src/assets"
],
"styles": [
- "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
+ "node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss",
"src/assets/themes/default.scss",
"node_modules/swagger-ui/dist/swagger-ui.css",
- "node_modules/simplebar/dist/simplebar.css"
+ "node_modules/simplebar/dist/simplebar.css",
+ "node_modules/prismjs/themes/prism.css"
],
"scripts": [
"node_modules/marked/lib/marked.js",
- "node_modules/simplebar/dist/simplebar.js"
+ "node_modules/simplebar/dist/simplebar.js",
+ "node_modules/prismjs/prism.js"
]
},
"configurations": {

MODIFY
package-lock.json
package-lock.json
"dev": true
},
"prismjs": {
- "version": "1.24.1",
- "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.24.1.tgz",
- "integrity": "sha512-mNPsedLuk90RVJioIky8ANZEwYm5w9LcvCXrxHlwf4fNVSn8jEipMybMkWUyyF0JhnC+C4VcOVSBuHRKs1L5Ow=="
+ "version": "1.25.0",
+ "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.25.0.tgz",
+ "integrity": "sha512-WCjJHl1KEWbnkQom1+SzftbtXMKQoezOCYs5rECqMN+jP+apI7ftoflyqigqzopSO3hMhTEb0mFClA8lkolgEg=="
},
"process-nextick-args": {
"version": "2.0.1",

MODIFY
package.json
package.json
"keycloak-angular": "^8.4.0",
"keycloak-js": "^15.0.2",
"ngx-markdown": "^12.0.1",
+ "prismjs": "^1.25.0",
"rxjs": "~6.6.0",
"simplebar": "^5.3.6",
"swagger-ui": "^3.52.4",

MODIFY
src/app/components/marketplace-api-description/marketplace-api-description.component.scss
src/app/components/marketplace-api-description/marketplace-api-description.component.scss
.box{
- height: 100%;
+ height: 50vh;
padding-left: 1%;
padding-right: 1%;
}

MODIFY
src/app/components/marketplace-api-details/marketplace-api-details.component.html
src/app/components/marketplace-api-details/marketplace-api-details.component.html
<ng-container *ngIf="apis">
<mat-accordion class="exampe-headers-align">
- <ng-container *ngFor="let api of apis; last as isLatest">
+ <ng-container *ngFor="let api of apis; first as isLatest">
<app-marketplace-api-description
[isLatest]="isLatest"
[api]="api"

MODIFY
src/app/components/policy-card-light/policy-card-light.component.html
src/app/components/policy-card-light/policy-card-light.component.html
<div class="limit-flex">
<div>
<p [innerHTML]="'POLICIES.' + policy.policyIdentifier + '.CONDITION_LIGHT' | translate:policy.restrictions"></p>
- <p><b>TODO</b> / {{policy.restrictions?.limit}}</p>
+ <p><b>{{currentValue}}</b> / {{policy.restrictions?.limit}}</p>
</div>
<div class="second">
<button (click)="setSectionToPolicies()" mat-icon-button color="primary" class="mt-10">

MODIFY
src/app/components/policy-card-light/policy-card-light.component.ts
src/app/components/policy-card-light/policy-card-light.component.ts
import {Component, Input, OnInit} from '@angular/core';
-import {IPolicyExt} from "../../interfaces/IPolicyExt";
-import {PolicyService} from "../../services/policy/policy.service";
-import {IContractExt} from "../../interfaces/IContractExt";
+import {IPolicyExt} from '../../interfaces/IPolicyExt';
+import {PolicyService} from '../../services/policy/policy.service';
+import {IContractExt} from '../../interfaces/IContractExt';
+import {formatBytes} from "../../shared/utility";
@Component({
selector: 'app-policy-card-light',
@@ -12,14 +13,30 @@ export class PolicyCardLightComponent implements OnInit {
@Input() policy!: IPolicyExt;
@Input() contract?: IContractExt;
+ // string because of bytes
+ currentValue = '0';
+
constructor(private policyService: PolicyService) {}
ngOnInit(): void {
- this.policy = this.policyService.initPolicy(this.policy!);
+ this.policy = this.policyService.initPolicy(this.policy);
+ this.setCurrentValue();
}
setSectionToPolicies() {
- if (this.contract)
- this.contract.section = 'policies';
+ if (this.contract) this.contract.section = 'policies';
+ }
+
+ setCurrentValue() {
+ this.policyService.getPolicyProbe(this.contract!, this.policy).subscribe(
+ (probeResult) => {
+ if (this.policy.policyIdentifier === this.policyService.policyIds.TRANSFER_QUOTA) {
+ this.currentValue = formatBytes((probeResult[0].config.limit - probeResult[0].status.remaining));
+ } else {
+ this.currentValue = String(probeResult[0].config.limit - probeResult[0].status.remaining);
+ }
+ },
+ (error) => console.warn(error)
+ );
}
}

MODIFY
src/app/services/policy/policy.service.ts
src/app/services/policy/policy.service.ts
@@ -6,6 +6,7 @@ import {map, switchMap, tap} from "rxjs/operators";
import {BackendService} from "../backend/backend.service";
import {forkJoin, Observable, of} from "rxjs";
import {formatBytes} from "../../shared/utility";
+import {IContractExt} from "../../interfaces/IContractExt";
export interface PolicyHeaders {
headerLimit: string;
@@ -31,9 +32,9 @@ export class PolicyService {
};
public readonly policyIds = {
- 'RATE_LIMITING': 'RateLimitingPolicy',
- 'TRANSFER_QUOTA': 'TransferQuotaPolicy'
- }
+ RATE_LIMITING: 'RateLimitingPolicy',
+ TRANSFER_QUOTA: 'TransferQuotaPolicy'
+ };
constructor(private backendService: BackendService) {}
@@ -98,13 +99,13 @@ export class PolicyService {
const policyConfig = JSON.parse(extendedPolicy.configuration);
switch (extendedPolicy.definition.id) {
case this.policyIds.RATE_LIMITING: {
- extendedPolicy.shortName = 'Rate Limit'
- extendedPolicy.shortDescription = `${policyConfig.limit} Request${policyConfig.limit > 1 ? 's' : ''} per ${policyConfig.period}`
+ extendedPolicy.shortName = 'Rate Limit';
+ extendedPolicy.shortDescription = `${policyConfig.limit} Request${policyConfig.limit > 1 ? 's' : ''} per ${policyConfig.period}`;
break;
}
case this.policyIds.TRANSFER_QUOTA: {
- extendedPolicy.shortName = 'Quota'
- extendedPolicy.shortDescription = `${formatBytes(policyConfig.limit)} per ${policyConfig.period}`
+ extendedPolicy.shortName = 'Quota';
+ extendedPolicy.shortDescription = `${formatBytes(policyConfig.limit)} per ${policyConfig.period}`;
break;
}
}
@@ -126,8 +127,8 @@ export class PolicyService {
tap(policySummaries => {
policySummaries.forEach(policySummary => {
const policySummaryExt = policySummary as IPolicySummaryExt;
- policySummaryExt.planId = planId
- policySummaryExt.planVersion = planVersion
+ policySummaryExt.planId = planId;
+ policySummaryExt.planVersion = planVersion;
})
})
)
@@ -190,4 +191,8 @@ export class PolicyService {
policy.headers = newHeaders;
}
+
+ public getPolicyProbe(contract: IContractExt, policy: IPolicy): Observable<any> {
+ return this.backendService.getPolicyProbe(contract, policy);
+ }
}

fix: markdown styles, probe for policy-card-light