Compare commits
No commits in common. "main" and "0.11.1" have entirely different histories.
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,19 +1,4 @@
|
|||
# Changelog
|
||||
## [0.11.2] - 2025-4-16
|
||||
### Fixed
|
||||
- Se ha corregido un error en la actualizacion del estado de los pcs en la vista tarjetas.
|
||||
|
||||
---
|
||||
## [0.11.1] - 2025-4-16
|
||||
### Improved
|
||||
- Nuevos campos en la tabla de clientes. Tipo de firmware y mac.
|
||||
|
||||
## Fixed
|
||||
- Se ha corregido error al crear OUs, que no refrescaba la web.
|
||||
- Se ha corregido error en el formulario de creacion de imagenes. Si se seleccionaba una imagen para un versionado, no dejaba deseleccionar.
|
||||
- Se ha corregido un bug en el particionador que impedia ejecutar, cuando eliminabamos una particion.
|
||||
|
||||
---
|
||||
## [0.11.0] - 2025-4-11
|
||||
### Added
|
||||
- Se ha diseñado el nuevo formulario para poder ejecutar script. Sistema mejorado con variables etiquetadas.
|
||||
|
|
|
@ -9,5 +9,5 @@ Package: oggui
|
|||
Architecture: any
|
||||
Maintainer: Nicolas Arenas <nicolas.arenas@qindel.com>
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, nginx
|
||||
Description: OpenGnsys GUI created for the Opengnsys Team
|
||||
Opengnsys Graphical Intercface
|
||||
Description: OpenGnsys GUI
|
||||
Una interfaz gráfica para OpenGnsys.
|
||||
|
|
|
@ -13,25 +13,6 @@ OGMERCURE_URL="$RET"
|
|||
USER="opengnsys"
|
||||
CONFIG_FILE="/opt/opengnsys/oggui/browser/assets/config.json"
|
||||
|
||||
restore_config_if_modified() {
|
||||
local new="$1"
|
||||
local backup="$1.bak"
|
||||
|
||||
if [ -f "$backup" ]; then
|
||||
if ! cmp -s "$new" "$backup"; then
|
||||
echo ">>> Archivo modificado por el usuario detectado en $new"
|
||||
echo " - Guardando archivo nuevo como ${new}.new"
|
||||
mv -f "$new" "${new}.new"
|
||||
echo " - Restaurando archivo anterior desde backup"
|
||||
mv -f "$backup" "$new"
|
||||
else
|
||||
echo ">>> El archivo $new no ha cambiado desde la última versión, eliminando backup"
|
||||
rm -f "$backup"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Detectar si es una instalación nueva o una actualización
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
|
@ -48,11 +29,6 @@ if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
|||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
cd /opt/opengnsys/oggui
|
||||
echo "Actualización desde la versión $2"
|
||||
# Si upgrade recupero los archivos de configuracion
|
||||
echo ">>> Backup de archivos de configuración reales en /opt/opengnsys"
|
||||
restore_config_if_modified "/opt/opengnsys/oggui/etc/nginx/oggui.conf"
|
||||
restore_config_if_modified "$CONFIG_FILE"
|
||||
|
||||
fi
|
||||
|
||||
# Cambiar la propiedad de los archivos al usuario especificado
|
||||
|
|
|
@ -2,16 +2,6 @@
|
|||
|
||||
set -e
|
||||
|
||||
backup_file_if_exists() {
|
||||
local original="$1"
|
||||
local backup="$1.bak"
|
||||
|
||||
if [ -e "$original" ]; then
|
||||
echo " - Guardando backup de $original en $backup"
|
||||
cp -a "$original" "$backup"
|
||||
fi
|
||||
}
|
||||
CONFIG_FILE="/opt/opengnsys/oggui/browser/assets/config.json"
|
||||
# Asegurarse de que el usuario exista
|
||||
USER="opengnsys"
|
||||
HOME_DIR="/opt/opengnsys"
|
||||
|
@ -22,11 +12,4 @@ else
|
|||
useradd -m -d "$HOME_DIR" -s /bin/bash "$USER"
|
||||
fi
|
||||
|
||||
# Si upgrade hago backup del archivo de configuración
|
||||
if [ "$1" = "upgrade" ]; then
|
||||
echo ">>> Backup de archivos de configuración reales en /opt/opengnsys"
|
||||
backup_file_if_exists "/opt/opengnsys/oggui/etc/nginx/sites-available/oggui.conf"
|
||||
backup_file_if_exists "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit 0
|
|
@ -8,17 +8,12 @@
|
|||
[matMenuTriggerFor]="commandMenu">
|
||||
{{ buttonText }}
|
||||
</button>
|
||||
|
||||
<button mat-menu-item *ngSwitchCase="'menu-item'" [matMenuTriggerFor]="commandMenu" [disabled]="disabled">
|
||||
<mat-icon>{{ icon }}</mat-icon>
|
||||
<span>{{ buttonText }}</span>
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
<mat-menu #commandMenu="matMenu">
|
||||
<button mat-menu-item [disabled]="command.disabled
|
||||
|| (command.slug === 'create-image' && clientData.length > 1)" *ngFor="let command of arrayCommands"
|
||||
(click)="onCommandSelect(command.slug)">
|
||||
|| (command.slug === 'create-image' && clientData.length > 1)"
|
||||
*ngFor="let command of arrayCommands" (click)="onCommandSelect(command.slug)">
|
||||
{{ command.name }}
|
||||
</button>
|
||||
</mat-menu>
|
||||
</mat-menu>
|
||||
|
|
|
@ -11,7 +11,7 @@ import { ConfigService } from '@services/config.service';
|
|||
})
|
||||
export class ExecuteCommandComponent implements OnInit {
|
||||
@Input() clientData: any[] = [];
|
||||
@Input() buttonType: 'icon' | 'text' | 'menu-item' = 'icon';
|
||||
@Input() buttonType: 'icon' | 'text' = 'icon';
|
||||
@Input() buttonText: string = 'Ejecutar Comandos';
|
||||
@Input() icon: string = 'terminal';
|
||||
@Input() disabled: boolean = false;
|
||||
|
|
|
@ -2,7 +2,6 @@ import { HttpClient } from '@angular/common/http';
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { MatTabChangeEvent } from '@angular/material/tabs';
|
||||
import {ToastrService} from "ngx-toastr";
|
||||
|
||||
@Component({
|
||||
selector: 'app-global-status',
|
||||
|
@ -41,7 +40,6 @@ export class GlobalStatusComponent implements OnInit {
|
|||
|
||||
constructor(
|
||||
private configService: ConfigService,
|
||||
private toastService: ToastrService,
|
||||
private http: HttpClient
|
||||
) {
|
||||
this.baseUrl = this.configService.apiUrl;
|
||||
|
@ -52,56 +50,6 @@ export class GlobalStatusComponent implements OnInit {
|
|||
|
||||
ngOnInit(): void {
|
||||
this.loadOgBootStatus();
|
||||
this.syncSubnets()
|
||||
this.syncTemplates()
|
||||
this.syncOgLives()
|
||||
}
|
||||
|
||||
syncSubnets() {
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.toastService.error('Error al sincronizar las subredes: tiempo de espera agotado');
|
||||
}, 3500);
|
||||
|
||||
this.http.post(`${this.baseUrl}/subnets/sync`, {}).subscribe({
|
||||
next: (response) => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.success('Sincronización con componente DHCP exitosa');
|
||||
},
|
||||
error: (error) => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.error('Error al sincronizar las subredes DHCP');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
syncTemplates() {
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.toastService.error('Error al sincronizar las plantillas Pxe: tiempo de espera agotado');
|
||||
}, 3500);
|
||||
|
||||
this.http.post(`${this.baseUrl}/pxe-templates/sync`, {})
|
||||
.subscribe(response => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.success('Sincronización de las plantillas Pxe completada');
|
||||
}, error => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.error('Error al sincronizar las plantillas Pxe');
|
||||
});
|
||||
}
|
||||
|
||||
syncOgLives(): void {
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.toastService.error('Error al sincronizar las imagenes ogLive : tiempo de espera agotado');
|
||||
}, 3500);
|
||||
|
||||
this.http.post(`${this.baseUrl}/og-lives/sync`, {})
|
||||
.subscribe(response => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.success('Sincronización con los ogLives completada');
|
||||
}, error => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.error('Error al sincronizar imágenes ogLive');
|
||||
});
|
||||
}
|
||||
|
||||
[key: string]: any;
|
||||
|
@ -245,4 +193,4 @@ export class GlobalStatusComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,10 +24,6 @@
|
|||
<mat-select [(ngModel)]="selectedImage" name="selectedImage" (selectionChange)="resetCanonicalName()" required>
|
||||
<mat-option *ngFor="let image of images" [value]="image">{{ image?.name }}</mat-option>
|
||||
</mat-select>
|
||||
<button *ngIf="selectedImage" mat-icon-button matSuffix aria-label="Clear client search"
|
||||
(click)="selectedImage = null; resetCanonicalName()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
<mat-hint>Seleccione la imagen para sobreescribir si se requiere. </mat-hint>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
|
|
@ -288,9 +288,7 @@ export class PartitionAssistantComponent {
|
|||
|
||||
this.loading = true;
|
||||
|
||||
const totalPartitionSize = this.selectedDisk.partitions
|
||||
.filter((partition: any) => !partition.removed)
|
||||
.reduce((sum: any, partition: any) => sum + partition.size, 0);
|
||||
const totalPartitionSize = this.selectedDisk.partitions.reduce((sum: any, partition: { size: any; }) => sum + partition.size, 0);
|
||||
|
||||
if (totalPartitionSize > this.selectedDisk.totalDiskSize) {
|
||||
this.toastService.error('El tamaño total de las particiones en el disco seleccionado excede el tamaño total del disco.');
|
||||
|
|
|
@ -198,9 +198,6 @@
|
|||
<mat-icon>delete</mat-icon>
|
||||
<span>{{ 'delete' | translate }}</span>
|
||||
</button>
|
||||
<app-execute-command [clientData]="selectedNode?.clients || []" [buttonType]="'menu-item'"
|
||||
[buttonText]="'Ejecutar comandos'" [icon]="'terminal'" [disabled]="!((selectedNode?.clients ?? []).length > 0)">
|
||||
</app-execute-command>
|
||||
</mat-menu>
|
||||
|
||||
</div>
|
||||
|
@ -248,8 +245,7 @@
|
|||
<div *ngFor="let client of arrayClients" class="client-item">
|
||||
<div class="client-card">
|
||||
<mat-checkbox (click)="$event.stopPropagation()" (change)="toggleRow(client)"
|
||||
[checked]="selection.isSelected(client)"
|
||||
[disabled]="client.status === 'busy' || client.status === 'off' || client.status === 'disconnected'">
|
||||
[checked]="selection.isSelected(client)" [disabled]="client.status === 'busy' || client.status === 'off' || client.status === 'disconnected'">
|
||||
</mat-checkbox>
|
||||
<img style="margin-top: 0.5em;" [src]="'assets/images/computer_' + client.status + '.svg'"
|
||||
alt="Client Icon" class="client-image" />
|
||||
|
@ -318,8 +314,7 @@
|
|||
</th>
|
||||
<td mat-cell *matCellDef="let row">
|
||||
<mat-checkbox (click)="$event.stopPropagation()" (change)="toggleRow(row)"
|
||||
[checked]="selection.isSelected(row)"
|
||||
[disabled]="row.status === 'busy' || row.status === 'off' || row.status === 'disconnected'">
|
||||
[checked]="selection.isSelected(row)" [disabled]="row.status === 'busy' || row.status === 'off' || row.status === 'disconnected'">
|
||||
</mat-checkbox>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
@ -348,22 +343,9 @@
|
|||
<th mat-header-cell *matHeaderCellDef mat-sort-header>IP </th>
|
||||
<td mat-cell *matCellDef="let client" matTooltip="{{ getClientPath(client) }}"
|
||||
matTooltipPosition="left" matTooltipShowDelay="500">
|
||||
<div style="display: flex; flex-direction: column;">
|
||||
<span>{{ client.ip }}</span>
|
||||
<span style="font-size: 0.75rem; color: gray;">{{ client.mac }}</span>
|
||||
</div>
|
||||
{{ client.ip }}
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="firmwareType">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> {{ 'firmwareType' | translate }} </th>
|
||||
<td mat-cell *matCellDef="let client">
|
||||
<mat-chip s>
|
||||
{{ client.firmwareType ? client.firmwareType : 'N/A' }}
|
||||
</mat-chip>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="oglive">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> OG Live </th>
|
||||
<td mat-cell *matCellDef="let client"> {{ client.ogLive?.date | date }} </td>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Component, OnInit, OnDestroy, ViewChild, QueryList, ViewChildren, ChangeDetectorRef} from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, ViewChild, QueryList, ViewChildren } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
@ -87,7 +87,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
{ value: 'mac', name: 'Mac' },
|
||||
];
|
||||
|
||||
displayedColumns: string[] = ['select', 'status', 'ip', 'firmwareType', 'name', 'oglive', 'subnet', 'pxeTemplate', 'actions'];
|
||||
displayedColumns: string[] = ['select', 'status', 'ip', 'name', 'oglive', 'subnet', 'pxeTemplate', 'actions'];
|
||||
|
||||
private _sort!: MatSort;
|
||||
|
||||
|
@ -110,8 +110,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
private joyrideService: JoyrideService,
|
||||
private breakpointObserver: BreakpointObserver,
|
||||
private toastr: ToastrService,
|
||||
private configService: ConfigService,
|
||||
private cd: ChangeDetectorRef,
|
||||
private configService: ConfigService
|
||||
) {
|
||||
this.baseUrl = this.configService.apiUrl;
|
||||
this.mercureUrl = this.configService.mercureUrl;
|
||||
|
@ -176,35 +175,23 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
})
|
||||
}
|
||||
|
||||
private updateClientStatus(clientUuid: string, status: string): void {
|
||||
let updated = false;
|
||||
private updateClientStatus(clientUuid: string, newStatus: string): void {
|
||||
const clientIndex = this.selectedClients.data.findIndex(client => client['@id'] === clientUuid);
|
||||
|
||||
const index = this.arrayClients.findIndex(client => client['@id'] === clientUuid);
|
||||
if (index !== -1) {
|
||||
const updatedClient = {...this.arrayClients[index], status};
|
||||
this.arrayClients = [
|
||||
...this.arrayClients.slice(0, index),
|
||||
updatedClient,
|
||||
...this.arrayClients.slice(index + 1)
|
||||
];
|
||||
updated = true;
|
||||
}
|
||||
|
||||
const tableIndex = this.selectedClients.data.findIndex(client => client['@id'] === clientUuid);
|
||||
|
||||
if (tableIndex !== -1) {
|
||||
if (clientIndex !== -1) {
|
||||
const updatedClients = [...this.selectedClients.data];
|
||||
|
||||
updatedClients[tableIndex] = {
|
||||
...updatedClients[tableIndex],
|
||||
status: status
|
||||
updatedClients[clientIndex] = {
|
||||
...updatedClients[clientIndex],
|
||||
status: newStatus
|
||||
};
|
||||
|
||||
this.selectedClients.data = updatedClients;
|
||||
}
|
||||
this.arrayClients = updatedClients;
|
||||
|
||||
if (updated) {
|
||||
this.cd.detectChanges();
|
||||
console.log(`Estado actualizado para el cliente ${clientUuid}: ${newStatus}`);
|
||||
} else {
|
||||
console.warn(`Cliente con UUID ${clientUuid} no encontrado en la lista.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,15 +369,13 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
onNodeClick(event: MouseEvent, node: TreeNode): void {
|
||||
event.stopPropagation();
|
||||
this.selectedNode = node;
|
||||
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
|
||||
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
|
||||
this.fetchClientsForNode(node);
|
||||
}
|
||||
|
||||
onMenuClick(event: Event, node: any): void {
|
||||
event.stopPropagation();
|
||||
this.selectedNode = node;
|
||||
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
|
||||
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
|
||||
this.fetchClientsForNode(node);
|
||||
}
|
||||
|
||||
|
||||
|
@ -401,9 +386,6 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
this.http.get<any>(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}&page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`, { params }).subscribe({
|
||||
next: (response: any) => {
|
||||
this.selectedClients.data = response['hydra:member'];
|
||||
if (this.selectedNode) {
|
||||
this.selectedNode.clients = response['hydra:member'];
|
||||
}
|
||||
this.length = response['hydra:totalItems'];
|
||||
this.arrayClients = this.selectedClients.data;
|
||||
this.hasClients = this.selectedClients.data.length > 0;
|
||||
|
@ -437,7 +419,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
width: '900px',
|
||||
});
|
||||
dialogRef.afterClosed().subscribe((newUnit) => {
|
||||
if (newUnit) {
|
||||
if (newUnit?.uuid) {
|
||||
this.refreshData(newUnit.uuid);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -105,7 +105,6 @@ export class ManageClientComponent implements OnInit {
|
|||
this.parentUnitsWithPaths = this.parentUnits.map(unit => ({
|
||||
id: unit['@id'],
|
||||
name: unit.name,
|
||||
netiface: unit.networkSettings?.netiface,
|
||||
path: this.dataService.getOrganizationalUnitPath(unit, this.parentUnits),
|
||||
repository: unit.networkSettings?.repository?.['@id'],
|
||||
hardwareProfile: unit.networkSettings?.hardwareProfile?.['@id'],
|
||||
|
@ -227,8 +226,7 @@ export class ManageClientComponent implements OnInit {
|
|||
repository: selectedUnit.repository || null,
|
||||
hardwareProfile: selectedUnit.hardwareProfile || null,
|
||||
ogLive: selectedUnit.ogLive || null,
|
||||
menu: selectedUnit.menu || null,
|
||||
netiface: selectedUnit.netiface || null,
|
||||
menu: selectedUnit.menu || null
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<app-loading [isLoading]="loading"></app-loading>
|
||||
|
||||
<div class="header-container">
|
||||
<button mat-icon-button color="primary" (click)="iniciarTour()">
|
||||
<mat-icon>help</mat-icon>
|
||||
|
|
|
@ -79,6 +79,7 @@ export class PXEimagesComponent implements OnInit {
|
|||
this.loading = true;
|
||||
this.search();
|
||||
this.loadAlert();
|
||||
this.syncOgBoot()
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
|
@ -244,6 +245,17 @@ export class PXEimagesComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
|
||||
syncOgBoot(): void {
|
||||
this.http.post(`${this.apiUrl}/sync`, {})
|
||||
.subscribe(response => {
|
||||
this.toastService.success('Sincronización con oGBoot exitosa');
|
||||
this.search()
|
||||
}, error => {
|
||||
console.error('Error al sincronizar', error);
|
||||
this.toastService.error('Error al sincronizar');
|
||||
});
|
||||
}
|
||||
|
||||
iniciarTour(): void {
|
||||
this.joyrideService.startTour({
|
||||
steps: [
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
</div>
|
||||
|
||||
<app-loading [isLoading]="loading"></app-loading>
|
||||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep"
|
||||
<table *ngIf="!loading" mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep"
|
||||
text="{{ 'tableDescription' | translate }}">
|
||||
<ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
|
||||
<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 === 'synchronized'">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { HttpClient } from '@angular/common/http';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { CreatePxeTemplateComponent } from './create-pxeTemplate/create-pxe-template.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
|
@ -19,7 +19,7 @@ import { ConfigService } from '@services/config.service';
|
|||
templateUrl: './pxe.component.html',
|
||||
styleUrls: ['./pxe.component.css']
|
||||
})
|
||||
export class PxeComponent implements OnInit{
|
||||
export class PxeComponent {
|
||||
baseUrl: string;
|
||||
private apiUrl: string;
|
||||
pxeTemplates: any[] = [];
|
||||
|
@ -76,6 +76,7 @@ export class PxeComponent implements OnInit{
|
|||
this.loading = true;
|
||||
this.search();
|
||||
this.loadAlert()
|
||||
this.syncTemplates()
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
|
@ -146,6 +147,17 @@ export class PxeComponent implements OnInit{
|
|||
const dialogRef = this.dialog.open(ShowTemplateContentComponent, { data: { data }, width: '700px' });
|
||||
}
|
||||
|
||||
syncTemplates() {
|
||||
this.http.post(`${this.apiUrl}/sync`, {})
|
||||
.subscribe(response => {
|
||||
this.toastService.success('Sincronización completada');
|
||||
this.search()
|
||||
}, error => {
|
||||
console.error('Error al sincronizar', error);
|
||||
this.toastService.error('Error al sincronizar');
|
||||
});
|
||||
}
|
||||
|
||||
applyFilter() {
|
||||
this.http.get<any>(`${this.apiUrl}?page=${this.page}&itemsPerPage=${this.itemsPerPage}`).subscribe({
|
||||
next: (response) => {
|
||||
|
|
|
@ -72,4 +72,10 @@ describe('OgDhcpSubnetsComponent', () => {
|
|||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should call syncSubnets and handle success', () => {
|
||||
component.syncSubnets();
|
||||
expect(mockHttpClient.post).toHaveBeenCalledWith(`${component.baseUrl}/subnets/sync`, {});
|
||||
expect(mockToastrService.success).toHaveBeenCalledWith('Sincronización con componente DHCP exitosa');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -69,21 +69,19 @@ export class OgDhcpSubnetsComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.loading = true;
|
||||
this.loadAlert()
|
||||
this.loadSubnets()
|
||||
this.syncSubnets()
|
||||
}
|
||||
|
||||
loadSubnets() {
|
||||
this.loading = true;
|
||||
this.http.get<any>(`${this.baseUrl}/subnets?page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`).subscribe({
|
||||
next: (response) => {
|
||||
this.dataSource.data = response['hydra:member'];
|
||||
this.length = response['hydra:totalItems'];
|
||||
this.loading = false;
|
||||
},
|
||||
error: error => {
|
||||
this.toastService.error(error.error['hydra:description']);
|
||||
this.loading = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -92,6 +90,28 @@ export class OgDhcpSubnetsComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
syncSubnets() {
|
||||
this.loading = true;
|
||||
const timeoutId = setTimeout(() => {
|
||||
this.loading = false;
|
||||
this.toastService.error('Error al sincronizar: tiempo de espera agotado');
|
||||
}, 3500);
|
||||
|
||||
this.http.post(`${this.apiUrl}/sync`, {}).subscribe({
|
||||
next: (response) => {
|
||||
clearTimeout(timeoutId);
|
||||
this.toastService.success('Sincronización con componente DHCP exitosa');
|
||||
this.loadSubnets();
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
clearTimeout(timeoutId);
|
||||
this.loading = false;
|
||||
this.toastService.error('Error al sincronizar');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleAction(subnet: any, action: string): void {
|
||||
switch (action) {
|
||||
case 'get':
|
||||
|
|
|
@ -60,7 +60,7 @@ export class RepositoriesComponent implements OnInit {
|
|||
cell: (repository: any) => `${this.datePipe.transform(repository.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
|
||||
}
|
||||
];
|
||||
isGitModuleInstalled: boolean = false;
|
||||
isGitModuleInstalled: boolean = true;
|
||||
displayedColumns: string[] = ['id', 'name', 'ip', 'user', 'images', 'createdAt', 'actions'];
|
||||
|
||||
constructor(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
<div class="images-button-row">
|
||||
<button class="action-button" (click)="openImageInfoDialog()">Ver Información</button>
|
||||
<button disabled class="action-button" (click)="syncRepository()">Sincronizar base de datos</button>
|
||||
<button class="action-button" (click)="syncRepository()">Sincronizar base de datos</button>
|
||||
<button class="action-button" (click)="importImage()">
|
||||
{{ 'importImageButton' | translate }}
|
||||
</button>
|
||||
|
|
|
@ -12,7 +12,7 @@ export class ConfigService {
|
|||
constructor(private http: HttpClient) {}
|
||||
|
||||
loadConfig() {
|
||||
return this.http.get('assets/config.json').pipe(
|
||||
return this.http.get('/assets/config.json').pipe(
|
||||
catchError((error) => {
|
||||
console.error('Error loading config.json', error);
|
||||
return of({});
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"labelOrganizationalUnit": "Organizational Unit",
|
||||
"buttonCancel": "Cancel",
|
||||
"buttonAdd": "Add",
|
||||
"firmwareType": "Firmware",
|
||||
"addRule": "Add rule",
|
||||
"rulesHeader": "Rules",
|
||||
"statusUnavailable": "Unavailable",
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
"labelOrganizationalUnit": "Unidad organizativa",
|
||||
"buttonCancel": "Cancelar",
|
||||
"buttonAdd": "Añadir",
|
||||
"firmwareType": "Firmware",
|
||||
"back": "Atrás",
|
||||
"addClientDialogTitle": "Añadir Cliente",
|
||||
"dialogTitleEditUser": "Editar usuario",
|
||||
|
|
Loading…
Reference in New Issue