-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
775 additions
and
280 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
projects/aas-portal/src/app/start/extras-endpoint-form/extras-endpoint-form.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!----------------------------------------------------------------------------- | ||
! | ||
! Copyright (c) 2019-2024 Fraunhofer IOSB-INA Lemgo, | ||
! eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
! zur Foerderung der angewandten Forschung e.V. | ||
! | ||
!----------------------------------------------------------------------------> | ||
|
||
<form (ngSubmit)="submit()"> | ||
<div class="modal-header text-info"> | ||
<h4 class="modal-title"> | ||
<i class="bi bi-gear"></i> | ||
<span class="ms-2" translate>ExtrasEndpointForm.CAPTION</span> | ||
</h4> | ||
<button type="button" class="btn-close" (click)="submit()"> </button> | ||
</div> | ||
<div class="modal-body"> | ||
@for (message of messages(); track message) { | ||
<ngb-toast [autohide]="false" class="bg-danger w-100 mb-3"> | ||
<div class="d-flex"> | ||
<div class="flex-grow-1">{{ message }}</div> | ||
</div> | ||
</ngb-toast> | ||
} | ||
<table class="table table-sm"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col" translate>ExtrasEndpointForm.NAME</th> | ||
<th scope="col" translate>ExtrasEndpointForm.COUNT</th> | ||
<th scope="col" translate>ExtrasEndpointForm.UPDATE</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@for (item of endpoints(); track item.name; let index = $index) { | ||
<tr class="align-middle"> | ||
<th scope="row">{{index + 1}}</th> | ||
<td> | ||
<div class="d-flex flex-column flex-grow-1"> | ||
<div>{{item.name}}</div> | ||
<div class="ts-small">{{item.url}}</div> | ||
</div> | ||
</td> | ||
<td>{{item.count}}</td> | ||
@if (item.schedule === 'manual') { | ||
<td><a href="javascript:void(0);" (click)="scan(item.name)">{{'ExtrasEndpointForm.'+item.schedule | | ||
translate}}</a></td> | ||
} @else { | ||
<td>{{'ExtrasEndpointForm.' + item.schedule | translate}}</td> | ||
} | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
<button type="button" class="btn btn-secondary" (click)="collapse.toggle()" [attr.aria-expanded]="!isCollapsed" | ||
aria-controls="collapseReset"> | ||
<span translate>ExtrasEndpointForm.RESET</span><span>...</span> | ||
</button> | ||
<div #collapse="ngbCollapse" class="mt-2" [(ngbCollapse)]="isCollapsed"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<p class="card-text" translate>ExtrasEndpointForm.CONFIRM_RESET_CONFIGURATION</p> | ||
<button type="button" class="btn btn-danger" (click)="reset()" | ||
translate>ExtrasEndpointForm.RESET</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-primary" translate>ExtrasEndpointForm.CLOSE</button> | ||
</div> | ||
</form> |
8 changes: 8 additions & 0 deletions
8
projects/aas-portal/src/app/start/extras-endpoint-form/extras-endpoint-form.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2024 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
98 changes: 98 additions & 0 deletions
98
projects/aas-portal/src/app/start/extras-endpoint-form/extras-endpoint-form.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2024 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
||
import { Component, Signal, signal, computed } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { NgbActiveModal, NgbCollapse, NgbToast } from '@ng-bootstrap/ng-bootstrap'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { AASEndpointScheduleType, convertToString } from 'aas-core'; | ||
import { ExtrasEndpointService } from './extras-endpoint.service'; | ||
import { toSignal } from '@angular/core/rxjs-interop'; | ||
import { from, map, mergeMap, toArray } from 'rxjs'; | ||
|
||
export type ExtrasEndpointItem = { | ||
name: string; | ||
url: string; | ||
count: number; | ||
schedule: AASEndpointScheduleType; | ||
}; | ||
|
||
@Component({ | ||
selector: 'fhg-extras-endpoint', | ||
standalone: true, | ||
imports: [FormsModule, NgbToast, NgbCollapse, TranslateModule], | ||
providers: [ExtrasEndpointService], | ||
templateUrl: './extras-endpoint-form.component.html', | ||
styleUrl: './extras-endpoint-form.component.scss', | ||
}) | ||
export class ExtrasEndpointFormComponent { | ||
private readonly _messages = signal<string[]>([]); | ||
private readonly _endpoints: Signal<ExtrasEndpointItem[]>; | ||
|
||
public constructor( | ||
private readonly modal: NgbActiveModal, | ||
private readonly translate: TranslateService, | ||
private readonly api: ExtrasEndpointService, | ||
) { | ||
this._endpoints = toSignal( | ||
api.getEndpoints().pipe( | ||
mergeMap(values => | ||
from(values).pipe( | ||
mergeMap(value => | ||
this.api.getDocumentCount(value.name).pipe( | ||
map( | ||
count => | ||
({ | ||
name: value.name, | ||
url: value.url, | ||
count, | ||
schedule: value.schedule?.type || 'every', | ||
}) as ExtrasEndpointItem, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
toArray(), | ||
), | ||
{ initialValue: [] as ExtrasEndpointItem[] }, | ||
); | ||
} | ||
|
||
public readonly messages = this._messages.asReadonly(); | ||
|
||
public readonly endpoints = computed(() => this._endpoints().map(item => item)); | ||
|
||
public readonly isCollapsed = signal(true); | ||
|
||
public submit(): void { | ||
this.modal.close(); | ||
} | ||
|
||
public reset(): void { | ||
this.api | ||
.reset() | ||
.pipe() | ||
.subscribe({ | ||
next: () => this.modal.close(), | ||
error: error => | ||
this._messages.update(state => [...state, convertToString(error, this.translate.currentLang)]), | ||
}); | ||
} | ||
|
||
public scan(endpointName: string): void { | ||
this.api | ||
.scan(endpointName) | ||
.pipe() | ||
.subscribe({ | ||
next: () => this.modal.close(), | ||
error: error => | ||
this._messages.update(state => [...state, convertToString(error, this.translate.currentLang)]), | ||
}); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
projects/aas-portal/src/app/start/extras-endpoint-form/extras-endpoint.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/****************************************************************************** | ||
* | ||
* Copyright (c) 2019-2024 Fraunhofer IOSB-INA Lemgo, | ||
* eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft | ||
* zur Foerderung der angewandten Forschung e.V. | ||
* | ||
*****************************************************************************/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { map, Observable } from 'rxjs'; | ||
import { AASEndpoint } from 'aas-core'; | ||
import { encodeBase64Url } from 'aas-lib'; | ||
|
||
@Injectable() | ||
export class ExtrasEndpointService { | ||
public constructor(private readonly http: HttpClient) {} | ||
|
||
/** | ||
* Returns all configured AAS endpoints. | ||
* @returns An array of `AASContainer`. | ||
**/ | ||
public getEndpoints(): Observable<AASEndpoint[]> { | ||
return this.http.get<AASEndpoint[]>('/api/v1/endpoints'); | ||
} | ||
|
||
/** | ||
* Restores the default AAS endpoint configuration. | ||
**/ | ||
public reset(): Observable<void> { | ||
return this.http.delete<void>('/api/v1/endpoints'); | ||
} | ||
|
||
/** | ||
* Gets the total amount of documents contained in the endpoint with the specified name. | ||
* @param endpointName The name of the endpoint. | ||
**/ | ||
public getDocumentCount(endpointName: string): Observable<number> { | ||
return this.http | ||
.get<{ count: number }>(`/api/v1/endpoints/${encodeBase64Url(endpointName)}/documents/count`) | ||
.pipe(map(value => value.count)); | ||
} | ||
|
||
/** | ||
* Starts an update of the endpoint index. | ||
* @param endpointName The name of the endpoint. | ||
**/ | ||
public scan(endpointName: string): Observable<void> { | ||
return this.http.put<void>(`/api/v1/endpoints/${encodeBase64Url(endpointName)}/scan`, null); | ||
} | ||
} |
Oops, something went wrong.