Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rtal into development
  • Loading branch information
fpethig committed Apr 8, 2024
2 parents 5a20185 + 6afba37 commit dbe36d4
Show file tree
Hide file tree
Showing 41 changed files with 866 additions and 391 deletions.
110 changes: 55 additions & 55 deletions aasportal.mdx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aas-portal-project",
"version": "3.0.0-development.40",
"version": "3.0.0-development.41",
"description": "Web-based visualization and control of asset administration shells.",
"type": "module",
"scripts": {
Expand Down
17 changes: 8 additions & 9 deletions projects/aas-lib/src/lib/aas-table/aas-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Observable, Subscription } from 'rxjs';
import { AASTableRow, AASTableFeatureState } from './aas-table.state';
import * as AASTableSelectors from './aas-table.selectors';
import * as AASTableActions from './aas-table.actions';
import { AASQuery } from '../types/aas-query-params';
import { ClipboardService } from '../clipboard.service';
import { WindowService } from '../window.service';
import { ViewMode } from '../types/view-mode';
Expand Down Expand Up @@ -144,14 +143,14 @@ export class AASTableComponent implements OnInit, OnChanges, OnDestroy {
}

public open(row: AASTableRow): void {
const query: AASQuery = {
id: row.id,
name: row.endpoint,
document: row.document,
};

this.clipboard.set('AASQuery', query);
this.router.navigateByUrl('/aas?format=AASQuery', { skipLocationChange: true });
this.clipboard.set('AASDocument', row.document);
this.router.navigate(['/aas'], {
skipLocationChange: true,
queryParams: {
id: row.id,
endpoint: row.endpoint,
},
});
}

