CST-12174 Updated delete services to mark for deletion

This commit is contained in:
Mattia Vianelli
2023-10-24 12:59:21 +02:00
parent 5cca15daec
commit 0963a32081
28 changed files with 1388 additions and 1397 deletions

View File

@@ -7,30 +7,30 @@ import { LdnServiceNewComponent } from './ldn-service-new/ldn-service-new.compon
import { LdnServiceFormEditComponent } from './ldn-service-form-edit/ldn-service-form-edit.component';
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LdnServicesOverviewComponent,
resolve: { breadcrumb: I18nBreadcrumbResolver },
data: { title: 'ldn-registered-services.title', breadcrumbKey: 'ldn-registered-services.new' },
canActivate: [LdnServicesGuard]
},
{
path: 'new',
resolve: { breadcrumb: I18nBreadcrumbResolver },
component: LdnServiceNewComponent,
data: { title: 'ldn-register-new-service.title', breadcrumbKey: 'ldn-register-new-service' }
},
{
path: 'edit/:serviceId',
resolve: { breadcrumb: I18nBreadcrumbResolver },
component: LdnServiceFormEditComponent,
data: { title: 'ldn-edit-service.title', breadcrumbKey: 'ldn-edit-service' }
},
]),
]
imports: [
RouterModule.forChild([
{
path: '',
pathMatch: 'full',
component: LdnServicesOverviewComponent,
resolve: {breadcrumb: I18nBreadcrumbResolver},
data: {title: 'ldn-registered-services.title', breadcrumbKey: 'ldn-registered-services.new'},
canActivate: [LdnServicesGuard]
},
{
path: 'new',
resolve: {breadcrumb: I18nBreadcrumbResolver},
component: LdnServiceNewComponent,
data: {title: 'ldn-register-new-service.title', breadcrumbKey: 'ldn-register-new-service'}
},
{
path: 'edit/:serviceId',
resolve: {breadcrumb: I18nBreadcrumbResolver},
component: LdnServiceFormEditComponent,
data: {title: 'ldn-edit-service.title', breadcrumbKey: 'ldn-edit-service'}
},
]),
]
})
export class AdminLdnServicesRoutingModule {

View File

@@ -10,20 +10,20 @@ import { FormsModule } from '@angular/forms';
import { LdnItemfiltersService } from './ldn-services-data/ldn-itemfilters-data.service';
@NgModule({
imports: [
CommonModule,
SharedModule,
AdminLdnServicesRoutingModule,
FormsModule
],
declarations: [
LdnServicesOverviewComponent,
LdnServiceNewComponent,
LdnServiceFormComponent,
LdnServiceFormEditComponent,
],
providers: [LdnItemfiltersService]
imports: [
CommonModule,
SharedModule,
AdminLdnServicesRoutingModule,
FormsModule
],
declarations: [
LdnServicesOverviewComponent,
LdnServiceNewComponent,
LdnServiceFormComponent,
LdnServiceFormEditComponent,
],
providers: [LdnItemfiltersService]
})
export class AdminLdnServicesModule { }
export class AdminLdnServicesModule {
}

View File

@@ -1,275 +1,277 @@
<div class="container">
<form (ngSubmit)="onSubmit()" [formGroup]="formModel">
<div class="d-flex">
<h2 class="flex-grow-1">{{ 'ldn-edit-registered-service.title' | translate }}</h2>
</div>
<!-- In the toggle section -->
<div class="toggle-switch-container">
<label class="status-label" for="enabled">{{ 'ldn-service-status' | translate }}</label>
<div>
<input formControlName="enabled" hidden id="enabled" name="enabled" type="checkbox">
<div (click)="toggleEnabled()" [class.checked]="formModel.get('enabled').value" class="toggle-switch">
<div class="slider"></div>
</div>
</div>
</div>
<div class="mb-2">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name"
name="name"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the description section -->
<div class="mb-2 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea>
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the url section -->
<div class="mb-2">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url"
name="url"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the ldnUrl section -->
<div class="mb-2">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl"
id="ldnUrl"
name="ldnUrl"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm1 ">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div>
<div class="col-sm-1">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceInboundPatterns">
<ng-container [formGroupName]="i">
<div [class.marked-for-deletion]="markedForDeletion.includes(i)" class="row mb-1">
<div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
name="additionalInboundPattern{{i}}" required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option>
<option *ngFor="let pattern of inboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
<form (ngSubmit)="onSubmit()" [formGroup]="formModel">
<div class="d-flex">
<h2 class="flex-grow-1">{{ 'ldn-edit-registered-service.title' | translate }}</h2>
</div>
<!-- In the toggle section -->
<div class="toggle-switch-container">
<label class="status-label" for="enabled">{{ 'ldn-service-status' | translate }}</label>
<div>
<input formControlName="enabled" hidden id="enabled" name="enabled" type="checkbox">
<div (click)="toggleEnabled()" [class.checked]="formModel.get('enabled').value" class="toggle-switch">
<div class="slider"></div>
</div>
</div>
</div>
<div class="col">
<ng-container *ngIf="inboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
<div class="mb-2">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name"
name="name"
type="text">
</div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div (click)="toggleAutomatic(i)"
[class.checked]="formModel.get('notifyServiceInboundPatterns.' + i + '.automatic').value"
class="toggle-switch">
<div class="slider"></div>
</div>
<div class="mb-4">
&nbsp;
</div>
<div class="col-sm-1 btn-group">
<button type="button" (click)="markForDeletion(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
<button *ngIf="markedForDeletion.includes(i)" type="button" (click)="unmarkForDeletion(i)" class="btn btn-outline-dark undo-button">
<i class="fas fa-undo"></i>
</button>
<!-- In the description section -->
<div class="mb-2 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea>
</div>
</div>
</ng-container>
</div>
<span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<div class="mb-4">
&nbsp;
</div>
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }}</label>
</div>
<div class="col">
<label class="label-box-3">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm-1 ">
<label class="label-box-2"></label>
</div>
<div class="col-sm-1 ">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceOutboundPatterns">
<ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1">
<div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}"
required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option>
<option *ngFor="let pattern of outboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
<div class="mb-4">
&nbsp;
</div>
<div class="col">
<ng-container *ngIf="outboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
<!-- In the url section -->
<div class="mb-2">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url"
name="url"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the ldnUrl section -->
<div class="mb-2">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl"
id="ldnUrl"
name="ldnUrl"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm1 ">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div>
<div class="col-sm-1">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceInboundPatterns">
<ng-container [formGroupName]="i">
<div [class.marked-for-deletion]="markedForDeletion.includes(i)" class="row mb-1">
<div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
name="additionalInboundPattern{{i}}" required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option>
<option *ngFor="let pattern of inboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
</div>
<div class="col">
<ng-container *ngIf="inboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
</div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}"
type="checkbox">
<div (click)="toggleAutomatic(i)"
[class.checked]="formModel.get('notifyServiceInboundPatterns.' + i + '.automatic').value"
class="toggle-switch">
<div class="slider"></div>
</div>
</div>
<div class="col-sm-1 btn-group">
<button (click)="markForDeletion(i)" class="btn btn-outline-dark trash-button" type="button">
<i class="fas fa-trash"></i>
</button>
<button (click)="unmarkForDeletion(i)" *ngIf="markedForDeletion.includes(i)" class="btn btn-outline-dark undo-button"
type="button">
<i class="fas fa-undo"></i>
</button>
</div>
</div>
</ng-container>
</div>
<div [style.visibility]="'hidden'" class="col-sm1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div
class="toggle-switch">
<div class="slider"></div>
</div>
<span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<div class="mb-4">
&nbsp;
</div>
<div class="col-sm-1">
<button type="button" (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }}</label>
</div>
<div class="col">
<label class="label-box-3">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm-1 ">
<label class="label-box-2"></label>
</div>
<div class="col-sm-1 ">
</div>
</div>
</div>
</ng-container>
</div>
<span
(click)="addOutboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceOutboundPatterns">
<ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1">
<div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}"
required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option>
<option *ngFor="let pattern of outboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
</div>
<div class="col">
<ng-container *ngIf="outboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
</div>
<div [style.visibility]="'hidden'" class="col-sm1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div
class="toggle-switch">
<div class="slider"></div>
</div>
</div>
<div class="col-sm-1">
<button (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button"
type="button">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
</ng-container>
</div>
<span
(click)="addOutboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}
</span>
<div class="mb-5">
&nbsp;
</div>
<div class="submission-form-footer mt-1 mb-1 position-sticky" role="group" aria-label="Basic example">
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>
<div class="d-flex">
<button type="button" class="btn btn-danger" (click)="this.openResetFormModal(this.resetFormModal)">
<span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span>
</button>
</div>
</div>
</form>
<div class="mb-5">
&nbsp;
</div>
<div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group">
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>
<div class="d-flex">
<button (click)="this.openResetFormModal(this.resetFormModal)" class="btn btn-danger" type="button">
<span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span>
</button>
</div>
</div>
</form>
</div>
<ng-template #confirmModal>
<div>
<div>
<div class="modal-header">
<div>
<h4>{{'service.overview.edit.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-header">
<div>
<h4>{{'service.overview.edit.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.overview.edit.body' | translate }}
</div>
<div class="mt-4">
<button (click)="closeModal()" class="btn btn-danger mr-2"
id="delete-confirm">{{ 'service.detail.return' | translate }}
</button>
<button (click)="this.patchService()"
class="btn btn-primary custom-btn">{{ 'service.detail.update' | translate }}
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.overview.edit.body' | translate }}
</div>
<div class="mt-4">
<button (click)="closeModal()" class="btn btn-danger mr-2"
id="delete-confirm">{{ 'service.detail.return' | translate }}
</button>
<button (click)="this.patchService()"
class="btn btn-primary custom-btn">{{ 'service.detail.update' | translate }}
</button>
</div>
</div>
</div>
</div>
</ng-template>
<ng-template #resetFormModal>
<div>
<div>
<div class="modal-header">
<div>
<h4>{{'service.overview.reset-form.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-header">
<div>
<h4>{{'service.overview.reset-form.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.overview.reset-form.body' | translate }}
</div>
<div class="mt-4">
<button (click)="resetFormAndLeave()"
class="btn btn-primary mr-2 custom-btn" id="reset-confirm">{{ 'service.overview.reset-form.reset-return' | translate }}</button>
<button (click)="closeModal()" class="btn btn-danger"
id="reset-delete">{{ 'service.overview.reset-form.reset-confirm' | translate }}
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.overview.reset-form.body' | translate }}
</div>
<div class="mt-4">
<button (click)="resetFormAndLeave()"
class="btn btn-primary mr-2 custom-btn"
id="reset-confirm">{{ 'service.overview.reset-form.reset-return' | translate }}</button>
<button (click)="closeModal()" class="btn btn-danger"
id="reset-delete">{{ 'service.overview.reset-form.reset-confirm' | translate }}
</button>
</div>
</div>
</div>
</div>
</ng-template>

View File

@@ -27,12 +27,13 @@ textarea {
resize: none;
}
.add-pattern-link{
.add-pattern-link {
color: #0048ff;
cursor: pointer;
margin-left: 10px;
}
.remove-pattern-link{
.remove-pattern-link {
color: #e34949;
cursor: pointer;
margin-left: 10px;
@@ -75,7 +76,6 @@ textarea {
}
.toggle-switch .slider {
width: 22px;
height: 22px;
@@ -101,16 +101,16 @@ textarea {
margin-right: 3px
}
.label-box{
margin-left:11px;
.label-box {
margin-left: 11px;
}
.label-box-2{
margin-left:14px;
.label-box-2 {
margin-left: 14px;
}
.label-box-3{
margin-left:5px;
.label-box-3 {
margin-left: 5px;
}
form button.btn.btn-primary[type="submit"] {

View File

@@ -3,21 +3,21 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LdnServiceFormEditComponent } from './ldn-service-form-edit.component';
describe('LdnServiceFormEditComponent', () => {
let component: LdnServiceFormEditComponent;
let fixture: ComponentFixture<LdnServiceFormEditComponent>;
let component: LdnServiceFormEditComponent;
let fixture: ComponentFixture<LdnServiceFormEditComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LdnServiceFormEditComponent ]
})
.compileComponents();
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LdnServiceFormEditComponent]
})
.compileComponents();
fixture = TestBed.createComponent(LdnServiceFormEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
fixture = TestBed.createComponent(LdnServiceFormEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -21,371 +21,365 @@ import { FindListOptions } from '../../../core/data/find-list-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
@Component({
selector: 'ds-ldn-service-form-edit',
templateUrl: './ldn-service-form-edit.component.html',
styleUrls: ['./ldn-service-form-edit.component.scss'],
animations: [
trigger('toggleAnimation', [
state('true', style({})),
state('false', style({})),
transition('true <=> false', animate('300ms ease-in')),
]),
],
selector: 'ds-ldn-service-form-edit',
templateUrl: './ldn-service-form-edit.component.html',
styleUrls: ['./ldn-service-form-edit.component.scss'],
animations: [
trigger('toggleAnimation', [
state('true', style({})),
state('false', style({})),
transition('true <=> false', animate('300ms ease-in')),
]),
],
})
export class LdnServiceFormEditComponent implements OnInit {
formModel: FormGroup;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
formModel: FormGroup;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
@Input() public name: string;
@Input() public description: string;
@Input() public url: string;
@Input() public ldnUrl: string;
@Input() public inboundPattern: string;
@Input() public outboundPattern: string;
@Input() public constraint: string;
@Input() public automatic: boolean;
@Input() public headerKey: string;
private originalInboundPatterns: any[] = [];
private originalOutboundPatterns: any[] = [];
private deletedInboundPatterns: number[] = [];
private deletedOutboundPatterns: number[] = [];
private modalRef: any;
private service: LdnService;
protected serviceId: string;
markedForDeletion: number[] = [];
constructor(
protected ldnServicesService: LdnServicesService,
private ldnItemfiltersService: LdnItemfiltersService,
private formBuilder: FormBuilder,
private router: Router,
private route: ActivatedRoute,
private cdRef: ChangeDetectorRef,
protected modalService: NgbModal,
private notificationService: NotificationsService,
private translateService: TranslateService,
protected paginationService: PaginationService
) {
this.formModel = this.formBuilder.group({
id: [''],
name: ['', Validators.required],
description: ['', Validators.required],
url: ['', Validators.required],
ldnUrl: ['', Validators.required],
inboundPattern: [''],
outboundPattern: [''],
constraintPattern: [''],
enabled: [''],
notifyServiceInboundPatterns: this.formBuilder.array([this.createInboundPatternFormGroup()]),
notifyServiceOutboundPatterns: this.formBuilder.array([this.createOutboundPatternFormGroup()]),
type: LDN_SERVICE.value,
public inboundPatterns: object[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
}
ngOnInit(): void {
this.route.params.subscribe((params) => {
this.serviceId = params.serviceId;
if (this.serviceId) {
this.fetchServiceData(this.serviceId);
}
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
this.setItemfilters();
}
@Input() public name: string;
@Input() public description: string;
@Input() public url: string;
@Input() public ldnUrl: string;
@Input() public inboundPattern: string;
@Input() public outboundPattern: string;
@Input() public constraint: string;
@Input() public automatic: boolean;
@Input() public headerKey: string;
markedForDeletion: number[] = [];
protected serviceId: string;
private originalInboundPatterns: any[] = [];
private originalOutboundPatterns: any[] = [];
private deletedInboundPatterns: number[] = [];
private deletedOutboundPatterns: number[] = [];
private modalRef: any;
private service: LdnService;
setItemfilters() {
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
getFirstCompletedRemoteData());
}
constructor(
protected ldnServicesService: LdnServicesService,
private ldnItemfiltersService: LdnItemfiltersService,
private formBuilder: FormBuilder,
private router: Router,
private route: ActivatedRoute,
private cdRef: ChangeDetectorRef,
protected modalService: NgbModal,
private notificationService: NotificationsService,
private translateService: TranslateService,
protected paginationService: PaginationService
) {
this.formModel = this.formBuilder.group({
id: [''],
name: ['', Validators.required],
description: ['', Validators.required],
url: ['', Validators.required],
ldnUrl: ['', Validators.required],
inboundPattern: [''],
outboundPattern: [''],
constraintPattern: [''],
enabled: [''],
notifyServiceInboundPatterns: this.formBuilder.array([this.createInboundPatternFormGroup()]),
notifyServiceOutboundPatterns: this.formBuilder.array([this.createOutboundPatternFormGroup()]),
type: LDN_SERVICE.value,
});
}
ngOnInit(): void {
this.route.params.subscribe((params) => {
this.serviceId = params.serviceId;
if (this.serviceId) {
this.fetchServiceData(this.serviceId);
}
});
this.setItemfilters();
}
setItemfilters() {
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
getFirstCompletedRemoteData());
}
fetchServiceData(serviceId: string): void {
this.ldnServicesService.findById(serviceId).pipe(
getFirstCompletedRemoteData()
).subscribe(
(data: RemoteData<LdnService>) => {
if (data.hasSucceeded) {
this.service = data.payload;
this.formModel.patchValue({
id: this.service.id,
name: this.service.name,
description: this.service.description,
url: this.service.url,
ldnUrl: this.service.ldnUrl,
type: this.service.type,
enabled: this.service.enabled
});
fetchServiceData(serviceId: string): void {
this.ldnServicesService.findById(serviceId).pipe(
getFirstCompletedRemoteData()
).subscribe(
(data: RemoteData<LdnService>) => {
if (data.hasSucceeded) {
this.service = data.payload;
const inboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
inboundPatternsArray.clear();
this.formModel.patchValue({
id: this.service.id,
name: this.service.name,
description: this.service.description,
url: this.service.url,
ldnUrl: this.service.ldnUrl,
type: this.service.type,
enabled: this.service.enabled
});
this.service.notifyServiceInboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeInboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
inboundPatternsArray.push(patternFormGroup);
this.cdRef.detectChanges();
});
const inboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
inboundPatternsArray.clear();
const outboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
outboundPatternsArray.clear();
this.service.notifyServiceInboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeInboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
inboundPatternsArray.push(patternFormGroup);
this.cdRef.detectChanges();
});
this.service.notifyServiceOutboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeOutboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
outboundPatternsArray.push(patternFormGroup);
const outboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
outboundPatternsArray.clear();
this.cdRef.detectChanges();
});
this.originalInboundPatterns = [...this.service.notifyServiceInboundPatterns];
this.originalOutboundPatterns = [...this.service.notifyServiceOutboundPatterns];
}
},
);
}
this.service.notifyServiceOutboundPatterns.forEach((pattern: any) => {
const patternFormGroup = this.initializeOutboundPatternFormGroup();
patternFormGroup.patchValue(pattern);
outboundPatternsArray.push(patternFormGroup);
generatePatchOperations(): any[] {
const patchOperations: any[] = [];
this.cdRef.detectChanges();
});
this.originalInboundPatterns = [...this.service.notifyServiceInboundPatterns];
this.originalOutboundPatterns = [...this.service.notifyServiceOutboundPatterns];
this.createReplaceOperation(patchOperations, 'name', '/name');
this.createReplaceOperation(patchOperations, 'description', '/description');
this.createReplaceOperation(patchOperations, 'ldnUrl', '/ldnurl');
this.createReplaceOperation(patchOperations, 'url', '/url');
this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns');
this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns');
this.deletedInboundPatterns.forEach(index => {
const removeOperation: Operation = {
op: 'remove',
path: `notifyServiceInboundPatterns[${index}]`
};
patchOperations.push(removeOperation);
});
this.deletedOutboundPatterns.forEach(index => {
const removeOperation: Operation = {
op: 'remove',
path: `notifyServiceOutboundPatterns[${index}]`
};
patchOperations.push(removeOperation);
});
return patchOperations;
}
onSubmit() {
this.openConfirmModal(this.confirmModal);
}
addInboundPattern() {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.push(this.createInboundPatternFormGroup());
}
addOutboundPattern() {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
}
removeOutboundPattern(index: number): void {
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
const patternGroup = patternsArray.at(index) as FormGroup;
const patternValue = patternGroup.value;
if (index < 0 || index >= patternsArray.length || patternValue.isNew) {
patternsArray.removeAt(index);
return;
}
},
);
}
generatePatchOperations(): any[] {
const patchOperations: any[] = [];
this.createReplaceOperation(patchOperations, 'name', '/name');
this.createReplaceOperation(patchOperations, 'description', '/description');
this.createReplaceOperation(patchOperations, 'ldnUrl', '/ldnurl');
this.createReplaceOperation(patchOperations, 'url', '/url');
this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns');
this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns');
this.deletedInboundPatterns.forEach(index => {
const removeOperation: Operation = {
op: 'remove',
path: `notifyServiceInboundPatterns[${index}]`
};
patchOperations.push(removeOperation);
});
this.deletedOutboundPatterns.forEach(index => {
const removeOperation: Operation = {
op: 'remove',
path: `notifyServiceOutboundPatterns[${index}]`
};
patchOperations.push(removeOperation);
});
return patchOperations;
}
onSubmit() {
this.openConfirmModal(this.confirmModal);
}
addInboundPattern() {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.push(this.createInboundPatternFormGroup());
}
addOutboundPattern() {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
}
removeOutboundPattern(index: number): void {
const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
const patternGroup = patternsArray.at(index) as FormGroup;
const patternValue = patternGroup.value;
if (index < 0 || index >= patternsArray.length || patternValue.isNew) {
patternsArray.removeAt(index);
return;
}
this.deletedOutboundPatterns.push(index);
this.deletedOutboundPatterns.push(index);
patternsArray.removeAt(index);
this.cdRef.detectChanges();
}
toggleAutomatic(i: number) {
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
if (automaticControl) {
automaticControl.setValue(!automaticControl.value);
}
}
toggleEnabled() {
const newStatus = !this.formModel.get('enabled').value;
const patchOperation: Operation = {
op: 'replace',
path: '/enabled',
value: newStatus,
};
this.ldnServicesService.patch(this.service, [patchOperation]).pipe(
getFirstCompletedRemoteData()
).subscribe(
() => {
this.formModel.get('enabled').setValue(newStatus);
this.cdRef.detectChanges();
}
);
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
openConfirmModal(content) {
this.modalRef = this.modalService.open(content);
}
openResetFormModal(content) {
this.modalRef = this.modalService.open(content);
}
patchService() {
this.deleteMarkedPatterns();
const patchOperations = this.generatePatchOperations();
this.ldnServicesService.patch(this.service, patchOperations).pipe(
getFirstCompletedRemoteData()
).subscribe(
() => {
this.closeModal();
this.sendBack();
this.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
this.translateService.get('admin.registries.services-formats.modify.success.content'));
},
(error) => {
this.notificationService.error(this.translateService.get('admin.registries.services-formats.modify.failure.head'),
this.translateService.get('admin.registries.services-formats.modify.failure.content'));
}
);
}
private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
if (this.formModel.get(formControlName).dirty) {
patchOperations.push({
op: 'replace',
path,
value: this.formModel.get(formControlName).value,
});
}
}
private handlePatterns(patchOperations: any[], formArrayName: string): void {
const patternsArray = this.formModel.get(formArrayName) as FormArray;
for (let i = 0; i < patternsArray.length; i++) {
const patternGroup = patternsArray.at(i) as FormGroup;
const patternValue = patternGroup.value;
if (patternGroup.dirty) {
if (patternValue.isNew) {
delete patternValue.isNew;
const addOperation = {
op: 'add',
path: `${formArrayName}/-`,
value: patternValue,
};
patchOperations.push(addOperation);
} else {
const replaceOperation = {
op: 'replace',
path: `${formArrayName}[${i}]`,
value: patternValue,
};
patchOperations.push(replaceOperation);
}
}
}
}
private sendBack() {
this.router.navigateByUrl('admin/ldn/services');
}
resetFormAndLeave() {
this.sendBack();
this.closeModal();
}
private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
isNew: true,
});
}
private createInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
automatic: false,
isNew: true
});
}
private initializeOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
});
}
private initializeInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
automatic: '',
});
}
markForDeletion(index: number) {
if (!this.markedForDeletion.includes(index)) {
this.markedForDeletion.push(index);
}
}
unmarkForDeletion(index: number) {
const i = this.markedForDeletion.indexOf(index);
if (i !== -1) {
this.markedForDeletion.splice(i, 1);
}
}
deleteMarkedPatterns() {
this.markedForDeletion.sort((a, b) => b - a);
const patternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
for (const index of this.markedForDeletion) {
if (index >= 0 && index < patternsArray.length) {
this.deletedInboundPatterns.push(index);
patternsArray.removeAt(index);
}
this.cdRef.detectChanges();
}
this.markedForDeletion = [];
}
toggleAutomatic(i: number) {
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
if (automaticControl) {
automaticControl.setValue(!automaticControl.value);
}
}
toggleEnabled() {
const newStatus = !this.formModel.get('enabled').value;
const patchOperation: Operation = {
op: 'replace',
path: '/enabled',
value: newStatus,
};
this.ldnServicesService.patch(this.service, [patchOperation]).pipe(
getFirstCompletedRemoteData()
).subscribe(
() => {
this.formModel.get('enabled').setValue(newStatus);
this.cdRef.detectChanges();
}
);
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
openConfirmModal(content) {
this.modalRef = this.modalService.open(content);
}
openResetFormModal(content) {
this.modalRef = this.modalService.open(content);
}
patchService() {
this.deleteMarkedPatterns();
const patchOperations = this.generatePatchOperations();
this.ldnServicesService.patch(this.service, patchOperations).pipe(
getFirstCompletedRemoteData()
).subscribe(
() => {
this.closeModal();
this.sendBack();
this.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
this.translateService.get('admin.registries.services-formats.modify.success.content'));
}
);
}
resetFormAndLeave() {
this.sendBack();
this.closeModal();
}
markForDeletion(index: number) {
if (!this.markedForDeletion.includes(index)) {
this.markedForDeletion.push(index);
}
}
unmarkForDeletion(index: number) {
const i = this.markedForDeletion.indexOf(index);
if (i !== -1) {
this.markedForDeletion.splice(i, 1);
}
}
deleteMarkedPatterns() {
this.markedForDeletion.sort((a, b) => b - a);
const patternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
for (const index of this.markedForDeletion) {
if (index >= 0 && index < patternsArray.length) {
this.deletedInboundPatterns.push(index);
patternsArray.removeAt(index);
}
}
this.markedForDeletion = [];
}
private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
if (this.formModel.get(formControlName).dirty) {
patchOperations.push({
op: 'replace',
path,
value: this.formModel.get(formControlName).value,
});
}
}
private handlePatterns(patchOperations: any[], formArrayName: string): void {
const patternsArray = this.formModel.get(formArrayName) as FormArray;
for (let i = 0; i < patternsArray.length; i++) {
const patternGroup = patternsArray.at(i) as FormGroup;
const patternValue = patternGroup.value;
if (patternGroup.dirty) {
if (patternValue.isNew) {
delete patternValue.isNew;
const addOperation = {
op: 'add',
path: `${formArrayName}/-`,
value: patternValue,
};
patchOperations.push(addOperation);
} else {
const replaceOperation = {
op: 'replace',
path: `${formArrayName}[${i}]`,
value: patternValue,
};
patchOperations.push(replaceOperation);
}
}
}
}
private sendBack() {
this.router.navigateByUrl('admin/ldn/services');
}
private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
isNew: true,
});
}
private createInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
automatic: false,
isNew: true
});
}
private initializeOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
});
}
private initializeInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: '',
constraint: '',
automatic: '',
});
}
}

