Merged in CST-12455_coar-7_sync (pull request #1024)

CST-12455 coar 7 sync

Approved-by: Stefano Maffei
This commit is contained in:
Mattia Vianelli
2023-11-17 09:08:18 +00:00
committed by Stefano Maffei
27 changed files with 1731 additions and 1393 deletions

View File

@@ -1,9 +1,9 @@
import { NgModule } from '@angular/core'; import {NgModule} from '@angular/core';
import { RouterModule } from '@angular/router'; import {RouterModule} from '@angular/router';
import { I18nBreadcrumbResolver } from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver'; import {I18nBreadcrumbResolver} from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver';
import { LdnServicesOverviewComponent } from './ldn-services-directory/ldn-services-directory.component'; import {LdnServicesOverviewComponent} from './ldn-services-directory/ldn-services-directory.component';
import { LdnServiceNewComponent } from './ldn-service-new/ldn-service-new.component'; import {LdnServiceNewComponent} from './ldn-service-new/ldn-service-new.component';
import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service-form-edit.component'; import {LdnServiceFormEditComponent} from './ldn-service-form-edit/ldn-service-form-edit.component';
@NgModule({ @NgModule({
imports: [ imports: [

View File

@@ -1,13 +1,13 @@
import { NgModule } from '@angular/core'; import {NgModule} from '@angular/core';
import { CommonModule } from '@angular/common'; import {CommonModule} from '@angular/common';
import { AdminLdnServicesRoutingModule } from './admin-ldn-services-routing.module'; import {AdminLdnServicesRoutingModule} from './admin-ldn-services-routing.module';
import { LdnServicesOverviewComponent } from './ldn-services-directory/ldn-services-directory.component'; import {LdnServicesOverviewComponent} from './ldn-services-directory/ldn-services-directory.component';
import { SharedModule } from '../../shared/shared.module'; import {SharedModule} from '../../shared/shared.module';
import { LdnServiceNewComponent } from './ldn-service-new/ldn-service-new.component'; import {LdnServiceNewComponent} from './ldn-service-new/ldn-service-new.component';
import { LdnServiceFormComponent } from './ldn-service-form/ldn-service-form.component'; import {LdnServiceFormComponent} from './ldn-service-form/ldn-service-form.component';
import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service-form-edit.component'; import {LdnServiceFormEditComponent} from './ldn-service-form-edit/ldn-service-form-edit.component';
import { FormsModule } from '@angular/forms'; import {FormsModule} from '@angular/forms';
import { LdnItemfiltersService } from './ldn-services-data/ldn-itemfilters-data.service'; import {LdnItemfiltersService} from './ldn-services-data/ldn-itemfilters-data.service';
@NgModule({ @NgModule({

View File

@@ -13,11 +13,13 @@
</div> </div>
</div> </div>
</div> </div>
<!-- In the Name section -->
<div class="mb-5"> <div class="mb-5">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label> <label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched" <input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" [placeholder]="'ldn-new-service.form.placeholder.name' | translate" class="form-control"
formControlName="name"
id="name"
name="name" name="name"
type="text"> type="text">
<div *ngIf="formModel.get('name').invalid && formModel.get('name').touched" class="error-text"> <div *ngIf="formModel.get('name').invalid && formModel.get('name').touched" class="error-text">
@@ -29,14 +31,16 @@
<div class="mb-5 mt-5 d-flex flex-column"> <div class="mb-5 mt-5 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label> <label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate" <textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea> class="form-control" formControlName="description" id="description" name="description"></textarea>
</div> </div>
<!-- In the url section --> <!-- In the url section -->
<div class="mb-5 mt-5"> <div class="mb-5 mt-5">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label> <label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched" <input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" [placeholder]="'ldn-new-service.form.placeholder.url' | translate" class="form-control"
formControlName="url"
id="url"
name="url" name="url"
type="text"> type="text">
<div *ngIf="formModel.get('url').invalid && formModel.get('url').touched" class="error-text"> <div *ngIf="formModel.get('url').invalid && formModel.get('url').touched" class="error-text">
@@ -44,12 +48,12 @@
</div> </div>
</div> </div>
<!-- In the ldnUrl section --> <!-- In the ldnUrl section -->
<div class="mb-5 mt-5"> <div class="mb-5 mt-5">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label> <label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" <input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl" [placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" class="form-control"
formControlName="ldnUrl"
id="ldnUrl" id="ldnUrl"
name="ldnUrl" name="ldnUrl"
type="text"> type="text">
@@ -71,21 +75,24 @@
</div> </div>
</div> </div>
<!-- In the Inbound Patterns Labels section -->
<div class="row mb-1 mt-5"> <div class="row mb-1 mt-5">
<div class="col"> <div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label> <label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div> </div>
<ng-container *ngIf="!!(formModel.get('notifyServiceInboundPatterns')['controls'][0]?.value?.pattern)">
<div class="col"> <div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label> <label>{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div> </div>
<div class="col-sm1 "> <div class="col-sm-1">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label> <label class="">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div> </div>
</ng-container>
<div class="col-sm-2"> <div class="col-sm-2">
</div> </div>
</div> </div>
<!-- In the Inbound Patterns section -->
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index" <div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
[class.marked-for-deletion]="markedForDeletionInboundPattern.includes(i)" [class.marked-for-deletion]="markedForDeletionInboundPattern.includes(i)"
formGroupName="notifyServiceInboundPatterns"> formGroupName="notifyServiceInboundPatterns">
@@ -95,25 +102,80 @@
<div class="row mb-1"> <div class="row mb-1">
<div class="col"> <div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}" <div #inboundPatternDropdown="ngbDropdown" class="w-80" display="dynamic"
name="additionalInboundPattern{{i}}" required> id="additionalInboundPattern{{i}}"
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option> ngbDropdown placement="bottom-start">
<option *ngFor="let pattern of inboundPatterns" <div class="position-relative right-addon" role="combobox">
[value]="pattern">{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }} </option> <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
</select> ngbDropdownToggle></i>
<input
(click)="inboundPatternDropdown.open();"
[readonly]="true"
class="form-control w-80 scrollable-dropdown-input"
formControlName="patternLabel"
id="inboundPatternDropdownButton"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="inboundPatternDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectInboundPattern(pattern, i); $event.stopPropagation()"
*ngFor="let pattern of inboundPatterns; let internalIndex = index"
[title]="'ldn-service.form.pattern.' + pattern + '.description' | translate"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</div>
<div
class="small-text">{{ 'ldn-service.form.pattern.' + pattern + '.description' | translate }}</div>
</button>
</div>
</div>
</div>
</div>
</div> </div>
<div class="col"> <div class="col">
<ng-container *ngIf="inboundPattern.value"> <ng-container
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}"> *ngIf="!!(formModel.get('notifyServiceInboundPatterns')['controls'][i].value.pattern)">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option> <div #inboundItemfilterDropdown="ngbDropdown" class="w-100" id="constraint{{i}}" ngbDropdown
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page" placement="bottom-start">
[value]="itemFilter.id">{{ itemFilter.id }}</option> <div class="position-relative right-addon" role="combobox">
</select> <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
ngbDropdownToggle></i>
<input
(click)="inboundItemfilterDropdown.open();"
[readonly]="true"
[value]="selectedInboundItemfilters"
class="form-control w-100 scrollable-dropdown-input"
formControlName="constraint"
id="inboundItemfilterDropdown"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="inboundItemfilterDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectInboundItemFilter(constraint.id, i); $event.stopPropagation()"
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ constraint.id }}</div>
</button>
</div>
</div>
</div>
</div>
</ng-container> </ng-container>
</div> </div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm1"> <div
[style.visibility]="formModel.get('notifyServiceInboundPatterns')['controls'][i].value.pattern ? 'visible' : 'hidden'"
class="col-sm-1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}" <input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}"
type="checkbox"> type="checkbox">
<div (click)="toggleAutomatic(i)" <div (click)="toggleAutomatic(i)"
@@ -130,8 +192,11 @@
type="button"> type="button">
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
</button> </button>
<button (click)="unmarkForInboundPatternDeletion(i)" *ngIf="markedForDeletionInboundPattern.includes(i)"
class="btn btn-warning"
<button (click)="unmarkForInboundPatternDeletion(i)"
*ngIf="markedForDeletionInboundPattern.includes(i)"
class="btn btn-warning "
type="button"> type="button">
<i class="fas fa-undo"></i> <i class="fas fa-undo"></i>
</button> </button>
@@ -145,51 +210,107 @@
<span (click)="addInboundPattern()" <span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span> class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<!-- In the Outbound Patterns Labels section -->
<div class="row mb-1 mt-5"> <div class="row mb-1 mt-5">
<div class="col"> <div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }} </label> <label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }} </label>
</div> </div>
<ng-container *ngIf="!!(formModel.get('notifyServiceOutboundPatterns')['controls'][0]?.value?.pattern)">
<div class="col"> <div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label> <label>{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div> </div>
<div class="col-sm1 "> </ng-container>
<div class="col-sm-1 ">
<label class="label-box-2" style="visibility: hidden;"> <label class="label-box-2" style="visibility: hidden;">
{{ 'ldn-new-service.form.label.automatic' | translate }} {{ 'ldn-new-service.form.label.automatic' | translate }}
</label> </label>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2 ">
</div> </div>
</div> </div>
<!-- In the Outbound Patterns section -->
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index" <div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
[class.marked-for-deletion]="markedForDeletionOutboundPattern.includes(i)" [class.marked-for-deletion]="markedForDeletionOutboundPattern.includes(i)"
formGroupName="notifyServiceOutboundPatterns"> formGroupName="notifyServiceOutboundPatterns">
<ng-container [formGroupName]="i"> <ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1"> <div class="row mb-1">
<div class="col"> <div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}" <div #outboundPatternDropdown="ngbDropdown" class="w-100" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}" ngbDropdown
required> placement="bottom-start">
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option> <div class="position-relative right-addon" role="combobox">
<option *ngFor="let pattern of outboundPatterns" <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
[value]="pattern">{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }} </option> ngbDropdownToggle></i>
</select> <input
(click)="outboundPatternDropdown.open();"
[readonly]="true"
[value]="selectedOutboundPatterns"
class="form-control w-100 scrollable-dropdown-input"
formControlName="patternLabel"
id="outboundPatternDropdownButton"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="outboundPatternDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectOutboundPattern(pattern, i); $event.stopPropagation()"
*ngFor="let pattern of outboundPatterns; let internalIndex = index"
[title]="'ldn-service.form.pattern.' + pattern + '.description' | translate"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</div>
<div
class="small-text">{{ 'ldn-service.form.pattern.' + pattern + '.description' | translate }}</div>
</button>
</div>
</div>
</div>
</div>
</div> </div>
<div class="col"> <div class="col">
<ng-container *ngIf="outboundPattern.value"> <ng-container
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}"> *ngIf="!!(formModel.get('notifyServiceOutboundPatterns')['controls'][i].value.pattern)">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option> <div #outboundItemfilterDropdown="ngbDropdown" class="w-100" id="constraint{{i}}"
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page" ngbDropdown
[value]="itemFilter.id">{{ itemFilter.id }}</option> placement="bottom-start">
</select> <div class="position-relative right-addon" role="combobox">
<i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
ngbDropdownToggle></i>
<input
(click)="outboundItemfilterDropdown.open();"
[readonly]="true"
[value]="selectedOutboundItemfilters"
class="form-control w-100 scrollable-dropdown-input"
formControlName="constraint"
id="outboundItemfilterDropdown"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="outboundItemfilterDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectOutboundItemFilter(constraint.id, i); $event.stopPropagation()"
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ constraint.id }}</div>
</button>
</div>
</div>
</div>
</div>
</ng-container> </ng-container>
</div> </div>
<div [style.visibility]="'hidden'" class="col-sm1"> <div [style.visibility]="'hidden'" class="col-sm-1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox"> <input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div <div
class="toggle-switch"> class="toggle-switch">
@@ -199,12 +320,13 @@
<div class="col-sm-2"> <div class="col-sm-2">
<div class="btn-group"> <div class="btn-group">
<button (click)="markForOutboundPatternDeletion(i)" class="btn btn-outline-dark trash-button" <button (click)="markForOutboundPatternDeletion(i)"
type="button"> class="btn btn-outline-dark trash-button" type="button">
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
</button> </button>
<button (click)="unmarkForOutboundPatternDeletion(i)" *ngIf="markedForDeletionOutboundPattern.includes(i)" <button (click)="unmarkForOutboundPatternDeletion(i)"
class="btn btn-warning" *ngIf="markedForDeletionOutboundPattern.includes(i)"
class="btn btn-warning "
type="button"> type="button">
<i class="fas fa-undo"></i> <i class="fas fa-undo"></i>
</button> </button>
@@ -218,12 +340,14 @@
(click)="addOutboundPattern()" (click)="addOutboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }} class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}
</span> </span>
<div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group"> <div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group">
<button class="btn btn-primary" type="submit"> <button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span> <span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button> </button>
<div class="d-flex"> <div class="d-flex">
<button (click)="this.openResetFormModal(this.resetFormModal)" class="btn btn-danger" type="button"> <button (click)="openResetFormModal(resetFormModal)" class="btn btn-danger" type="button">
<span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span> <span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span>
</button> </button>
</div> </div>
@@ -252,7 +376,7 @@
<button (click)="closeModal()" class="btn btn-danger mr-2" <button (click)="closeModal()" class="btn btn-danger mr-2"
id="delete-confirm">{{ 'service.detail.return' | translate }} id="delete-confirm">{{ 'service.detail.return' | translate }}
</button> </button>
<button (click)="this.patchService()" <button (click)="patchService()"
class="btn btn-primary custom-btn">{{ 'service.detail.update' | translate }} class="btn btn-primary custom-btn">{{ 'service.detail.update' | translate }}
</button> </button>
</div> </div>

