Skip to content

Commit

Permalink
fix: https request updated; update AASApiClientV3
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfaron committed Jul 21, 2024
1 parent 230d115 commit f2e5e5a
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 386 deletions.
6 changes: 3 additions & 3 deletions aasportal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4676,7 +4676,7 @@ File System]]></value>
- Static .aasx files organised in a folder (endpoint)]]></value>
</value-owner>
<value-owner id="q0je4tOT6U+Jt9BRkZ25Ng">
<value name="rendering">{&quot;bounds&quot;: &quot;652,671,307,50&quot;,&quot;model&quot;: &quot;nvq7J+QtYEWAUdAXIk4UEw&quot;,&quot;name&quot;: &quot;Comment2&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;652,671,307,50&quot;,&quot;path&quot;: &quot;shapes/comment.png&quot;,&quot;preserveRatio&quot;: &quot;true&quot;,&quot;sliceMargin&quot;: &quot;1,14,13,1&quot;,&quot;type&quot;: &quot;Image&quot;},{&quot;bounds&quot;: &quot;657,676,287,32&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;- Templates\n- Static .aasx files organised in a folder (endpoint)&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;CommentView&quot;}</value>
<value name="rendering">{&quot;bounds&quot;: &quot;652,671,307,50&quot;,&quot;model&quot;: &quot;nvq7J+QtYEWAUdAXIk4UEw&quot;,&quot;name&quot;: &quot;Comment2&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;652,671,307,50&quot;,&quot;path&quot;: &quot;shapes/comment.png&quot;,&quot;preserveRatio&quot;: &quot;true&quot;,&quot;sliceMargin&quot;: &quot;1,14,13,1&quot;,&quot;type&quot;: &quot;Image&quot;},{&quot;bounds&quot;: &quot;657,676,287,32&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;- Templates\r\n- Static .aasx files organised in a folder (endpoint)&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;CommentView&quot;}</value>
<value name="bounds">652,671,307,50</value>
</value-owner>
<value-owner id="dbJ2ZXplg0mFAqQrROtyuQ">
Expand Down Expand Up @@ -5556,7 +5556,7 @@ Tablet
Mobile Phone]]></value>
</value-owner>
<value-owner id="1CSm1GLCakaeAQ7iHk+MCg">
<value name="rendering">{&quot;bounds&quot;: &quot;601,87,127,65&quot;,&quot;model&quot;: &quot;ZtMAiFX1j0aRRaff6X+9Nw&quot;,&quot;name&quot;: &quot;Comment3&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;601,87,127,65&quot;,&quot;path&quot;: &quot;shapes/comment.png&quot;,&quot;preserveRatio&quot;: &quot;true&quot;,&quot;sliceMargin&quot;: &quot;1,14,13,1&quot;,&quot;type&quot;: &quot;Image&quot;},{&quot;bounds&quot;: &quot;606,92,76,48&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;PC\nTablet\nMobile Phone&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;CommentView&quot;}</value>
<value name="rendering">{&quot;bounds&quot;: &quot;601,87,127,65&quot;,&quot;model&quot;: &quot;ZtMAiFX1j0aRRaff6X+9Nw&quot;,&quot;name&quot;: &quot;Comment3&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;601,87,127,65&quot;,&quot;path&quot;: &quot;shapes/comment.png&quot;,&quot;preserveRatio&quot;: &quot;true&quot;,&quot;sliceMargin&quot;: &quot;1,14,13,1&quot;,&quot;type&quot;: &quot;Image&quot;},{&quot;bounds&quot;: &quot;606,92,76,48&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;PC\r\nTablet\r\nMobile Phone&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;CommentView&quot;}</value>
<value name="bounds">601,87,127,65</value>
</value-owner>
<value-owner id="cuko9kb+bEaJBPGlJE2UdQ">
Expand All @@ -5568,7 +5568,7 @@ Mobile Phone]]></value>
<value name="order">25</value>
</value-owner>
<value-owner id="g0jjnLiGUUycmsxOz0Rvzg">
<value name="rendering">{&quot;bounds&quot;: &quot;61,661,228,48&quot;,&quot;model&quot;: &quot;nNYTytmN+E6fRcW3SyzZfw&quot;,&quot;name&quot;: &quot;Text1&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;61,661,228,48&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;&lt;&lt;service&gt;&gt; : docker container\n&lt;&lt;image&gt;&gt; : docker image\n&lt;&lt;compose&gt;&gt; : docker multi-container&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;TextShapeView&quot;}</value>
<value name="rendering">{&quot;bounds&quot;: &quot;61,661,228,48&quot;,&quot;model&quot;: &quot;nNYTytmN+E6fRcW3SyzZfw&quot;,&quot;name&quot;: &quot;Text1&quot;,&quot;render&quot;: [{&quot;bounds&quot;: &quot;61,661,228,48&quot;,&quot;multiline&quot;: &quot;true&quot;,&quot;text&quot;: &quot;&lt;&lt;service&gt;&gt; : docker container\r\n&lt;&lt;image&gt;&gt; : docker image\r\n&lt;&lt;compose&gt;&gt; : docker multi-container&quot;,&quot;type&quot;: &quot;Text&quot;}],&quot;type&quot;: &quot;TextShapeView&quot;}</value>
<value name="bounds">61,661,228,48</value>
<value name="text"><![CDATA[<<service>> : docker container
<<image>> : docker image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
!
!---------------------------------------------------------------------------->

<div id="fhg-dashboard-container" class="container">
<div id="fhg-dashboard-container" class="container-fluid">
@if (!isEmpty()) {
@for (row of rows(); track row) {
<div class="row">
@for (column of row.columns; track column) {
@for (column of row.columns; track column.id) {
<div [ngClass]="'col border border-3 rounded m-1 ' + (selected(column) ? 'border-primary' : 'border-secondary')"
(click)="toggleSelection(column)" (keydown.enter)="toggleSelection(column)" tabindex="0">
@if (!editMode()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
private readonly map = new Map<string, UpdateTuple>();
private readonly charts = new Map<string, ChartConfigurationTuple>();
private webSocketSubject: WebSocketSubject<WebSocketData> | null = null;
// private reset = false;
private selections = new Set<string>();
private selectedSources = new Map<string, number>();

Expand Down
2 changes: 1 addition & 1 deletion projects/aas-portal/src/app/main/main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<ul ngbNav #nav="ngbNav" [(activeId)]="activeId" class="navbar-nav me-auto">
<ul ngbNav #nav="ngbNav" [activeId]="route.fragment | async" class="navbar-nav me-auto">
@for (link of links(); track link) {
<li [ngbNavItem]="link.id">
<a ngbNavLink routerLink="{{link.url}}" routerLinkActive="active" skipLocationChange="true">{{link.name | translate}}</a>
Expand Down
7 changes: 3 additions & 4 deletions projects/aas-portal/src/app/main/main.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
*****************************************************************************/

import { ChangeDetectionStrategy, Component, OnInit, TemplateRef, ViewChild, model, signal } from '@angular/core';
import { Router, RouterLink, RouterOutlet } from '@angular/router';
import { ChangeDetectionStrategy, Component, OnInit, TemplateRef, ViewChild, signal } from '@angular/core';
import { ActivatedRoute, Router, RouterLink, RouterOutlet } from '@angular/router';
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import { first } from 'rxjs';
import { AuthComponent, LocalizeComponent, NotifyComponent, WindowService } from 'aas-lib';
Expand Down Expand Up @@ -50,6 +50,7 @@ export interface LinkDescriptor {
})
export class MainComponent implements OnInit {
public constructor(
public readonly route: ActivatedRoute,
private readonly router: Router,
private readonly window: WindowService,
private readonly api: MainApiService,
Expand All @@ -61,8 +62,6 @@ export class MainComponent implements OnInit {

public readonly toolbarTemplate = this.toolbar.toolbarTemplate;

public readonly activeId = model(LinkId.START);

public readonly links = signal<LinkDescriptor[]>([
{
id: LinkId.START,
Expand Down
2 changes: 1 addition & 1 deletion projects/aas-server/src/app/aas-provider/aas-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class AASProvider {
return this.index.getDocuments(cursor);
}

public async getDocumentCountAsync(filter?: string): Promise<number> {
public getDocumentCountAsync(filter?: string): Promise<number> {
return this.index.getCount(filter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class DocumentsController extends AASController {
@Get('count')
@Security('bearerAuth', ['guest'])
@OperationId('getDocumentCount')
public async getDocumentCount(@Query() filter?: string): Promise<AASPage> {
public async getDocumentCount(@Query() filter?: string): Promise<number> {
try {
this.logger.start('getDocuments');
if (filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,28 @@ export class AASApiClientV3 extends AASApiClient {
public readonly onlineReady = true;

public async getShellsAsync(): Promise<string[]> {
const pagedResult = await this.message.get<PagedResult<aas.AssetAdministrationShell>>(this.resolve('/shells'));

return pagedResult.result.map(shell => shell.id);
const result = await this.message.get<PagedResult<aas.AssetAdministrationShell>>(this.resolve('shells'));
return result.result.map(shell => shell.id);
}

public async readEnvironmentAsync(id: string): Promise<aas.Environment> {
const aasId = encodeBase64Url(id);
const shell = await this.message.get<aas.AssetAdministrationShell>(this.resolve(`/shells/${aasId}`));
const shell = await this.message.get<aas.AssetAdministrationShell>(this.resolve(`shells/${aasId}`));

const submodels: aas.Submodel[] = [];
if (shell.submodels) {
for (const reference of shell.submodels) {
const submodelId = encodeBase64Url(reference.keys[0].value);
try {
submodels.push(await this.message.get<aas.Submodel>(this.resolve(`/submodels/${submodelId}`)));
submodels.push(await this.message.get<aas.Submodel>(this.resolve(`submodels/${submodelId}`)));
} catch (error) {
this.logger.error(`Unable to read Submodel "${reference.keys[0].value}": ${error?.message}`);
}
}
}

const pagedResult = await this.message.get<PagedResult<aas.ConceptDescription>>(
this.resolve(`/concept-descriptions`),
this.resolve(`concept-descriptions`),
);

const sourceEnv: aas.Environment = {
Expand All @@ -109,7 +108,7 @@ export class AASApiClientV3 extends AASApiClient {
}

public override getThumbnailAsync(id: string): Promise<NodeJS.ReadableStream> {
return this.message.getResponse(this.resolve(`/shells/${encodeBase64Url(id)}/asset-information/thumbnail`));
return this.message.getResponse(this.resolve(`shells/${encodeBase64Url(id)}/asset-information/thumbnail`));
}

public async commitAsync(
Expand Down Expand Up @@ -160,36 +159,36 @@ export class AASApiClientV3 extends AASApiClient {
public async openFileAsync(_: aas.AssetAdministrationShell, file: aas.File): Promise<NodeJS.ReadableStream> {
const smId = encodeBase64Url(file.parent!.keys[0].value);
const path = getIdShortPath(file);
const url = this.resolve(`/submodels/${smId}/submodel-elements/${path}/attachment`);
const url = this.resolve(`submodels/${smId}/submodel-elements/${path}/attachment`);
return await this.message.getResponse(url);
}

public resolveNodeId(shell: aas.AssetAdministrationShell, nodeId: string): string {
const aasId = encodeBase64Url(shell.id);
const items = nodeId.split('.');
const path = items[1].split('/').slice(1).join('.');
return this.resolve(`/shells/${aasId}/submodels/${items[0]}/submodel-elements/${path}`).href;
return this.resolve(`shells/${aasId}/submodels/${items[0]}/submodel-elements/${path}`).href;
}

public async getPackageAsync(aasIdentifier: string): Promise<NodeJS.ReadableStream> {
const aasId = encodeBase64Url(aasIdentifier);
const descriptors: PackageDescriptor[] = await this.message.get(this.resolve(`/packages?aasId=${aasId}`));
const descriptors: PackageDescriptor[] = await this.message.get(this.resolve(`packages?aasId=${aasId}`));
const packageId = encodeBase64Url(descriptors[0].packageId);
return await this.message.getResponse(this.resolve(`/packages/${packageId}`));
return await this.message.getResponse(this.resolve(`packages/${packageId}`));
}

public postPackageAsync(file: Express.Multer.File): Promise<string> {
const formData = new FormData();
formData.append('file', createReadStream(file.path));
formData.append('fileName', file.filename);
return this.message.post(this.resolve(`/packages`), formData);
return this.message.post(this.resolve(`packages`), formData);
}

public async deletePackageAsync(aasIdentifier: string): Promise<string> {
const aasId = encodeBase64Url(aasIdentifier);
const descriptors: PackageDescriptor[] = await this.message.get(this.resolve(`/packages?aasId=${aasId}`));
const descriptors: PackageDescriptor[] = await this.message.get(this.resolve(`packages?aasId=${aasId}`));
const packageId = encodeBase64Url(descriptors[0].packageId);
return await this.message.delete(this.resolve(`/packages/${packageId}`));
return await this.message.delete(this.resolve(`packages/${packageId}`));
}

public async invoke(env: aas.Environment, operation: aas.Operation): Promise<aas.Operation> {
Expand All @@ -207,7 +206,7 @@ export class AASApiClientV3 extends AASApiClient {

const result: OperationResult = JSON.parse(
await this.message.post(
this.resolve(`/shells/${aasId}/submodels/${smId}/submodel-elements/${path}/invoke`),
this.resolve(`shells/${aasId}/submodels/${smId}/submodel-elements/${path}/invoke`),
request,
),
);
Expand All @@ -229,7 +228,7 @@ export class AASApiClientV3 extends AASApiClient {
idShortPath: string,
): Promise<string | undefined> {
const blob = await this.message.get<aas.Blob>(
this.resolve(`/submodels/${submodelId}/submodel-elements/${idShortPath}/?extent=WithBlobValue`),
this.resolve(`submodels/${submodelId}/submodel-elements/${idShortPath}/?extent=WithBlobValue`),
);

if (!blob) {
Expand All @@ -241,26 +240,26 @@ export class AASApiClientV3 extends AASApiClient {

private async putShellAsync(shell: aas.AssetAdministrationShell): Promise<string> {
const aasId = encodeBase64Url(shell.id);
return await this.message.put(this.resolve(`/shells/${aasId}`), new JsonWriter().convert(shell));
return await this.message.put(this.resolve(`shells/${aasId}`), new JsonWriter().convert(shell));
}

private async putSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
const smId = encodeBase64Url(submodel.id);
return await this.message.put(
this.resolve(`/shells/${aasId}/submodels/${smId}`),
this.resolve(`shells/${aasId}/submodels/${smId}`),
new JsonWriter().convert(submodel),
);
}

private async postSubmodelAsync(aasId: string, submodel: aas.Submodel): Promise<string> {
return await this.message.post(
this.resolve(`/submodels?aasIdentifier=${aasId}`),
this.resolve(`submodels?aasIdentifier=${aasId}`),
new JsonWriter().convert(submodel),
);
}

private async deleteSubmodelAsync(smId: string): Promise<string> {
return await this.message.delete(this.resolve(`/submodels/${encodeBase64Url(smId)}`));
return await this.message.delete(this.resolve(`submodels/${encodeBase64Url(smId)}`));
}

private async putSubmodelElementAsync(
Expand All @@ -270,7 +269,7 @@ export class AASApiClientV3 extends AASApiClient {
const smId = encodeBase64Url(submodel.id);
const path = getIdShortPath(submodelElement);
return await this.message.put(
this.resolve(`/submodels/${smId}/submodel-elements/${path}`),
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
);
}
Expand All @@ -282,7 +281,7 @@ export class AASApiClientV3 extends AASApiClient {
const smId = encodeBase64Url(submodel.id);
const path = getIdShortPath(submodelElement);
return await this.message.post(
this.resolve(`/submodels/${smId}/submodel-elements/${path}`),
this.resolve(`submodels/${smId}/submodel-elements/${path}`),
new JsonWriter().convert(submodelElement),
);
}
Expand All @@ -293,7 +292,7 @@ export class AASApiClientV3 extends AASApiClient {
): Promise<string> {
const smId = encodeBase64Url(submodel.id);
const path = getIdShortPath(submodelElement);
return await this.message.delete(this.resolve(`/submodels/${smId}/submodel-elements/${path}`));
return await this.message.delete(this.resolve(`submodels/${smId}/submodel-elements/${path}`));
}

private getSubmodel(env: aas.Environment, referable?: aas.Referable): aas.Submodel {
Expand Down
13 changes: 3 additions & 10 deletions projects/aas-server/src/app/packages/aas-server/aas-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ export abstract class AASApiClient extends AASResource {

public async testAsync(): Promise<void> {
if (this.reentry === 0) {
try {
await this.openAsync();
} finally {
await this.closeAsync();
}
await this.message.checkUrlExist(this.url);
}
}

Expand All @@ -59,12 +55,9 @@ export abstract class AASApiClient extends AASResource {
*/
public abstract getThumbnailAsync(id: string): Promise<NodeJS.ReadableStream>;

public async openAsync(): Promise<void> {
if (this.reentry === 0) {
await this.message.checkUrlExist(this.url);
}

public openAsync(): Promise<void> {
++this.reentry;
return Promise.resolve();
}

public closeAsync(): Promise<void> {
Expand Down
Loading

0 comments on commit f2e5e5a

Please sign in to comment.