View File

@@ -1,263 +1,266 @@
<div class="container">
<form (ngSubmit)="onSubmit()" [formGroup]="formModel">
<div class="d-flex">
<h2 class="flex-grow-1">{{ 'ldn-create-service.title' | translate }}</h2>
</div>
<!-- In the name section -->
<div class="mb-2">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name"
name="name"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the description section -->
<div class="mb-2 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea>
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the url section -->
<div class="mb-2">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url"
name="url"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the ldnUrl section -->
<div class="mb-2">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl" id="ldnUrl"
name="ldnUrl"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the Inbound Patterns section -->
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm1 ">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div>
<div class="col-sm-1">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceInboundPatterns">
<ng-container [formGroupName]="i">
<div class="row mb-1">
<div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
name="additionalInboundPattern{{i}}" required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option>
<option *ngFor="let pattern of inboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
<form (ngSubmit)="onSubmit()" [formGroup]="formModel">
<div class="d-flex">
<h2 class="flex-grow-1">{{ 'ldn-create-service.title' | translate }}</h2>
</div>
<!-- In the name section -->
<div class="mb-2">
<label for="name">{{ 'ldn-new-service.form.label.name' | translate }}</label>
<input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched"
[placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name"
name="name"
type="text">
</div>
<div class="col">
<ng-container *ngIf="inboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
<div class="mb-4">
&nbsp;
</div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm-1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div (click)="toggleAutomatic(i)"
[class.checked]="formModel.get('notifyServiceInboundPatterns.' + i + '.automatic').value"
class="toggle-switch">
<div class="slider"></div>
</div>
<!-- In the description section -->
<div class="mb-2 d-flex flex-column">
<label for="description">{{ 'ldn-new-service.form.label.description' | translate }}</label>
<textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate"
formControlName="description" id="description" name="description"></textarea>
</div>
<div class="col-sm-1">
<button (click)="removeInboundPattern(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
<div class="mb-4">
&nbsp;
</div>
</div>
</ng-container>
</div>
<span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<div class="mb-4">
&nbsp;
</div>
<!-- In the Outbound Patterns section -->
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }}</label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm-1 ">
</div>
<div class="col-sm-1 ">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceOutboundPatterns">
<ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1">
<div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}"
required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option>
<option *ngFor="let pattern of outboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
<!-- In the url section -->
<div class="mb-2">
<label for="url">{{ 'ldn-new-service.form.label.url' | translate }}</label>
<input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched"
[placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url"
name="url"
type="text">
</div>
<div class="col">
<ng-container *ngIf="outboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
<div class="mb-4">
&nbsp;
</div>
<!-- In the ldnUrl section -->
<div class="mb-2">
<label for="ldnUrl">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label>
<input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched"
[placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" formControlName="ldnUrl"
id="ldnUrl"
name="ldnUrl"
type="text">
</div>
<div class="mb-4">
&nbsp;
</div>
<!-- In the Inbound Patterns section -->
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm1 ">
<label class="label-box-2">{{ 'ldn-new-service.form.label.automatic' | translate }}</label>
</div>
<div class="col-sm-1">
</div>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceInboundPatterns">
<ng-container [formGroupName]="i">
<div class="row mb-1">
<div class="col">
<select #inboundPattern formControlName="pattern" id="additionalInboundPattern{{i}}"
name="additionalInboundPattern{{i}}" required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.inboundPattern' | translate }}</option>
<option *ngFor="let pattern of inboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
</div>
<div class="col">
<ng-container *ngIf="inboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
</div>
<div [style.visibility]="inboundPattern.value ? 'visible' : 'hidden'" class="col-sm-1">
<input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}"
type="checkbox">
<div (click)="toggleAutomatic(i)"
[class.checked]="formModel.get('notifyServiceInboundPatterns.' + i + '.automatic').value"
class="toggle-switch">
<div class="slider"></div>
</div>
</div>
<div class="col-sm-1">
<button (click)="removeInboundPattern(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
</ng-container>
</div>
<div [style.visibility]="'hidden'" class="col-sm1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div
class="toggle-switch">
<div class="slider"></div>
</div>
<span (click)="addInboundPattern()"
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
<div class="mb-4">
&nbsp;
</div>
<div class="col-sm-1">
<button (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
<!-- In the Outbound Patterns section -->
<div class="row">
<div class="col">
<label>{{ 'ldn-new-service.form.label.outboundPattern' | translate }}</label>
</div>
<div class="col">
<label class="label-box">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label>
</div>
<div class="col-sm-1 ">
</div>
<div class="col-sm-1 ">
</div>
</div>
</div>
</ng-container>
</div>
<div *ngFor="let patternGroup of formModel.get('notifyServiceOutboundPatterns')['controls']; let i = index"
formGroupName="notifyServiceOutboundPatterns">
<span (click)="addOutboundPattern()"
class="add-pattern-link">{{ 'ldn-new-service.form.label.addPattern' | translate }}
<ng-container [formGroupName]="i">
<!-- Input elements in a separate row -->
<div class="row mb-1">
<div class="col">
<select #outboundPattern formControlName="pattern" id="additionalOutboundPattern{{i}}"
name="additionalOutboundPattern{{i}}"
required>
<option value="">{{ 'ldn-new-service.form.label.placeholder.outboundPattern' | translate }}</option>
<option *ngFor="let pattern of outboundPatterns"
[ngValue]="pattern.name">{{ pattern.name }}</option>
</select>
</div>
<div class="col">
<ng-container *ngIf="outboundPattern.value">
<select formControlName="constraint" id="constraint{{i}}" name="constraint{{i}}">
<option value="">{{ 'ldn-new-service.form.label.placeholder.selectedItemFilter' | translate }}</option>
<option *ngFor="let itemFilter of (itemfiltersRD$ | async)?.payload?.page"
[value]="itemFilter.id">{{ itemFilter.id }}</option>
</select>
</ng-container>
</div>
<div [style.visibility]="'hidden'" class="col-sm1">
<input hidden id="automatic{{i}}" name="automatic{{i}}" type="checkbox">
<div
class="toggle-switch">
<div class="slider"></div>
</div>
</div>
<div class="col-sm-1">
<button (click)="removeOutboundPattern(i)" class="btn btn-outline-dark trash-button">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
</ng-container>
</div>
<span (click)="addOutboundPattern()"
class="add-pattern-link">{{ 'ldn-new-service.form.label.addPattern' | translate }}
</span>
<div class="mb-4">
&nbsp;
</div>
<div class="mb-4">
&nbsp;
</div>
<div class="submission-form-footer mt-1 mb-1 position-sticky" role="group" aria-label="Basic example">
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>
<div class="d-flex">
<button type="button" class="btn btn-danger" (click)="this.openResetFormModal(this.resetFormModal)">
<span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span>
</button>
</div>
</div>
<div aria-label="Basic example" class="submission-form-footer mt-1 mb-1 position-sticky" role="group">
<button class="btn btn-primary" type="submit">
<span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span>
</button>
<div class="d-flex">
<button (click)="this.openResetFormModal(this.resetFormModal)" class="btn btn-danger" type="button">
<span><i class="fas fa-trash"></i> {{ 'submission.general.discard.submit' | translate }}</span>
</button>
</div>
</div>
</form>
</form>
</div>
<ng-template #confirmModal>
<div>
<div>
<div class="modal-header">
<div>
<h4>{{'service.overview.create.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-header">
<div>
<h4>{{'service.overview.create.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.create.body' | translate }}
</div>
<div class="mt-4">
<button (click)="closeModal()" class="btn btn-danger"
id="delete-confirm">{{ 'service.refuse.create' | translate }}
</button>
<button (click)="createService()"
class="btn btn-primary mr-2 custom-btn">{{ 'service.confirm.create' | translate }}
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.create.body' | translate }}
</div>
<div class="mt-4">
<button (click)="closeModal()" class="btn btn-danger"
id="delete-confirm">{{ 'service.refuse.create' | translate }}
</button>
<button (click)="createService()"
class="btn btn-primary mr-2 custom-btn">{{ 'service.confirm.create' | translate }}
</button>
</div>
</div>
</div>
</div>
</ng-template>
<ng-template #resetFormModal>
<div>
<div>
<div class="modal-header">
<div>
<h4>{{'service.create.reset-form.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-header">
<div>
<h4>{{'service.create.reset-form.modal' | translate }}</h4>
</div>
<button (click)="closeModal()" aria-label="Close"
class="close" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.create.reset-form.body' | translate }}
</div>
<div class="mt-4">
<button (click)="resetFormAndLeave()"
class="btn btn-primary mr-2 custom-btn" id="reset-confirm">{{ 'service.overview.reset-form.reset-return' | translate }}
</button>
<button (click)="closeModal()" class="btn btn-danger"
id="reset-delete">{{ 'service.overview.reset-form.reset-confirm' | translate }}
</button>
</div>
<div class="modal-body">
<div>
{{ 'service.create.reset-form.body' | translate }}
</div>
<div class="mt-4">
<button (click)="resetFormAndLeave()"
class="btn btn-primary mr-2 custom-btn"
id="reset-confirm">{{ 'service.overview.reset-form.reset-return' | translate }}
</button>
<button (click)="closeModal()" class="btn btn-danger"
id="reset-delete">{{ 'service.overview.reset-form.reset-confirm' | translate }}
</button>
</div>
</div>
</div>
</div>
</ng-template>

View File

@@ -27,12 +27,13 @@ textarea {
resize: none;
}
.add-pattern-link{
.add-pattern-link {
color: #0048ff;
cursor: pointer;
margin-left: 10px;
}
.remove-pattern-link{
.remove-pattern-link {
color: #e34949;
cursor: pointer;
margin-left: 10px;
@@ -75,7 +76,6 @@ textarea {
}
.toggle-switch .slider {
width: 22px;
height: 22px;
@@ -99,21 +99,21 @@ textarea {
cursor: pointer;
}
.label-box{
margin-left:11px;
.label-box {
margin-left: 11px;
}
.label-box-2{
margin-left:14px;
.label-box-2 {
margin-left: 14px;
}
.label-box-3{
margin-left:5px;
.label-box-3 {
margin-left: 5px;
}
form button.btn.btn-primary[type="submit"] {
position: absolute;
bottom: 0px;
bottom: 0;
right: -10px;
}

View File

@@ -3,23 +3,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LdnServiceFormComponent } from './ldn-service-form.component';
describe('LdnServiceFormComponent', () => {
let component: LdnServiceFormComponent;
let fixture: ComponentFixture<LdnServiceFormComponent>;
let component: LdnServiceFormComponent;
let fixture: ComponentFixture<LdnServiceFormComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LdnServiceFormComponent ]
})
.compileComponents();
});
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LdnServiceFormComponent]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LdnServiceFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(LdnServiceFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -30,203 +30,193 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'ds-ldn-service-form',
templateUrl: './ldn-service-form.component.html',
styleUrls: ['./ldn-service-form.component.scss'],
animations: [
trigger('toggleAnimation', [
state('true', style({})),
state('false', style({})),
transition('true <=> false', animate('300ms ease-in')),
]),
],
selector: 'ds-ldn-service-form',
templateUrl: './ldn-service-form.component.html',
styleUrls: ['./ldn-service-form.component.scss'],
animations: [
trigger('toggleAnimation', [
state('true', style({})),
state('false', style({})),
transition('true <=> false', animate('300ms ease-in')),
]),
],
})
export class LdnServiceFormComponent implements OnInit {
formModel: FormGroup;
private modalRef: any;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
@Input() public name: string;
@Input() public description: string;
@Input() public url: string;
@Input() public ldnUrl: string;
@Input() public inboundPattern: string;
@Input() public outboundPattern: string;
@Input() public constraint: string;
@Input() public automatic: boolean;
@Input() public headerKey: string;
@Output() submitForm: EventEmitter<any> = new EventEmitter();
@Output() cancelForm: EventEmitter<any> = new EventEmitter();
constructor(
private ldnServicesService: LdnServicesService,
private ldnItemfiltersService: LdnItemfiltersService,
private formBuilder: FormBuilder,
private router: Router,
private notificationsService: NotificationsService,
private translateService: TranslateService,
private cdRef: ChangeDetectorRef,
protected modalService: NgbModal,
) {
this.formModel = this.formBuilder.group({
enabled: true,
id: [''],
name: ['', Validators.required],
description: [''],
url: ['', Validators.required],
ldnUrl: ['', Validators.required],
inboundPattern: [''],
outboundPattern: [''],
constraintPattern: [''],
notifyServiceInboundPatterns: this.formBuilder.array([this.createInboundPatternFormGroup()]),
notifyServiceOutboundPatterns: this.formBuilder.array([this.createOutboundPatternFormGroup()]),
type: LDN_SERVICE.value,
formModel: FormGroup;
@ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef<any>;
@ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef<any>;
public inboundPatterns: object[] = notifyPatterns;
public outboundPatterns: object[] = notifyPatterns;
itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
}
ngOnInit(): void {
this.setItemfilters();
}
setItemfilters() {
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
getFirstCompletedRemoteData());
this.itemfiltersRD$.subscribe((rd: RemoteData<PaginatedList<Itemfilter>>) => {
if (rd.hasSucceeded) {
}
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
}
@Input() public name: string;
@Input() public description: string;
@Input() public url: string;
@Input() public ldnUrl: string;
@Input() public inboundPattern: string;
@Input() public outboundPattern: string;
@Input() public constraint: string;
@Input() public automatic: boolean;
@Input() public headerKey: string;
@Output() submitForm: EventEmitter<any> = new EventEmitter();
@Output() cancelForm: EventEmitter<any> = new EventEmitter();
private modalRef: any;
onSubmit() {
this.openConfirmModal(this.confirmModal);
}
constructor(
private ldnServicesService: LdnServicesService,
private ldnItemfiltersService: LdnItemfiltersService,
private formBuilder: FormBuilder,
private router: Router,
private notificationsService: NotificationsService,
private translateService: TranslateService,
private cdRef: ChangeDetectorRef,
protected modalService: NgbModal,
) {
openConfirmModal(content) {
this.modalRef = this.modalService.open(content);
}
openResetFormModal(content) {
this.modalRef = this.modalService.open(content);
}
createService() {
this.formModel.get('name').markAsTouched();
this.formModel.get('url').markAsTouched();
this.formModel.get('ldnUrl').markAsTouched();
const name = this.formModel.get('name').value;
const url = this.formModel.get('url').value;
const ldnUrl = this.formModel.get('ldnUrl').value;
if (!name || !url || !ldnUrl) {
this.closeModal();
return;
this.formModel = this.formBuilder.group({
enabled: true,
id: [''],
name: ['', Validators.required],
description: [''],
url: ['', Validators.required],
ldnUrl: ['', Validators.required],
inboundPattern: [''],
outboundPattern: [''],
constraintPattern: [''],
notifyServiceInboundPatterns: this.formBuilder.array([this.createInboundPatternFormGroup()]),
notifyServiceOutboundPatterns: this.formBuilder.array([this.createOutboundPatternFormGroup()]),
type: LDN_SERVICE.value,
});
}
const values = this.formModel.value;
ngOnInit(): void {
this.setItemfilters();
const inboundPatternValue = this.formModel.get('inboundPattern').value;
const outboundPatternValue = this.formModel.get('outboundPattern').value;
if (inboundPatternValue === '') {
values.notifyServiceInboundPatterns = [];
}
if (outboundPatternValue === '') {
values.notifyServiceOutboundPatterns = [];
}
const ldnServiceData = this.ldnServicesService.create(values);
setItemfilters() {
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
getFirstCompletedRemoteData());
}
ldnServiceData.pipe(
getFirstCompletedRemoteData()
).subscribe((rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get('ldn-service-notification.created.success.title'));
(this.translateService.get('ldn-service-notification.created.success.title'),
this.translateService.get('ldn-service-notification.created.success.body'));
onSubmit() {
this.openConfirmModal(this.confirmModal);
}
openConfirmModal(content) {
this.modalRef = this.modalService.open(content);
}
openResetFormModal(content) {
this.modalRef = this.modalService.open(content);
}
createService() {
this.formModel.get('name').markAsTouched();
this.formModel.get('url').markAsTouched();
this.formModel.get('ldnUrl').markAsTouched();
const name = this.formModel.get('name').value;
const url = this.formModel.get('url').value;
const ldnUrl = this.formModel.get('ldnUrl').value;
if (!name || !url || !ldnUrl) {
this.closeModal();
return;
}
const values = this.formModel.value;
const inboundPatternValue = this.formModel.get('inboundPattern').value;
const outboundPatternValue = this.formModel.get('outboundPattern').value;
if (inboundPatternValue === '') {
values.notifyServiceInboundPatterns = [];
}
if (outboundPatternValue === '') {
values.notifyServiceOutboundPatterns = [];
}
const ldnServiceData = this.ldnServicesService.create(values);
ldnServiceData.pipe(
getFirstCompletedRemoteData()
).subscribe((rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get('ldn-service-notification.created.success.title'));
(this.translateService.get('ldn-service-notification.created.success.title'),
this.translateService.get('ldn-service-notification.created.success.body'));
this.sendBack();
this.closeModal();
} else {
this.notificationsService.error(this.translateService.get('notification.created.failure'));
}
});
}
resetFormAndLeave() {
this.sendBack();
this.closeModal();
} else {
this.notificationsService.error(this.translateService.get('notification.created.failure'));
}
});
}
resetFormAndLeave() {
this.sendBack();
this.closeModal();
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
addInboundPattern() {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.push(this.createInboundPatternFormGroup());
}
removeInboundPattern(index: number) {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.removeAt(index);
}
addOutboundPattern() {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
}
removeOutboundPattern(index: number) {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.removeAt(index);
}
toggleAutomatic(i: number) {
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
if (automaticControl) {
automaticControl.setValue(!automaticControl.value);
}
}
private sendBack() {
this.router.navigateByUrl('admin/ldn/services');
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
addInboundPattern() {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.push(this.createInboundPatternFormGroup());
}
removeInboundPattern(index: number) {
const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
notifyServiceInboundPatternsArray.removeAt(index);
}
addOutboundPattern() {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
}
removeOutboundPattern(index: number) {
const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
notifyServiceOutboundPatternsArray.removeAt(index);
}
toggleAutomatic(i: number) {
const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
if (automaticControl) {
automaticControl.setValue(!automaticControl.value);
}
}
private sendBack() {
this.router.navigateByUrl('admin/ldn/services');
}
private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: [''],
constraint: [''],
});
}
private createOutboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: [''],
constraint: [''],
});
}
private createInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: [''],
constraint: [''],
automatic: false
});
}
private createInboundPatternFormGroup(): FormGroup {
return this.formBuilder.group({
pattern: [''],
constraint: [''],
automatic: false
});
}
}

View File

@@ -3,23 +3,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LdnServiceNewComponent } from './ldn-service-new.component';
describe('LdnServiceNewComponent', () => {
let component: LdnServiceNewComponent;
let fixture: ComponentFixture<LdnServiceNewComponent>;
let component: LdnServiceNewComponent;
let fixture: ComponentFixture<LdnServiceNewComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ LdnServiceNewComponent ]
})
.compileComponents();
});
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [LdnServiceNewComponent]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(LdnServiceNewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(LdnServiceNewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -4,25 +4,24 @@ import { LdnService } from "../ldn-services-model/ldn-services.model";
import { ActivatedRoute } from "@angular/router";
import { ProcessDataService } from "../../../core/data/processes/process-data.service";
import { LinkService } from "../../../core/cache/builders/link.service";
import { getFirstSucceededRemoteDataPayload } from "../../../core/shared/operators";
@Component({
selector: 'ds-ldn-service-new',
templateUrl: './ldn-service-new.component.html',
styleUrls: ['./ldn-service-new.component.scss']
selector: 'ds-ldn-service-new',
templateUrl: './ldn-service-new.component.html',
styleUrls: ['./ldn-service-new.component.scss']
})
export class LdnServiceNewComponent implements OnInit {
/**
* Emits preselected process if there is one
*/
ldnService$?: Observable<LdnService>;
/**
* Emits preselected process if there is one
*/
ldnService$?: Observable<LdnService>;
constructor(private route: ActivatedRoute, private processService: ProcessDataService, private linkService: LinkService) {
}
constructor(private route: ActivatedRoute, private processService: ProcessDataService, private linkService: LinkService) {
}
/**
* If there's an id parameter, use this the process with this identifier as presets for the form
*/
ngOnInit() {
}
/**
* If there's an id parameter, use this the process with this identifier as presets for the form
*/
ngOnInit() {
}
}

View File

@@ -37,8 +37,6 @@ export const mockLdnService: LdnService = {
};
const mockLdnServices = {
payload: {
elementsPerPage: 20,
@@ -52,7 +50,7 @@ const mockLdnServices = {
page: [mockLdnService],
type: LDN_SERVICE,
self: undefined,
getPageLength: function() {
getPageLength: function () {
return this.page.length;
},
_links: {
@@ -67,7 +65,5 @@ const mockLdnServices = {
};
// Create a mock ldnServicesRD$ observable
export const mockLdnServicesRD$: Observable<RemoteData<PaginatedList<LdnService>>> = of((mockLdnServices as unknown) as RemoteData<PaginatedList<LdnService>>);

View File

@@ -17,7 +17,6 @@ import { Itemfilter } from '../ldn-services-model/ldn-service-itemfilters';
import { PaginatedList } from '../../../core/data/paginated-list.model';
/**
* A service responsible for fetching/sending data from/to the REST API on the itemfilters endpoint
*/
@@ -38,11 +37,11 @@ export class LdnItemfiltersService extends IdentifiableDataService<Itemfilter> i
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
}
getEndpoint() {
return this.halService.getEndpoint(this.linkPath);
}
getEndpoint() {
return this.halService.getEndpoint(this.linkPath);
}
findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Itemfilter>[]): Observable<RemoteData<PaginatedList<Itemfilter>>> {
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Itemfilter>[]): Observable<RemoteData<PaginatedList<Itemfilter>>> {
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
}

View File

@@ -38,90 +38,89 @@ import { hasValue } from 'src/app/shared/empty.util';
@Injectable()
@dataService(LDN_SERVICE)
export class LdnServicesService extends IdentifiableDataService<LdnService> implements FindAllData<LdnService>, DeleteData<LdnService>, PatchData<LdnService>, CreateData<LdnService> {
createData: CreateDataImpl<LdnService>;
private findAllData: FindAllDataImpl<LdnService>;
private deleteData: DeleteDataImpl<LdnService>;
private patchData: PatchDataImpl<LdnService>;
private comparator: ChangeAnalyzer<LdnService>;
createData: CreateDataImpl<LdnService>;
private findAllData: FindAllDataImpl<LdnService>;
private deleteData: DeleteDataImpl<LdnService>;
private patchData: PatchDataImpl<LdnService>;
private comparator: ChangeAnalyzer<LdnService>;
constructor(
protected requestService: RequestService,
protected rdbService: RemoteDataBuildService,
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
) {
super('ldnservices', requestService, rdbService, objectCache, halService);
constructor(
protected requestService: RequestService,
protected rdbService: RemoteDataBuildService,
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
) {
super('ldnservices', requestService, rdbService, objectCache, halService);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.comparator, this.responseMsToLive, this.constructIdEndpoint);
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
}
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
this.patchData = new PatchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.comparator, this.responseMsToLive, this.constructIdEndpoint);
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
}
create(object: LdnService): Observable<RemoteData<LdnService>> {
return this.createData.create(object);
}
create(object: LdnService): Observable<RemoteData<LdnService>> {
return this.createData.create(object);
}
patch(object: LdnService, operations: Operation[]): Observable<RemoteData<LdnService>> {
return this.patchData.patch(object, operations);
}
patch(object: LdnService, operations: Operation[]): Observable<RemoteData<LdnService>> {
return this.patchData.patch(object, operations);
}
update(object: LdnService): Observable<RemoteData<LdnService>> {
return this.patchData.update(object);
}
update(object: LdnService): Observable<RemoteData<LdnService>> {
return this.patchData.update(object);
}
commitUpdates(method?: RestRequestMethod): void {
return this.patchData.commitUpdates(method);
}
commitUpdates(method?: RestRequestMethod): void {
return this.patchData.commitUpdates(method);
}
createPatchFromCache(object: LdnService): Observable<Operation[]> {
return this.patchData.createPatchFromCache(object);
}
createPatchFromCache(object: LdnService): Observable<Operation[]> {
return this.patchData.createPatchFromCache(object);
}
findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<LdnService>[]): Observable<RemoteData<PaginatedList<LdnService>>> {
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
findAll(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<LdnService>[]): Observable<RemoteData<PaginatedList<LdnService>>> {
return this.findAllData.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
}
public delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
return this.deleteData.delete(objectId, copyVirtualMetadata);
}
public delete(objectId: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
return this.deleteData.delete(objectId, copyVirtualMetadata);
}
public deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
return this.deleteData.deleteByHref(href, copyVirtualMetadata);
}
public deleteByHref(href: string, copyVirtualMetadata?: string[]): Observable<RemoteData<NoContent>> {
return this.deleteData.deleteByHref(href, copyVirtualMetadata);
}
public invoke(serviceName: string, serviceId: string, parameters: ldnServiceConstrain[], files: File[]): Observable<RemoteData<LdnService>> {
const requestId = this.requestService.generateRequestId();
this.getBrowseEndpoint().pipe(
take(1),
map((endpoint: string) => new URLCombiner(endpoint, serviceName, 'processes', serviceId).toString()),
map((endpoint: string) => {
const body = this.getInvocationFormData(parameters, files);
return new MultipartPostRequest(requestId, endpoint, body);
})
).subscribe((request: RestRequest) => this.requestService.send(request));
public invoke(serviceName: string, serviceId: string, parameters: ldnServiceConstrain[], files: File[]): Observable<RemoteData<LdnService>> {
const requestId = this.requestService.generateRequestId();
this.getBrowseEndpoint().pipe(
take(1),
map((endpoint: string) => new URLCombiner(endpoint, serviceName, 'processes', serviceId).toString()),
map((endpoint: string) => {
const body = this.getInvocationFormData(parameters, files);
return new MultipartPostRequest(requestId, endpoint, body);
})
).subscribe((request: RestRequest) => this.requestService.send(request));
return this.rdbService.buildFromRequestUUID<LdnService>(requestId);
}
return this.rdbService.buildFromRequestUUID<LdnService>(requestId);
}
public ldnServiceWithNameExistsAndCanExecute(scriptName: string): Observable<boolean> {
return this.findById(scriptName).pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<LdnService>) => {
return hasValue(rd.payload);
}),
);
}
private getInvocationFormData(constrain: ldnServiceConstrain[], files: File[]): FormData {
const form: FormData = new FormData();
form.set('properties', JSON.stringify(constrain));
files.forEach((file: File) => {
form.append('file', file);
});
return form;
}
public ldnServiceWithNameExistsAndCanExecute(scriptName: string): Observable<boolean> {
return this.findById(scriptName).pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<LdnService>) => {
return hasValue(rd.payload);
}),
);
}
private getInvocationFormData(constrain: ldnServiceConstrain[], files: File[]): FormData {
const form: FormData = new FormData();
form.set('properties', JSON.stringify(constrain));
files.forEach((file: File) => {
form.append('file', file);
});
return form;
}
}

