From e3cf6a85d0edd7ebbcb4a9e0d7aabec21891781b Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Thu, 5 Dec 2024 12:50:15 +0100 Subject: [PATCH] Added router in subnet. Advanced bootfile changes, and partition assistant updates --- .../task-logs/task-logs.component.css | 4 +- .../client-main-view.component.css | 3 +- .../client-main-view.component.ts | 33 ++++---- .../deploy-image/deploy-image.component.html | 2 +- .../deploy-image/deploy-image.component.ts | 21 ++++- .../partition-assistant.component.ts | 2 +- .../components/groups/groups.component.html | 6 +- .../groups/services/data.service.ts | 42 +++++++++- .../create-organizational-unit.component.html | 16 ++++ .../create-organizational-unit.component.ts | 31 ++++++++ .../edit-organizational-unit.component.html | 20 ++++- .../edit-organizational-unit.component.ts | 46 ++++++++--- .../show-organizational-unit.component.ts | 62 ++++++++++----- .../components/images/images.component.css | 18 +++-- .../components/images/images.component.html | 9 ++- .../pxe-boot-files.component.html | 44 +++++------ .../pxe-boot-files.component.ts | 78 +++++-------------- .../create-subnet.component.html | 6 +- .../create-subnet/create-subnet.component.ts | 9 ++- .../og-dhcp-subnets.component.ts | 1 + ogWebconsole/src/locale/en.json | 1 + ogWebconsole/src/locale/es.json | 1 + 22 files changed, 296 insertions(+), 159 deletions(-) diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.css b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.css index 64e2e55..53254bd 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.css +++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.css @@ -71,12 +71,12 @@ table { } .chip-failed { - background-color: #f15d5d !important; + background-color: #e87979 !important; color: white; } .chip-success { - background-color: #32c532 !important; + background-color: #46c446 !important; color: white; } diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.css b/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.css index c1c12f0..533ab69 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.css +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.css @@ -247,9 +247,8 @@ } .charts-container { - flex: 2; + flex: 1; display: flex; - flex-direction: column; align-items: center; gap: 10px; } diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.ts index 6e9728b..95a3563 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/client-main-view.component.ts @@ -34,7 +34,7 @@ export class ClientMainViewComponent implements OnInit { partitions: any[] = []; commands: any[] = []; chartDisk: any[] = []; - view: [number, number] = [600, 300]; + view: [number, number] = [300, 200]; showLegend: boolean = true; arrayCommands: any[] = [ @@ -100,15 +100,28 @@ export class ClientMainViewComponent implements OnInit { } ngOnInit() { - this.clientData = history.state.clientData; - this.loadPartitions() - this.updateGeneralData(); - this.updateNetworkData(); + this.clientData = history.state.clientData['@id']; + this.loadClient(this.clientData) this.loadCommands() this.calculateDiskUsage(); this.loading = false; } + + loadClient = (uuid: string) => { + this.http.get(`${this.baseUrl}${uuid}`).subscribe({ + next: data => { + this.clientData = data; + this.updateGeneralData(); + this.updateNetworkData(); + this.loadPartitions() + this.loading = false; + }, + error: error => { + console.error('Error al obtener el cliente:', error); + } + }); + } updateGeneralData() { this.generalData = [ { property: 'Nombre', value: this.clientData?.name || '' }, @@ -184,15 +197,6 @@ export class ClientMainViewComponent implements OnInit { dialogRef.afterClosed().subscribe(); } - getStrokeOffset(partitions: any[], index: number): number { - const totalSize = partitions.reduce((acc, part) => acc + (part.size / 1024), 0); - - const offset = partitions.slice(0, index).reduce((acc, part) => acc + (part.size / 1024), 0); - console.log(offset, totalSize) - - return totalSize > 0 ? (offset / totalSize) : 0; - } - loadPartitions(): void { this.http.get(`${this.baseUrl}/partitions?client.id=${this.clientData?.id}&order[partitionNumber]=ASC`).subscribe({ next: data => { @@ -218,7 +222,6 @@ export class ClientMainViewComponent implements OnInit { } onCommandSelect(action: any): void { - console.log(action); if (action === 'partition') { this.openPartitionAssistant(); } diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html index e514d0b..eb9611c 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.html @@ -25,7 +25,7 @@ Seleccione método de deploy - {{ method }} + {{ method }} diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts index 2c48a74..2e9e25b 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/deploy-image/deploy-image.component.ts @@ -20,7 +20,7 @@ export class DeployImageComponent { images: any[] = []; clientName: string = ''; selectedImage: string | null = null; - selectedOption: string | null = null; + selectedOption: string | null = 'deploy-image'; selectedMethod: string | null = null; selectedPartition: any = null; mcastIp: string = ''; @@ -98,7 +98,7 @@ export class DeployImageComponent { ngOnInit() { this.clientId = this.route.snapshot.paramMap.get('id'); - + this.selectedOption = 'deploy-image'; this.loadPartitions(); this.loadImages(); } @@ -147,6 +147,21 @@ export class DeployImageComponent { } save(): void { + if (!this.selectedImage) { + this.toastService.error('Debe seleccionar una imagen'); + return; + } + + if (!this.selectedMethod) { + this.toastService.error('Debe seleccionar un método'); + return; + } + + if (!this.selectedPartition) { + this.toastService.error('Debe seleccionar una partición'); + return; + } + const payload = { client: `/clients/${this.clientId}`, method: this.selectedMethod, @@ -163,7 +178,7 @@ export class DeployImageComponent { .subscribe({ next: (response) => { this.toastService.success('Imagen creada exitosamente'); - this.router.navigate(['/images']); + this.router.navigate(['/commmands-logs']) }, error: (error) => { console.error('Error:', error); diff --git a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts index cab33a8..752a376 100644 --- a/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts +++ b/ogWebconsole/src/app/components/groups/components/client-main-view/partition-assistant/partition-assistant.component.ts @@ -289,7 +289,7 @@ export class PartitionAssistantComponent implements OnInit { this.http.post(this.apiUrl, bulkPayload).subscribe( (response) => { this.toastService.success('Particiones creadas exitosamente'); - this.router.navigate(['/traces']); + this.router.navigate(['/commands-logs']); }, (error) => { console.error('Error al crear las particiones:', error); diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index 85c1ad6..2dc00e3 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -218,7 +218,7 @@ sync Sincronizar - + - + - -
+
+
diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts index 1bc65e3..7f293ef 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/edit-organizational-unit/edit-organizational-unit.component.ts @@ -1,8 +1,8 @@ -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { CreateOrganizationalUnitComponent } from '../create-organizational-unit/create-organizational-unit.component'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {Component, EventEmitter, Inject, OnInit, Output} from '@angular/core'; +import {FormBuilder, FormGroup} from '@angular/forms'; +import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import {CreateOrganizationalUnitComponent} from '../create-organizational-unit/create-organizational-unit.component'; import {DataService} from "../../../services/data.service"; import {ToastrService} from "ngx-toastr"; @@ -23,6 +23,8 @@ export class EditOrganizationalUnitComponent implements OnInit { hardwareProfiles: any[] = []; isEditMode: boolean; currentCalendar: any = []; + ogLives: any[] = []; + repositories: any[] = []; protected p2pModeOptions = [ {"name": 'Leecher', "value": "p2p-mode-leecher"}, {"name": 'Peer', "value": "p2p-mode-peer"}, @@ -57,6 +59,8 @@ export class EditOrganizationalUnitComponent implements OnInit { }); this.networkSettingsFormGroup = this._formBuilder.group({ + ogLive: [null], + repository: [null], proxy: [null], dns: [null], netmask: [null], @@ -90,6 +94,8 @@ export class EditOrganizationalUnitComponent implements OnInit { this.loadParentUnits(); this.loadHardwareProfiles(); this.loadCalendars(); + this.loadOgLives(); + this.loadRepositories(); } loadParentUnits() { @@ -116,6 +122,20 @@ export class EditOrganizationalUnitComponent implements OnInit { ); } + loadOgLives() { + this.dataService.getOgLives().subscribe( + (data: any[]) => this.ogLives = data, + error => console.error('Error fetching ogLives', error) + ); + } + + loadRepositories() { + this.dataService.getRepositories().subscribe( + (data: any[]) => this.repositories = data, + error => console.error('Error fetching repositories', error) + ); + } + loadCalendars() { const apiUrl = `${this.baseUrl}/remote-calendars?page=1&itemsPerPage=30`; this.http.get(apiUrl).subscribe( @@ -138,9 +158,15 @@ export class EditOrganizationalUnitComponent implements OnInit { );} onCalendarChange(event: any) { - const selectedCalendarId = event.value; - console.log('Selected calendar ID:', selectedCalendarId); - this.generalFormGroup.value.remoteCalendar = selectedCalendarId; + this.generalFormGroup.value.remoteCalendar = event.value; + } + + onOgLiveChange(event: any) { + this.networkSettingsFormGroup.value.ogLive = event.value; + } + + onRepositoryChange(event: any) { + this.networkSettingsFormGroup.value.repository = event.value } loadData(uuid: string) { @@ -171,6 +197,8 @@ export class EditOrganizationalUnitComponent implements OnInit { mcastMode: data.networkSettings.mcastMode, menu: data.networkSettings.menu ? data.networkSettings.menu['@id'] : null, hardwareProfile: data.networkSettings.hardwareProfile ? data.networkSettings.hardwareProfile['@id'] : null, + ogLive: data.networkSettings.ogLive ? data.networkSettings.ogLive['@id'] : null, + repository: data.networkSettings.repository ? data.networkSettings.repository['@id'] : null, validation: data.networkSettings.validation }); this.classroomInfoFormGroup.patchValue({ @@ -245,5 +273,5 @@ export class EditOrganizationalUnitComponent implements OnInit { this.dialogRef.close(); } - + } diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/show-organizational-unit/show-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/show-organizational-unit/show-organizational-unit.component.ts index a62e1ee..14be025 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/show-organizational-unit/show-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/show-organizational-unit/show-organizational-unit.component.ts @@ -11,9 +11,9 @@ export class ShowOrganizationalUnitComponent { baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; displayedColumns: string[] = ['property', 'value']; currentCalendar: any; + ou: any; generalData: any[] = []; - networkData = [ - ]; + networkData: any[] = []; constructor( @Inject(MAT_DIALOG_DATA) public data: any, @@ -22,11 +22,22 @@ export class ShowOrganizationalUnitComponent { } ngOnInit(): void { - if (this.data.data.remoteCalendar) { - this.loadCurrentCalendar(this.data.data.remoteCalendar.uuid); - } else { - this.initializeGeneralData(); - } + this.loadOrganizationalUnit(this.data.data['@id']); + } + + loadOrganizationalUnit(uuid: string): void { + console.log(this.data['@id']) + const apiUrl = `${this.baseUrl}${uuid}`; + this.http.get(apiUrl).subscribe( + response => { + this.ou = response; + console.log('Organizational unit', this.ou); + this.initializeData(); + }, + error => { + console.error('Error loading organizational unit', error); + this.initializeData(); + }); } loadCurrentCalendar(uuid: string): void { @@ -34,26 +45,39 @@ export class ShowOrganizationalUnitComponent { this.http.get(apiUrl).subscribe( response => { this.currentCalendar = response.name; - this.initializeGeneralData(); + this.initializeData(); }, error => { console.error('Error loading current calendar', error); - this.initializeGeneralData(); + this.initializeData(); } ); } - initializeGeneralData(): void { + initializeData(): void { this.generalData = [ - { property: 'Nombre', value: this.data.data.name }, - { property: 'Uuid', value: this.data.data.uuid }, - { property: 'Descripción', value: this.data.data.description }, - { property: 'Comentarios', value: this.data.data.comments }, - { property: 'Tipo', value: this.data.data.type }, - { property: 'Unidad organizativa superior', value: this.data.data.parent ? this.data.data.parent.name : '-' }, - { property: 'Creado por', value: this.data.data.createdBy }, - { property: 'Creado el', value: this.data.data.createdAt }, - { property: 'Calendario asociado', value: this.data.data.remoteCalendar ? this.currentCalendar : '-' } + { property: 'Nombre', value: this.ou.name }, + { property: 'Uuid', value: this.ou.uuid }, + { property: 'Descripción', value: this.ou.description }, + { property: 'Comentarios', value: this.ou.comments }, + { property: 'Tipo', value: this.ou.type }, + { property: 'Unidad organizativa superior', value: this.ou.parent ? this.ou.parent.name : '-' }, + { property: 'Creado el', value: this.ou.createdAt }, ]; + + this.networkData = [ + { property: 'Calendario asociado', value: this.ou.remoteCalendar ? this.currentCalendar : '-' }, + { property: 'Aforo', value: this.ou.capacity }, + { property: 'Localización', value: this.ou.location }, + { property: 'Calendario', value: this.ou.calendar ? this.ou.calendar.name : '-' }, + { property: 'Proyector', value: this.ou.projector }, + { property: 'Pizarra', value: this.ou.board }, + { property: 'OgLive', value: this.ou.networkSettings.ogLive ? this.ou.networkSettings.ogLive.name : '-' }, + { property: 'Repositorio', value: this.ou.networkSettings.repository ? this.ou.networkSettings.repository.name : '-' }, + { property: 'OgLog', value: this.ou.networkSettings.oglog }, + { property: 'OgShare', value: this.ou.networkSettings.ogshare }, + { property: 'Perfil de hardware', value: this.ou.networkSettings.hardwareProfile ? this.ou.networkSettings.hardwareProfile.name : '-' }, + { property: 'Máscara de red', value: this.ou.networkSettings.netmask }, + ] } } diff --git a/ogWebconsole/src/app/components/images/images.component.css b/ogWebconsole/src/app/components/images/images.component.css index 6c78292..50f0f3a 100644 --- a/ogWebconsole/src/app/components/images/images.component.css +++ b/ogWebconsole/src/app/components/images/images.component.css @@ -71,19 +71,23 @@ table { margin: 8px 8px 8px 0; } -.status-success { - background-color: #4caf50; /* Verde */ +.chip-failed { + background-color: #e87979 !important; color: white; } -.status-failed { - background-color: #f44336; /* Rojo */ +.chip-success { + background-color: #46c446 !important; color: white; } -.status-pending { - background-color: #ff9800; /* Naranja */ +.chip-pending { + background-color: lightgrey !important; + color: black; +} + +.chip-in-progress { + background-color: #f5a623 !important; color: white; } - diff --git a/ogWebconsole/src/app/components/images/images.component.html b/ogWebconsole/src/app/components/images/images.component.html index 071d165..235fdb9 100644 --- a/ogWebconsole/src/app/components/images/images.component.html +++ b/ogWebconsole/src/app/components/images/images.component.html @@ -32,7 +32,12 @@ - + {{ getStatusLabel(image[column.columnDef]) }} @@ -54,7 +59,7 @@ menu - + diff --git a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html index c9ae5c5..19cc3ac 100644 --- a/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html +++ b/ogWebconsole/src/app/components/ogboot/pxe-boot-files/pxe-boot-files.component.html @@ -8,30 +8,14 @@
- - {{ 'selectUnitLabel' | translate }} - - {{ 'loadingUnitsOption' | translate }} - - {{ unit.name }} - - - - {{ 'requiredFieldError' | translate }} - - - - - {{ 'selectClassLabel' | translate }} - - - {{ 'noClassesOption' | translate }} - - - {{ child.name }} - - - +
+ + {{ 'selectClassLabel' | translate }} + + {{ unit.name }} + + +
@@ -49,7 +33,7 @@ - + diff --git a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts index a0d5ef4..ada8414 100644 --- a/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts +++ b/ogWebconsole/src/app/components/ogdhcp/og-dhcp-subnets/create-subnet/create-subnet.component.ts @@ -17,6 +17,7 @@ export class CreateSubnetComponent implements OnInit { ipAddress: string = ''; nextServer: string = ''; bootFileName: string = ''; + router: string = ''; syncronized: boolean = false; serverId: number = 0; clients: any[] = []; @@ -44,6 +45,7 @@ export class CreateSubnetComponent implements OnInit { this.ipAddress = this.data.ipAddress; this.nextServer = this.data.nextServer; this.bootFileName = this.data.bootFileName; + this.router = this.data.router; this.syncronized = this.data.syncronized; this.serverId = this.data.serverId; this.clients = this.data.clients @@ -53,13 +55,14 @@ export class CreateSubnetComponent implements OnInit { this.dialogRef.close(); } - addNetworkConfig(): void { + save(): void { const payload = { name: this.name, netmask: this.netmask, ipAddress: this.ipAddress, - nextServer: this.nextServer || null, - bootFileName: this.bootFileName || null + router: this.router || null, + nextServer: this.nextServer || null, + bootFileName: this.bootFileName || null }; if (!this.data){ 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 dfec859..6305bda 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 @@ -18,6 +18,7 @@ export interface Subnet { netmask: string; ipAddress: string; nextServer: string; + router: string; bootFileName: string; synchronized: boolean; serverId: number; diff --git a/ogWebconsole/src/locale/en.json b/ogWebconsole/src/locale/en.json index 59fe4cd..fd2e26c 100644 --- a/ogWebconsole/src/locale/en.json +++ b/ogWebconsole/src/locale/en.json @@ -232,6 +232,7 @@ "editClientDialogTitle": "Edit Client", "organizationalUnitLabel": "Parent", "ogLiveLabel": "OgLive", + "repositoryLabel": "Repository", "serialNumberLabel": "Serial Number", "netifaceLabel": "Network interface", "netDriverLabel": "Network driver", diff --git a/ogWebconsole/src/locale/es.json b/ogWebconsole/src/locale/es.json index b13e8b4..e571e59 100644 --- a/ogWebconsole/src/locale/es.json +++ b/ogWebconsole/src/locale/es.json @@ -233,6 +233,7 @@ "editClientDialogTitle": "Editar Cliente", "organizationalUnitLabel": "Padre", "ogLiveLabel": "OgLive", + "repositoryLabel": "Repositorio", "serialNumberLabel": "Número de Serie", "netifaceLabel": "Interfaz de red", "netDriverLabel": "Controlador de red",