public getToolTip(row: AASTableRow): string {
Expand Down
47 changes: 27 additions & 20 deletions projects/aas-lib/src/lib/aas-tree/aas-tree-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,40 @@ export class AASTreeSearch {
this.subscription.unsubscribe();
}

public find(referable: aas.Referable): void {
const index = this.rows.findIndex(row => row.element === referable);
if (index >= 0) {
this.store.dispatch(AASTreeActions.setMatchIndex({ index: index }));
}
}

public start(value: string) {
if (value) {
const terms: SearchTerm[] = [];
for (const expression of this.splitOr(value)) {
const term: SearchTerm = {};
if (expression.length >= 3) {
if (expression.startsWith('#')) {
const query = this.parseExpression(expression);
if (query) {
term.query = query;
}
} else {
term.text = expression.toLocaleLowerCase(this.translate.currentLang);
if (!value) return;

const terms: SearchTerm[] = [];
for (const expression of this.splitOr(value)) {
const term: SearchTerm = {};
if (expression.length >= 3) {
if (expression.startsWith('#')) {
const query = this.parseExpression(expression);
if (query) {
term.query = query;
}
}

if (term.text || term.query) {
terms.push(term);
} else {
term.text = expression.toLocaleLowerCase(this.translate.currentLang);
}
}

if (terms.length > 0) {
this.store.dispatch(AASTreeActions.setSearchText({ terms }));
} else {
this.store.dispatch(AASTreeActions.setMatchIndex({ index: -1 }));
if (term.text || term.query) {
terms.push(term);
}
}

if (terms.length > 0) {
this.store.dispatch(AASTreeActions.setSearchText({ terms }));
} else {
this.store.dispatch(AASTreeActions.setMatchIndex({ index: -1 }));
}
}

public findNext(): boolean {
Expand Down
49 changes: 27 additions & 22 deletions projects/aas-lib/src/lib/aas-tree/aas-tree.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,40 +79,45 @@
@if (node.isLeaf) {
<td class="text-end">
@switch(node.element.modelType) {
@case ('AnnotatedRelationshipElement') {}
@case ('AssetAdministrationShell') {}
@case ('BasicEventElement') {}
@case ('Blob') {}
@case ('Capability') {}
@case ('ConceptDescription') {}
@case ('DataSpecificationIec61360') {}
@case ('Entity') {}
@case ('File') {
@case ('AnnotatedRelationshipElement') {
<div class="d-flex flex-column ts-x-small me-2">
<a href="javascript:void(0);" class="text-nowrap"
(click)="openReference(node.annotatedRelationship?.first)">{{toString(node.annotatedRelationship?.first)}}</a>
<a href="javascript:void(0);" class="text-nowrap"
(click)="openReference(node.annotatedRelationship?.second)">{{toString(node.annotatedRelationship?.second)}}</a>
</div>
}
@case ('Blob') {
<a href="javascript:void(0);" class="text-nowrap me-2" (click)="openBlob(node.blob)">{{node.value}}</a>
}
@case('Entity') {
<a href="javascript:void(0);" class="text-nowrap me-2"
(click)="openFile(node.file)">{{node.file?.value}}</a>
(click)="openReference(node.entity?.globalAssetId)">{{node.value}}</a>
}
@case ('MultiLanguageProperty') {}
@case ('Operation') {}
@case ('Property') {
<div>{{1}}</div>
@case ('File') {
<a href="javascript:void(0);" class="text-nowrap me-2" (click)="openFile(node.file)">{{node.value}}</a>
}
@case ('Operation') {
<a href="javascript:void(0);" class="text-nowrap me-2"
(click)="openOperation(node.operation)">{{node.value}}</a>
}
@case ('Range') {}
@case ('ReferenceElement') {
<a href="javascript:void(0);" class="text-nowrap me-2" (click)="open(node)">{{node.reference?.value}}</a>
<a href="javascript:void(0);" class="text-nowrap me-2"
(click)="openReference(node.reference?.value)">{{node.value}}</a>
}
@case ('RelationshipElement') {
<div class="d-flex">
<a href="javascript:void(0);" class="text-nowrap me-2"
(click)="openRelationship(node.relationship, node.relationship?.first)">first</a>
<a href="javascript:void(0);" class="text-nowrap me-2"
(click)="openRelationship(node.relationship, node.relationship?.second)">seconde</a>
<div class="d-flex flex-column ts-x-small me-2">
<a href="javascript:void(0);" class="text-nowrap"
(click)="openReference(node.relationship?.first)">{{toString(node.relationship?.first)}}</a>
<a href="javascript:void(0);" class="text-nowrap"
(click)="openReference(node.relationship?.second)">{{toString(node.relationship?.second)}}</a>
</div>
}
@case ('Submodel') {}
@case ('SubmodelElementCollection') {}
@case ('SubmodelElementList') {}
@default {
<div class="text-nowrap me-2">-</div>
<div class="text-nowrap me-2">{{node.value}}</div>
}
}
</td>
Expand Down
128 changes: 82 additions & 46 deletions projects/aas-lib/src/lib/aas-tree/aas-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
selectSubmodel,
getIdShortPath,
mimeTypeToExtension,
selectReferable,
} from 'common';

import { AASTreeRow, AASTreeFeatureState } from './aas-tree.state';
Expand All @@ -34,7 +35,6 @@ import { ShowVideoFormComponent } from './show-video-form/show-video-form.compon
import { OperationCallFormComponent } from './operation-call-form/operation-call-form.component';
import { AASTreeSearch } from './aas-tree-search';
import { basename, encodeBase64Url } from '../convert';
import { AASQuery } from '../types/aas-query-params';
import { ViewQuery } from '../types/view-query-params';
import { WindowService } from '../window.service';
import { DocumentService } from '../document.service';
Expand Down Expand Up @@ -68,6 +68,7 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
private readonly liveNodes: LiveNode[] = [];
private readonly map = new Map<string, PropertyValue>();
private readonly subscription = new Subscription();
private searchSubscription?: Subscription;
private _selected: aas.Referable[] = [];
private shiftKey = false;
private altKey = false;
Expand All @@ -93,16 +94,6 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
this.someSelected = this.store.select(AASTreeSelectors.selectSomeSelected);
this.everySelected = this.store.select(AASTreeSelectors.selectEverySelected);

this.subscription.add(
this.store
.select(AASTreeSelectors.selectSelectedElements)
.pipe()
.subscribe(elements => {
this._selected = elements;
this.selectedChange.emit(elements);
}),
);

this.window.addEventListener('keyup', this.keyup);
this.window.addEventListener('keydown', this.keydown);
}
Expand Down Expand Up @@ -149,6 +140,16 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
public nodes: Observable<AASTreeRow[]>;

public ngOnInit(): void {
this.subscription.add(
this.store
.select(AASTreeSelectors.selectSelectedElements)
.pipe()
.subscribe(elements => {
this._selected = elements;
this.selectedChange.emit(elements);
}),
);

this.subscription.add(
this.store
.select(AASTreeSelectors.selectError)
Expand Down Expand Up @@ -207,8 +208,15 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
);
}

if (changes['search'] && this.search) {
this.subscription.add(this.search.subscribe(value => this.searching.start(value)));
if (changes['search']) {
if (this.searchSubscription) {
this.searchSubscription.unsubscribe();
this.searchSubscription = undefined;
}

if (this.search) {
this.searchSubscription = this.search.subscribe(value => this.searching.start(value));
}
}

const stateChange = changes['state'];
Expand All @@ -225,6 +233,7 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {

public ngOnDestroy(): void {
this.subscription.unsubscribe();
this.searchSubscription?.unsubscribe();
this.webSocketSubject?.unsubscribe();
this.searching?.destroy();
this.window.removeEventListener('keyup', this.keyup);
Expand Down Expand Up @@ -286,15 +295,6 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
this.store.dispatch(AASTreeActions.toggleSelected({ row: node, altKey: this.altKey, shiftKey: this.shiftKey }));
}

public openEntity(entity: aas.Entity): void {
if (this.state === 'online') return;

if (entity && entity.globalAssetId) {
this.clipboard.set('AASQuery', { id: entity.globalAssetId } as AASQuery);
this.router.navigateByUrl('/aas?format=AASQuery', { skipLocationChange: true });
}
}

public async openFile(file: aas.File | undefined): Promise<void> {
if (!file || !file.value || this.state === 'online') return;

Expand Down Expand Up @@ -361,18 +361,22 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
}
}

public openReference(reference: aas.ReferenceElement | undefined): void {
if (!reference?.value || this.state === 'online') return;
public openReference(reference: aas.Reference | string | undefined): void {
if (!reference || this.state === 'online') return;

this.clipboard.set('AASQuery', { id: reference.value.keys[0].value } as AASQuery);
this.router.navigateByUrl('/aas?format=AASQuery', { skipLocationChange: true });
}
if (typeof reference === 'string') {
this.openDocumentByAssetId(reference);
} else {
if (reference.keys.length === 0) {
return;
}

public openRelationship(
relationship: aas.RelationshipElement | undefined,
reference: aas.Reference | undefined,
): void {
if (!relationship || !reference || this.state === 'online') return;
if (reference.type === 'ExternalReference') {
this.openExternalReference(reference);
} else {
this.selectModelReference(reference);
}
}
}

public openSubmodel(submodel: aas.Submodel | undefined): void {
Expand All @@ -399,20 +403,6 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
}
}

public open(node: AASTreeRow): void {
try {
switch (node.element.modelType) {
case 'Property': {
const property = node.element as aas.Property;
this.window.open(String(property.value));
break;
}
}
} catch (error) {
this.notify.error(error);
}
}

public findNext(): void {
this.searching.findNext();
}
Expand All @@ -421,6 +411,14 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
this.searching.findPrevious();
}

public toString(value: aas.Reference | undefined): string {
if (!value) {
return '-';
}

return value.keys.map(key => key.value).join('.');
}

private async showImageAsync(name: string, src: string): Promise<void> {
try {
const modalRef = this.modal.open(ShowImageFormComponent, { backdrop: 'static' });
Expand Down Expand Up @@ -524,6 +522,44 @@ export class AASTreeComponent implements OnInit, OnChanges, OnDestroy {
}
}

private openDocumentByAssetId(assetId: string): void {
if (assetId) {
this.clipboard.clear('AASDocument');
this.router.navigate(['/aas'], {
skipLocationChange: true,
onSameUrlNavigation: 'reload',
queryParams: { id: assetId },
});
}
}

private openExternalReference(reference: aas.Reference): void {
this.clipboard.clear('AASDocument');
this.router.navigate(['/aas'], {
skipLocationChange: true,
onSameUrlNavigation: 'reload',
queryParams: { id: reference.keys[0].value },
});
}

private selectModelReference(reference: aas.Reference): void {
if (!this.document?.content) {
return;
}

const referable = selectReferable(this.document.content, reference);
if (referable) {
this.searching.find(referable);
} else if (reference.keys[0].type === 'AssetAdministrationShell') {
this.clipboard.clear('AASDocument');
this.router.navigate(['/aas'], {
skipLocationChange: true,
onSameUrlNavigation: 'reload',
queryParams: { id: reference.keys[0].value },
});
}
}

private createMessage(document: AASDocument): WebSocketData {
return {
type: 'LiveRequest',
Expand Down
Loading

0 comments on commit dbe36d4

Please sign in to comment.