View File

@@ -15,34 +15,34 @@
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">{{ 'service.overview.table.name' | translate }}</th>
<th scope="col">{{ 'service.overview.table.description' | translate }}</th>
<th scope="col">{{ 'service.overview.table.status' | translate }}</th>
<th scope="col">{{ 'service.overview.table.actions' | translate }}</th>
</tr>
<tr>
<th scope="col">{{ 'service.overview.table.name' | translate }}</th>
<th scope="col">{{ 'service.overview.table.description' | translate }}</th>
<th scope="col">{{ 'service.overview.table.status' | translate }}</th>
<th scope="col">{{ 'service.overview.table.actions' | translate }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let ldnService of (ldnServicesRD$ | async)?.payload?.page">
<td>{{ ldnService.name }}</td>
<td>{{ ldnService.description }}</td>
<td>
<span [ngClass]="{ 'status-enabled': ldnService.enabled, 'status-disabled': !ldnService.enabled }"
class="status-indicator" (click)="toggleStatus(ldnService, ldnServicesService)"
[title]="ldnService.enabled ? ('ldn-service.overview.table.clickToDisable' | translate) : ('ldn-service.overview.table.clickToEnable' | translate)">
<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)"
class="status-indicator">
{{ ldnService.enabled ? ('ldn-service.overview.table.enabled' | translate) : ('ldn-service.overview.table.disabled' | translate) }}
</span>
</td>
<td>
<div class="btn-group">
<button (click)="selectServiceToDelete(ldnService.id)" class="btn btn-outline-danger">
<i class="fas fa-trash"></i>
</button>
<button [routerLink]="['/admin/ldn/services/edit/', ldnService.id]"
class="btn btn-outline-dark">
<i class="fas fa-edit"></i>
</button>
</div>
<button (click)="selectServiceToDelete(ldnService.id)" class="btn btn-outline-danger">
<i class="fas fa-trash"></i>
</button>
<button [routerLink]="['/admin/ldn/services/edit/', ldnService.id]"
class="btn btn-outline-dark">
<i class="fas fa-edit"></i>
</button>
</div>
</td>
</tr>
</tbody>
@@ -72,7 +72,8 @@
<div class="mt-4">
<button (click)="closeModal()"
class="btn btn-primary mr-2">{{ 'service.detail.delete.cancel' | translate }}</button>
<button (click)="deleteSelected(this.selectedServiceId.toString(), ldnServicesService)" class="btn btn-danger"
<button (click)="deleteSelected(this.selectedServiceId.toString(), ldnServicesService)"
class="btn btn-danger"
id="delete-confirm">{{ 'service.overview.delete' | translate }}
</button>
</div>

