Merge pull request 'Updated partition assistant and Sync UDS button.' (#82) from develop into main
Reviewed-on: #82pull/83/head
commit
e2b760007b
|
|
@ -147,8 +147,21 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<button class="action-button add-partition-btn" *ngIf="selectedDisk" (click)="addPartition(selectedDisk.diskNumber)">
|
||||
<mat-icon>add</mat-icon> {{ 'addPartition' | translate }}</button>
|
||||
<ng-container *ngIf="selectedDisk">
|
||||
<button class="action-button add-partition-btn" [matMenuTriggerFor]="addPartitionMenu">
|
||||
<mat-icon>add</mat-icon> {{ 'addPartition' | translate }}
|
||||
</button>
|
||||
<mat-menu #addPartitionMenu="matMenu">
|
||||
<button mat-menu-item (click)="addPrimaryPartition(selectedDisk.diskNumber)">
|
||||
<mat-icon>storage</mat-icon>
|
||||
<span>Partición normal <small>(1–4)</small></span>
|
||||
</button>
|
||||
<button mat-menu-item (click)="addLogicalPartition(selectedDisk.diskNumber)">
|
||||
<mat-icon>account_tree</mat-icon>
|
||||
<span>Partición extendida <small>(5+)</small></span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
<div class="no-disks-message" *ngIf="!disks || disks.length === 0">
|
||||
|
|
@ -186,19 +199,18 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<ng-container *ngFor="let partition of selectedDisk.partitions; let j = index">
|
||||
<tr *ngIf="!partition.removed"
|
||||
[ngClass]="{
|
||||
<ng-container *ngFor="let partition of orderedPartitions; let j = index">
|
||||
<tr [ngClass]="{
|
||||
'extended-row': partition.partitionCode === 'EXTENDED',
|
||||
'logical-row': isLogicalPartition(selectedDisk.partitions, j)
|
||||
'logical-row': partition.partitionNumber >= 5
|
||||
}">
|
||||
<td>
|
||||
<span *ngIf="isLogicalPartition(selectedDisk.partitions, j)" class="logical-indent">└</span>
|
||||
<span *ngIf="partition.partitionNumber >= 5" class="logical-indent">└</span>
|
||||
{{ partition.partitionNumber }}
|
||||
</td>
|
||||
<td>
|
||||
<select [(ngModel)]="partition.partitionCode" required>
|
||||
<option *ngFor="let type of partitionTypes" [value]="type.name">
|
||||
<option *ngFor="let type of getAvailablePartitionTypes(partition)" [value]="type.name">
|
||||
{{ type.name }}
|
||||
</option>
|
||||
</select>
|
||||
|
|
@ -213,12 +225,12 @@
|
|||
<td>
|
||||
<input type="number" [(ngModel)]="partition.size" required
|
||||
[disabled]="partition.partitionCode === 'EXTENDED'"
|
||||
(input)="updatePartitionSize(selectedDisk.diskNumber, j, partition.size)" />
|
||||
(input)="updatePartitionSize(selectedDisk.diskNumber, partition, partition.size)" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="number" [(ngModel)]="partition.percentage"
|
||||
[disabled]="partition.partitionCode === 'EXTENDED'"
|
||||
(input)="updatePartitionSizeFromPercentage(selectedDisk.diskNumber, j, partition.percentage)" />
|
||||
(input)="updatePartitionSizeFromPercentage(selectedDisk.diskNumber, partition, partition.percentage)" />
|
||||
</td>
|
||||
<td>
|
||||
<mat-checkbox type="checkbox" [(ngModel)]="partition.format" />
|
||||
|
|
|
|||
|
|
@ -374,56 +374,90 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
|
|||
}
|
||||
|
||||
addPartition(diskNumber: number) {
|
||||
const disk = this.disks.find((d) => d.diskNumber === diskNumber);
|
||||
|
||||
if (disk) {
|
||||
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize);
|
||||
|
||||
if (remainingGB > 0) {
|
||||
const removedPartitions = disk.partitions.filter((p) => !p.removed);
|
||||
const maxPartitionNumber =
|
||||
removedPartitions.length > 0 ? Math.max(...removedPartitions.map((p) => p.partitionNumber)) : 0;
|
||||
const newPartitionNumber = maxPartitionNumber + 1;
|
||||
|
||||
// Verificar si es UEFI y es la primera partición
|
||||
const isUEFI = this.selectedModelClient?.firmwareType === 'UEFI';
|
||||
const isFirstPartition = removedPartitions.length === 0;
|
||||
const isFirstDisk = diskNumber === 1;
|
||||
|
||||
// Si es UEFI, primera partición y primer disco, crear partición EFI
|
||||
const shouldCreateEFI = isUEFI && isFirstPartition && isFirstDisk;
|
||||
|
||||
disk.partitions.push({
|
||||
partitionNumber: newPartitionNumber,
|
||||
size: shouldCreateEFI ? 512 : 0,
|
||||
partitionCode: shouldCreateEFI ? 'EFI' : 'EMPTY',
|
||||
filesystem: shouldCreateEFI ? 'FAT32' : 'EXT4',
|
||||
memoryUsage: 0,
|
||||
sizeBytes: shouldCreateEFI ? 512 : 0,
|
||||
format: false,
|
||||
color: this.getNextPartitionColor(),
|
||||
percentage: 0,
|
||||
removed: false
|
||||
});
|
||||
this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize);
|
||||
this.updateDiskChart(disk);
|
||||
|
||||
this.resetValidationStatus();
|
||||
this.validationSubject.next();
|
||||
|
||||
setTimeout(() => {
|
||||
this.resizeChart();
|
||||
}, 100);
|
||||
} else {
|
||||
this.toastService.error(this.translate.instant('notEnoughFreeSpace'));
|
||||
}
|
||||
}
|
||||
this.addPrimaryPartition(diskNumber);
|
||||
}
|
||||
|
||||
updatePartitionSize(diskNumber: number, index: number, size: number) {
|
||||
addPrimaryPartition(diskNumber: number): void {
|
||||
const disk = this.disks.find(d => d.diskNumber === diskNumber);
|
||||
if (!disk) return;
|
||||
|
||||
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize);
|
||||
if (remainingGB <= 0) {
|
||||
this.toastService.error(this.translate.instant('notEnoughFreeSpace'));
|
||||
return;
|
||||
}
|
||||
|
||||
const activePrimary = disk.partitions.filter(p => !p.removed && p.partitionNumber < 5);
|
||||
if (activePrimary.length >= 4) {
|
||||
this.toastService.error('No se pueden añadir más de 4 particiones primarias');
|
||||
return;
|
||||
}
|
||||
|
||||
const maxPrimary = activePrimary.length > 0 ? Math.max(...activePrimary.map(p => p.partitionNumber)) : 0;
|
||||
const newNumber = maxPrimary + 1;
|
||||
|
||||
const isUEFI = this.selectedModelClient?.firmwareType === 'UEFI';
|
||||
const isFirstPartition = disk.partitions.filter(p => !p.removed).length === 0;
|
||||
const isFirstDisk = diskNumber === 1;
|
||||
const shouldCreateEFI = isUEFI && isFirstPartition && isFirstDisk;
|
||||
|
||||
disk.partitions.push({
|
||||
partitionNumber: newNumber,
|
||||
size: shouldCreateEFI ? 512 : 0,
|
||||
partitionCode: shouldCreateEFI ? 'EFI' : 'EMPTY',
|
||||
filesystem: shouldCreateEFI ? 'FAT32' : 'EXT4',
|
||||
memoryUsage: 0,
|
||||
sizeBytes: shouldCreateEFI ? 512 : 0,
|
||||
format: false,
|
||||
color: this.getNextPartitionColor(),
|
||||
percentage: 0,
|
||||
removed: false
|
||||
});
|
||||
|
||||
this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize);
|
||||
this.updateDiskChart(disk);
|
||||
this.resetValidationStatus();
|
||||
this.validationSubject.next();
|
||||
setTimeout(() => this.resizeChart(), 100);
|
||||
}
|
||||
|
||||
addLogicalPartition(diskNumber: number): void {
|
||||
const disk = this.disks.find(d => d.diskNumber === diskNumber);
|
||||
if (!disk) return;
|
||||
|
||||
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize);
|
||||
if (remainingGB <= 0) {
|
||||
this.toastService.error(this.translate.instant('notEnoughFreeSpace'));
|
||||
return;
|
||||
}
|
||||
|
||||
const activeLogical = disk.partitions.filter(p => !p.removed && p.partitionNumber >= 5);
|
||||
const maxLogical = activeLogical.length > 0 ? Math.max(...activeLogical.map(p => p.partitionNumber)) : 4;
|
||||
const newNumber = maxLogical + 1;
|
||||
|
||||
disk.partitions.push({
|
||||
partitionNumber: newNumber,
|
||||
size: 0,
|
||||
partitionCode: 'EMPTY',
|
||||
filesystem: 'EXT4',
|
||||
memoryUsage: 0,
|
||||
sizeBytes: 0,
|
||||
format: false,
|
||||
color: this.getNextPartitionColor(),
|
||||
percentage: 0,
|
||||
removed: false
|
||||
});
|
||||
|
||||
this.updatePartitionPercentages(disk.partitions, disk.totalDiskSize);
|
||||
this.updateDiskChart(disk);
|
||||
this.resetValidationStatus();
|
||||
this.validationSubject.next();
|
||||
setTimeout(() => this.resizeChart(), 100);
|
||||
}
|
||||
|
||||
updatePartitionSize(diskNumber: number, partition: Partition, size: number) {
|
||||
const disk = this.disks.find((d) => d.diskNumber === diskNumber);
|
||||
if (disk) {
|
||||
const partition = disk.partitions[index];
|
||||
const remainingGB = this.getRemainingGB(disk.partitions, disk.totalDiskSize) + partition.size;
|
||||
if (partition) {
|
||||
partition.percentage = Number(((size / disk.totalDiskSize) * 100).toFixed(2));
|
||||
|
|
@ -549,10 +583,9 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
|
|||
}
|
||||
}
|
||||
|
||||
updatePartitionSizeFromPercentage(diskNumber: number, partitionIndex: number, percentage: number): void {
|
||||
updatePartitionSizeFromPercentage(diskNumber: number, partition: Partition, percentage: number): void {
|
||||
const disk = this.disks.find(d => d.diskNumber === diskNumber);
|
||||
if (disk) {
|
||||
const partition = disk.partitions[partitionIndex];
|
||||
if (partition) {
|
||||
partition.size = (disk.totalDiskSize * percentage) / 100;
|
||||
}
|
||||
|
|
@ -901,11 +934,31 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
|
|||
}
|
||||
|
||||
isLogicalPartition(partitions: Partition[], currentIndex: number): boolean {
|
||||
for (let i = 0; i < currentIndex; i++) {
|
||||
if (!partitions[i].removed && partitions[i].partitionCode === 'EXTENDED') {
|
||||
return true;
|
||||
return partitions[currentIndex]?.partitionNumber >= 5;
|
||||
}
|
||||
|
||||
getAvailablePartitionTypes(partition: Partition) {
|
||||
const hasExtended = this.selectedDisk?.partitions.some(
|
||||
(p: Partition) => !p.removed && p.partitionCode === 'EXTENDED' && p !== partition
|
||||
);
|
||||
return hasExtended
|
||||
? this.partitionTypes.filter((t: any) => t.name !== 'EXTENDED')
|
||||
: this.partitionTypes;
|
||||
}
|
||||
|
||||
get orderedPartitions(): Partition[] {
|
||||
if (!this.selectedDisk) return [];
|
||||
const sortByNumber = (a: Partition, b: Partition) => a.partitionNumber - b.partitionNumber;
|
||||
const active: Partition[] = this.selectedDisk.partitions.filter((p: Partition) => !p.removed);
|
||||
const primaries = active.filter((p: Partition) => p.partitionNumber < 5).sort(sortByNumber);
|
||||
const logicals = active.filter((p: Partition) => p.partitionNumber >= 5).sort(sortByNumber);
|
||||
const result: Partition[] = [];
|
||||
for (const p of primaries) {
|
||||
result.push(p);
|
||||
if (p.partitionCode === 'EXTENDED') {
|
||||
result.push(...logicals);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,9 +322,9 @@
|
|||
</div>
|
||||
|
||||
<button *ngIf="classroomCalendarUuid && !syncingUds" class="action-button" (click)="syncUds($event)"
|
||||
[disabled]="!selectedNode?.remotePc"
|
||||
matTooltip="Sincronizar calendarios con UDS" matTooltipShowDelay="500">
|
||||
<mat-icon>sync</mat-icon>
|
||||
Sincronizar con UDS
|
||||
</button>
|
||||
<mat-spinner *ngIf="syncingUds" diameter="24" style="margin: 0 8px;"></mat-spinner>
|
||||
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
name: node.name,
|
||||
type: node.type,
|
||||
'@id': node['@id'],
|
||||
remotePc: node.remotePc,
|
||||
children: children,
|
||||
hasClients: hasClients,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export interface UnidadOrganizativa {
|
|||
name: string;
|
||||
type: string;
|
||||
'@id': string;
|
||||
remotePc?: boolean;
|
||||
clients?: Client[];
|
||||
children?: UnidadOrganizativa[];
|
||||
parent?: UnidadOrganizativa;
|
||||
|
|
@ -68,6 +69,7 @@ export interface TreeNode {
|
|||
name: string;
|
||||
type: string;
|
||||
'@id'?: string;
|
||||
remotePc?: boolean;
|
||||
children?: TreeNode[];
|
||||
hasClients?: boolean;
|
||||
clients?: Client[];
|
||||
|
|
|
|||
Loading…
Reference in New Issue