View File

@@ -1,3 +1,6 @@
@import '../../../shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.scss';
@import '../../../shared/form/form.component.scss';
form { form {
font-size: 14px; font-size: 14px;
position: relative; position: relative;
@@ -28,7 +31,6 @@ textarea {
.add-pattern-link { .add-pattern-link {
color: #0048ff; color: #0048ff;
cursor: pointer; cursor: pointer;
margin-left: 10px;
} }
.remove-pattern-link { .remove-pattern-link {
@@ -99,6 +101,11 @@ textarea {
margin-top: 10px; margin-top: 10px;
} }
.small-text {
font-size: 0.7em;
color: #888;
}
.toggle-switch { .toggle-switch {
cursor: pointer; cursor: pointer;
margin-top: 3px; margin-top: 3px;

View File

@@ -1,21 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import { LdnServiceFormEditComponent } from './ldn-service-form-edit.component'; import {NgbDropdownModule, NgbModal} from '@ng-bootstrap/ng-bootstrap';
import { ChangeDetectorRef, EventEmitter } from '@angular/core'; import {LdnServiceFormEditComponent} from './ldn-service-form-edit.component';
import { ReactiveFormsModule, FormBuilder } from '@angular/forms'; import {ChangeDetectorRef, EventEmitter} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import {FormBuilder, ReactiveFormsModule} from '@angular/forms';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {ActivatedRoute, Router} from '@angular/router';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import {TranslateModule, TranslateService} from '@ngx-translate/core';
import { PaginationService } from 'ngx-pagination'; import {PaginationService} from 'ngx-pagination';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
import { RouterStub } from '../../../shared/testing/router.stub'; import {RouterStub} from '../../../shared/testing/router.stub';
import { MockActivatedRoute } from '../../../shared/mocks/active-router.mock'; import {MockActivatedRoute} from '../../../shared/mocks/active-router.mock';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub'; import {NotificationsServiceStub} from '../../../shared/testing/notifications-service.stub';
import { of } from 'rxjs'; import {of} from 'rxjs';
import { RouteService } from '../../../core/services/route.service'; import {RouteService} from '../../../core/services/route.service';
import { provideMockStore } from '@ngrx/store/testing'; import {provideMockStore} from '@ngrx/store/testing';
describe('LdnServiceFormEditComponent', () => { describe('LdnServiceFormEditComponent', () => {
let component: LdnServiceFormEditComponent; let component: LdnServiceFormEditComponent;
@@ -49,21 +49,21 @@ describe('LdnServiceFormEditComponent', () => {
}; };
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [ReactiveFormsModule, TranslateModule.forRoot()], imports: [ReactiveFormsModule, TranslateModule.forRoot(), NgbDropdownModule],
declarations: [LdnServiceFormEditComponent], declarations: [LdnServiceFormEditComponent],
providers: [ providers: [
{ provide: LdnServicesService, useValue: ldnServicesService }, {provide: LdnServicesService, useValue: ldnServicesService},
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService }, {provide: LdnItemfiltersService, useValue: ldnItemfiltersService},
{ provide: Router, useValue: new RouterStub() }, {provide: Router, useValue: new RouterStub()},
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() }, {provide: ActivatedRoute, useValue: new MockActivatedRoute()},
{ provide: ChangeDetectorRef, useValue: cdRefStub }, {provide: ChangeDetectorRef, useValue: cdRefStub},
{ provide: NgbModal, useValue: modalService }, {provide: NgbModal, useValue: modalService},
{ provide: NotificationsService, useValue: NotificationsServiceStub }, {provide: NotificationsService, useValue: NotificationsServiceStub},
{ provide: TranslateService, useValue: translateServiceStub }, {provide: TranslateService, useValue: translateServiceStub},
{ provide: PaginationService, useValue: {} }, {provide: PaginationService, useValue: {}},
FormBuilder, FormBuilder,
RouteService, RouteService,
provideMockStore({ }), provideMockStore({}),
] ]
}) })
.compileComponents(); .compileComponents();

View File

@@ -1,24 +1,25 @@
import { ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild } from '@angular/core'; import {ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild} from '@angular/core';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms'; import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
import { LDN_SERVICE } from '../ldn-services-model/ldn-service.resource-type'; import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
import { ActivatedRoute, Router } from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
import { notifyPatterns } from '../ldn-services-patterns/ldn-service-coar-patterns'; import {notifyPatterns} from '../ldn-services-patterns/ldn-service-coar-patterns';
import { animate, state, style, transition, trigger } from '@angular/animations'; import {animate, state, style, transition, trigger} from '@angular/animations';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import { LdnService } from '../ldn-services-model/ldn-services.model'; import {LdnService} from '../ldn-services-model/ldn-services.model';
import { RemoteData } from 'src/app/core/data/remote-data'; import {RemoteData} from 'src/app/core/data/remote-data';
import { Operation } from 'fast-json-patch'; import {Operation} from 'fast-json-patch';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import {getFirstCompletedRemoteData} from '../../../core/shared/operators';
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters'; import {Itemfilter} from '../ldn-services-model/ldn-service-itemfilters';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
import { Observable } from 'rxjs'; import {Observable} from 'rxjs';
import { PaginationService } from '../../../core/pagination/pagination.service'; import {PaginationService} from '../../../core/pagination/pagination.service';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import {FindListOptions} from '../../../core/data/find-list-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import {PaginationComponentOptions} from '../../../shared/pagination/pagination-component-options.model';
import {NotifyServicePattern} from "../ldn-services-model/ldn-service-patterns.model";
@Component({ @Component({
selector: 'ds-ldn-service-form-edit', selector: 'ds-ldn-service-form-edit',
@@ -37,8 +38,8 @@ export class LdnServiceFormEditComponent implements OnInit {
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>; @ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>; @ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns; public inboundPatterns: string[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns; public outboundPatterns: string[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>; itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), { config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20 elementsPerPage: 20
@@ -59,9 +60,11 @@ export class LdnServiceFormEditComponent implements OnInit {
@Input() public headerKey: string; @Input() public headerKey: string;
markedForDeletionInboundPattern: number[] = []; markedForDeletionInboundPattern: number[] = [];
markedForDeletionOutboundPattern: number[] = []; markedForDeletionOutboundPattern: number[] = [];
selectedOutboundPatterns: string[];
selectedInboundItemfilters: string[];
selectedOutboundItemfilters: string[];
selectedInboundPatterns: string[];
protected serviceId: string; protected serviceId: string;
private originalInboundPatterns: any[] = [];
private originalOutboundPatterns: any[] = [];
private deletedInboundPatterns: number[] = []; private deletedInboundPatterns: number[] = [];
private deletedOutboundPatterns: number[] = []; private deletedOutboundPatterns: number[] = [];
private modalRef: any; private modalRef: any;
@@ -86,8 +89,7 @@ export class LdnServiceFormEditComponent implements OnInit {
description: ['', Validators.required], description: ['', Validators.required],
url: ['', Validators.required], url: ['', Validators.required],
ldnUrl: ['', Validators.required], ldnUrl: ['', Validators.required],
score: ['', [Validators.required, Validators.pattern('^0*(\.[0-9]+)?$|^1(\.0+)?$')]], score: ['', [Validators.required, Validators.pattern('^0*(\.[0-9]+)?$|^1(\.0+)?$')]], inboundPattern: [''],
inboundPattern: [''],
outboundPattern: [''], outboundPattern: [''],
constraintPattern: [''], constraintPattern: [''],
enabled: [''], enabled: [''],
@@ -126,39 +128,47 @@ export class LdnServiceFormEditComponent implements OnInit {
name: this.service.name, name: this.service.name,
description: this.service.description, description: this.service.description,
url: this.service.url, url: this.service.url,
score: this.service.score, score: this.service.score, ldnUrl: this.service.ldnUrl,
ldnUrl: this.service.ldnUrl,
type: this.service.type, type: this.service.type,
enabled: this.service.enabled enabled: this.service.enabled
}); });
this.filterPatternObjectsAndPickLabel('notifyServiceInboundPatterns', false)
const inboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray; this.filterPatternObjectsAndPickLabel('notifyServiceOutboundPatterns', true)
inboundPatternsArray.clear();
this.service.notifyServiceInboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeInboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
inboundPatternsArray.push(patternFormGroup);
this.cdRef.detectChanges();
});
const outboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
outboundPatternsArray.clear();
this.service.notifyServiceOutboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeOutboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
outboundPatternsArray.push(patternFormGroup);
this.cdRef.detectChanges();
});
this.originalInboundPatterns = [...this.service.notifyServiceInboundPatterns];
this.originalOutboundPatterns = [...this.service.notifyServiceOutboundPatterns];
} }
}, },
); );
} }
filterPatternObjectsAndPickLabel(formArrayName: string, isOutbound: boolean) {
const PatternsArray = this.formModel.get(formArrayName) as FormArray;
PatternsArray.clear();
let servicesToUse;
if (isOutbound) {
servicesToUse = this.service.notifyServiceOutboundPatterns
} else {
servicesToUse = this.service.notifyServiceInboundPatterns
}
servicesToUse.forEach((patternObj: NotifyServicePattern) => {
let patternFormGroup;
if (isOutbound) {
patternFormGroup = this.initializeOutboundPatternFormGroup();
} else {
patternFormGroup = this.initializeInboundPatternFormGroup();
}
const newPatternObjWithLabel = Object.assign(new NotifyServicePattern(), {
...patternObj,
patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternObj?.pattern + '.label')
})
patternFormGroup.patchValue(newPatternObjWithLabel);
PatternsArray.push(patternFormGroup);
this.cdRef.detectChanges();
})
}
generatePatchOperations(): any[] { generatePatchOperations(): any[] {
const patchOperations: any[] = []; const patchOperations: any[] = [];
@@ -168,10 +178,10 @@ export class LdnServiceFormEditComponent implements OnInit {
this.createReplaceOperation(patchOperations, 'url', '/url'); this.createReplaceOperation(patchOperations, 'url', '/url');
this.createReplaceOperation(patchOperations, 'score', '/score'); this.createReplaceOperation(patchOperations, 'score', '/score');
this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns'); this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns');
this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns'); this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns');
this.deletedInboundPatterns.forEach(index => { this.deletedInboundPatterns.forEach(index => {
const removeOperation: Operation = { const removeOperation: Operation = {
op: 'remove', op: 'remove',
@@ -206,6 +216,29 @@ export class LdnServiceFormEditComponent implements OnInit {
} }
selectOutboundPattern(patternValue: string, index: number): void {
const patternArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray)
patternArray.controls[index].patchValue({pattern: patternValue})
patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')})
}
selectOutboundItemFilter(filterValue: string, index: number) {
const filterArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray)
filterArray.controls[index].patchValue({constraint: filterValue})
}
selectInboundPattern(patternValue: string, index: number): void {
const patternArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray)
patternArray.controls[index].patchValue({pattern: patternValue})
patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')})
}
selectInboundItemFilter(filterValue: string, index: number): void {
const filterArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray)
filterArray.controls[index].patchValue({constraint: filterValue})
}
toggleAutomatic(i: number) { toggleAutomatic(i: number) {
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`); const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
if (automaticControl) { if (automaticControl) {
@@ -250,12 +283,14 @@ export class LdnServiceFormEditComponent implements OnInit {
patchService() { patchService() {
this.deleteMarkedInboundPatterns(); this.deleteMarkedInboundPatterns();
this.deleteMarkedOutboundPatterns(); this.deleteMarkedOutboundPatterns();
const patchOperations = this.generatePatchOperations(); const patchOperations = this.generatePatchOperations();
this.ldnServicesService.patch(this.service, patchOperations).pipe( this.ldnServicesService.patch(this.service, patchOperations).pipe(
getFirstCompletedRemoteData() getFirstCompletedRemoteData()
).subscribe((rd: RemoteData<LdnService>) => { ).subscribe(
(rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) { if (rd.hasSucceeded) {
this.closeModal(); this.closeModal();
this.sendBack(); this.sendBack();
@@ -340,6 +375,7 @@ export class LdnServiceFormEditComponent implements OnInit {
this.markedForDeletionOutboundPattern = []; this.markedForDeletionOutboundPattern = [];
} }
private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void { private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
if (this.formModel.get(formControlName).dirty) { if (this.formModel.get(formControlName).dirty) {
patchOperations.push({ patchOperations.push({
@@ -351,13 +387,15 @@ export class LdnServiceFormEditComponent implements OnInit {
} }
private handlePatterns(patchOperations: any[], formArrayName: string): void { private handlePatterns(patchOperations: any[], formArrayName: string): void {
const patternsArray = this.formModel.get(formArrayName) as FormArray; const patternsArray = this.formModel.get(formArrayName) as FormArray
for (let i = 0; i < patternsArray.length; i++) { for (let i = 0; i < patternsArray.length; i++) {
const patternGroup = patternsArray.at(i) as FormGroup; const patternGroup = patternsArray.at(i) as FormGroup;
const patternValue = patternGroup.value;
if (patternGroup.dirty) { const patternValue = patternGroup.value;
if (patternGroup.touched) {
delete patternValue?.patternLabel;
if (patternValue.isNew) { if (patternValue.isNew) {
delete patternValue.isNew; delete patternValue.isNew;
const addOperation = { const addOperation = {
@@ -385,6 +423,7 @@ export class LdnServiceFormEditComponent implements OnInit {
private createOutboundPatternFormGroup(): FormGroup { private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: '', pattern: '',
patternLabel: 'Select a pattern',
constraint: '', constraint: '',
isNew: true, isNew: true,
}); });
@@ -393,6 +432,7 @@ export class LdnServiceFormEditComponent implements OnInit {
private createInboundPatternFormGroup(): FormGroup { private createInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: '', pattern: '',
patternLabel: 'Select a pattern',
constraint: '', constraint: '',
automatic: false, automatic: false,
isNew: true isNew: true
@@ -402,6 +442,7 @@ export class LdnServiceFormEditComponent implements OnInit {
private initializeOutboundPatternFormGroup(): FormGroup { private initializeOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: '', pattern: '',
patternLabel: '',
constraint: '', constraint: '',
}); });
} }
@@ -409,6 +450,7 @@ export class LdnServiceFormEditComponent implements OnInit {
private initializeInboundPatternFormGroup(): FormGroup { private initializeInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: '', pattern: '',
patternLabel: '',
constraint: '', constraint: '',
automatic: '', automatic: '',
}); });

View File

@@ -4,10 +4,12 @@
<h2 class="flex-grow-1">{{ 'ldn-create-service.title' | translate }}</h2> <h2 class="flex-grow-1">{{ 'ldn-create-service.title' | translate }}</h2>
</div> </div>
<!-- In the name section --> <!-- In the name section -->
<div class="mb-5"> <div class="mb-5 ">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label> <label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched" <input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" [placeholder]="'ldn-new-service.form.placeholder.name' | translate" class="form-control"
formControlName="name"
id="name"
name="name" name="name"
type="text"> type="text">
<div *ngIf="formModel.get('name').invalid && formModel.get('name').touched" class="error-text"> <div *ngIf="formModel.get('name').invalid && formModel.get('name').touched" class="error-text">
@@ -15,12 +17,11 @@
</div> </div>
</div> </div>
<!-- In the description section --> <!-- In the description section -->
<div class="mb-5 mt-5 d-flex flex-column"> <div class="mb-5 mt-5 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label> <label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate" <textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea> class="form-control" formControlName="description" id="description" name="description"></textarea>
</div> </div>
@@ -28,7 +29,9 @@
<div class="mb-5 mt-5"> <div class="mb-5 mt-5">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label> <label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched" <input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" [placeholder]="'ldn-new-service.form.placeholder.url' | translate" class="form-control"
formControlName="url"
id="url"
name="url" name="url"
type="text"> type="text">
<div *ngIf="formModel.get('url').invalid && formModel.get('url').touched" class="error-text"> <div *ngIf="formModel.get('url').invalid && formModel.get('url').touched" class="error-text">
@@ -41,7 +44,8 @@
<div class="mb-5 mt-5"> <div class="mb-5 mt-5">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label> <label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" <input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl" [placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" class="form-control"
formControlName="ldnUrl"
id="ldnUrl" id="ldnUrl"
name="ldnUrl" name="ldnUrl"
type="text"> type="text">
@@ -62,21 +66,24 @@
</div> </div>
</div> </div>
<!-- In the Inbound Patterns section --> <!-- In the Inbound Patterns Labels section -->
<div class="row mb-2 mt-5"> <div class="row mb-2 mt-5">
<div class="col"> <div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label> <label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div> </div>
<ng-container *ngIf="!!(formModel.get('notifyServiceInboundPatterns')['controls'][0]?.value?.pattern)">
<div class="col"> <div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label> <label>{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div> </div>
<div class="col-sm1 "> <div class="col-sm-1">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label> <label class="">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div> </div>
</ng-container>
<div class="col-sm-2"> <div class="col-sm-2">
</div> </div>
</div> </div>
<!-- In the Inbound Patterns section -->
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index" <div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceInboundPatterns"> formGroupName="notifyServiceInboundPatterns">
@@ -85,29 +92,83 @@
<div class="row mb-1"> <div class="row mb-1">
<div class="col"> <div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}" <div #inboundPatternDropdown="ngbDropdown" class="w-100" id="additionalInboundPattern{{i}}" ngbDropdown
name="additionalInboundPattern{{i}}" required> placement="bottom-start">
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option> <div class="position-relative right-addon" role="combobox">
<option *ngFor="let pattern of inboundPatterns" <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
[value]="pattern">{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }} </option> ngbDropdownToggle>
</select>
<div *ngIf="!patternSelected()" class="error-text"> </i>
{{ 'ldn-new-service.form.error.patterns' | translate }} <input
(click)="inboundPatternDropdown.open();"
[readonly]="true"
[value]="selectedInboundPatterns"
class="form-control w-100 scrollable-dropdown-input"
formControlName="patternLabel"
id="inboundPatternDropdownButton"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="inboundPatternDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectInboundPattern(pattern, i); $event.stopPropagation()"
*ngFor="let pattern of inboundPatterns"
[title]="'ldn-service.form.pattern.' + pattern + '.description' | translate"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</div>
<div
class="small-text">{{ 'ldn-service.form.pattern.' + pattern + '.description' | translate }}</div>
</button>
</div>
</div>
</div>
</div> </div>
</div> </div>
<div class="col"> <div class="col">
<ng-container *ngIf="inboundPattern.value"> <ng-container
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}"> *ngIf="!!(formModel.get('notifyServiceInboundPatterns')['controls'][i].value.pattern)">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option> <div #inboundItemfilterDropdown="ngbDropdown" class="w-100" id="constraint{{i}}" ngbDropdown
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page" placement="bottom-start">
[value]="itemFilter.id">{{ itemFilter.id }}</option> <div class="position-relative right-addon" role="combobox">
</select> <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
ngbDropdownToggle></i>
<input
(click)="inboundItemfilterDropdown.open();"
[readonly]="true"
[value]="selectedInboundItemfilters"
class="form-control w-100 scrollable-dropdown-input"
formControlName="constraint"
id="inboundItemfilterDropdown"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="inboundItemfilterDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectInboundItemFilter(constraint.id, i); $event.stopPropagation() "
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ constraint.id }}</div>
</button>
</div>
</div>
</div>
</div>
</ng-container> </ng-container>
</div> </div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm-1"> <div
[style.visibility]="formModel.get('notifyServiceInboundPatterns')['controls'][i]?.value?.pattern ? 'visible' : 'hidden'"
class="col-sm-1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}" <input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}"
type="checkbox"> type="checkbox">
<div (click)="toggleAutomatic(i)" <div (click)="toggleAutomatic(i)"
@@ -122,6 +183,7 @@
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
</button> </button>
</div> </div>
</div> </div>
</ng-container> </ng-container>
</div> </div>
@@ -129,54 +191,110 @@
<span (click)="addInboundPattern()" <span (click)="addInboundPattern()"
class="add-pattern-link mb-4">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span> class="add-pattern-link mb-4">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<!-- In the Outbound Patterns section -->
<!-- In the Outbound Patterns Labels section -->
<div class="row mb-1 mt-5"> <div class="row mb-1 mt-5">
<div class="col"> <div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }} </label> <label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }}</label>
</div> </div>
<ng-container *ngIf="!!(formModel.get('notifyServiceOutboundPatterns')['controls'][0]?.value?.pattern)">
<div class="col"> <div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label> <label class="">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div> </div>
</ng-container>
<div class="col-sm1 "> <div class="col-sm1 ">
<label class="label-box-2" style="visibility: hidden;"> <label class="label-box-2" style="visibility: hidden;">
{{ 'ldn-new-service.form.label.automatic' | translate }} {{ 'ldn-new-service.form.label.automatic' | translate }}
</label> </label>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2 ">
</div> </div>
</div> </div>
<!-- In the Outbound Patterns section -->
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index" <div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceOutboundPatterns"> formGroupName="notifyServiceOutboundPatterns">
<ng-container [formGroupName]="i"> <ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1"> <div class="row mb-1">
<div class="col"> <div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}" <div #outboundPatternDropdown="ngbDropdown" class="w-100" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}" ngbDropdown
required> placement="bottom-start">
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option> <div class="position-relative right-addon" role="combobox">
<option *ngFor="let pattern of outboundPatterns" <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
[value]="pattern">{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</option> ngbDropdownToggle></i>
</select> <input
<div *ngIf="!patternSelected()" class="error-text"> (click)="outboundPatternDropdown.open();"
{{ 'ldn-new-service.form.error.patterns' | translate }} [readonly]="true"
[value]="selectedOutboundPatterns"
class="form-control w-100 scrollable-dropdown-input"
formControlName="patternLabel"
id="outboundPatternDropdownButton"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="outboundPatternDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectOutboundPattern(pattern, i); $event.stopPropagation()"
*ngFor="let pattern of outboundPatterns"
[title]="'ldn-service.form.pattern.' + pattern + '.description' | translate"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</div>
<div
class="small-text">{{ 'ldn-service.form.pattern.' + pattern + '.description' | translate }}</div>
</button>
</div> </div>
</div> </div>
</div>
</div>
</div>
<div class="col"> <div class="col">
<ng-container *ngIf="outboundPattern.value"> <ng-container
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}"> *ngIf="!!(formModel.get('notifyServiceOutboundPatterns')['controls'][i].value.pattern)">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option> <div #outboundItemfilterDropdown="ngbDropdown" class="w-100" id="constraint{{i}}"
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page" ngbDropdown
[value]="itemFilter.id">{{ itemFilter.id }}</option> placement="bottom-start">
</select> <div class="position-relative right-addon" role="combobox">
<i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle"
ngbDropdownToggle></i>
<input
(click)="outboundItemfilterDropdown.open();"
[readonly]="true"
[value]="selectedOutboundItemfilters"
class="form-control w-100 scrollable-dropdown-input"
formControlName="constraint"
id="outboundItemfilterDropdown"
ngbDropdownAnchor
type="text"
/>
<div aria-labelledby="outboundItemfilterDropdownButton"
class="dropdown-menu scrollable-dropdown-menu w-100 "
ngbDropdownMenu>
<div class="scrollable-menu" role="listbox">
<button (click)="selectOutboundItemFilter(constraint.id, i); $event.stopPropagation()"
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
class="dropdown-item collection-item text-truncate w-100"
ngbDropdownItem
type="button">
<div>{{ constraint.id }}</div>
</button>
</div>
</div>
</div>
</div>
</ng-container> </ng-container>
</div> </div>
<div [style.visibility]="'hidden'" class="col-sm1"> <div [style.visibility]="'hidden'" class="col-sm-1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox"> <input hidden id="automatic{{i}}" name="automatic{{i}}"
type="checkbox">
<div <div
class="toggle-switch"> class="toggle-switch">
<div class="slider"></div> <div class="slider"></div>
@@ -196,6 +314,9 @@
<span (click)="addOutboundPattern()" <span (click)="addOutboundPattern()"
class="add-pattern-link mb-4">{{ 'ldn-new-service.form.label.addPattern' | translate }} class="add-pattern-link mb-4">{{ 'ldn-new-service.form.label.addPattern' | translate }}
</span> </span>
<div class="mb-4">
&nbsp;
</div>
<div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group"> <div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group">
<button class="btn btn-primary" type="submit"> <button class="btn btn-primary" type="submit">
@@ -207,6 +328,8 @@
</button> </button>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<ng-template #confirmModal> <ng-template #confirmModal>

View File

@@ -1,8 +1,15 @@
@import '../../../shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.scss';
@import '../../../shared/form/form.component.scss';
form { form {
font-size: 14px; font-size: 14px;
position: relative; position: relative;
} }
label {
font-weight: bold;
}
input[type="text"], input[type="text"],
select { select {
max-width: 100%; max-width: 100%;
@@ -28,7 +35,6 @@ textarea {
.add-pattern-link { .add-pattern-link {
color: #0048ff; color: #0048ff;
cursor: pointer; cursor: pointer;
margin-left: 10px;
} }
.remove-pattern-link { .remove-pattern-link {
@@ -37,6 +43,11 @@ textarea {
margin-left: 10px; margin-left: 10px;
} }
.small-text {
font-size: 0.7em;
color: #888;
}
.status-checkbox { .status-checkbox {
margin-top: 5px; margin-top: 5px;
} }
@@ -103,18 +114,6 @@ textarea {
cursor: pointer; cursor: pointer;
} }
.label-box {
margin-left: 11px;
}
.label-box-2 {
margin-left: 14px;
}
.label-box-3 {
margin-left: 5px;
}
form button.btn.btn-primary[type="submit"] { form button.btn.btn-primary[type="submit"] {
position: absolute; position: absolute;
bottom: 0; bottom: 0;

View File

@@ -1,20 +1,20 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import { LdnServiceFormComponent } from './ldn-service-form.component'; import {LdnServiceFormComponent} from './ldn-service-form.component';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import {FormBuilder, ReactiveFormsModule} from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing'; import {RouterTestingModule} from '@angular/router/testing';
import { NgbModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; import {NgbDropdownModule, NgbModal, NgbModalModule} from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import {TranslateModule, TranslateService} from '@ngx-translate/core';
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
import { NotificationsService } from 'src/app/shared/notifications/notifications.service'; import {NotificationsService} from 'src/app/shared/notifications/notifications.service';
import { Router } from '@angular/router'; import {Router} from '@angular/router';
import { RouterStub } from 'src/app/shared/testing/router.stub'; import {RouterStub} from 'src/app/shared/testing/router.stub';
import { createPaginatedList } from 'src/app/shared/testing/utils.test'; import {createPaginatedList} from 'src/app/shared/testing/utils.test';
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters'; import {Itemfilter} from '../ldn-services-model/ldn-service-itemfilters';
import { createSuccessfulRemoteDataObject$ } from 'src/app/shared/remote-data.utils'; import {createSuccessfulRemoteDataObject$} from 'src/app/shared/remote-data.utils';
import { of } from 'rxjs'; import {of} from 'rxjs';
import { EventEmitter } from '@angular/core'; import {EventEmitter} from '@angular/core';
describe('LdnServiceFormComponent', () => { describe('LdnServiceFormComponent', () => {
let component: LdnServiceFormComponent; let component: LdnServiceFormComponent;
@@ -51,15 +51,21 @@ describe('LdnServiceFormComponent', () => {
ReactiveFormsModule, ReactiveFormsModule,
RouterTestingModule, RouterTestingModule,
NgbModalModule, NgbModalModule,
TranslateModule.forRoot() TranslateModule.forRoot(),
NgbDropdownModule
], ],
providers: [ providers: [
{ provide: LdnItemfiltersService, useValue: ldnItemfiltersService }, {provide: LdnItemfiltersService, useValue: ldnItemfiltersService},
{ provide: LdnServicesService, useValue: ldnServicesService }, {provide: LdnServicesService, useValue: ldnServicesService},
{ provide: NotificationsService, useValue: notificationsService }, {provide: NotificationsService, useValue: notificationsService},
{ provide: TranslateService, useValue: translateServiceStub }, {provide: TranslateService, useValue: translateServiceStub},
{ provide: Router, useValue: new RouterStub() }, {provide: Router, useValue: new RouterStub()},
{ provide: NgbModal, useValue: { open: () => {/*comment*/ } } }, {
provide: NgbModal, useValue: {
open: () => {/*comment*/
}
}
},
FormBuilder FormBuilder
], ],
declarations: [LdnServiceFormComponent] declarations: [LdnServiceFormComponent]

View File

@@ -1,32 +1,23 @@
import { import {ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, TemplateRef, ViewChild} from '@angular/core';
ChangeDetectorRef, import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
Component, import {Router} from '@angular/router';
EventEmitter,
Input,
OnInit,
Output,
TemplateRef,
ViewChild
} from '@angular/core';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
import { notifyPatterns } from '../ldn-services-patterns/ldn-service-coar-patterns'; import {notifyPatterns} from '../ldn-services-patterns/ldn-service-coar-patterns';
import { LDN_SERVICE } from '../ldn-services-model/ldn-service.resource-type'; import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
import { animate, state, style, transition, trigger } from '@angular/animations'; import {animate, state, style, transition, trigger} from '@angular/animations';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import {getFirstCompletedRemoteData} from '../../../core/shared/operators';
import { RemoteData } from '../../../core/data/remote-data'; import {RemoteData} from '../../../core/data/remote-data';
import { LdnService } from '../ldn-services-model/ldn-services.model'; import {LdnService} from '../ldn-services-model/ldn-services.model';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters'; import {Itemfilter} from '../ldn-services-model/ldn-service-itemfilters';
import { Observable } from 'rxjs'; import {Observable} from 'rxjs';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import {FindListOptions} from '../../../core/data/find-list-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import {PaginationComponentOptions} from '../../../shared/pagination/pagination-component-options.model';
import { LdnItemfiltersService } from '../ldn-services-data/ldn-itemfilters-data.service'; import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
@Component({ @Component({
@@ -45,8 +36,8 @@ export class LdnServiceFormComponent implements OnInit {
formModel: FormGroup; formModel: FormGroup;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>; @ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>; @ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns; public inboundPatterns: string[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns; public outboundPatterns: string[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>; itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), { config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20 elementsPerPage: 20
@@ -67,10 +58,14 @@ export class LdnServiceFormComponent implements OnInit {
@Input() public headerKey: string; @Input() public headerKey: string;
@Output() submitForm: EventEmitter<any> = new EventEmitter(); @Output() submitForm: EventEmitter<any> = new EventEmitter();
@Output() cancelForm: EventEmitter<any> = new EventEmitter(); @Output() cancelForm: EventEmitter<any> = new EventEmitter();
private modalRef: any; selectedOutboundPatterns: string[];
selectedInboundPatterns: string[];
selectedInboundItemfilters: string[];
selectedOutboundItemfilters: string[];
hasInboundPattern: boolean; hasInboundPattern: boolean;
hasOutboundPattern: boolean; hasOutboundPattern: boolean;
isScoreValid: boolean; isScoreValid: boolean;
private modalRef: any;
constructor( constructor(
private ldnServicesService: LdnServicesService, private ldnServicesService: LdnServicesService,
@@ -143,8 +138,21 @@ export class LdnServiceFormComponent implements OnInit {
return; return;
} }
this.formModel.value.notifyServiceInboundPatterns = this.formModel.value.notifyServiceInboundPatterns.filter((pattern: { pattern: string; }) => pattern.pattern !== ''); this.formModel.value.notifyServiceInboundPatterns = this.formModel.value.notifyServiceInboundPatterns.map((pattern: {
this.formModel.value.notifyServiceOutboundPatterns = this.formModel.value.notifyServiceOutboundPatterns.filter((pattern: { pattern: string; }) => pattern.pattern !== ''); pattern: string;
patternLabel: string
}) => {
const {patternLabel, ...rest} = pattern;
return rest;
});
this.formModel.value.notifyServiceOutboundPatterns = this.formModel.value.notifyServiceOutboundPatterns.map((pattern: {
pattern: string;
patternLabel: string
}) => {
const {patternLabel, ...rest} = pattern;
return rest;
});
const values = this.formModel.value; const values = this.formModel.value;
@@ -156,6 +164,7 @@ export class LdnServiceFormComponent implements OnInit {
if (rd.hasSucceeded) { if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get('ldn-service-notification.created.success.title'), this.notificationsService.success(this.translateService.get('ldn-service-notification.created.success.title'),
this.translateService.get('ldn-service-notification.created.success.body')); this.translateService.get('ldn-service-notification.created.success.body'));
this.sendBack(); this.sendBack();
this.closeModal(); this.closeModal();
} else { } else {
@@ -214,20 +223,29 @@ export class LdnServiceFormComponent implements OnInit {
} }
} }
patternSelected(): boolean {
for (let pattern of this.formModel.get('notifyServiceInboundPatterns').value) { selectOutboundPattern(patternValue: string, index: number): void {
if (pattern.pattern !== '') { const patternArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray)
return true; patternArray.controls[index].patchValue({pattern: patternValue})
} patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')})
} }
for (let pattern of this.formModel.get('notifyServiceOutboundPatterns').value) { selectInboundPattern(patternValue: string, index: number): void {
if (pattern.pattern !== '') { const patternArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray)
return true; patternArray.controls[index].patchValue({pattern: patternValue})
} patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')})
} }
return false; selectInboundItemFilter(filterValue: string, index: number): void {
const filterArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray)
filterArray.controls[index].patchValue({constraint: filterValue})
}
selectOutboundItemFilter(filterValue: string, index: number) {
const filterArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray)
filterArray.controls[index].patchValue({constraint: filterValue})
} }
private sendBack() { private sendBack() {
@@ -239,6 +257,7 @@ export class LdnServiceFormComponent implements OnInit {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: [''], pattern: [''],
constraint: [''], constraint: [''],
patternLabel: 'Select a Pattern',
}); });
} }
@@ -246,7 +265,8 @@ export class LdnServiceFormComponent implements OnInit {
return this.formBuilder.group({ return this.formBuilder.group({
pattern: [''], pattern: [''],
constraint: [''], constraint: [''],
automatic: false automatic: false,
patternLabel: 'Select a Pattern',
}); });
} }

View File

@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import { LdnServiceNewComponent } from './ldn-service-new.component'; import {LdnServiceNewComponent} from './ldn-service-new.component';
describe('LdnServiceNewComponent', () => { describe('LdnServiceNewComponent', () => {
let component: LdnServiceNewComponent; let component: LdnServiceNewComponent;

View File

@@ -1,4 +1,4 @@
import { Component } from '@angular/core'; import {Component} from '@angular/core';
@Component({ @Component({
selector: 'ds-ldn-service-new', selector: 'ds-ldn-service-new',

View File

@@ -1,8 +1,8 @@
import { LdnService } from '../ldn-services-model/ldn-services.model'; import {LdnService} from '../ldn-services-model/ldn-services.model';
import { LDN_SERVICE } from '../ldn-services-model/ldn-service.resource-type'; import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
import { RemoteData } from '../../../core/data/remote-data'; import {RemoteData} from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
import { Observable, of } from 'rxjs'; import {Observable, of} from 'rxjs';
// Create a mock data object for a single LDN notify service // Create a mock data object for a single LDN notify service
export const mockLdnService: LdnService = { export const mockLdnService: LdnService = {
id: 1, id: 1,

View File

@@ -1,20 +1,20 @@
import { Injectable } from '@angular/core'; import {Injectable} from '@angular/core';
import { dataService } from '../../../core/data/base/data-service.decorator'; import {dataService} from '../../../core/data/base/data-service.decorator';
import { LDN_SERVICE_CONSTRAINT_FILTERS } from '../ldn-services-model/ldn-service.resource-type'; import {LDN_SERVICE_CONSTRAINT_FILTERS} from '../ldn-services-model/ldn-service.resource-type';
import { IdentifiableDataService } from '../../../core/data/base/identifiable-data.service'; import {IdentifiableDataService} from '../../../core/data/base/identifiable-data.service';
import { FindAllData, FindAllDataImpl } from '../../../core/data/base/find-all-data'; import {FindAllData, FindAllDataImpl} from '../../../core/data/base/find-all-data';
import { RequestService } from '../../../core/data/request.service'; import {RequestService} from '../../../core/data/request.service';
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service'; import {RemoteDataBuildService} from '../../../core/cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../core/cache/object-cache.service'; import {ObjectCacheService} from '../../../core/cache/object-cache.service';
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service'; import {HALEndpointService} from '../../../core/shared/hal-endpoint.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import {FindListOptions} from '../../../core/data/find-list-options.model';
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model'; import {FollowLinkConfig} from '../../../shared/utils/follow-link-config.model';
import { Observable } from 'rxjs'; import {Observable} from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import {RemoteData} from '../../../core/data/remote-data';
import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters'; import {Itemfilter} from '../ldn-services-model/ldn-service-itemfilters';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
/** /**

View File

@@ -1,38 +1,38 @@
import { Injectable } from '@angular/core'; import {Injectable} from '@angular/core';
import { dataService } from '../../../core/data/base/data-service.decorator'; import {dataService} from '../../../core/data/base/data-service.decorator';
import { LDN_SERVICE } from '../ldn-services-model/ldn-service.resource-type'; import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
import { IdentifiableDataService } from '../../../core/data/base/identifiable-data.service'; import {IdentifiableDataService} from '../../../core/data/base/identifiable-data.service';
import { FindAllData, FindAllDataImpl } from '../../../core/data/base/find-all-data'; import {FindAllData, FindAllDataImpl} from '../../../core/data/base/find-all-data';
import { DeleteData, DeleteDataImpl } from '../../../core/data/base/delete-data'; import {DeleteData, DeleteDataImpl} from '../../../core/data/base/delete-data';
import { RequestService } from '../../../core/data/request.service'; import {RequestService} from '../../../core/data/request.service';
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service'; import {RemoteDataBuildService} from '../../../core/cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../core/cache/object-cache.service'; import {ObjectCacheService} from '../../../core/cache/object-cache.service';
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service'; import {HALEndpointService} from '../../../core/shared/hal-endpoint.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import {FindListOptions} from '../../../core/data/find-list-options.model';
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model'; import {FollowLinkConfig} from '../../../shared/utils/follow-link-config.model';
import { Observable } from 'rxjs'; import {Observable} from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import {RemoteData} from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
import { NoContent } from '../../../core/shared/NoContent.model'; import {NoContent} from '../../../core/shared/NoContent.model';
import { map, take } from 'rxjs/operators'; import {map, take} from 'rxjs/operators';
import { URLCombiner } from '../../../core/url-combiner/url-combiner'; import {URLCombiner} from '../../../core/url-combiner/url-combiner';
import { MultipartPostRequest } from '../../../core/data/request.models'; import {MultipartPostRequest} from '../../../core/data/request.models';
import { RestRequest } from '../../../core/data/rest-request.model'; import {RestRequest} from '../../../core/data/rest-request.model';
import { LdnService } from '../ldn-services-model/ldn-services.model'; import {LdnService} from '../ldn-services-model/ldn-services.model';
import { PatchData, PatchDataImpl } from '../../../core/data/base/patch-data'; import {PatchData, PatchDataImpl} from '../../../core/data/base/patch-data';
import { ChangeAnalyzer } from '../../../core/data/change-analyzer'; import {ChangeAnalyzer} from '../../../core/data/change-analyzer';
import { Operation } from 'fast-json-patch'; import {Operation} from 'fast-json-patch';
import { RestRequestMethod } from '../../../core/data/rest-request-method'; import {RestRequestMethod} from '../../../core/data/rest-request-method';
import { CreateData, CreateDataImpl } from '../../../core/data/base/create-data'; import {CreateData, CreateDataImpl} from '../../../core/data/base/create-data';
import { LdnServiceConstrain } from '../ldn-services-model/ldn-service.constrain.model'; import {LdnServiceConstrain} from '../ldn-services-model/ldn-service.constrain.model';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import {getFirstCompletedRemoteData} from '../../../core/shared/operators';
import { hasValue } from '../../../shared/empty.util'; import {hasValue} from '../../../shared/empty.util';
import { SearchDataImpl } from '../../../core/data/base/search-data'; import {SearchDataImpl} from '../../../core/data/base/search-data';
import { RequestParam } from '../../../core/cache/models/request-param.model'; import {RequestParam} from '../../../core/cache/models/request-param.model';
/** /**
* A service responsible for fetching/sending data from/to the REST API on the ldnservices endpoint * A service responsible for fetching/sending data from/to the REST API on the ldnservices endpoint
@@ -92,7 +92,7 @@ export class LdnServicesService extends IdentifiableDataService<LdnService> impl
findByInboundPattern(pattern: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<LdnService>[]): Observable<RemoteData<PaginatedList<LdnService>>> { findByInboundPattern(pattern: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<LdnService>[]): Observable<RemoteData<PaginatedList<LdnService>>> {
const params = [new RequestParam('pattern', pattern)]; const params = [new RequestParam('pattern', pattern)];
const findListOptions = Object.assign(new FindListOptions(), options, { searchParams: params }); const findListOptions = Object.assign(new FindListOptions(), options, {searchParams: params});
return this.searchData.searchBy(this.findByPatternEndpoint, findListOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); return this.searchData.searchBy(this.findByPatternEndpoint, findListOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
} }

View File

@@ -28,7 +28,8 @@
<td>{{ ldnService.description }}</td> <td>{{ ldnService.description }}</td>
<td> <td>
<span (click)="toggleStatus(ldnService, ldnServicesService)" <span (click)="toggleStatus(ldnService, ldnServicesService)"
[ngClass]="{ 'status-enabled': ldnService.enabled, 'status-disabled': !ldnService.enabled }" [title]="ldnService.enabled ? ('ldn-service.overview.table.clickToDisable' | translate) : ('ldn-service.overview.table.clickToEnable' | translate)" [ngClass]="{ 'status-enabled': ldnService.enabled, 'status-disabled': !ldnService.enabled }"
[title]="ldnService.enabled ? ('ldn-service.overview.table.clickToDisable' | translate) : ('ldn-service.overview.table.clickToEnable' | translate)"
class="status-indicator"> class="status-indicator">
{{ ldnService.enabled ? ('ldn-service.overview.table.enabled' | translate) : ('ldn-service.overview.table.disabled' | translate) }} {{ ldnService.enabled ? ('ldn-service.overview.table.enabled' | translate) : ('ldn-service.overview.table.disabled' | translate) }}
</span> </span>

View File

@@ -1,14 +1,14 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import {ComponentFixture, TestBed} from '@angular/core/testing';
import { LdnServicesOverviewComponent } from './ldn-services-directory.component'; import {LdnServicesOverviewComponent} from './ldn-services-directory.component';
import { ChangeDetectorRef, EventEmitter } from '@angular/core'; import {ChangeDetectorRef, EventEmitter} from '@angular/core';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub'; import {NotificationsServiceStub} from '../../../shared/testing/notifications-service.stub';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import {TranslateModule, TranslateService} from '@ngx-translate/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import { LdnServicesService } from '../ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
import { PaginationService } from '../../../core/pagination/pagination.service'; import {PaginationService} from '../../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; import {PaginationServiceStub} from '../../../shared/testing/pagination-service.stub';
import { of } from 'rxjs'; import {of} from 'rxjs';
describe('LdnServicesOverviewComponent', () => { describe('LdnServicesOverviewComponent', () => {
let component: LdnServicesOverviewComponent; let component: LdnServicesOverviewComponent;
@@ -26,17 +26,17 @@ describe('LdnServicesOverviewComponent', () => {
imports: [TranslateModule.forRoot()], imports: [TranslateModule.forRoot()],
declarations: [LdnServicesOverviewComponent], declarations: [LdnServicesOverviewComponent],
providers: [ providers: [
{ provide: LdnServicesService, useValue: {} }, {provide: LdnServicesService, useValue: {}},
{ provide: PaginationService, useValue: new PaginationServiceStub() }, {provide: PaginationService, useValue: new PaginationServiceStub()},
{ {
provide: NgbModal, useValue: { provide: NgbModal, useValue: {
open: () => {/*comment*/ open: () => {/*comment*/
} }
} }
}, },
{ provide: ChangeDetectorRef, useValue: {} }, {provide: ChangeDetectorRef, useValue: {}},
{ provide: NotificationsService, useValue: NotificationsServiceStub }, {provide: NotificationsService, useValue: NotificationsServiceStub},
{ provide: TranslateService, useValue: translateServiceStub }, {provide: TranslateService, useValue: translateServiceStub},
] ]
}) })
.compileComponents(); .compileComponents();

View File

@@ -7,21 +7,21 @@ import {
TemplateRef, TemplateRef,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { Observable, Subscription } from 'rxjs'; import {Observable, Subscription} from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import {RemoteData} from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model'; import {PaginatedList} from '../../../core/data/paginated-list.model';
import { FindListOptions } from '../../../core/data/find-list-options.model'; import {FindListOptions} from '../../../core/data/find-list-options.model';
import { LdnService } from '../ldn-services-model/ldn-services.model'; import {LdnService} from '../ldn-services-model/ldn-services.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model'; import {PaginationComponentOptions} from '../../../shared/pagination/pagination-component-options.model';
import { map, switchMap } from 'rxjs/operators'; import {map, switchMap} from 'rxjs/operators';
import { LdnServicesService } from 'src/app/admin/admin-ldn-services/ldn-services-data/ldn-services-data.service'; import {LdnServicesService} from 'src/app/admin/admin-ldn-services/ldn-services-data/ldn-services-data.service';
import { PaginationService } from 'src/app/core/pagination/pagination.service'; import {PaginationService} from 'src/app/core/pagination/pagination.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import { hasValue } from '../../../shared/empty.util'; import {hasValue} from '../../../shared/empty.util';
import { Operation } from 'fast-json-patch'; import {Operation} from 'fast-json-patch';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import {getFirstCompletedRemoteData} from '../../../core/shared/operators';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import {NotificationsService} from '../../../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core'; import {TranslateService} from '@ngx-translate/core';
@Component({ @Component({
@@ -66,6 +66,7 @@ export class LdnServicesOverviewComponent implements OnInit, OnDestroy {
switchMap((config) => this.ldnServicesService.findAll(config, false, false).pipe( switchMap((config) => this.ldnServicesService.findAll(config, false, false).pipe(
getFirstCompletedRemoteData() getFirstCompletedRemoteData()
)) ))
); );
} }

View File

@@ -1,9 +1,9 @@
import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import {autoserialize, deserialize, inheritSerialization} from 'cerialize';
import { LDN_SERVICE_CONSTRAINT_FILTER } from './ldn-service.resource-type'; import {LDN_SERVICE_CONSTRAINT_FILTER} from './ldn-service.resource-type';
import { CacheableObject } from '../../../core/cache/cacheable-object.model'; import {CacheableObject} from '../../../core/cache/cacheable-object.model';
import { typedObject } from '../../../core/cache/builders/build-decorators'; import {typedObject} from '../../../core/cache/builders/build-decorators';
import { excludeFromEquals } from '../../../core/utilities/equals.decorators'; import {excludeFromEquals} from '../../../core/utilities/equals.decorators';
import { ResourceType } from '../../../core/shared/resource-type'; import {ResourceType} from '../../../core/shared/resource-type';
/** A single filter value and its properties. */ /** A single filter value and its properties. */
@typedObject @typedObject

View File

@@ -1,4 +1,4 @@
import { autoserialize } from 'cerialize'; import {autoserialize} from 'cerialize';
/** /**
* notify service patterns * notify service patterns

View File

@@ -4,7 +4,7 @@
* Needs to be in a separate file to prevent circular * Needs to be in a separate file to prevent circular
* dependencies in webpack. * dependencies in webpack.
*/ */
import { ResourceType } from '../../../core/shared/resource-type'; import {ResourceType} from '../../../core/shared/resource-type';
export const LDN_SERVICE = new ResourceType('ldnservice'); export const LDN_SERVICE = new ResourceType('ldnservice');
export const LDN_SERVICE_CONSTRAINT_FILTERS = new ResourceType('itemfilters'); export const LDN_SERVICE_CONSTRAINT_FILTERS = new ResourceType('itemfilters');

View File

@@ -1,10 +1,10 @@
import { ResourceType } from '../../../core/shared/resource-type'; import {ResourceType} from '../../../core/shared/resource-type';
import { CacheableObject } from '../../../core/cache/cacheable-object.model'; import {CacheableObject} from '../../../core/cache/cacheable-object.model';
import { autoserialize, deserialize, deserializeAs, inheritSerialization } from 'cerialize'; import {autoserialize, deserialize, deserializeAs, inheritSerialization} from 'cerialize';
import { LDN_SERVICE } from './ldn-service.resource-type'; import {LDN_SERVICE} from './ldn-service.resource-type';
import { excludeFromEquals } from '../../../core/utilities/equals.decorators'; import {excludeFromEquals} from '../../../core/utilities/equals.decorators';
import { typedObject } from '../../../core/cache/builders/build-decorators'; import {typedObject} from '../../../core/cache/builders/build-decorators';
import { NotifyServicePattern } from './ldn-service-patterns.model'; import {NotifyServicePattern} from './ldn-service-patterns.model';
/** An LdnService and its properties. */ /** An LdnService and its properties. */

View File

@@ -1,69 +1,31 @@
export const notifyPatterns = [ export const notifyPatterns = [
{
name: 'Acknowledge and Accept', 'ack-accept',
description: 'This pattern is used to acknowledge and accept a request (offer). It implies an intention to act on the request.',
category: 'Acknowledgements' 'ack-reject',
},
{ 'ack-tentative-accept',
name: 'Acknowledge and Reject',
description: 'This pattern is used to acknowledge and reject a request (offer). It signifies no further action regarding the request.', 'ack-tentative-reject',
category: 'Acknowledgements'
}, 'announce-endorsement',
{
name: 'Acknowledge and Tentatively Accept', 'announce-ingest',
description: 'This pattern is used to acknowledge and tentatively accept a request (offer). It implies an intention to act, which may change.',
category: 'Acknowledgements' 'announce-relationship',
},
{ 'announce-review',
name: 'Acknowledge and Tentatively Reject',
description: 'This pattern is used to acknowledge and tentatively reject a request (offer). It signifies no further action, subject to change.', 'announce-service-result',
category: 'Acknowledgements'
}, 'request-endorsement',
{
name: 'Announce Endorsement', 'request-ingest',
description: 'This pattern is used to announce the existence of an endorsement, referencing the endorsed resource.',
category: 'Announcements' 'request-review',
},
{ 'undo-offer',
name: 'Announce Ingest',
description: 'This pattern is used to announce that a resource has been ingested.',
category: 'Announcements'
},
{
name: 'Announce Relationship',
description: 'This pattern is used to announce a relationship between two resources.',
category: 'Announcements'
},
{
name: 'Announce Review',
description: 'This pattern is used to announce the existence of a review, referencing the reviewed resource.',
category: 'Announcements'
},
{
name: 'Announce Service Result',
description: 'This pattern is used to announce the existence of a "service result", referencing the relevant resource.',
category: 'Announcements'
},
{
name: 'Request Endorsement',
description: 'This pattern is used to request endorsement of a resource owned by the origin system.',
category: 'Requests'
},
{
name: 'Request Ingest',
description: 'This pattern is used to request that the target system ingest a resource.',
category: 'Requests'
},
{
name: 'Request Review',
description: 'This pattern is used to request a review of a resource owned by the origin system.',
category: 'Requests'
},
{
name: 'Undo Offer',
description: 'This pattern is used to undo (retract) an offer previously made.',
category: 'Undo'
}
]; ];

View File

@@ -938,6 +938,59 @@
"ldn-new-service.form.placeholder.score": "Please enter a value between 0 and 1. Use the “.” as decimal separator", "ldn-new-service.form.placeholder.score": "Please enter a value between 0 and 1. Use the “.” as decimal separator",
"ldn-new-service.form.label.inboundPattern": "Inbound Patterns", "ldn-new-service.form.label.inboundPattern": "Inbound Patterns",
"ldn-new-service.form.label.placeholder.inboundPattern": "Select an Inbound Pattern", "ldn-new-service.form.label.placeholder.inboundPattern": "Select an Inbound Pattern",
"ldn-service.form.pattern.ack-accept.label": "Acknowledge and Accept",
"ldn-service.form.pattern.ack-accept.description": "This pattern is used to acknowledge and accept a request (offer). It implies an intention to act on the request.",
"ldn-service.form.pattern.ack-accept.category": "Acknowledgements",
"ldn-service.form.pattern.ack-reject.label": "Acknowledge and Reject",
"ldn-service.form.pattern.ack-reject.description": "This pattern is used to acknowledge and reject a request (offer). It signifies no further action regarding the request.",
"ldn-service.form.pattern.ack-reject.category": "Acknowledgements",
"ldn-service.form.pattern.ack-tentative-accept.label": "Acknowledge and Tentatively Accept",
"ldn-service.form.pattern.ack-tentative-accept.description": "This pattern is used to acknowledge and tentatively accept a request (offer). It implies an intention to act, which may change.",
"ldn-service.form.pattern.ack-tentative-accept.category": "Acknowledgements",
"ldn-service.form.pattern.ack-tentative-reject.label": "Acknowledge and Tentatively Reject",
"ldn-service.form.pattern.ack-tentative-reject.description": "This pattern is used to acknowledge and tentatively reject a request (offer). It signifies no further action, subject to change.",
"ldn-service.form.pattern.ack-tentative-reject.category": "Acknowledgements",
"ldn-service.form.pattern.announce-endorsement.label": "Announce Endorsement",
"ldn-service.form.pattern.announce-endorsement.description": "This pattern is used to announce the existence of an endorsement, referencing the endorsed resource.",
"ldn-service.form.pattern.announce-endorsement.category": "Announcements",
"ldn-service.form.pattern.announce-ingest.label": "Announce Ingest",
"ldn-service.form.pattern.announce-ingest.description": "This pattern is used to announce that a resource has been ingested.",
"ldn-service.form.pattern.announce-ingest.category": "Announcements",
"ldn-service.form.pattern.announce-relationship.label": "Announce Relationship",
"ldn-service.form.pattern.announce-relationship.description": "This pattern is used to announce a relationship between two resources.",
"ldn-service.form.pattern.announce-relationship.category": "Announcements",
"ldn-service.form.pattern.announce-review.label": "Announce Review",
"ldn-service.form.pattern.announce-review.description": "This pattern is used to announce the existence of a review, referencing the reviewed resource.",
"ldn-service.form.pattern.announce-review.category": "Announcements",
"ldn-service.form.pattern.announce-service-result.label": "Announce Service Result",
"ldn-service.form.pattern.announce-service-result.description": "This pattern is used to announce the existence of a 'service result', referencing the relevant resource.",
"ldn-service.form.pattern.announce-service-result.category": "Announcements",
"ldn-service.form.pattern.request-endorsement.label": "Request Endorsement",
"ldn-service.form.pattern.request-endorsement.description": "This pattern is used to request endorsement of a resource owned by the origin system.",
"ldn-service.form.pattern.request-endorsement.category": "Requests",
"ldn-service.form.pattern.request-ingest.label": "Request Ingest",
"ldn-service.form.pattern.request-ingest.description": "This pattern is used to request that the target system ingest a resource.",
"ldn-service.form.pattern.request-ingest.category": "Requests",
"ldn-service.form.pattern.request-review.label": "Request Review",
"ldn-service.form.pattern.request-review.description": "This pattern is used to request a review of a resource owned by the origin system.",
"ldn-service.form.pattern.request-review.category": "Requests",
"ldn-service.form.pattern.undo-offer.label": "Undo Offer",
"ldn-service.form.pattern.undo-offer.description": "This pattern is used to undo (retract) an offer previously made.",
"ldn-service.form.pattern.undo-offer.category": "Undo",
"ldn-new-service.form.label.placeholder.selectedItemFilter": "No Item Filter Selected", "ldn-new-service.form.label.placeholder.selectedItemFilter": "No Item Filter Selected",
"ldn-new-service.form.label.ItemFilter": "Item Filter", "ldn-new-service.form.label.ItemFilter": "Item Filter",
"ldn-new-service.form.label.automatic": "Automatic", "ldn-new-service.form.label.automatic": "Automatic",