View File

@@ -3,23 +3,23 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ServicesDirectoryComponent } from './services-directory.component';
describe('ServicesDirectoryComponent', () => {
let component: ServicesDirectoryComponent;
let fixture: ComponentFixture<ServicesDirectoryComponent>;
let component: ServicesDirectoryComponent;
let fixture: ComponentFixture<ServicesDirectoryComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ServicesDirectoryComponent ]
})
.compileComponents();
});
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ServicesDirectoryComponent]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ServicesDirectoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(ServicesDirectoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,4 +1,12 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
OnDestroy,
OnInit,
TemplateRef,
ViewChild
} from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
@@ -11,130 +19,128 @@ import { PaginationService } from 'src/app/core/pagination/pagination.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { hasValue } from '../../../shared/empty.util';
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 { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'ds-ldn-services-directory',
templateUrl: './ldn-services-directory.component.html',
styleUrls: ['./ldn-services-directory.component.scss'],
changeDetection: ChangeDetectionStrategy.Default
selector: 'ds-ldn-services-directory',
templateUrl: './ldn-services-directory.component.html',
styleUrls: ['./ldn-services-directory.component.scss'],
changeDetection: ChangeDetectionStrategy.Default
})
export class LdnServicesOverviewComponent implements OnInit, OnDestroy {
selectedServiceId: string | number | null = null;
servicesData: any[] = [];
@ViewChild('deleteModal', {static: true}) deleteModal: TemplateRef<any>;
ldnServicesRD$: Observable<RemoteData<PaginatedList<LdnService>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
isProcessingSub: Subscription;
private modalRef: any;
selectedServiceId: string | number | null = null;
servicesData: any[] = [];
@ViewChild('deleteModal', {static: true}) deleteModal: TemplateRef<any>;
ldnServicesRD$: Observable<RemoteData<PaginatedList<LdnService>>>;
config: FindListOptions = Object.assign(new FindListOptions(), {
elementsPerPage: 20
});
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
id: 'po',
pageSize: 20
});
isProcessingSub: Subscription;
private modalRef: any;
constructor(
protected ldnServicesService: LdnServicesService,
protected paginationService: PaginationService,
protected modalService: NgbModal,
private cdRef: ChangeDetectorRef,
private notificationService: NotificationsService,
private translateService: TranslateService,
) {
}
ngOnInit(): void {
this.setLdnServices();
}
setLdnServices() {
this.ldnServicesRD$ = this.paginationService.getFindListOptions(this.pageConfig.id, this.config).pipe(
switchMap((config) => this.ldnServicesService.findAll(config, false, false).pipe(
getFirstCompletedRemoteData()
))
);
}
ngOnDestroy(): void {
this.paginationService.clearPagination(this.pageConfig.id);
if (hasValue(this.isProcessingSub)) {
this.isProcessingSub.unsubscribe();
constructor(
protected ldnServicesService: LdnServicesService,
protected paginationService: PaginationService,
protected modalService: NgbModal,
private cdRef: ChangeDetectorRef,
private notificationService: NotificationsService,
private translateService: TranslateService,
) {
}
}
openDeleteModal(content) {
this.modalRef = this.modalService.open(content);
}
ngOnInit(): void {
this.setLdnServices();
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
setLdnServices() {
this.ldnServicesRD$ = this.paginationService.getFindListOptions(this.pageConfig.id, this.config).pipe(
switchMap((config) => this.ldnServicesService.findAll(config, false, false).pipe(
getFirstCompletedRemoteData()
))
);
}
selectServiceToDelete(serviceId: number) {
this.selectedServiceId = serviceId;
this.openDeleteModal(this.deleteModal);
}
ngOnDestroy(): void {
this.paginationService.clearPagination(this.pageConfig.id);
if (hasValue(this.isProcessingSub)) {
this.isProcessingSub.unsubscribe();
}
}
deleteSelected(serviceId: string, ldnServicesService: LdnServicesService): void {
if (this.selectedServiceId !== null) {
ldnServicesService.delete(serviceId).pipe(getFirstCompletedRemoteData()).subscribe((rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
this.servicesData = this.servicesData.filter(service => service.id !== serviceId);
this.ldnServicesRD$ = this.ldnServicesRD$.pipe(
map((remoteData: RemoteData<PaginatedList<LdnService>>) => {
if (remoteData.hasSucceeded) {
remoteData.payload.page = remoteData.payload.page.filter(service => service.id.toString() !== serviceId);
openDeleteModal(content) {
this.modalRef = this.modalService.open(content);
}
closeModal() {
this.modalRef.close();
this.cdRef.detectChanges();
}
selectServiceToDelete(serviceId: number) {
this.selectedServiceId = serviceId;
this.openDeleteModal(this.deleteModal);
}
deleteSelected(serviceId: string, ldnServicesService: LdnServicesService): void {
if (this.selectedServiceId !== null) {
ldnServicesService.delete(serviceId).pipe(getFirstCompletedRemoteData()).subscribe((rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
this.servicesData = this.servicesData.filter(service => service.id !== serviceId);
this.ldnServicesRD$ = this.ldnServicesRD$.pipe(
map((remoteData: RemoteData<PaginatedList<LdnService>>) => {
if (remoteData.hasSucceeded) {
remoteData.payload.page = remoteData.payload.page.filter(service => service.id.toString() !== serviceId);
}
return remoteData;
})
);
this.cdRef.detectChanges();
this.closeModal();
this.notificationService.success(this.translateService.get('ldn-service-delete.notification.success.title'),
this.translateService.get('ldn-service-delete.notification.success.content'));
} else {
this.notificationService.error(this.translateService.get('ldn-service-delete.notification.error.title'),
this.translateService.get('ldn-service-delete.notification.error.content'));
this.cdRef.detectChanges();
}
return remoteData;
})
);
this.cdRef.detectChanges();
this.closeModal();
this.notificationService.success(this.translateService.get('ldn-service-delete.notification.success.title'),
this.translateService.get('ldn-service-delete.notification.success.content'));
} else {
this.notificationService.error(this.translateService.get('ldn-service-delete.notification.error.title'),
this.translateService.get('ldn-service-delete.notification.error.content'));
this.cdRef.detectChanges();
});
}
});
}
}
toggleStatus(ldnService: any, ldnServicesService: LdnServicesService): void {
const newStatus = !ldnService.enabled;
const originalStatus = ldnService.enabled;
const patchOperation: Operation = {
op: 'replace',
path: '/enabled',
value: newStatus,
};
toggleStatus(ldnService: any, ldnServicesService: LdnServicesService): void {
const newStatus = !ldnService.enabled;
const originalStatus = ldnService.enabled;
const patchOperation: Operation = {
op: 'replace',
path: '/enabled',
value: newStatus,
};
ldnServicesService.patch(ldnService, [patchOperation]).pipe(getFirstCompletedRemoteData()).subscribe(
(rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
ldnService.enabled = newStatus;
this.notificationService.success(this.translateService.get('ldn-enable-service.notification.success.title'),
this.translateService.get('ldn-enable-service.notification.success.content'));
} else {
ldnService.enabled = originalStatus;
this.notificationService.error(this.translateService.get('ldn-enable-service.notification.error.title'),
this.translateService.get('ldn-enable-service.notification.error.content'));
}
}
);
}
ldnServicesService.patch(ldnService, [patchOperation]).pipe(getFirstCompletedRemoteData()).subscribe(
(rd: RemoteData<LdnService>) => {
if (rd.hasSucceeded) {
ldnService.enabled = newStatus;
this.notificationService.success(this.translateService.get('ldn-enable-service.notification.success.title'),
this.translateService.get('ldn-enable-service.notification.success.content'));
} else {
ldnService.enabled = originalStatus;
this.notificationService.error(this.translateService.get('ldn-enable-service.notification.error.title'),
this.translateService.get('ldn-enable-service.notification.error.content'));
}
}
);
}
}

View File

@@ -4,26 +4,28 @@ import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
providedIn: 'root'
})
export class LdnServicesGuard implements CanActivate {
constructor(
//private notifyInfoService: NotifyInfoService,
private router: Router
) {}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
/*return this.notifyInfoService.isCoarConfigEnabled().pipe(
map(coarLdnEnabled => {
if (coarLdnEnabled) {
return true;
} else {
return this.router.parseUrl('/404');
}
})
);*/
}
constructor(
//private notifyInfoService: NotifyInfoService,
private router: Router
) {
}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return true;
/*return this.notifyInfoService.isCoarConfigEnabled().pipe(
map(coarLdnEnabled => {
if (coarLdnEnabled) {
return true;
} else {
return this.router.parseUrl('/404');
}
})
);*/
}
}

