refs #1048. Updated client view and partition assistant
parent
bbbaeb87fa
commit
60a96170e1
|
|
@ -1,3 +1,10 @@
|
||||||
|
.header-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.client-header {
|
.client-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -18,6 +25,45 @@
|
||||||
min-height: 120px;
|
min-height: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.row-container {
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-container {
|
||||||
|
padding-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.charts-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.charts-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: space-between; /* Distribuye el espacio entre los gráficos */
|
||||||
|
gap: 20px; /* Añade espacio entre los gráficos */
|
||||||
|
}
|
||||||
|
|
||||||
|
.disk-usage {
|
||||||
|
text-align: center;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 200px; /* Ajusta este valor según el tamaño mínimo deseado para cada gráfico */
|
||||||
|
}
|
||||||
|
|
||||||
|
.circular-chart {
|
||||||
|
max-width: 150px;
|
||||||
|
max-height: 150px;
|
||||||
|
margin: 0 auto; /* Centra el gráfico dentro del contenedor */
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.icon-pc {
|
.icon-pc {
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
color: #3b82f6;
|
color: #3b82f6;
|
||||||
|
|
@ -43,7 +89,6 @@
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.two-column-table {
|
.two-column-table {
|
||||||
|
|
@ -53,6 +98,10 @@
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mat-elevation-z8 {
|
||||||
|
box-shadow: 0px 0px 0px rgba(0,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
.table-row {
|
.table-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
@ -92,7 +141,6 @@
|
||||||
|
|
||||||
.second-section {
|
.second-section {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 3fr;
|
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,24 +159,6 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disk-usage {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
flex-direction: column;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.chart-container {
|
|
||||||
width: 150px;
|
|
||||||
height: 150px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.circular-chart {
|
.circular-chart {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
<div class="header-container">
|
||||||
|
<h2 class="title" i18n="@@adminImagesTitle">Datos de cliente</h2>
|
||||||
|
<div class="calendar-button-row">
|
||||||
|
<button mat-flat-button color="primary" [matMenuTriggerFor]="commandMenu">Comandos</button>
|
||||||
|
</div>
|
||||||
|
<mat-menu #commandMenu="matMenu">
|
||||||
|
<button mat-menu-item *ngFor="let command of commands" (click)="onCommandSelect(command)">
|
||||||
|
{{ command.name }}
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
||||||
|
</div>
|
||||||
<div class="client-info">
|
<div class="client-info">
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<mat-tab-group dynamicHeight>
|
<mat-tab-group dynamicHeight>
|
||||||
|
|
@ -17,54 +28,56 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="Propiedades del aula">
|
|
||||||
<div class="two-column-table">
|
|
||||||
<div class="table-row" *ngFor="let clientData of classroomData">
|
|
||||||
<div class="column property">{{ clientData?.property }}</div>
|
|
||||||
<div class="column value">{{ clientData?.value }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</mat-tab>
|
|
||||||
</mat-tab-group>
|
</mat-tab-group>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="second-section">
|
<div class="header-container">
|
||||||
<div class="buttons-row">
|
<h2 class="title" i18n="@@adminImagesTitle">Discos/Particiones</h2>
|
||||||
<button mat-flat-button color="primary" (click)="togglePartitionAssistant()">Asistente a particionado</button>
|
</div>
|
||||||
<button mat-flat-button color="primary" (click)="showBootImage()">Restaurar imagen</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="info-section">
|
<div class="table-container">
|
||||||
<h2 *ngIf="isDiskUsageVisible">Disco</h2>
|
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
|
||||||
<ng-container *ngIf="diskUsageData && diskUsageData.length > 0">
|
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
|
||||||
|
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th>
|
||||||
|
<td mat-cell *matCellDef="let image" >
|
||||||
|
<ng-container *ngIf="column.columnDef !== 'size'">
|
||||||
|
{{ column.cell(image) }}
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="column.columnDef === 'size'">
|
||||||
|
<mat-chip color="primary" >
|
||||||
|
{{ (image.size / 1024).toFixed(2) }} GB
|
||||||
|
</mat-chip>
|
||||||
|
</ng-container>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="charts-wrapper">
|
||||||
|
<ng-container *ngIf="diskUsageData && diskUsageData.length > 0">
|
||||||
|
<div class="charts-row">
|
||||||
<div *ngFor="let disk of diskUsageData" class="disk-usage">
|
<div *ngFor="let disk of diskUsageData" class="disk-usage">
|
||||||
<h3>Disco {{ disk.diskNumber }}</h3>
|
<h3>Disco {{ disk.diskNumber }}</h3>
|
||||||
<div class="chart-container">
|
<div class="chart">
|
||||||
<svg viewBox="0 0 36 36" class="circular-chart green">
|
<svg viewBox="0 0 36 36" class="circular-chart green">
|
||||||
<path class="circle-bg"
|
<path class="circle-bg"
|
||||||
d="M18 2.0845
|
d="M18 2.0845
|
||||||
a 15.9155 15.9155 0 0 1 0 31.831
|
a 15.9155 15.9155 0 0 1 0 31.831
|
||||||
a 15.9155 15.9155 0 0 1 0 -31.831" />
|
a 15.9155 15.9155 0 0 1 0 -31.831" />
|
||||||
<path class="circle"
|
<path class="circle"
|
||||||
[attr.stroke-dasharray]="disk.percentage + ', 100'"
|
[attr.stroke-dasharray]="disk.percentage + ', 100'"
|
||||||
d="M18 2.0845
|
d="M18 2.0845
|
||||||
a 15.9155 15.9155 0 0 1 0 31.831
|
a 15.9155 15.9155 0 0 1 0 31.831
|
||||||
a 15.9155 15.9155 0 0 1 0 -31.831" />
|
a 15.9155 15.9155 0 0 1 0 -31.831" />
|
||||||
<text x="18" y="20.35" class="percentage">{{ disk.percentage }}%</text>
|
<text x="18" y="20.35" class="percentage">{{ disk.percentage }}%</text>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<p>Usado: {{ disk.used }} GB ({{ disk.percentage }}%)</p>
|
<p>Usado: {{ disk.used }} GB ({{ disk.percentage }}%)</p>
|
||||||
<p>Total: {{ disk.total }} GB</p>
|
<p>Total: {{ disk.total }} GB</p>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</div>
|
||||||
</div>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="assistants-container" *ngIf="isPartitionAssistantVisible" #assistantContainer>
|
|
||||||
<app-partition-assistant [data]="clientData" [clientUuid]="clientUuid"></app-partition-assistant>
|
|
||||||
</div>
|
|
||||||
<div class="assistants-container" *ngIf="isBootImageVisible" #assistantContainer>
|
|
||||||
<app-restore-image [data]="clientData"></app-restore-image>
|
|
||||||
</div>
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import {DatePipe} from "@angular/common";
|
||||||
|
import {MatTableDataSource} from "@angular/material/table";
|
||||||
|
import {PartitionAssistantComponent} from "./partition-assistant/partition-assistant.component";
|
||||||
|
import {MatDialog} from "@angular/material/dialog";
|
||||||
interface ClientInfo {
|
interface ClientInfo {
|
||||||
property: string;
|
property: string;
|
||||||
value: any;
|
value: any;
|
||||||
|
|
@ -18,13 +22,44 @@ export class ClientMainViewComponent implements OnInit {
|
||||||
isPartitionAssistantVisible: boolean = false;
|
isPartitionAssistantVisible: boolean = false;
|
||||||
isBootImageVisible: boolean = false;
|
isBootImageVisible: boolean = false;
|
||||||
isDiskUsageVisible: boolean = true;
|
isDiskUsageVisible: boolean = true;
|
||||||
|
dataSource = new MatTableDataSource<any>();
|
||||||
generalData: ClientInfo[] = [];
|
generalData: ClientInfo[] = [];
|
||||||
networkData: ClientInfo[] = [];
|
networkData: ClientInfo[] = [];
|
||||||
classroomData: ClientInfo[] = [];
|
classroomData: ClientInfo[] = [];
|
||||||
diskUsageData: any[] = [];
|
diskUsageData: any[] = [];
|
||||||
|
partitions: any[] = [];
|
||||||
|
commands: any[] = [];
|
||||||
|
datePipe: DatePipe = new DatePipe('es-ES');
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
columnDef: 'diskNumber',
|
||||||
|
header: 'Disco',
|
||||||
|
cell: (partition: any) => `${partition.diskNumber}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnDef: 'partitionNumber',
|
||||||
|
header: 'Particion',
|
||||||
|
cell: (partition: any) => `${partition.partitionNumber}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnDef: 'description',
|
||||||
|
header: 'Sistema de ficheros',
|
||||||
|
cell: (partition: any) => `${partition.filesystem}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnDef: 'size',
|
||||||
|
header: 'Tamaño',
|
||||||
|
cell: (partition: any) => `${(partition.size / 1024).toFixed(2)} GB`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnDef: 'memoryUsage',
|
||||||
|
header: 'Uso',
|
||||||
|
cell: (partition: any) => `${partition.memoryUsage} %`
|
||||||
|
},
|
||||||
|
];
|
||||||
|
displayedColumns = [...this.columns.map(column => column.columnDef)];
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient, private dialog: MatDialog) {
|
||||||
const url = window.location.href;
|
const url = window.location.href;
|
||||||
const segments = url.split('/');
|
const segments = url.split('/');
|
||||||
this.clientUuid = segments[segments.length - 1];
|
this.clientUuid = segments[segments.length - 1];
|
||||||
|
|
@ -32,10 +67,10 @@ export class ClientMainViewComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.clientData = history.state.clientData;
|
this.clientData = history.state.clientData;
|
||||||
|
this.loadPartitions()
|
||||||
this.updateGeneralData();
|
this.updateGeneralData();
|
||||||
this.updateNetworkData();
|
this.updateNetworkData();
|
||||||
this.updateClassroomData();
|
this.loadCommands()
|
||||||
this.calculateDiskUsage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGeneralData() {
|
updateGeneralData() {
|
||||||
|
|
@ -48,54 +83,36 @@ export class ClientMainViewComponent implements OnInit {
|
||||||
{ property: 'Netiface', value: this.clientData?.netiface || '' },
|
{ property: 'Netiface', value: this.clientData?.netiface || '' },
|
||||||
{ property: 'Perfil hardware', value: this.clientData?.hardwareProfile?.description || '' },
|
{ property: 'Perfil hardware', value: this.clientData?.hardwareProfile?.description || '' },
|
||||||
{ property: 'Menú', value: this.clientData?.menu?.description || '' },
|
{ property: 'Menú', value: this.clientData?.menu?.description || '' },
|
||||||
{ property: 'Fecha de creación', value: this.clientData?.createdAt || '' },
|
|
||||||
{ property: 'Creado por', value: this.clientData?.createdBy || '' }
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
updateNetworkData() {
|
updateNetworkData() {
|
||||||
this.networkData = [
|
this.networkData = [
|
||||||
{ property: 'Perfil hardware', value: this.clientData?.hardwareProfile?.description || '' },
|
{ property: 'Remote Pc', value: this.clientData.remotePc || '' },
|
||||||
{ property: 'Subred', value: this.clientData?.subnet || '' },
|
{ property: 'Subred', value: this.clientData?.subnet || '' },
|
||||||
{ property: 'OGlive', value: '' },
|
{ property: 'OGlive', value: '' },
|
||||||
{ property: 'Autoexec', value: '' },
|
{ property: 'Autoexec', value: '' },
|
||||||
{ property: 'Repositorio', value: '' },
|
{ property: 'Repositorio', value: '' },
|
||||||
{ property: 'Validación', value: this.clientData?.organizationalUnit?.networkSettings?.validation || '' },
|
{ property: 'Validación', value: this.clientData?.organizationalUnit?.networkSettings?.validation || '' },
|
||||||
{ property: 'Fecha de creación', value: this.clientData?.createdAt || '' },
|
{ property: 'Pxe', value: this.clientData?.template.name || '' },
|
||||||
{ property: 'Creado por', value: this.clientData?.createdBy || '' }
|
{ property: 'Creado por', value: this.clientData?.createdBy || '' }
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
updateClassroomData() {
|
|
||||||
this.classroomData = [
|
|
||||||
{ property: 'Url servidor proxy', value: this.clientData?.organizationalUnit?.networkSettings?.proxy || '' },
|
|
||||||
{ property: 'IP DNS', value: this.clientData?.organizationalUnit?.networkSettings?.dns || '' },
|
|
||||||
{ property: 'Máscara de red', value: this.clientData?.organizationalUnit?.networkSettings?.netmask || '' },
|
|
||||||
{ property: 'Router', value: this.clientData?.organizationalUnit?.networkSettings?.router || '' },
|
|
||||||
{ property: 'NTP', value: this.clientData?.organizationalUnit?.networkSettings?.ntp || '' },
|
|
||||||
{ property: 'Modo p2p', value: this.clientData?.organizationalUnit?.networkSettings?.p2pMode || '' },
|
|
||||||
{ property: 'Tiempo p2p', value: this.clientData?.organizationalUnit?.networkSettings?.p2pTime || '' },
|
|
||||||
{ property: 'IP multicast', value: this.clientData?.organizationalUnit?.networkSettings?.mcastIp || '' },
|
|
||||||
{ property: 'Modo multicast', value: this.clientData?.organizationalUnit?.networkSettings?.mcastMode || '' },
|
|
||||||
{ property: 'Puerto multicast', value: this.clientData?.organizationalUnit?.networkSettings?.mcastPort || '' },
|
|
||||||
{ property: 'Velocidad multicast', value: this.clientData?.organizationalUnit?.networkSettings?.mcastSpeed || '' },
|
|
||||||
{ property: 'Perfil hardware', value: this.clientData?.organizationalUnit?.networkSettings?.hardwareProfile?.description || '' }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
calculateDiskUsage() {
|
calculateDiskUsage() {
|
||||||
const diskUsageMap = new Map<number, { total: number, used: number }>();
|
const diskUsageMap = new Map<number, { total: number, used: number }>();
|
||||||
|
|
||||||
this.clientData.partitions.forEach((partition: any) => {
|
this.partitions.forEach((partition: any) => {
|
||||||
const diskNumber = partition.diskNumber;
|
const diskNumber = partition.diskNumber;
|
||||||
if (!diskUsageMap.has(diskNumber)) {
|
if (!diskUsageMap.has(diskNumber)) {
|
||||||
diskUsageMap.set(diskNumber, { total: 0, used: 0 });
|
diskUsageMap.set(diskNumber, { total: 0, used: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const diskData = diskUsageMap.get(diskNumber);
|
const diskData = diskUsageMap.get(diskNumber);
|
||||||
|
|
||||||
if (partition.partitionNumber === 0) {
|
if (partition.partitionNumber === 0) {
|
||||||
diskData!.total = partition.size / (1024 * 1024);
|
diskData!.total = Number((partition.size / 1024).toFixed(2));
|
||||||
} else {
|
} else {
|
||||||
diskData!.used += partition.size / (1024 * 1024);
|
diskData!.used += Number(((partition.size * (partition.memoryUsage / 100))/ 1024).toFixed(2));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -105,23 +122,44 @@ export class ClientMainViewComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePartitionAssistant() {
|
loadPartitions(): void {
|
||||||
this.isPartitionAssistantVisible = !this.isPartitionAssistantVisible;
|
this.http.get<any>(`${this.baseUrl}/partitions?client.id=${this.clientData?.id}`).subscribe({
|
||||||
this.isBootImageVisible = false
|
next: data => {
|
||||||
if (this.isPartitionAssistantVisible) {
|
this.dataSource = data['hydra:member'];
|
||||||
setTimeout(() => {
|
this.partitions = data['hydra:member'];
|
||||||
this.assistantContainer.nativeElement.scrollIntoView({ behavior: 'smooth' });
|
this.calculateDiskUsage();
|
||||||
}, 0);
|
},
|
||||||
|
error: error => {
|
||||||
|
console.error('Error al obtener las particiones:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loadCommands(): void {
|
||||||
|
this.http.get<any>(`${this.baseUrl}/commands?`).subscribe({
|
||||||
|
next: data => {
|
||||||
|
this.commands = data['hydra:member'];
|
||||||
|
},
|
||||||
|
error: error => {
|
||||||
|
console.error('Error al obtener las particiones:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onCommandSelect(command: any): void {
|
||||||
|
if (command.name === 'Particionar y Formatear') {
|
||||||
|
this.openPartitionDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showBootImage() {
|
openPartitionDialog(): void {
|
||||||
this.isBootImageVisible = !this.isBootImageVisible;
|
const dialogRef = this.dialog.open(PartitionAssistantComponent, {
|
||||||
this.isPartitionAssistantVisible = false;
|
width: '1000px',
|
||||||
if (this.isBootImageVisible) {
|
data: this.clientData['@id']
|
||||||
setTimeout(() => {
|
});
|
||||||
this.assistantContainer.nativeElement.scrollIntoView({ behavior: 'smooth' });
|
|
||||||
}, 0);
|
dialogRef.afterClosed().subscribe((result: any) => {
|
||||||
}
|
console.log('El diálogo se cerró', result);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
background-color: #f9f9f9;
|
background-color: #f9f9f9;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13,7 +11,7 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #fff;
|
background-color: #cecbcb;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
@ -52,8 +50,6 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
@ -68,15 +64,12 @@
|
||||||
.partition-table td {
|
.partition-table td {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.partition-table select,
|
.partition-table select,
|
||||||
.partition-table input[type="number"],
|
.partition-table input[type="number"],
|
||||||
.partition-table input[type="checkbox"] {
|
.partition-table input[type="checkbox"] {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 4px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,62 +1,73 @@
|
||||||
<div class="partition-assistant" *ngFor="let disk of disks; let i = index">
|
<h2 mat-dialog-title>Asistente de particionado</h2>
|
||||||
<h2>Asistente a particionado</h2>
|
|
||||||
<div class="header">
|
|
||||||
<label for="disk-number-{{i}}">Disco {{ disk.diskNumber }}:</label>
|
|
||||||
<span class="disk-size">Tamaño: {{ disk.totalDiskSize }} GB</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="partition-bar">
|
|
||||||
<div
|
<mat-dialog-content>
|
||||||
*ngFor="let partition of disk.partitions"
|
<div class="partition-assistant" *ngFor="let disk of disks; let i = index">
|
||||||
[ngStyle]="{'width': partition.percentage + '%', 'background-color': partition.color}"
|
<div class="header">
|
||||||
class="partition-segment"
|
<label for="disk-number-{{i}}">Disco {{ disk.diskNumber }}:</label>
|
||||||
>
|
<span class="disk-size">Tamaño: {{ (disk.totalDiskSize / 1024).toFixed(2) }} GB</span>
|
||||||
{{ partition.type }} ({{ partition.size }} GB)
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="partition-bar">
|
||||||
|
<div
|
||||||
|
*ngFor="let partition of disk.partitions"
|
||||||
|
[ngStyle]="{'width': partition.percentage + '%', 'background-color': partition.color}"
|
||||||
|
class="partition-segment"
|
||||||
|
>
|
||||||
|
{{ partition.type }} ({{ (partition.size / 1024).toFixed(2) }} GB)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button mat-flat-button color="primary" (click)="addPartition(disk.diskNumber)"> + </button>
|
||||||
|
|
||||||
|
<table class="partition-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Partición</th>
|
||||||
|
<th>Tipo partición</th>
|
||||||
|
<th>Tamaño (MB)</th>
|
||||||
|
<th>Uso (%)</th>
|
||||||
|
<th>Formatear</th>
|
||||||
|
<th>Eliminar</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let partition of disk.partitions; let j = index">
|
||||||
|
<td>{{ partition.partitionNumber }}</td>
|
||||||
|
<td>
|
||||||
|
<select [(ngModel)]="partition.type">
|
||||||
|
<option value="NTFS">NTFS</option>
|
||||||
|
<option value="LINUX">LINUX</option>
|
||||||
|
<option value="CACHE">CACHE</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
[(ngModel)]="partition.size"
|
||||||
|
(input)="updatePartitionSize(disk.diskNumber, j, partition.size)"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
[(ngModel)]="partition.memoryUsage"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" [(ngModel)]="partition.format" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button (click)="removePartition(disk.diskNumber, partition)" class="remove-btn">X</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</mat-dialog-content>
|
||||||
<button mat-button (click)="addPartition(disk.diskNumber)">Añadir +</button>
|
|
||||||
|
|
||||||
<table class="partition-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Partición</th>
|
|
||||||
<th>Tipo partición</th>
|
|
||||||
<th>Tamaño (GB)</th>
|
|
||||||
<th>Formatear</th>
|
|
||||||
<th>Eliminar</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let partition of disk.partitions; let j = index">
|
|
||||||
<td>{{ partition.partitionNumber }}</td>
|
|
||||||
<td>
|
|
||||||
<select [(ngModel)]="partition.type">
|
|
||||||
<option value="NTFS">NTFS</option>
|
|
||||||
<option value="LINUX">LINUX</option>
|
|
||||||
<option value="CACHE">CACHE</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
[(ngModel)]="partition.size"
|
|
||||||
(input)="updatePartitionSize(disk.diskNumber, j, partition.size)"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="checkbox" [(ngModel)]="partition.format" />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button (click)="removePartition(disk.diskNumber, partition)" class="remove-btn">X</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="errorMessage" class="error-message">{{ errorMessage }}</div>
|
<div *ngIf="errorMessage" class="error-message">{{ errorMessage }}</div>
|
||||||
|
|
||||||
<div class="actions">
|
<mat-dialog-actions align="end">
|
||||||
<button mat-flat-button color="primary" (click)="save()">Guardar</button>
|
<button mat-button (click)="save()">Guardar</button>
|
||||||
</div>
|
</mat-dialog-actions>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import {Component, EventEmitter, Inject, Input, OnInit, Output} from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { ToastrService } from 'ngx-toastr';
|
import { ToastrService } from 'ngx-toastr';
|
||||||
|
import {MAT_DIALOG_DATA} from "@angular/material/dialog";
|
||||||
|
|
||||||
interface Partition {
|
interface Partition {
|
||||||
uuid?: string;
|
uuid?: string;
|
||||||
|
|
@ -8,6 +9,7 @@ interface Partition {
|
||||||
size: number;
|
size: number;
|
||||||
type: string;
|
type: string;
|
||||||
sizeBytes: number;
|
sizeBytes: number;
|
||||||
|
memoryUsage: number;
|
||||||
format: boolean;
|
format: boolean;
|
||||||
color: string;
|
color: string;
|
||||||
percentage: number;
|
percentage: number;
|
||||||
|
|
@ -20,8 +22,6 @@ interface Partition {
|
||||||
})
|
})
|
||||||
export class PartitionAssistantComponent implements OnInit {
|
export class PartitionAssistantComponent implements OnInit {
|
||||||
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
||||||
@Input() data: any;
|
|
||||||
@Input() clientUuid: string | undefined;
|
|
||||||
@Output() dataChange = new EventEmitter<any>();
|
@Output() dataChange = new EventEmitter<any>();
|
||||||
|
|
||||||
errorMessage = '';
|
errorMessage = '';
|
||||||
|
|
@ -30,14 +30,18 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
|
|
||||||
private apiUrl: string = this.baseUrl + '/partitions';
|
private apiUrl: string = this.baseUrl + '/partitions';
|
||||||
|
|
||||||
constructor(private http: HttpClient, private toastService: ToastrService) {}
|
constructor(
|
||||||
|
private http: HttpClient,
|
||||||
|
private toastService: ToastrService,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loadClientData();
|
this.loadPartitions();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadClientData() {
|
loadPartitions() {
|
||||||
const url = `${this.baseUrl}/clients/${this.clientUuid}`;
|
const url = `${this.baseUrl}${this.data}`;
|
||||||
this.http.get(url).subscribe(
|
this.http.get(url).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.data = response;
|
this.data = response;
|
||||||
|
|
@ -68,6 +72,7 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
uuid: partition.uuid,
|
uuid: partition.uuid,
|
||||||
partitionNumber: partition.partitionNumber,
|
partitionNumber: partition.partitionNumber,
|
||||||
size: this.convertBytesToGB(partition.size),
|
size: this.convertBytesToGB(partition.size),
|
||||||
|
memoryUsage: partition.memoryUsage,
|
||||||
type: partition.type || partition.filesystem || 'NTFS',
|
type: partition.type || partition.filesystem || 'NTFS',
|
||||||
sizeBytes: partition.size,
|
sizeBytes: partition.size,
|
||||||
format: false,
|
format: false,
|
||||||
|
|
@ -88,12 +93,12 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
convertBytesToGB(bytes: number): number {
|
convertBytesToGB(bytes: number): number {
|
||||||
return bytes / 1024;
|
return bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePartitionPercentages(partitions: Partition[], totalDiskSize: number) {
|
updatePartitionPercentages(partitions: Partition[], totalDiskSize: number) {
|
||||||
partitions.forEach((partition) => {
|
partitions.forEach((partition) => {
|
||||||
partition.percentage = (partition.size / totalDiskSize) * 100;
|
partition.percentage = (partition.size / totalDiskSize) * 100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,6 +107,7 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
|
|
||||||
if (disk) {
|
if (disk) {
|
||||||
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize);
|
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize);
|
||||||
|
console.log(remainingGB)
|
||||||
if (remainingGB > 0) {
|
if (remainingGB > 0) {
|
||||||
const maxPartitionNumber =
|
const maxPartitionNumber =
|
||||||
disk.partitions.length > 0 ? Math.max(...disk.partitions.map((p) => p.partitionNumber)) : 0;
|
disk.partitions.length > 0 ? Math.max(...disk.partitions.map((p) => p.partitionNumber)) : 0;
|
||||||
|
|
@ -111,6 +117,7 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
partitionNumber: newPartitionNumber,
|
partitionNumber: newPartitionNumber,
|
||||||
size: 0,
|
size: 0,
|
||||||
type: 'NTFS',
|
type: 'NTFS',
|
||||||
|
memoryUsage: 0,
|
||||||
sizeBytes: 0,
|
sizeBytes: 0,
|
||||||
format: false,
|
format: false,
|
||||||
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
||||||
|
|
@ -136,13 +143,14 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
this.errorMessage = '';
|
this.errorMessage = '';
|
||||||
partition.size = size;
|
partition.size = size;
|
||||||
partition.sizeBytes = size * 1024;
|
partition.sizeBytes = size;
|
||||||
this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize);
|
this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRemainingGB(partitions: Partition[], totalDiskSize: number): number {
|
getRemainingGB(partitions: Partition[], totalDiskSize: number): number {
|
||||||
|
console.log(totalDiskSize)
|
||||||
const totalUsedGB = partitions.reduce((acc, partition) => acc + partition.size, 0);
|
const totalUsedGB = partitions.reduce((acc, partition) => acc + partition.size, 0);
|
||||||
return Math.max(0, totalDiskSize - totalUsedGB);
|
return Math.max(0, totalDiskSize - totalUsedGB);
|
||||||
}
|
}
|
||||||
|
|
@ -182,6 +190,18 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
|
const invalidDisks = this.disks.filter(disk => {
|
||||||
|
const totalPartitionSize = disk.partitions.reduce((sum, partition) => sum + partition.size, 0);
|
||||||
|
return totalPartitionSize > disk.totalDiskSize;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (invalidDisks.length > 0) {
|
||||||
|
this.errorMessage = 'El tamaño total de las particiones en uno o más discos excede el tamaño total del disco.';
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.errorMessage = '';
|
||||||
|
}
|
||||||
|
|
||||||
const modifiedPartitions = this.getModifiedOrNewPartitions();
|
const modifiedPartitions = this.getModifiedOrNewPartitions();
|
||||||
|
|
||||||
if (modifiedPartitions.length === 0) {
|
if (modifiedPartitions.length === 0) {
|
||||||
|
|
@ -193,32 +213,40 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
const payload = {
|
const payload = {
|
||||||
diskNumber: diskNumber,
|
diskNumber: diskNumber,
|
||||||
partitionNumber: partitionNumber,
|
partitionNumber: partitionNumber,
|
||||||
|
memoryUsage: partition.memoryUsage,
|
||||||
size: partition.size,
|
size: partition.size,
|
||||||
filesystem: partition.type,
|
filesystem: partition.type,
|
||||||
client: `/clients/${this.clientUuid}`
|
client: this.data['@id']
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
this.http.post(this.apiUrl, payload).subscribe(
|
this.http.post(this.apiUrl, payload).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.toastService.success('Partición creada exitosamente');
|
this.toastService.success('Partición creada exitosamente');
|
||||||
this.loadClientData();
|
this.loadPartitions();
|
||||||
},
|
},
|
||||||
(error) => {}
|
(error) => {
|
||||||
|
console.error('Error al crear la partición:', error);
|
||||||
|
this.toastService.error('Error al crear la partición');
|
||||||
|
}
|
||||||
);
|
);
|
||||||
} else if (partition.uuid) {
|
} else if (partition.uuid) {
|
||||||
const patchUrl = `${this.apiUrl}/${partition.uuid}`;
|
const patchUrl = `${this.apiUrl}/${partition.uuid}`;
|
||||||
this.http.patch(patchUrl, payload).subscribe(
|
this.http.patch(patchUrl, payload).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.toastService.success('Partición actualizada exitosamente');
|
this.toastService.success('Partición actualizada exitosamente');
|
||||||
this.loadClientData();
|
this.loadPartitions();
|
||||||
},
|
},
|
||||||
(error) => {}
|
(error) => {
|
||||||
|
console.error('Error al actualizar la partición:', error);
|
||||||
|
this.toastService.error('Error al actualizar la partición');
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
removePartition(diskNumber: number, partition: Partition) {
|
removePartition(diskNumber: number, partition: Partition) {
|
||||||
const disk = this.disks.find((d) => d.diskNumber === diskNumber);
|
const disk = this.disks.find((d) => d.diskNumber === diskNumber);
|
||||||
|
|
||||||
|
|
@ -233,7 +261,7 @@ export class PartitionAssistantComponent implements OnInit {
|
||||||
this.http.delete(deleteUrl).subscribe(
|
this.http.delete(deleteUrl).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.toastService.success('Partición eliminada exitosamente');
|
this.toastService.success('Partición eliminada exitosamente');
|
||||||
this.loadClientData();
|
this.loadPartitions();
|
||||||
},
|
},
|
||||||
(error) => {}
|
(error) => {}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,6 @@ export class ClientTabViewComponent {
|
||||||
|
|
||||||
handleClientClick(event: MouseEvent, client: any): void {
|
handleClientClick(event: MouseEvent, client: any): void {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
/* const dialogRef = this.dialog.open(ClientViewComponent, { data: { client }, width: '800px', height:'700px' }); */
|
|
||||||
|
|
||||||
this.router.navigate(['client', client.uuid], { state: { clientData: client } });
|
this.router.navigate(['client', client.uuid], { state: { clientData: client } });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue