From f590ff51dc5f90e864100ac374dd2e8a92297e48 Mon Sep 17 00:00:00 2001 From: apuente Date: Wed, 4 Sep 2024 10:44:31 +0200 Subject: [PATCH] Subnets new stepper modal --- ogWebconsole/.vscode/launch.json | 2 +- .../admin/roles/roles/roles.component.ts | 2 +- .../admin/roles/roles/roles.service.ts | 2 +- .../admin/users/users/users.component.ts | 2 +- .../admin/users/users/users.service.ts | 2 +- .../classroom-view.component.ts | 2 +- .../create-client/create-client.component.ts | 6 +- .../edit-client/edit-client.component.ts | 10 +- .../src/app/components/groups/data.service.ts | 16 +-- .../app/components/groups/groups.component.ts | 4 +- .../create-organizational-unit.component.html | 9 ++ .../create-organizational-unit.component.ts | 22 ++-- .../edit-organizational-unit.component.ts | 8 +- .../app/components/login/login.component.ts | 2 +- .../create-image/create-image.component.ts | 6 +- .../components/ogboot/images/data.service.ts | 2 +- .../ogboot/images/images.component.ts | 2 +- .../ogboot-status/ogboot-status.component.ts | 2 +- .../create-pxe-boot-file.component.ts | 6 +- .../ogboot/pxe-boot-files/data.service.ts | 2 +- .../pxe-boot-files.component.ts | 2 +- .../create-pxe-template.component.ts | 4 +- .../app/components/ogboot/pxe/data.service.ts | 2 +- .../components/ogboot/pxe/pxe.component.ts | 2 +- .../create-subnet/create-subnet.component.css | 6 +- .../create-subnet.component.html | 95 ++++++++++++----- .../create-subnet/create-subnet.component.ts | 100 ++++++++++++++---- .../og-dhcp-subnets.component.ts | 6 +- 28 files changed, 218 insertions(+), 108 deletions(-) diff --git a/ogWebconsole/.vscode/launch.json b/ogWebconsole/.vscode/launch.json index 925af83..04f6674 100644 --- a/ogWebconsole/.vscode/launch.json +++ b/ogWebconsole/.vscode/launch.json @@ -7,7 +7,7 @@ "type": "chrome", "request": "launch", "preLaunchTask": "npm: start", - "url": "http://localhost:4200/" + "url": "http://127.0.0.1:8001/" }, { "name": "ng test", diff --git a/ogWebconsole/src/app/components/admin/roles/roles/roles.component.ts b/ogWebconsole/src/app/components/admin/roles/roles/roles.component.ts index 92a68f9..0cf84fc 100644 --- a/ogWebconsole/src/app/components/admin/roles/roles/roles.component.ts +++ b/ogWebconsole/src/app/components/admin/roles/roles/roles.component.ts @@ -64,7 +64,7 @@ export class RolesComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result) { - const apiUrl = `http://127.0.0.1:8080/user-groups/${role.uuid}`; + const apiUrl = `http://127.0.0.1:8081/user-groups/${role.uuid}`; this.http.delete(apiUrl).subscribe({ next: () => { diff --git a/ogWebconsole/src/app/components/admin/roles/roles/roles.service.ts b/ogWebconsole/src/app/components/admin/roles/roles/roles.service.ts index c9d9ee6..cade075 100644 --- a/ogWebconsole/src/app/components/admin/roles/roles/roles.service.ts +++ b/ogWebconsole/src/app/components/admin/roles/roles/roles.service.ts @@ -12,7 +12,7 @@ interface Role { providedIn: 'root' }) export class RoleService { - private apiUrl = 'http://127.0.0.1:8080'; + private apiUrl = 'http://127.0.0.1:8081'; constructor(private http: HttpClient) {} diff --git a/ogWebconsole/src/app/components/admin/users/users/users.component.ts b/ogWebconsole/src/app/components/admin/users/users/users.component.ts index 20214c7..b9a036b 100644 --- a/ogWebconsole/src/app/components/admin/users/users/users.component.ts +++ b/ogWebconsole/src/app/components/admin/users/users/users.component.ts @@ -81,7 +81,7 @@ export class UsersComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result) { - const apiUrl = `http://127.0.0.1:8080/users/${user.uuid}`; + const apiUrl = `http://127.0.0.1:8081/users/${user.uuid}`; this.http.delete(apiUrl).subscribe({ next: () => { diff --git a/ogWebconsole/src/app/components/admin/users/users/users.service.ts b/ogWebconsole/src/app/components/admin/users/users/users.service.ts index 52338fe..75befbf 100644 --- a/ogWebconsole/src/app/components/admin/users/users/users.service.ts +++ b/ogWebconsole/src/app/components/admin/users/users/users.service.ts @@ -26,7 +26,7 @@ interface UserGroup { providedIn: 'root' }) export class UserService { - private apiUrl = 'http://127.0.0.1:8080'; + private apiUrl = 'http://127.0.0.1:8081'; constructor(private http: HttpClient) {} diff --git a/ogWebconsole/src/app/components/groups/classroom-view/classroom-view.component.ts b/ogWebconsole/src/app/components/groups/classroom-view/classroom-view.component.ts index 0889dc2..4956af5 100644 --- a/ogWebconsole/src/app/components/groups/classroom-view/classroom-view.component.ts +++ b/ogWebconsole/src/app/components/groups/classroom-view/classroom-view.component.ts @@ -85,7 +85,7 @@ export class ClassroomViewComponent implements OnInit, OnChanges { this.groupedClients.forEach(group => { group.clientRows.forEach(row => { row.forEach(client => { - const url = `http://127.0.0.1:8080/clients/${client.uuid}`; + const url = `http://127.0.0.1:8081/clients/${client.uuid}`; const payload = { name: client.name, position: client.position diff --git a/ogWebconsole/src/app/components/groups/clients/create-client/create-client.component.ts b/ogWebconsole/src/app/components/groups/clients/create-client/create-client.component.ts index d669b9e..a8c2797 100644 --- a/ogWebconsole/src/app/components/groups/clients/create-client/create-client.component.ts +++ b/ogWebconsole/src/app/components/groups/clients/create-client/create-client.component.ts @@ -71,7 +71,7 @@ export class CreateClientComponent implements OnInit { loadParentUnits() { this.loading = true; - const url = 'http://127.0.0.1:8080/organizational-units?page=1&itemsPerPage=10000'; + const url = 'http://127.0.0.1:8081/organizational-units?page=1&itemsPerPage=10000'; this.http.get(url).subscribe( response => { @@ -87,7 +87,7 @@ export class CreateClientComponent implements OnInit { loadOgLives() { - const url = 'http://127.0.0.1:8080/og-lives?page=1&itemsPerPage=30'; + const url = 'http://127.0.0.1:8081/og-lives?page=1&itemsPerPage=30'; this.http.get(url).subscribe( response => { this.ogLives = response['hydra:member']; @@ -104,7 +104,7 @@ export class CreateClientComponent implements OnInit { const formData = this.clientForm.value; formData.ogLive = formData.ogLive; console.log('Form data:', formData ); - this.http.post('http://127.0.0.1:8080/clients', formData).subscribe( + this.http.post('http://127.0.0.1:8081/clients', formData).subscribe( response => { this.dialogRef.close(response); this.openSnackBar(false, 'Cliente creado exitosamente'); diff --git a/ogWebconsole/src/app/components/groups/clients/edit-client/edit-client.component.ts b/ogWebconsole/src/app/components/groups/clients/edit-client/edit-client.component.ts index a6013f2..e2c54ad 100644 --- a/ogWebconsole/src/app/components/groups/clients/edit-client/edit-client.component.ts +++ b/ogWebconsole/src/app/components/groups/clients/edit-client/edit-client.component.ts @@ -60,7 +60,7 @@ export class EditClientComponent { } loadParentUnits() { - const url = 'http://127.0.0.1:8080/organizational-units?page=1&itemsPerPage=10000'; + const url = 'http://127.0.0.1:8081/organizational-units?page=1&itemsPerPage=10000'; this.http.get(url).subscribe( response => { @@ -84,7 +84,7 @@ export class EditClientComponent { } loadOgLives(): void { - const url = 'http://127.0.0.1:8080/og-lives?page=1&itemsPerPage=10000'; + const url = 'http://127.0.0.1:8081/og-lives?page=1&itemsPerPage=10000'; this.http.get(url).subscribe( response => { @@ -98,7 +98,7 @@ export class EditClientComponent { loadData(uuid: string) { this.loading = true; - const url = `http://127.0.0.1:8080/clients/${uuid}`; + const url = `http://127.0.0.1:8081/clients/${uuid}`; this.http.get(url).subscribe( data => { @@ -129,7 +129,7 @@ export class EditClientComponent { if (this.isEditMode) { // Edit mode: Send PUT request to update the unit - const putUrl = `http://127.0.0.1:8080/clients/${this.data.uuid}`; + const putUrl = `http://127.0.0.1:8081/clients/${this.data.uuid}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); this.http.patch(putUrl, formData, { headers }).subscribe( @@ -146,7 +146,7 @@ export class EditClientComponent { ); } else { // Create mode: Send POST request to create a new unit - const postUrl = 'http://127.0.0.1:8080/clients'; + const postUrl = 'http://127.0.0.1:8081/clients'; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); this.http.post(postUrl, formData, { headers }).subscribe( diff --git a/ogWebconsole/src/app/components/groups/data.service.ts b/ogWebconsole/src/app/components/groups/data.service.ts index 22b5293..66f40db 100644 --- a/ogWebconsole/src/app/components/groups/data.service.ts +++ b/ogWebconsole/src/app/components/groups/data.service.ts @@ -9,8 +9,8 @@ import { UnidadOrganizativa } from './model'; }) export class DataService { - private apiUrl = 'http://127.0.0.1:8080/organizational-units?page=1&itemsPerPage=1000'; - private clientsUrl = 'http://127.0.0.1:8080/clients?page=1&itemsPerPage=1000'; + private apiUrl = 'http://127.0.0.1:8001/organizational-units?page=1&itemsPerPage=1000'; + private clientsUrl = 'http://127.0.0.1:8001/clients?page=1&itemsPerPage=1000'; constructor(private http: HttpClient) {} @@ -68,7 +68,7 @@ export class DataService { } getHardwareProfiles(): Observable { - const url = 'http://127.0.0.1:8080/hardware-profiles'; + const url = 'http://127.0.0.1:8001/hardware-profiles'; return this.http.get(url).pipe( map(response => { if (response['hydra:member'] && Array.isArray(response['hydra:member'])) { @@ -86,8 +86,8 @@ export class DataService { deleteElement(uuid: string, type: string): Observable { const url = type === 'client' - ? `http://127.0.0.1:8080/clients/${uuid}` - : `http://127.0.0.1:8080/organizational-units/${uuid}`; + ? `http://127.0.0.1:8001/clients/${uuid}` + : `http://127.0.0.1:8001/organizational-units/${uuid}`; return this.http.delete(url).pipe( catchError(error => { console.error('Error deleting element', error); @@ -97,7 +97,7 @@ export class DataService { } changeParent(uuid: string): Observable { - const url = `http://127.0.0.1:8080/organizational-units/${uuid}/change-parent`; + const url = `http://127.0.0.1:8001/organizational-units/${uuid}/change-parent`; // @ts-ignore return this.http.post(url).pipe( catchError(error => { @@ -141,7 +141,7 @@ export class DataService { } getFilters(): Observable { - return this.http.get('http://127.0.0.1:8080/views?page=1&itemsPerPage=30').pipe( + return this.http.get('http://127.0.0.1:8001/views?page=1&itemsPerPage=30').pipe( map(response => { if (response['hydra:member'] && Array.isArray(response['hydra:member'])) { return response['hydra:member']; @@ -157,7 +157,7 @@ export class DataService { } getFilter(id: string): Observable { - return this.http.get('http://127.0.0.1:8080/views/' + id).pipe( + return this.http.get('http://127.0.0.1:8001/views/' + id).pipe( map(response => { diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 547b3c2..b717117 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -341,7 +341,7 @@ export class GroupsComponent implements OnInit { } }; - this.http.post('http://127.0.0.1:8080/views', filters).subscribe(response => { + this.http.post('http://127.0.0.1:8081/views', filters).subscribe(response => { console.log('Response from server:', response); this.toastService.success('Se ha guardado el filtro correctamente'); }, error => { @@ -353,7 +353,7 @@ export class GroupsComponent implements OnInit { } loadSelectedFilter(savedFilter: any) { - const url = 'http://127.0.0.1:8080/views/' + savedFilter[1]; + const url = 'http://127.0.0.1:8081/views/' + savedFilter[1]; console.log('llamando a:', url); this.dataService.getFilter(savedFilter[1]).subscribe(response => { diff --git a/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.html b/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.html index e076917..55ea6fc 100644 --- a/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.html +++ b/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.html @@ -75,6 +75,15 @@
Configuración de Red + + NextServer + + + + bootFileName + + + Url servidor Proxy diff --git a/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.ts index 61d38cc..dd6b1de 100644 --- a/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/organizational-units/create-organizational-unit/create-organizational-unit.component.ts @@ -42,7 +42,7 @@ export class CreateOrganizationalUnitComponent implements OnInit { private http: HttpClient, private toastService: ToastrService, private dataService: DataService, - @Inject(MAT_DIALOG_DATA) public data: any // Inject data for edit mode + @Inject(MAT_DIALOG_DATA) public data: any ) { this.generalFormGroup = this._formBuilder.group({ name: ['', Validators.required], @@ -54,6 +54,8 @@ export class CreateOrganizationalUnitComponent implements OnInit { comments: [''], }); this.networkSettingsFormGroup = this._formBuilder.group({ + nextServer: [''], + bootFileName: [''], proxy: [''], dns: [''], netmask: [''], @@ -65,8 +67,8 @@ export class CreateOrganizationalUnitComponent implements OnInit { mcastSpeed: [0, Validators.min(0)], mcastPort: [0, Validators.min(0)], mcastMode: [''], - menu: [null], - hardwareProfile: [null], + menu: [''], + hardwareProfile: [''], validation: [false] }); this.classroomInfoFormGroup = this._formBuilder.group({ @@ -83,7 +85,7 @@ export class CreateOrganizationalUnitComponent implements OnInit { } loadParentUnits() { - const url = 'http://127.0.0.1:8080/organizational-units?page=1&itemsPerPage=10000'; + const url = 'http://127.0.0.1:8001/organizational-units?page=1&itemsPerPage=10000'; this.http.get(url).subscribe( response => { @@ -126,21 +128,13 @@ export class CreateOrganizationalUnitComponent implements OnInit { const formData: any = { ...generalFormValues, + ...classroomInfoFormValues, comments: additionalInfoFormValues.comments, networkSettings: { ...networkSettingsFormValues } }; - if (this.generalFormGroup.value.type === 'classroom') { - formData.location = classroomInfoFormValues.location; - formData.projector = classroomInfoFormValues.projector; - formData.board = classroomInfoFormValues.board; - if (classroomInfoFormValues.capacity !== undefined) { - formData.capacity = classroomInfoFormValues.capacity; - } - } - console.log('POST data:', formData); - const postUrl = 'http://127.0.0.1:8080/organizational-units'; + const postUrl = 'http://127.0.0.1:8001/organizational-units'; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); this.http.post(postUrl, formData, { headers }).subscribe( diff --git a/ogWebconsole/src/app/components/groups/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts index 74564f8..2710325 100644 --- a/ogWebconsole/src/app/components/groups/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts @@ -88,7 +88,7 @@ export class EditOrganizationalUnitComponent implements OnInit { } loadParentUnits() { - const url = 'http://127.0.0.1:8080/organizational-units?page=1&itemsPerPage=10000'; + const url = 'http://127.0.0.1:8081/organizational-units?page=1&itemsPerPage=10000'; this.http.get(url).subscribe( response => { @@ -112,7 +112,7 @@ export class EditOrganizationalUnitComponent implements OnInit { } loadData(uuid: string) { - const url = `http://127.0.0.1:8080/organizational-units/${uuid}`; + const url = `http://127.0.0.1:8081/organizational-units/${uuid}`; this.http.get(url).subscribe( data => { @@ -172,7 +172,7 @@ export class EditOrganizationalUnitComponent implements OnInit { if (this.isEditMode) { // Edit mode: Send PUT request to update the unit - const putUrl = `http://127.0.0.1:8080/organizational-units/${this.data.uuid}`; + const putUrl = `http://127.0.0.1:8081/organizational-units/${this.data.uuid}`; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); this.http.put(putUrl, formData, { headers }).subscribe( @@ -187,7 +187,7 @@ export class EditOrganizationalUnitComponent implements OnInit { ); } else { // Create mode: Send POST request to create a new unit - const postUrl = 'http://127.0.0.1:8080/organizational-units'; + const postUrl = 'http://127.0.0.1:8081/organizational-units'; const headers = new HttpHeaders({ 'Content-Type': 'application/json' }); this.http.post(postUrl, formData, { headers }).subscribe( diff --git a/ogWebconsole/src/app/components/login/login.component.ts b/ogWebconsole/src/app/components/login/login.component.ts index 8dc2c09..a689b36 100644 --- a/ogWebconsole/src/app/components/login/login.component.ts +++ b/ogWebconsole/src/app/components/login/login.component.ts @@ -43,7 +43,7 @@ export class LoginComponent { return; } - this.http.post('http://127.0.0.1:8080/auth/login', this.loginObj).subscribe({ + this.http.post('http://127.0.0.1:8001/auth/login', this.loginObj).subscribe({ next: (res: any) => { if (res.token) { localStorage.setItem('loginToken', res.token); diff --git a/ogWebconsole/src/app/components/ogboot/images/create-image/create-image/create-image.component.ts b/ogWebconsole/src/app/components/ogboot/images/create-image/create-image/create-image.component.ts index 0726926..c6517d6 100644 --- a/ogWebconsole/src/app/components/ogboot/images/create-image/create-image/create-image.component.ts +++ b/ogWebconsole/src/app/components/ogboot/images/create-image/create-image/create-image.component.ts @@ -33,7 +33,7 @@ export class CreateImageComponent implements OnInit { } fetchDownloads(): void { - this.http.get('http://127.0.0.1:8080/og-lives/server/get-isos?page=1&itemsPerPage=30') + this.http.get('http://127.0.0.1:8081/og-lives/server/get-isos?page=1&itemsPerPage=30') .subscribe({ next: (response: any) => { this.downloads = response.data.downloads; @@ -56,7 +56,7 @@ export class CreateImageComponent implements OnInit { }; if (this.isEditMode && this.imageId) { - this.http.patch(`http://127.0.0.1:8080/og-lives/${this.imageId}`, payload) + this.http.patch(`http://127.0.0.1:8081/og-lives/${this.imageId}`, payload) .subscribe({ next: (response) => { this.toastService.success('Image updated successfully'); @@ -68,7 +68,7 @@ export class CreateImageComponent implements OnInit { } }); } else { - this.http.post('http://127.0.0.1:8080/og-lives', payload) + this.http.post('http://127.0.0.1:8081/og-lives', payload) .subscribe({ next: (response) => { this.toastService.success('Image created successfully'); diff --git a/ogWebconsole/src/app/components/ogboot/images/data.service.ts b/ogWebconsole/src/app/components/ogboot/images/data.service.ts index 44ded6f..72d2ea5 100644 --- a/ogWebconsole/src/app/components/ogboot/images/data.service.ts +++ b/ogWebconsole/src/app/components/ogboot/images/data.service.ts @@ -7,7 +7,7 @@ import { catchError, map } from 'rxjs/operators'; providedIn: 'root' }) export class DataService { - private apiUrl = 'http://127.0.0.1:8080/og-lives?page=1&itemsPerPage=1000'; + private apiUrl = 'http://127.0.0.1:8081/og-lives?page=1&itemsPerPage=1000'; constructor(private http: HttpClient) {} diff --git a/ogWebconsole/src/app/components/ogboot/images/images.component.ts b/ogWebconsole/src/app/components/ogboot/images/images.component.ts index fd27643..20eb895 100644 --- a/ogWebconsole/src/app/components/ogboot/images/images.component.ts +++ b/ogWebconsole/src/app/components/ogboot/images/images.component.ts @@ -62,7 +62,7 @@ export class ImagesComponent implements OnInit { ]; displayedColumns = [...this.columns.map(column => column.columnDef), 'actions']; - private apiUrl = 'http://127.0.0.1:8080/og-lives'; + private apiUrl = 'http://127.0.0.1:8081/og-lives'; constructor( public dialog: MatDialog, diff --git a/ogWebconsole/src/app/components/ogboot/ogboot-status/ogboot-status.component.ts b/ogWebconsole/src/app/components/ogboot/ogboot-status/ogboot-status.component.ts index 0dd8d3f..4a478b1 100644 --- a/ogWebconsole/src/app/components/ogboot/ogboot-status/ogboot-status.component.ts +++ b/ogWebconsole/src/app/components/ogboot/ogboot-status/ogboot-status.component.ts @@ -30,7 +30,7 @@ export class OgbootStatusComponent implements OnInit { } loadStatus(): void { - this.http.get('http://127.0.0.1:8080/og-boot/status').subscribe(data => { + this.http.get('http://127.0.0.1:8081/og-boot/status').subscribe(data => { this.diskUsage = data.disk_usage; this.servicesStatus = data.services_status; this.installedOglives = data.installed_oglives; diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/create-pxeBootFile/create-pxe-boot-file/create-pxe-boot-file.component.ts b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/create-pxeBootFile/create-pxe-boot-file/create-pxe-boot-file.component.ts index ae04295..1d1770a 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/create-pxeBootFile/create-pxe-boot-file/create-pxe-boot-file.component.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/create-pxeBootFile/create-pxe-boot-file/create-pxe-boot-file.component.ts @@ -39,7 +39,7 @@ export class CreatePxeBootFileComponent implements OnInit { } loadPxeTemplates(): void { - this.http.get('http://127.0.0.1:8080/pxe-templates?page=1&itemsPerPage=30') + this.http.get('http://127.0.0.1:8081/pxe-templates?page=1&itemsPerPage=30') .subscribe((response: any) => { this.pxeTemplates = response['hydra:member']; }, error => { @@ -60,7 +60,7 @@ export class CreatePxeBootFileComponent implements OnInit { if (this.isEditMode && this.data.bootFile) { // Edit mode: Actualizar boot file existente - this.http.put(`http://127.0.0.1:8080/pxe-boot-files/${this.data.bootFile.uuid}`, payload) + this.http.put(`http://127.0.0.1:8081/pxe-boot-files/${this.data.bootFile.uuid}`, payload) .subscribe({ next: response => { this.toastService.success('PXE actualizado con éxito'); @@ -72,7 +72,7 @@ export class CreatePxeBootFileComponent implements OnInit { }); } else { // Create mode: Crear nuevo boot file - this.http.post('http://127.0.0.1:8080/pxe-boot-files', payload) + this.http.post('http://127.0.0.1:8081/pxe-boot-files', payload) .subscribe({ next: response => { this.toastService.success('PXE asignado con éxito'); diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/data.service.ts b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/data.service.ts index 545f8aa..1af8c4a 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/data.service.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/data.service.ts @@ -8,7 +8,7 @@ import { DataService as TemplateDataService } from './../pxe/data.service'; providedIn: 'root' }) export class DataService { - private apiUrl = 'http://127.0.0.1:8080/pxe-boot-files?page=1&itemsPerPage=1000'; + private apiUrl = 'http://127.0.0.1:8081/pxe-boot-files?page=1&itemsPerPage=1000'; constructor( private http: HttpClient, diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts index 2b0416e..13ca398 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.ts @@ -51,7 +51,7 @@ export class PxeBootFilesComponent { ]; displayedColumns = [...this.columns.map(column => column.columnDef), 'actions']; - private apiUrl = 'http://127.0.0.1:8080/pxe-boot-files'; + private apiUrl = 'http://127.0.0.1:8081/pxe-boot-files'; constructor( public dialog: MatDialog, diff --git a/ogWebconsole/src/app/components/ogboot/pxe/create-pxeTemplate/create-pxe-template.component.ts b/ogWebconsole/src/app/components/ogboot/pxe/create-pxeTemplate/create-pxe-template.component.ts index 708b190..d204962 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe/create-pxeTemplate/create-pxe-template.component.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe/create-pxeTemplate/create-pxe-template.component.ts @@ -46,7 +46,7 @@ export class CreatePxeTemplateComponent implements OnInit { templateContent: formValues.templateContent }; - this.http.post('http://127.0.0.1:8080/pxe-templates', payload).subscribe({ + this.http.post('http://127.0.0.1:8081/pxe-templates', payload).subscribe({ next: data => { console.log('Plantilla PXE creada:', data); this.toastService.success('Plantilla PXE creada exitosamente'); @@ -67,7 +67,7 @@ export class CreatePxeTemplateComponent implements OnInit { templateContent: formValues.templateContent }; - this.http.patch(`http://127.0.0.1:8080/pxe-templates/${this.data.uuid}`, payload).subscribe({ + this.http.patch(`http://127.0.0.1:8081/pxe-templates/${this.data.uuid}`, payload).subscribe({ next: data => { console.log('Plantilla PXE actualizada:', data); this.toastService.success('Plantilla PXE actualizada exitosamente'); diff --git a/ogWebconsole/src/app/components/ogboot/pxe/data.service.ts b/ogWebconsole/src/app/components/ogboot/pxe/data.service.ts index b5d4a1a..74828e0 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe/data.service.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe/data.service.ts @@ -8,7 +8,7 @@ import { catchError, map } from 'rxjs/operators'; providedIn: 'root' }) export class DataService { - private apiUrl = 'http://127.0.0.1:8080/pxe-templates?page=1&itemsPerPage=1000'; + private apiUrl = 'http://127.0.0.1:8081/pxe-templates?page=1&itemsPerPage=1000'; constructor(private http: HttpClient) {} diff --git a/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts b/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts index 6fbd752..d7cb448 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts +++ b/ogWebconsole/src/app/components/ogboot/pxe/pxe.component.ts @@ -53,7 +53,7 @@ export class PxeComponent { ]; displayedColumns = [...this.columns.map(column => column.columnDef), 'actions']; - private apiUrl = 'http://127.0.0.1:8080/pxe-templates'; + private apiUrl = 'http://127.0.0.1:8081/pxe-templates'; constructor( public dialog: MatDialog, diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css index 4525d20..6be2509 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.css @@ -1,4 +1,8 @@ .full-width { width: 100%; } - \ No newline at end of file + + form{ + + padding: 20px; + } \ No newline at end of file diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html index a99f009..2fcc08a 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.html @@ -1,27 +1,70 @@

{{ isEditMode ? 'Editar' : 'Añadir' }} configuración de red

- - - Nombre - - - - Netmask - - - - Dirección IP - - - - Next Server - - - - Boot File Name - - - - - - - + + + + + + Seleccionar Aulas + + Seleccionar Aulas + + {{ aula.name }} + + +
+ +
+ +
+ + + +
+ Configurar Subnet + +
+

Aulas Seleccionadas:

+
    +
  • {{ aula.name }}
  • +
+
+ + + Nombre + + + + + Next Server + + {{ server }} + + + + + Boot File Name + + {{ bootFile }} + + + + + + + Netmask + + + + + Dirección IP + + + +
+ + +
+
+
+ +
diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts index 9980986..55713c4 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet/create-subnet.component.ts @@ -1,6 +1,6 @@ -// create-subnet.component.ts import { HttpClient } from '@angular/common/http'; import { Component, Inject, OnInit } from '@angular/core'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; @@ -10,46 +10,103 @@ import { ToastrService } from 'ngx-toastr'; styleUrls: ['./create-subnet.component.css'] }) export class CreateSubnetComponent implements OnInit { - name: string = ''; - netmask: string = ''; - ipAddress: string = ''; - nextServer: string = ''; - bootFileName: string = ''; - isEditMode: boolean = false; + aulasForm: FormGroup; + subnetForm: FormGroup; + + aulas: any[] = []; // Lista de aulas + selectedAulas: any[] = []; // Aulas seleccionadas + nextServerOptions: string[] = []; // Opciones de Next Server + bootFileNameOptions: string[] = []; // Opciones de Boot File Name + isEditMode: boolean = false; constructor( + private fb: FormBuilder, // FormBuilder para manejar los formularios private toastService: ToastrService, private http: HttpClient, public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any - ) { } + ) { + // Inicializar los formularios + this.aulasForm = this.fb.group({ + selectedAulas: [[], Validators.required] + }); + + this.subnetForm = this.fb.group({ + name: ['', Validators.required], + netmask: ['', Validators.required], + ipAddress: ['', Validators.required], + nextServer: ['', Validators.required], + bootFileName: ['', Validators.required] + }); + } ngOnInit(): void { + this.loadAulas(); // Cargar las aulas al iniciar el componente + if (this.data && this.data.subnet) { this.isEditMode = true; - this.name = this.data.subnet.name; - this.netmask = this.data.subnet.netmask; - this.ipAddress = this.data.subnet.ipAddress; - this.nextServer = this.data.subnet.nextServer; - this.bootFileName = this.data.subnet.bootFileName; + this.subnetForm.patchValue({ + name: this.data.subnet.name, + netmask: this.data.subnet.netmask, + ipAddress: this.data.subnet.ipAddress, + nextServer: this.data.subnet.nextServer, + bootFileName: this.data.subnet.bootFileName + }); + this.selectedAulas = this.data.subnet.selectedAulas || []; + this.updateServerAndBootFileOptions(); } } + loadAulas(): void { + this.http.get('http://127.0.0.1:8001/organizational-units?page=1&itemsPerPage=30') + .subscribe(response => { + this.aulas = response['hydra:member']; + }, error => { + console.error('Error loading aulas:', error); + this.toastService.error('Error al cargar las aulas'); + }); + } + + onAulasSelectionChange(event: any): void { + this.selectedAulas = event.value; + this.updateServerAndBootFileOptions(); + } + + updateServerAndBootFileOptions(): void { + // Vaciar las opciones previas + this.nextServerOptions = []; + this.bootFileNameOptions = []; + + // Agregar las opciones de "nextServer" y "bootFileName" basadas en las aulas seleccionadas + this.selectedAulas.forEach(aula => { + if (aula.networkSettings) { + if (aula.networkSettings.nextServer && !this.nextServerOptions.includes(aula.networkSettings.nextServer)) { + this.nextServerOptions.push(aula.networkSettings.nextServer); + } + if (aula.networkSettings.bootFileName && !this.bootFileNameOptions.includes(aula.networkSettings.bootFileName)) { + this.bootFileNameOptions.push(aula.networkSettings.bootFileName); + } + } + }); + } + onNoClick(): void { this.dialogRef.close(); } submitForm(): void { + if (this.aulasForm.invalid || this.subnetForm.invalid) { + this.toastService.error('Por favor, complete los formularios.'); + return; + } + const payload = { - name: this.name, - netmask: this.netmask, - ipAddress: this.ipAddress, - nextServer: this.nextServer, - bootFileName: this.bootFileName + ...this.subnetForm.value, + /* selectedAulas: this.selectedAulas.map(aula => aula.uuid) */// Enviar solo los UUID de las aulas seleccionadas }; if (this.isEditMode) { - this.http.patch(`http://127.0.0.1:8080/subnets/${this.data.subnet.uuid}`, payload) + this.http.patch(`http://127.0.0.1:8001/subnets/${this.data.subnet.uuid}`, payload) .subscribe({ next: (response) => { console.log('Success:', response); @@ -62,7 +119,8 @@ export class CreateSubnetComponent implements OnInit { } }); } else { - this.http.post('http://127.0.0.1:8080/subnets', payload) + + this.http.post('http://127.0.0.1:8001/subnets', payload) .subscribe({ next: (response) => { console.log('Success:', response); @@ -73,7 +131,7 @@ export class CreateSubnetComponent implements OnInit { console.error('Error:', error); this.toastService.error('Error al añadir la configuración de red'); } - }); + }); } } } diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts index 8e6ab98..70da356 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component.ts @@ -53,7 +53,7 @@ export class OgDhcpSubnetsComponent { } loadSubnets() { - this.http.get(`http://127.0.0.1:8080/subnets?page=1&itemsPerPage=${this.itemsPerPage}`).subscribe({ + this.http.get(`http://127.0.0.1:8001/subnets?page=1&itemsPerPage=${this.itemsPerPage}`).subscribe({ next: (response) => { this.dataSource.data = response['hydra:member']; this.length = response['hydra:totalItems']; @@ -80,6 +80,7 @@ export class OgDhcpSubnetsComponent { dialogRef.afterClosed().subscribe(result => { console.log('The dialog was closed'); + this.loadSubnets() }); } @@ -92,6 +93,7 @@ export class OgDhcpSubnetsComponent { dialogRef.afterClosed().subscribe(result => { console.log('The dialog was closed'); + this.loadSubnets() }); } @@ -104,7 +106,7 @@ export class OgDhcpSubnetsComponent { dialogRef.afterClosed().subscribe(result => { if (result) { - const apiUrl = `http://127.0.0.1:8080${subnet['@id']}`; + const apiUrl = `http://127.0.0.1:8081${subnet['@id']}`; this.http.delete(apiUrl).subscribe({ next: () => {