View File

@@ -3,15 +3,15 @@ import { TestBed } from '@angular/core/testing';
import { LdnServicesGuard } from './ldn-services-guard.service';
describe('LdnServicesGuard', () => {
let guard: LdnServicesGuard;
let guard: LdnServicesGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(LdnServicesGuard);
});
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(LdnServicesGuard);
});
it('should be created', () => {
// @ts-ignore
expect(guard).toBeTruthy();
});
it('should be created', () => {
// @ts-ignore
expect(guard).toBeTruthy();
});
});

View File

@@ -1,7 +1,6 @@
import { autoserialize, inheritSerialization, deserialize } from 'cerialize';
import { autoserialize, deserialize, inheritSerialization } from 'cerialize';
import { LDN_SERVICE_CONSTRAINT_FILTER } from './ldn-service.resource-type';
import { CacheableObject } from '../../../core/cache/cacheable-object.model';
import { HALLink } from '../../../core/shared/hal-link.model';
import { typedObject } from '../../../core/cache/builders/build-decorators';
import { excludeFromEquals } from '../../../core/utilities/equals.decorators';
import { ResourceType } from '../../../core/shared/resource-type';

View File

@@ -4,10 +4,10 @@ import { autoserialize } from 'cerialize';
* notify service patterns
*/
export class NotifyServicePattern {
@autoserialize
pattern: string;
@autoserialize
constraint: string;
@autoserialize
automatic: string;
@autoserialize
pattern: string;
@autoserialize
constraint: string;
@autoserialize
automatic: string;
}

