CST-12498 Final refactor

This commit is contained in:
Mattia Vianelli
2023-11-20 13:29:44 +01:00
parent 36778a09cb
commit 532f4725b2
5 changed files with 18 additions and 14 deletions

View File

@@ -183,6 +183,7 @@ export class LdnServiceFormEditComponent implements OnInit {
} }
/** /**
* Generates an array of patch operations based on form changes * Generates an array of patch operations based on form changes
* @returns Array of patch operations * @returns Array of patch operations
@@ -253,6 +254,7 @@ export class LdnServiceFormEditComponent implements OnInit {
patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')}) patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')})
} }
/** /**
* Selects an outbound item filter by updating its value based on the provided filter value and index * Selects an outbound item filter by updating its value based on the provided filter value and index
* @param filterValue - The selected filter value * @param filterValue - The selected filter value
@@ -370,8 +372,8 @@ export class LdnServiceFormEditComponent implements OnInit {
} }
/** /**
* Resets the form and navigates back to the LDN services page * Resets the form and navigates back to the LDN services page
*/ */
resetFormAndLeave() { resetFormAndLeave() {
this.sendBack(); this.sendBack();
this.closeModal(); this.closeModal();
@@ -418,6 +420,7 @@ export class LdnServiceFormEditComponent implements OnInit {
this.markedForDeletionOutboundPattern.splice(i, 1); this.markedForDeletionOutboundPattern.splice(i, 1);
} }
} }
/** /**
* Deletes marked inbound patterns from the form model * Deletes marked inbound patterns from the form model
*/ */

View File

@@ -137,7 +137,7 @@ export class LdnServiceFormComponent implements OnInit {
} }
/** /**
* Handles the creation of an LDN service by validating form fields, * Handles the creation of an LDN service by retrieving and validating form fields,
* and submitting the form data to the LDN services endpoint. * and submitting the form data to the LDN services endpoint.
*/ */
createService() { createService() {
@@ -334,6 +334,7 @@ export class LdnServiceFormComponent implements OnInit {
private sendBack() { private sendBack() {
this.router.navigateByUrl('admin/ldn/services'); this.router.navigateByUrl('admin/ldn/services');
} }
/** /**
* Creates a form group for an outbound pattern in the notifyServiceOutboundPatterns form array. * Creates a form group for an outbound pattern in the notifyServiceOutboundPatterns form array.
* *

View File

@@ -84,7 +84,7 @@ export const mockLdnServices: LdnService[] = [{
get self(): string { get self(): string {
return ""; return "";
}, },
},{ }, {
uuid: "2", uuid: "2",
enabled: false, enabled: false,
score: 0, score: 0,

View File

@@ -15,7 +15,7 @@ import {LdnServicesOverviewComponent} from './ldn-services-directory.component';
import {createSuccessfulRemoteDataObject$} from "../../../shared/remote-data.utils"; import {createSuccessfulRemoteDataObject$} from "../../../shared/remote-data.utils";
import {createPaginatedList} from "../../../shared/testing/utils.test"; import {createPaginatedList} from "../../../shared/testing/utils.test";
describe('LdnServicesOverviewComponent', ( ) => { describe('LdnServicesOverviewComponent', () => {
let component: LdnServicesOverviewComponent; let component: LdnServicesOverviewComponent;
let fixture: ComponentFixture<LdnServicesOverviewComponent>; let fixture: ComponentFixture<LdnServicesOverviewComponent>;
let ldnServicesService; let ldnServicesService;
@@ -45,7 +45,8 @@ describe('LdnServicesOverviewComponent', ( ) => {
{provide: PaginationService, useValue: paginationService}, {provide: PaginationService, useValue: paginationService},
{ {
provide: NgbModal, useValue: { provide: NgbModal, useValue: {
open: () => { /*comment*/} open: () => { /*comment*/
}
} }
}, },
{provide: ChangeDetectorRef, useValue: {}}, {provide: ChangeDetectorRef, useValue: {}},

View File

@@ -27,7 +27,7 @@ import {TranslateService} from '@ngx-translate/core';
/** /**
* The `LdnServicesOverviewComponent` is a component that provides an overview of LDN (Linked Data Notifications) services. * The `LdnServicesOverviewComponent` is a component that provides an overview of LDN (Linked Data Notifications) services.
* It displays a paginated list of LDN services, allows users to edit and delete services, * It displays a paginated list of LDN services, allows users to edit and delete services,
* toggle the status of each service directly form the page and allows for creation of new services redirecting the user on the creation form * toggle the status of each service directly form the page and allows for creation of new services redirecting the user on the creation/edit form
*/ */
@Component({ @Component({
selector: 'ds-ldn-services-directory', selector: 'ds-ldn-services-directory',
@@ -52,14 +52,13 @@ export class LdnServicesOverviewComponent implements OnInit, OnDestroy {
modalRef: any; modalRef: any;
constructor( constructor(
protected ldnServicesService: LdnServicesService, protected ldnServicesService: LdnServicesService,
protected paginationService: PaginationService, protected paginationService: PaginationService,
protected modalService: NgbModal, protected modalService: NgbModal,
public cdRef: ChangeDetectorRef, public cdRef: ChangeDetectorRef,
private notificationService: NotificationsService, private notificationService: NotificationsService,
private translateService: TranslateService, private translateService: TranslateService,
) { ) {
} }