View File

@@ -2,7 +2,7 @@
* List of services statuses
*/
export enum LdnServiceStatus {
UNKOWN,
DISABLED,
ENABLED,
UNKOWN,
DISABLED,
ENABLED,
}

View File

@@ -1,3 +1,3 @@
export class ldnServiceConstrain {
void: any;
void: any;
}

View File

@@ -7,7 +7,6 @@ import { typedObject } from '../../../core/cache/builders/build-decorators';
import { NotifyServicePattern } from './ldn-service-patterns.model';
/** An LdnService and its properties. */
@typedObject
@inheritSerialization(CacheableObject)

View File

@@ -3,15 +3,15 @@ import { TestBed } from '@angular/core/testing';
import { LdnDirectoryService } from './ldn-directory.service';
describe('LdnDirectoryService', () => {
let service: LdnDirectoryService;
let service: LdnDirectoryService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LdnDirectoryService);
});
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LdnDirectoryService);
});
it('should be created', () => {
// @ts-ignore
expect(service).toBeTruthy();
});
it('should be created', () => {
// @ts-ignore
expect(service).toBeTruthy();
});
});

View File

@@ -4,22 +4,24 @@ import { map, Observable } from 'rxjs';
import { LdnServicesService } from "../ldn-services-data/ldn-services-data.service";
@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class LdnDirectoryService {
private itemFilterEndpoint = 'http://localhost:8080/server/api/config/itemfilters';
private itemFilterEndpoint = 'http://localhost:8080/server/api/config/itemfilters';
constructor(private http: HttpClient,
private ldnServicesService: LdnServicesService) {}
public getItemFilters(): Observable<any> {
constructor(private http: HttpClient,
private ldnServicesService: LdnServicesService) {
}
return this.ldnServicesService.findAll().pipe(
map((servicesData) => {
return servicesData;
})
);
}
public getItemFilters(): Observable<any> {
return this.ldnServicesService.findAll().pipe(
map((servicesData) => {
return servicesData;
})
);
}
}

View File

@@ -3,15 +3,15 @@ import { TestBed } from '@angular/core/testing';
import { LdnServicesBulkDeleteService } from './ldn-service-bulk-delete.service';
describe('LdnServiceBulkDeleteService', () => {
let service: LdnServicesBulkDeleteService;
let service: LdnServicesBulkDeleteService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LdnServicesBulkDeleteService);
});
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LdnServicesBulkDeleteService);
});
it('should be created', () => {
// @ts-ignore
expect(service).toBeTruthy();
});
it('should be created', () => {
// @ts-ignore
expect(service).toBeTruthy();
});
});