Añadido translate instante en los controladores ts

pull/72/head
Juan Manuel Bardallo 2026-04-23 09:20:13 +02:00
parent 954ca0cc6e
commit 6d29d017d9
143 changed files with 2056 additions and 800 deletions

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component } from '@angular/core'; import { Component } 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";
@ -9,6 +11,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './env-vars.component.css' styleUrl: './env-vars.component.css'
}) })
export class EnvVarsComponent { export class EnvVarsComponent {
public translate = inject(TranslateService);
envVars: { name: string; value: string }[] = []; envVars: { name: string; value: string }[] = [];
displayedColumns: string[] = ['name', 'value']; displayedColumns: string[] = ['name', 'value'];
private apiUrl: string; private apiUrl: string;
@ -31,7 +34,7 @@ export class EnvVarsComponent {
this.envVars = Object.entries(response.vars).map(([name, value]) => ({ name, value })); this.envVars = Object.entries(response.vars).map(([name, value]) => ({ name, value }));
}, },
error: (err) => { error: (err) => {
this.toastService.error('No se pudieron cargar las variables de entorno.'); this.toastService.error(this.translate.instant('noSePudieronCargarLas'));
} }
}); });
} }
@ -48,11 +51,11 @@ export class EnvVarsComponent {
this.http.post(this.apiUrl, { vars }).subscribe({ this.http.post(this.apiUrl, { vars }).subscribe({
next: () => { next: () => {
this.toastService.success('Variables de entorno guardadas correctamente.'); this.toastService.success(this.translate.instant('variablesDeEntornoGuardadasCorrectamente'));
}, },
error: (err) => { error: (err) => {
console.error('Error al guardar las variables de entorno:', err); console.error(this.translate.instant('errorAlGuardarLasVariables'), err);
this.toastService.error('No se pudieron cargar las variables de entorno.'); this.toastService.error(this.translate.instant('noSePudieronCargarLas'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./add-role-modal.component.css'] styleUrls: ['./add-role-modal.component.css']
}) })
export class AddRoleModalComponent { export class AddRoleModalComponent {
public translate = inject(TranslateService);
roleForm: FormGroup<any>; roleForm: FormGroup<any>;
roleId: string | null = null; roleId: string | null = null;
baseUrl: string; baseUrl: string;
@ -56,7 +59,7 @@ export class AddRoleModalComponent {
this.roleId = response['@id']; this.roleId = response['@id'];
}, },
error: (err) => { error: (err) => {
console.error('Error fetching remote calendar:', err); console.error(this.translate.instant('errorFetchingRemoteCalendar'), err);
} }
}); });
} }
@ -85,23 +88,23 @@ export class AddRoleModalComponent {
if (this.roleId) { if (this.roleId) {
this.http.put(`${this.baseUrl}${this.roleId}`, payload).subscribe( this.http.put(`${this.baseUrl}${this.roleId}`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Rol actualizado correctamente'); this.toastService.success(this.translate.instant('rolActualizadoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
this.toastService.error('Error al editar el rol:', error); this.toastService.error(this.translate.instant('errorAlEditarElRol1'), error);
console.error('Error al editar el rol', error); console.error(this.translate.instant('errorAlEditarElRol'), error);
} }
); );
} else { } else {
this.http.post(`${this.baseUrl}/user-groups`, payload).subscribe( this.http.post(`${this.baseUrl}/user-groups`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Rol añadido correctamente'); this.toastService.success(this.translate.instant('rolAnadidoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
this.toastService.error('Error al añadir rol:', error); this.toastService.error(this.translate.instant('errorAlAnadirRol1'), error);
console.error('Error al añadir rol', error); console.error(this.translate.instant('errorAlAnadirRol'), error);
} }
); );
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {HttpClient, HttpParams} from '@angular/common/http'; import {HttpClient, HttpParams} from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -8,6 +10,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -31,7 +34,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user groups', error); console.error(this.translate.instant('errorFetchingUserGroups'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -47,7 +50,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user group', error); console.error(this.translate.instant('errorFetchingUserGroup'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -24,7 +24,7 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let role"> {{ column.cell(role) }} </td> <td mat-cell *matCellDef="let role"> {{ column.cell(role) }} </td>
</ng-container> </ng-container>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -15,6 +17,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./roles.component.css'] styleUrls: ['./roles.component.css']
}) })
export class RolesComponent implements OnInit { export class RolesComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string = this.configService.apiUrl; baseUrl: string = this.configService.apiUrl;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
filters: { [key: string]: string } = {}; filters: { [key: string]: string } = {};
@ -27,17 +30,17 @@ export class RolesComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (role: any) => `${role.id}` cell: (role: any) => `${role.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (role: any) => `${role.name}` cell: (role: any) => `${role.name}`
}, },
{ {
columnDef: 'permissions', columnDef: 'permissions',
header: 'Permisos', header: 'permisos',
cell: (role: any) => `${role.permissions.join(', ')}` cell: (role: any) => `${role.permissions.join(', ')}`
} }
]; ];
@ -66,7 +69,7 @@ export class RolesComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching roles', error); console.error(this.translate.instant('errorFetchingRoles'), error);
this.loading = false; this.loading = false;
} }
); );
@ -108,10 +111,10 @@ export class RolesComponent implements OnInit {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('Role deleted successfully'); this.toastService.success(this.translate.instant('roleDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error deleting role:', error); this.toastService.error(this.translate.instant('errorDeletingRole'), error);
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
@ -18,6 +20,7 @@ interface UserGroup {
styleUrls: ['./add-user-modal.component.css'] styleUrls: ['./add-user-modal.component.css']
}) })
export class AddUserModalComponent implements OnInit { export class AddUserModalComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@Output() userAdded = new EventEmitter<void>(); @Output() userAdded = new EventEmitter<void>();
@Output() userEdited = new EventEmitter<void>(); @Output() userEdited = new EventEmitter<void>();
@ -94,7 +97,7 @@ export class AddUserModalComponent implements OnInit {
}, },
error: (err) => { error: (err) => {
this.loading = false; this.loading = false;
console.error('Error fetching user:', err); console.error(this.translate.instant('errorFetchingUser'), err);
} }
}); });
} }
@ -125,7 +128,7 @@ export class AddUserModalComponent implements OnInit {
if (this.userId) { if (this.userId) {
this.http.put(`${this.baseUrl}${this.userId}`, payload).subscribe( this.http.put(`${this.baseUrl}${this.userId}`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Usuario editado correctamente'); this.toastService.success(this.translate.instant('usuarioEditadoCorrectamente'));
this.userEdited.emit(); this.userEdited.emit();
this.dialogRef.close(); this.dialogRef.close();
this.loading = false; this.loading = false;
@ -138,7 +141,7 @@ export class AddUserModalComponent implements OnInit {
} else { } else {
this.http.post(`${this.baseUrl}/users`, payload).subscribe( this.http.post(`${this.baseUrl}/users`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Usuario añadido correctamente'); this.toastService.success(this.translate.instant('usuarioAnadidoCorrectamente'));
this.userAdded.emit(); this.userAdded.emit();
this.dialogRef.close(); this.dialogRef.close();
this.loading = false; this.loading = false;

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, EventEmitter, Inject, Output } from '@angular/core'; import { Component, EventEmitter, Inject, Output } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@ -10,6 +12,7 @@ import {ToastrService} from "ngx-toastr";
styleUrl: './change-password-modal.component.css' styleUrl: './change-password-modal.component.css'
}) })
export class ChangePasswordModalComponent { export class ChangePasswordModalComponent {
public translate = inject(TranslateService);
@Output() userEdited = new EventEmitter<void>(); @Output() userEdited = new EventEmitter<void>();
userForm: FormGroup; userForm: FormGroup;
passwordMismatch: boolean = false; passwordMismatch: boolean = false;
@ -55,10 +58,10 @@ export class ChangePasswordModalComponent {
next: () => { next: () => {
this.userEdited.emit(); this.userEdited.emit();
this.dialogRef.close(); this.dialogRef.close();
this.toastService.success('Contraseña cambiada con éxito'); this.toastService.success(this.translate.instant('contrasenaCambiadaConExito'));
}, },
error: (err) => { error: (err) => {
console.error('Error changing password:', err); console.error(this.translate.instant('errorChangingPassword'), err);
this.toastService.error(err.error['hydra:description']); this.toastService.error(err.error['hydra:description']);
this.resetPasswordError = err.error.message; this.resetPasswordError = err.error.message;
this.updateError = true; this.updateError = true;
@ -66,7 +69,7 @@ export class ChangePasswordModalComponent {
} }
}); });
} else { } else {
console.error('Form is invalid'); console.error(this.translate.instant('formIsInvalid'));
this.passwordMismatch = this.userForm.hasError('mismatch'); this.passwordMismatch = this.userForm.hasError('mismatch');
this.updateError = true; this.updateError = true;
this.loading = false this.loading = false

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {HttpClient, HttpParams} from '@angular/common/http'; import {HttpClient, HttpParams} from '@angular/common/http';
@ -9,6 +11,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -32,7 +35,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching users', error); console.error(this.translate.instant('errorFetchingUsers'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -48,7 +51,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user group', error); console.error(this.translate.instant('errorFetchingUserGroup'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -64,7 +67,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user groups', error); console.error(this.translate.instant('errorFetchingUserGroups'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -80,7 +83,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching organizational units', error); console.error(this.translate.instant('errorFetchingOrganizationalUnits'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -24,7 +24,7 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let user"> <td mat-cell *matCellDef="let user">
<ng-container *ngIf="column.columnDef === 'groupsView'"> <ng-container *ngIf="column.columnDef === 'groupsView'">
<mat-chip> <mat-chip>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -13,6 +15,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./users.component.css'] styleUrls: ['./users.component.css']
}) })
export class UsersComponent implements OnInit { export class UsersComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -25,32 +28,32 @@ export class UsersComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (user: any) => `${user.id}` cell: (user: any) => `${user.id}`
}, },
{ {
columnDef: 'username', columnDef: 'username',
header: 'Nombre de Usuario', header: 'nombreDeUsuario',
cell: (user: any) => `${user.username}` cell: (user: any) => `${user.username}`
}, },
{ {
columnDef: 'groupsView', columnDef: 'groupsView',
header: 'Vista de Grupos', header: 'vistaDeGrupos',
cell: (user: any) => `${user.groupsView}` cell: (user: any) => `${user.groupsView}`
}, },
{ {
columnDef: 'clientsPerPage', columnDef: 'clientsPerPage',
header: 'Clientes por página', header: 'clientesPorPagina',
cell: (user: any) => user.clientsPerPage != null ? `${user.clientsPerPage}` : '-' cell: (user: any) => user.clientsPerPage != null ? `${user.clientsPerPage}` : '-'
}, },
{ {
columnDef: 'allowedOrganizationalUnits', columnDef: 'allowedOrganizationalUnits',
header: 'Unidades Organizacionales Permitidas', header: 'unidadesOrganizacionalesPermitidas',
cell: (user: any) => `${user.allowedOrganizationalUnits.map((unit: { name: any; }) => unit.name).join(', ')}` cell: (user: any) => `${user.allowedOrganizationalUnits.map((unit: { name: any; }) => unit.name).join(', ')}`
}, },
{ {
columnDef: 'roles', columnDef: 'roles',
header: 'Roles', header: 'roles',
cell: (user: any) => `${user.roles.join(', ')}` cell: (user: any) => `${user.roles.join(', ')}`
} }
]; ];
@ -79,7 +82,7 @@ export class UsersComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching users', error); console.error(this.translate.instant('errorFetchingUsers'), error);
this.loading = false; this.loading = false;
} }
); );
@ -123,11 +126,11 @@ export class UsersComponent implements OnInit {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
console.log('User deleted successfully'); console.log('User deleted successfully');
this.toastService.success('User deleted successfully'); this.toastService.success(this.translate.instant('userDeletedSuccessfully'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error deleting user:', error); console.error(this.translate.instant('errorDeletingUser'), error);
} }
}); });
} }

View File

@ -30,7 +30,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep" <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep"
text="{{ 'tableStepText' | translate }}"> text="{{ 'tableStepText' | 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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'"> <ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'">
<mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, signal } from '@angular/core'; import { Component, OnInit, signal } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
@ -17,6 +19,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './calendar.component.css' styleUrl: './calendar.component.css'
}) })
export class CalendarComponent implements OnInit { export class CalendarComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
images: { downloadUrl: string; name: string; uuid: string }[] = []; images: { downloadUrl: string; name: string; uuid: string }[] = [];
@ -34,22 +37,22 @@ export class CalendarComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (remoteCalendar: any) => `${remoteCalendar.id}`, cell: (remoteCalendar: any) => `${remoteCalendar.id}`,
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (remoteCalendar: any) => `${remoteCalendar.name}` cell: (remoteCalendar: any) => `${remoteCalendar.name}`
}, },
{ {
columnDef: 'rulesLength', columnDef: 'rulesLength',
header: 'Nº de reglas', header: 'nDeReglas',
cell: (remoteCalendar: any) => `${remoteCalendar.remoteCalendarRules.length}` cell: (remoteCalendar: any) => `${remoteCalendar.remoteCalendarRules.length}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (remoteCalendar: any) => `${this.datePipe.transform(remoteCalendar.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (remoteCalendar: any) => `${this.datePipe.transform(remoteCalendar.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -89,7 +92,7 @@ export class CalendarComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error => { error => {
console.error('Error fetching calendars', error); console.error(this.translate.instant('errorFetchingCalendars'), error);
this.loading = false; this.loading = false;
} }
); );
@ -99,7 +102,7 @@ export class CalendarComponent implements OnInit {
this.syncUds = true; this.syncUds = true;
this.http.post(`${this.apiUrl}/${calendar.uuid}/sync-uds`, {}).subscribe({ this.http.post(`${this.apiUrl}/${calendar.uuid}/sync-uds`, {}).subscribe({
next: () => { next: () => {
this.toastService.success('Calendarios sincronizados correctamente'); this.toastService.success(this.translate.instant('calendariosSincronizadosCorrectamente'));
this.search(); this.search();
this.syncUds = false; this.syncUds = false;
}, },
@ -136,10 +139,10 @@ export class CalendarComponent implements OnInit {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('Calendar deleted successfully'); this.toastService.success(this.translate.instant('calendarDeletedSuccessfully'));
}, },
error: () => { error: () => {
this.toastService.error('Error deleting calendar'); this.toastService.error(this.translate.instant('errorDeletingCalendar'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { ToastrService } from "ngx-toastr"; import { ToastrService } from "ngx-toastr";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -10,6 +12,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './create-calendar-rule.component.css' styleUrl: './create-calendar-rule.component.css'
}) })
export class CreateCalendarRuleComponent { export class CreateCalendarRuleComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
name: string = ''; name: string = '';
remoteCalendarRules: any[] = []; remoteCalendarRules: any[] = [];
@ -98,7 +101,7 @@ export class CreateCalendarRuleComponent {
this.http.put(`${this.baseUrl}${this.ruleId}`, formData) this.http.put(`${this.baseUrl}${this.ruleId}`, formData)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Calendar rule updated successfully'); this.toastService.success(this.translate.instant('calendarRuleUpdatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {
@ -110,7 +113,7 @@ export class CreateCalendarRuleComponent {
this.http.post(`${this.baseUrl}/remote-calendar-rules`, formData) this.http.post(`${this.baseUrl}/remote-calendar-rules`, formData)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Calendar rule created successfully'); this.toastService.success(this.translate.instant('calendarRuleCreatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { ToastrService } from "ngx-toastr"; import { ToastrService } from "ngx-toastr";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -13,6 +15,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './create-calendar.component.css' styleUrl: './create-calendar.component.css'
}) })
export class CreateCalendarComponent implements OnInit { export class CreateCalendarComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
name: string = ''; name: string = '';
remoteCalendarRules: any[] = []; remoteCalendarRules: any[] = [];
@ -50,7 +53,7 @@ export class CreateCalendarComponent implements OnInit {
}); });
}, },
error: (err) => { error: (err) => {
console.error('Error fetching remote calendar:', err); console.error(this.translate.instant('errorFetchingRemoteCalendar'), err);
} }
}); });
} }
@ -75,7 +78,7 @@ export class CreateCalendarComponent implements OnInit {
this.http.patch(`${this.baseUrl}${this.calendarId}`, payload) this.http.patch(`${this.baseUrl}${this.calendarId}`, payload)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Calendar updated successfully'); this.toastService.success(this.translate.instant('calendarUpdatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
this.load() this.load()
}, },
@ -88,7 +91,7 @@ export class CreateCalendarComponent implements OnInit {
this.http.post(`${this.baseUrl}/remote-calendars`, payload) this.http.post(`${this.baseUrl}/remote-calendars`, payload)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Calendar created successfully'); this.toastService.success(this.translate.instant('calendarCreatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
this.load() this.load()
}, },
@ -129,10 +132,10 @@ export class CreateCalendarComponent implements OnInit {
next: () => { next: () => {
console.log('Calendar deleted successfully'); console.log('Calendar deleted successfully');
this.load(); this.load();
this.toastService.success('Calendar deleted successfully'); this.toastService.success(this.translate.instant('calendarDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error deleting calendar'); this.toastService.error(this.translate.instant('errorDeletingCalendar'));
} }
}); });
} else { } else {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -8,6 +10,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -28,7 +31,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching remote calendars', error); console.error(this.translate.instant('errorFetchingRemoteCalendars'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -44,7 +47,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching calendar', error); console.error(this.translate.instant('errorFetchingCalendar'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -28,7 +28,7 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | translate }}"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | 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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let commandGroup"> <td mat-cell *matCellDef="let commandGroup">
<ng-container *ngIf="column.columnDef !== 'commands'"> <ng-container *ngIf="column.columnDef !== 'commands'">
{{ column.cell(commandGroup) }} {{ column.cell(commandGroup) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -16,6 +18,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./commands-groups.component.css'] styleUrls: ['./commands-groups.component.css']
}) })
export class CommandsGroupsComponent implements OnInit { export class CommandsGroupsComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -29,22 +32,22 @@ export class CommandsGroupsComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (group: any) => `${group.id}`, cell: (group: any) => `${group.id}`,
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (group: any) => `${group.name}` cell: (group: any) => `${group.name}`
}, },
{ {
columnDef: 'commands', columnDef: 'commands',
header: 'Lista de comandos', header: 'listaDeComandos',
cell: (group: any) => `${group.commands}` cell: (group: any) => `${group.commands}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (group: any) => `${this.datePipe.transform(group.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (group: any) => `${this.datePipe.transform(group.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -69,7 +72,7 @@ export class CommandsGroupsComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching command groups', error); console.error(this.translate.instant('errorFetchingCommandGroups'), error);
this.loading = false; this.loading = false;
} }
); );
@ -103,11 +106,11 @@ export class CommandsGroupsComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${group.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${group.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Grupo de comandos eliminado con éxito'); this.toastService.success(this.translate.instant('grupoDeComandosEliminadoCon'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar el grupo de comandos:', error); console.error(this.translate.instant('errorAlEliminarElGrupo'), error);
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./create-command-group.component.css'] styleUrls: ['./create-command-group.component.css']
}) })
export class CreateCommandGroupComponent implements OnInit { export class CreateCommandGroupComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
availableCommands: any[] = []; availableCommands: any[] = [];
selectedCommands: any[] = []; selectedCommands: any[] = [];
@ -48,7 +51,7 @@ export class CreateCommandGroupComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching available commands', error); console.error(this.translate.instant('errorFetchingAvailableCommands'), error);
this.loading = false; this.loading = false;
} }
); );
@ -88,23 +91,23 @@ export class CreateCommandGroupComponent implements OnInit {
const groupId = this.data.group.uuid; const groupId = this.data.group.uuid;
this.http.patch(`${this.baseUrl}/command-groups/${groupId}`, payload).subscribe({ this.http.patch(`${this.baseUrl}/command-groups/${groupId}`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Grupo de comandos actualizado con éxito'); this.toastService.success(this.translate.instant('grupoDeComandosActualizadoCon'));
this.dialogRef.close(); this.dialogRef.close();
}, },
error: (error) => { error: (error) => {
console.error('Error actualizando el grupo de comandos', error); console.error(this.translate.instant('errorActualizandoElGrupoDe'), error);
this.toastService.error('Error al actualizar el grupo de comandos'); this.toastService.error(this.translate.instant('errorAlActualizarElGrupo'));
} }
}); });
} else { } else {
this.http.post(`${this.baseUrl}/command-groups`, payload).subscribe({ this.http.post(`${this.baseUrl}/command-groups`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Grupo de comandos creado con éxito'); this.toastService.success(this.translate.instant('grupoDeComandosCreadoCon'));
this.dialogRef.close(); this.dialogRef.close();
}, },
error: (error) => { error: (error) => {
console.error('Error creando el grupo de comandos', error); console.error(this.translate.instant('errorCreandoElGrupoDe'), error);
this.toastService.error('Error al crear el grupo de comandos'); this.toastService.error(this.translate.instant('errorAlCrearElGrupo'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./detail-command-group.component.css'] styleUrls: ['./detail-command-group.component.css']
}) })
export class DetailCommandGroupComponent implements OnInit { export class DetailCommandGroupComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
form!: FormGroup; form!: FormGroup;
clients: any[] = []; clients: any[] = [];
@ -45,7 +48,7 @@ export class DetailCommandGroupComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error: (error) => { error: (error) => {
console.error('Error fetching clients:', error); console.error(this.translate.instant('errorFetchingClients1'), error);
this.loading = false; this.loading = false;
} }
}); });
@ -70,11 +73,11 @@ export class DetailCommandGroupComponent implements OnInit {
this.http.post(apiUrl, payload).subscribe({ this.http.post(apiUrl, payload).subscribe({
next: () => { next: () => {
this.dialogRef.close(); this.dialogRef.close();
this.toastService.success('Grupo de comandos ejecutado exitosamente'); this.toastService.success(this.translate.instant('grupoDeComandosEjecutadoExitosamente'));
this.loading = false; this.loading = false;
}, },
error: (error) => { error: (error) => {
console.error('Error ejecutando grupo de comandos:', error); console.error(this.translate.instant('errorEjecutandoGrupoDeComandos'), error);
this.loading = false; this.loading = false;
} }
}); });

View File

@ -26,7 +26,7 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<table mat-table [dataSource]="tasks" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | translate }}"> <table mat-table [dataSource]="tasks" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | 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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let task"> <td mat-cell *matCellDef="let task">
<ng-container *ngIf="column.columnDef !== 'management' && column.columnDef !== 'scope' && column.columnDef !== 'organizationalUnit'"> <ng-container *ngIf="column.columnDef !== 'management' && column.columnDef !== 'scope' && column.columnDef !== 'organizationalUnit'">
{{ column.cell(task) }} {{ column.cell(task) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -16,6 +18,7 @@ import {DatePipe} from "@angular/common";
styleUrls: ['./commands-task.component.css'] styleUrls: ['./commands-task.component.css']
}) })
export class CommandsTaskComponent implements OnInit { export class CommandsTaskComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
tasks: any[] = []; tasks: any[] = [];
filters: { [key: string]: string | boolean } = {}; filters: { [key: string]: string | boolean } = {};
@ -26,13 +29,13 @@ export class CommandsTaskComponent implements OnInit {
datePipe: DatePipe = new DatePipe('es-ES'); datePipe: DatePipe = new DatePipe('es-ES');
columns = [ columns = [
{ columnDef: 'id', header: 'ID', cell: (task: any) => task.id }, { columnDef: 'id', header: 'id', cell: (task: any) => task.id },
{ columnDef: 'name', header: 'Nombre de tarea', cell: (task: any) => task.name }, { columnDef: 'name', header: 'nombreDeTarea', cell: (task: any) => task.name },
{ columnDef: 'scope', header: 'Ámbito', cell: (task: any) => task.scope }, { columnDef: 'scope', header: 'ambito', cell: (task: any) => task.scope },
{ columnDef: 'organizationalUnit', header: 'Unidad Organizativa', cell: (task: any) => task.organizationalUnit?.name || '' }, { columnDef: 'organizationalUnit', header: 'unidadOrganizativa', cell: (task: any) => task.organizationalUnit?.name || '' },
{ columnDef: 'management', header: 'Gestiones', cell: (task: any) => task.schedules }, { columnDef: 'management', header: 'gestiones', cell: (task: any) => task.schedules },
{ columnDef: 'nextExecution', header: 'Próxima ejecución', cell: (task: any) => this.datePipe.transform(task.nextExecution, 'dd/MM/yyyy HH:mm:ss') }, { columnDef: 'nextExecution', header: 'proximaEjecucion', cell: (task: any) => this.datePipe.transform(task.nextExecution, 'dd/MM/yyyy HH:mm:ss') },
{ columnDef: 'createdBy', header: 'Creado por', cell: (task: any) => task.createdBy }, { columnDef: 'createdBy', header: 'creadoPor', cell: (task: any) => task.createdBy },
]; ];
displayedColumns: string[] = ['id', 'name', 'scope', 'management', 'nextExecution', 'createdBy', 'actions']; displayedColumns: string[] = ['id', 'name', 'scope', 'management', 'nextExecution', 'createdBy', 'actions'];
@ -65,7 +68,7 @@ export class CommandsTaskComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching tasks', error); console.error(this.translate.instant('errorFetchingTasks'), error);
this.loading = false; this.loading = false;
} }
); );
@ -133,11 +136,11 @@ export class CommandsTaskComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${task.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${task.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Tarea eliminada con éxito'); this.toastService.success(this.translate.instant('tareaEliminadaConExito'));
this.loadTasks(); this.loadTasks();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar la tarea:', error); console.error(this.translate.instant('errorAlEliminarLaTarea'), error);
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import {FormBuilder, FormGroup} from "@angular/forms"; import {FormBuilder, FormGroup} from "@angular/forms";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@ -11,12 +13,13 @@ import {ConfigService} from "@services/config.service";
styleUrl: './create-task-schedule.component.css' styleUrl: './create-task-schedule.component.css'
}) })
export class CreateTaskScheduleComponent implements OnInit{ export class CreateTaskScheduleComponent implements OnInit{
public translate = inject(TranslateService);
form: FormGroup; form: FormGroup;
baseUrl: string; baseUrl: string;
apiUrl: string; apiUrl: string;
recurrenceTypes = [ recurrenceTypes = [
{ value: 'none', label: 'Sin repetición' }, { value: 'none', label : this.translate.instant('sinRepeticion') },
{ value: 'custom', label: 'Repetición personalizada' } { value: 'custom', label : this.translate.instant('repeticionPersonalizada') }
]; ];
weekDays: string[] = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; weekDays: string[] = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
isSingleDateSelected: boolean = true; isSingleDateSelected: boolean = true;
@ -105,7 +108,7 @@ export class CreateTaskScheduleComponent implements OnInit{
}, {}); }, {});
}, },
(error) => { (error) => {
console.error('Error loading schedule data', error); console.error(this.translate.instant('errorLoadingScheduleData'), error);
} }
); );
} }
@ -173,12 +176,12 @@ export class CreateTaskScheduleComponent implements OnInit{
const selectedMonthNames = Object.keys(this.selectedMonths).filter(month => this.selectedMonths[month]); const selectedMonthNames = Object.keys(this.selectedMonths).filter(month => this.selectedMonths[month]);
if (selectedDayNames.length === 0) { if (selectedDayNames.length === 0) {
this.toastr.error('Debe seleccionar al menos un día de la semana'); this.toastr.error(this.translate.instant('debeSeleccionarAlMenosUn1'));
return; return;
} }
if (selectedMonthNames.length === 0) { if (selectedMonthNames.length === 0) {
this.toastr.error('Debe seleccionar al menos un mes'); this.toastr.error(this.translate.instant('debeSeleccionarAlMenosUn2'));
return; return;
} }
@ -186,12 +189,12 @@ export class CreateTaskScheduleComponent implements OnInit{
const endDate = formData.recurrenceDetails?.endDate; const endDate = formData.recurrenceDetails?.endDate;
if (!initDate || !endDate) { if (!initDate || !endDate) {
this.toastr.error('Debe especificar fecha de inicio y fecha de fin'); this.toastr.error(this.translate.instant('debeEspecificarFechaDeInicio'));
return; return;
} }
if (new Date(endDate) <= new Date(initDate)) { if (new Date(endDate) <= new Date(initDate)) {
this.toastr.error('La fecha de fin debe ser posterior a la fecha de inicio'); this.toastr.error(this.translate.instant('laFechaDeFinDebe'));
return; return;
} }
} }
@ -215,21 +218,21 @@ export class CreateTaskScheduleComponent implements OnInit{
const taskId = this.data.task.uuid; const taskId = this.data.task.uuid;
this.http.patch<any>(`${this.baseUrl}${this.data.schedule['@id']}`, payload).subscribe({ this.http.patch<any>(`${this.baseUrl}${this.data.schedule['@id']}`, payload).subscribe({
next: () => { next: () => {
this.toastr.success('Programacion de tarea actualizada con éxito'); this.toastr.success(this.translate.instant('programacionDeTareaActualizadaCon'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: () => { error: () => {
this.toastr.error('Error al actualizar la tarea'); this.toastr.error(this.translate.instant('errorAlActualizarLaTarea'));
} }
}); });
} else { } else {
this.http.post<any>(this.apiUrl, payload).subscribe({ this.http.post<any>(this.apiUrl, payload).subscribe({
next: () => { next: () => {
this.toastr.success('Programacion de tarea creada con éxito'); this.toastr.success(this.translate.instant('programacionDeTareaCreadaCon'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: () => { error: () => {
this.toastr.error('Error al crear la tarea'); this.toastr.error(this.translate.instant('errorAlCrearLaTarea'));
} }
}); });
} }

View File

@ -200,7 +200,7 @@ export class CreateTaskScriptComponent implements OnInit {
saveNewScript(): void { saveNewScript(): void {
if (!this.newScript.trim()) { if (!this.newScript.trim()) {
this.toastService.error('Debe ingresar un script antes de guardar.'); this.toastService.error(this.translate.instant('debeIngresarUnScriptAntes'));
return; return;
} }
const dialogRef = this.dialog.open(SaveScriptComponent, { const dialogRef = this.dialog.open(SaveScriptComponent, {
@ -209,7 +209,7 @@ export class CreateTaskScriptComponent implements OnInit {
}); });
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Script guardado correctamente'); this.toastService.success(this.translate.instant('scriptGuardadoCorrectamente'));
} }
}); });
} }
@ -244,7 +244,7 @@ export class CreateTaskScriptComponent implements OnInit {
break; break;
default: default:
this.toastService.error('Tipo de acción no reconocido'); this.toastService.error(this.translate.instant('tipoDeAccionNoReconocido'));
return; return;
} }
@ -269,12 +269,12 @@ export class CreateTaskScriptComponent implements OnInit {
private validateScript(): boolean { private validateScript(): boolean {
if (this.commandType === 'new') { if (this.commandType === 'new') {
if (!this.newScript.trim()) { if (!this.newScript.trim()) {
this.toastService.error('Debe ingresar un script'); this.toastService.error(this.translate.instant('debeIngresarUnScript'));
return false; return false;
} }
} else if (this.commandType === 'existing') { } else if (this.commandType === 'existing') {
if (!this.selectedScript) { if (!this.selectedScript) {
this.toastService.error('Debe seleccionar un script'); this.toastService.error(this.translate.instant('debeSeleccionarUnScript'));
return false; return false;
} }
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material/dialog'; import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material/dialog';
@ -15,6 +17,7 @@ import {ShowTaskScriptComponent} from "../show-task-script/show-task-script.comp
styleUrls: ['./create-task.component.css'] styleUrls: ['./create-task.component.css']
}) })
export class CreateTaskComponent implements OnInit { export class CreateTaskComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
taskForm: FormGroup; taskForm: FormGroup;
availableCommandGroups: any[] = []; availableCommandGroups: any[] = [];
@ -109,7 +112,7 @@ export class CreateTaskComponent implements OnInit {
resolve(); resolve();
}, },
(error) => { (error) => {
this.toastr.error('Error al cargar los datos de la tarea'); this.toastr.error(this.translate.instant('errorAlCargarLosDatos'));
reject(error); reject(error);
} }
); );
@ -124,7 +127,7 @@ export class CreateTaskComponent implements OnInit {
resolve(); resolve();
}, },
(error) => { (error) => {
this.toastr.error('Error al cargar las tareas existentes'); this.toastr.error(this.translate.instant('errorAlCargarLasTareas'));
reject(error); reject(error);
} }
); );
@ -137,7 +140,7 @@ export class CreateTaskComponent implements OnInit {
this.selectedClients = [...this.data.selectedClients]; this.selectedClients = [...this.data.selectedClients];
this.clients = [...this.data.selectedClients]; this.clients = [...this.data.selectedClients];
} else { } else {
this.toastr.error('No hay clientes pre-seleccionados para este ámbito'); this.toastr.error(this.translate.instant('noHayClientesPreseleccionadosPara'));
this.taskForm.get('scope')?.setValue(''); this.taskForm.get('scope')?.setValue('');
return; return;
} }
@ -168,7 +171,7 @@ export class CreateTaskComponent implements OnInit {
this.availableOrganizationalUnits = filteredUnits; this.availableOrganizationalUnits = filteredUnits;
resolve(); resolve();
}, error => { }, error => {
this.toastr.error('Error al filtrar las unidades organizacionales'); this.toastr.error(this.translate.instant('errorAlFiltrarLasUnidades'));
reject(error); reject(error);
}); });
}) })
@ -187,7 +190,7 @@ export class CreateTaskComponent implements OnInit {
resolve(); resolve();
}, },
(error) => { (error) => {
this.toastr.error('Error al cargar los grupos de comandos'); this.toastr.error(this.translate.instant('errorAlCargarLosGrupos'));
reject(error); reject(error);
}); });
}); });
@ -201,7 +204,7 @@ export class CreateTaskComponent implements OnInit {
resolve(); resolve();
}, },
(error) => { (error) => {
this.toastr.error('Error al cargar los comandos individuales'); this.toastr.error(this.translate.instant('errorAlCargarLosComandos'));
reject(error); reject(error);
}); });
}); });
@ -216,7 +219,7 @@ export class CreateTaskComponent implements OnInit {
resolve(); resolve();
}, },
(error) => { (error) => {
this.toastr.error('Error al cargar las unidades organizacionales'); this.toastr.error(this.translate.instant('errorAlCargarLasUnidades'));
reject(error); reject(error);
} }
); );
@ -225,12 +228,12 @@ export class CreateTaskComponent implements OnInit {
addToExistingTask() { addToExistingTask() {
if (!this.selectedExistingTask) { if (!this.selectedExistingTask) {
this.toastr.error('Debes seleccionar una tarea existente.'); this.toastr.error(this.translate.instant('debesSeleccionarUnaTareaExistente'));
return; return;
} }
if (this.executionOrder == null || this.executionOrder < 1) { if (this.executionOrder == null || this.executionOrder < 1) {
this.toastr.error('Debes introducir un orden de ejecución válido (mayor que 0).'); this.toastr.error(this.translate.instant('debesIntroducirUnOrdenDe'));
return; return;
} }
@ -239,14 +242,14 @@ export class CreateTaskComponent implements OnInit {
executionOrder: this.executionOrder executionOrder: this.executionOrder
}; };
this.toastr.success('Tarea actualizada con éxito'); this.toastr.success(this.translate.instant('tareaActualizadaConExito'));
this.dialogRef.close(data); this.dialogRef.close(data);
} }
saveTask(): void { saveTask(): void {
if (this.taskForm.invalid) { if (this.taskForm.invalid) {
this.toastr.error('Por favor, rellene todos los campos obligatorios'); this.toastr.error(this.translate.instant('porFavorRelleneTodosLos'));
return; return;
} }
@ -254,12 +257,12 @@ export class CreateTaskComponent implements OnInit {
const scope = formData.scope; const scope = formData.scope;
if (scope === 'clients' && this.selectedClients.length === 0) { if (scope === 'clients' && this.selectedClients.length === 0) {
this.toastr.error('Debe seleccionar al menos un cliente'); this.toastr.error(this.translate.instant('debeSeleccionarAlMenosUn'));
return; return;
} }
if (scope !== 'clients' && !formData.organizationalUnit) { if (scope !== 'clients' && !formData.organizationalUnit) {
this.toastr.error('Debe seleccionar una unidad organizativa'); this.toastr.error(this.translate.instant('debeSeleccionarUnaUnidadOrganizativa'));
return; return;
} }
@ -280,17 +283,17 @@ export class CreateTaskComponent implements OnInit {
const taskId = this.data.task.uuid; const taskId = this.data.task.uuid;
this.http.patch<any>(`${this.apiUrl}/${taskId}`, payload).subscribe({ this.http.patch<any>(`${this.apiUrl}/${taskId}`, payload).subscribe({
next: () => { next: () => {
this.toastr.success('Tarea actualizada con éxito'); this.toastr.success(this.translate.instant('tareaActualizadaConExito'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: () => { error: () => {
this.toastr.error('Error al actualizar la tarea'); this.toastr.error(this.translate.instant('errorAlActualizarLaTarea'));
} }
}); });
} else { } else {
this.http.post<any>(this.apiUrl, payload).subscribe({ this.http.post<any>(this.apiUrl, payload).subscribe({
next: response => { next: response => {
this.toastr.success('Tarea creada con éxito'); this.toastr.success(this.translate.instant('tareaCreadaConExito'));
this.dialogRef.close(response); this.dialogRef.close(response);
if (this.data?.source === 'assistant') { if (this.data?.source === 'assistant') {
if (formData.scheduleAfterCreate) { if (formData.scheduleAfterCreate) {
@ -301,7 +304,7 @@ export class CreateTaskComponent implements OnInit {
} }
}, },
error: () => { error: () => {
this.toastr.error('Error al crear la tarea'); this.toastr.error(this.translate.instant('errorAlCrearLaTarea'));
} }
}); });
} }
@ -313,7 +316,7 @@ export class CreateTaskComponent implements OnInit {
data: { task: task } data: { task: task }
}).afterClosed().subscribe(result => { }).afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastr.success('Tarea programada correctamente'); this.toastr.success(this.translate.instant('tareaProgramadaCorrectamente'));
} }
}); });
} }
@ -334,7 +337,7 @@ export class CreateTaskComponent implements OnInit {
data: { task: task } data: { task: task }
}).afterClosed().subscribe(result => { }).afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastr.success('Tarea programada correctamente'); this.toastr.success(this.translate.instant('tareaProgramadaCorrectamente'));
} }
}); });
} }

View File

@ -26,7 +26,7 @@
<app-loading [isLoading]="loading"></app-loading> <app-loading [isLoading]="loading"></app-loading>
<table *ngIf="!loading" mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table *ngIf="!loading" mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let schedule"> <td mat-cell *matCellDef="let schedule">
<ng-container *ngIf="column.columnDef === 'recurrenceType'"> <ng-container *ngIf="column.columnDef === 'recurrenceType'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {Client} from "../../../groups/model/model"; import {Client} from "../../../groups/model/model";
@ -15,6 +17,7 @@ import {DatePipe} from "@angular/common";
styleUrl: './show-task-schedule.component.css' styleUrl: './show-task-schedule.component.css'
}) })
export class ShowTaskScheduleComponent implements OnInit{ export class ShowTaskScheduleComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
dataSource = new MatTableDataSource<any>([]); dataSource = new MatTableDataSource<any>([]);
length = 0; length = 0;
@ -26,13 +29,13 @@ export class ShowTaskScheduleComponent implements OnInit{
datePipe: DatePipe = new DatePipe('es-ES'); datePipe: DatePipe = new DatePipe('es-ES');
columns = [ columns = [
{ columnDef: 'id', header: 'ID', cell: (schedule: any) => schedule.id }, { columnDef: 'id', header: 'id', cell: (schedule: any) => schedule.id },
{ columnDef: 'recurrenceType', header: 'Tipo de Programación', cell: (schedule: any) => this.getRecurrenceTypeDisplay(schedule) }, { columnDef: 'recurrenceType', header: 'tipoDeProgramacion', cell: (schedule: any) => this.getRecurrenceTypeDisplay(schedule) },
{ columnDef: 'executionTime', header: 'Hora de ejecución', cell: (schedule: any) => this.formatExecutionTimeForDisplay(schedule.executionTime) }, { columnDef: 'executionTime', header: 'horaDeEjecucion', cell: (schedule: any) => this.formatExecutionTimeForDisplay(schedule.executionTime) },
{ columnDef: 'nextExecution', header: 'Próxima ejecución', cell: (schedule: any) => this.calculateNextExecution(schedule) }, { columnDef: 'nextExecution', header: 'proximaEjecucion', cell: (schedule: any) => this.calculateNextExecution(schedule) },
{ columnDef: 'daysOfWeek', header: 'Días de la semana', cell: (schedule: any) => this.formatDaysOfWeek(schedule.recurrenceDetails?.daysOfWeek) }, { columnDef: 'daysOfWeek', header: 'diasDeLaSemana', cell: (schedule: any) => this.formatDaysOfWeek(schedule.recurrenceDetails?.daysOfWeek) },
{ columnDef: 'months', header: 'Meses', cell: (schedule: any) => this.formatMonths(schedule.recurrenceDetails?.months) }, { columnDef: 'months', header: 'meses', cell: (schedule: any) => this.formatMonths(schedule.recurrenceDetails?.months) },
{ columnDef: 'enabled', header: 'Estado', cell: (schedule: any) => schedule.enabled } { columnDef: 'enabled', header: 'estado', cell: (schedule: any) => schedule.enabled }
]; ];
displayedColumns: string[] = ['id', 'recurrenceType', 'executionTime', 'nextExecution', 'daysOfWeek', 'months', 'enabled', 'actions']; displayedColumns: string[] = ['id', 'recurrenceType', 'executionTime', 'nextExecution', 'daysOfWeek', 'months', 'enabled', 'actions'];
@ -67,7 +70,7 @@ export class ShowTaskScheduleComponent implements OnInit{
}, },
(error) => { (error) => {
this.loading = false; this.loading = false;
this.toastService.error('Error al cargar las programaciones'); this.toastService.error(this.translate.instant('errorAlCargarLasProgramaciones'));
} }
); );
} }
@ -79,7 +82,7 @@ export class ShowTaskScheduleComponent implements OnInit{
}).afterClosed().subscribe(result => { }).afterClosed().subscribe(result => {
if (result) { if (result) {
this.loadData(); this.loadData();
this.toastService.success('Programación creada correctamente'); this.toastService.success(this.translate.instant('programacionCreadaCorrectamente'));
} }
}); });
} }
@ -91,7 +94,7 @@ export class ShowTaskScheduleComponent implements OnInit{
}).afterClosed().subscribe(result => { }).afterClosed().subscribe(result => {
if (result) { if (result) {
this.loadData(); this.loadData();
this.toastService.success('Programación actualizada correctamente'); this.toastService.success(this.translate.instant('programacionActualizadaCorrectamente'));
} }
}); });
} }
@ -106,7 +109,7 @@ export class ShowTaskScheduleComponent implements OnInit{
if (result) { if (result) {
this.http.delete(`${this.baseUrl}${schedule['@id']}`).subscribe( this.http.delete(`${this.baseUrl}${schedule['@id']}`).subscribe(
() => { () => {
this.toastService.success('Programación eliminada correctamente'); this.toastService.success(this.translate.instant('programacionEliminadaCorrectamente'));
this.loadData(); this.loadData();
}, },
(error) => { (error) => {
@ -317,7 +320,7 @@ export class ShowTaskScheduleComponent implements OnInit{
if (schedule.recurrenceType === 'none') { if (schedule.recurrenceType === 'none') {
return { return {
type: 'none', type: 'none',
label: 'Ejecución única', label : this.translate.instant('ejecucionUnica'),
icon: 'event', icon: 'event',
color: 'primary', color: 'primary',
details: schedule.executionDate ? details: schedule.executionDate ?

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {ToastrService} from "ngx-toastr"; import {ToastrService} from "ngx-toastr";
@ -15,6 +17,7 @@ import {ViewParametersModalComponent} from "./view-parameters-modal/view-paramet
styleUrl: './show-task-script.component.css' styleUrl: './show-task-script.component.css'
}) })
export class ShowTaskScriptComponent implements OnInit{ export class ShowTaskScriptComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
dataSource = new MatTableDataSource<any>([]); dataSource = new MatTableDataSource<any>([]);
length = 0; length = 0;
@ -25,26 +28,26 @@ export class ShowTaskScriptComponent implements OnInit{
filters: { [key: string]: string } = {}; filters: { [key: string]: string } = {};
columns = [ columns = [
{ columnDef: 'id', header: 'ID', cell: (item: any) => item.id }, { columnDef: 'id', header: 'id', cell: (item: any) => item.id },
{ columnDef: 'order', header: 'Orden', cell: (item: any) => item.order }, { columnDef: 'order', header: 'orden', cell: (item: any) => item.order },
{ columnDef: 'type', header: 'Tipo', cell: (item: any) => item.type }, { columnDef: 'type', header: 'tipo', cell: (item: any) => item.type },
{ columnDef: 'parameters', header: 'Parámetros', cell: (item: any) => item.parameters }, { columnDef: 'parameters', header: 'parametros', cell: (item: any) => item.parameters },
{ columnDef: 'content', header: 'Contenido', cell: (item: any) => item.content }, { columnDef: 'content', header: 'contenido', cell: (item: any) => item.content },
]; ];
displayedColumns: string[] = ['order', 'type', 'content', 'parameters', 'actions']; displayedColumns: string[] = ['order', 'type', 'content', 'parameters', 'actions'];
typeLabels: { [key: string]: { label: string, icon: string } } = { typeLabels: { [key: string]: { label: string, icon: string } } = {
'partition-and-format': { label: 'Particionar y formatear', icon: 'storage' }, 'partition-and-format': { label : this.translate.instant('particionarYFormatear'), icon: 'storage' },
'partition-assistant': { label: 'Asistente de particionado', icon: 'storage' }, 'partition-assistant': { label : this.translate.instant('asistenteDeParticionado'), icon: 'storage' },
'deploy-image': { label: 'Desplegar imagen', icon: 'cloud_download' }, 'deploy-image': { label : this.translate.instant('desplegarImagen'), icon: 'cloud_download' },
'create-image': { label: 'Crear imagen', icon: 'cloud_upload' }, 'create-image': { label : this.translate.instant('crearImagen'), icon: 'cloud_upload' },
'run-script': { label: 'Ejecutar script', icon: 'code' }, 'run-script': { label : this.translate.instant('ejecutarScript'), icon: 'code' },
'reboot': { label: 'Reiniciar', icon: 'restart_alt' }, 'reboot': { label: 'Reiniciar', icon: 'restart_alt' },
'shutdown': { label: 'Apagar', icon: 'power_off' }, 'shutdown': { label: 'Apagar', icon: 'power_off' },
'poweron': { label: 'Encender', icon: 'power' }, 'poweron': { label: 'Encender', icon: 'power' },
'power-on': { label: 'Encender', icon: 'power' }, 'power-on': { label: 'Encender', icon: 'power' },
'login': { label: 'Iniciar sesión', icon: 'login' }, 'login': { label : this.translate.instant('iniciarSesion'), icon: 'login' },
}; };
getTypeDisplay(type: string): { label: string, icon: string } { getTypeDisplay(type: string): { label: string, icon: string } {
@ -94,7 +97,7 @@ export class ShowTaskScriptComponent implements OnInit{
if (result) { if (result) {
this.http.delete(`${this.baseUrl}${schedule['@id']}`).subscribe( this.http.delete(`${this.baseUrl}${schedule['@id']}`).subscribe(
() => { () => {
this.toastService.success('Eliminado correctamente'); this.toastService.success(this.translate.instant('eliminadoCorrectamente'));
this.loadData(); this.loadData();
}, },
(error) => { (error) => {

View File

@ -26,7 +26,7 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | translate }}"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableStep" text="{{ 'tableStepText' | 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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let command"> <td mat-cell *matCellDef="let command">
<ng-container *ngIf="column.columnDef !== 'readOnly'"> <ng-container *ngIf="column.columnDef !== 'readOnly'">
{{ column.cell(command) }} {{ column.cell(command) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@ -16,6 +18,7 @@ import { JoyrideService } from 'ngx-joyride';
styleUrls: ['./commands.component.css'] styleUrls: ['./commands.component.css']
}) })
export class CommandsComponent implements OnInit { export class CommandsComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -29,22 +32,22 @@ export class CommandsComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (command: any) => `${command.id}`, cell: (command: any) => `${command.id}`,
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (command: any) => `${command.name}` cell: (command: any) => `${command.name}`
}, },
{ {
columnDef: 'readOnly', columnDef: 'readOnly',
header: 'Solo Lectura', header: 'soloLectura',
cell: (command: any) => `${command.readOnly}` cell: (command: any) => `${command.readOnly}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (command: any) => `${this.datePipe.transform(command.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (command: any) => `${this.datePipe.transform(command.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -69,7 +72,7 @@ export class CommandsComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
(error) => { (error) => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
this.loading = false; this.loading = false;
} }
); );
@ -106,11 +109,11 @@ export class CommandsComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${command.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${command.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Comando eliminado con éxito'); this.toastService.success(this.translate.instant('comandoEliminadoConExito'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar el comando:', error); console.error(this.translate.instant('errorAlEliminarElComando'), error);
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
@ -12,6 +14,7 @@ import { ConfigService } from "@services/config.service";
styleUrls: ['./create-command.component.css'] styleUrls: ['./create-command.component.css']
}) })
export class CreateCommandComponent implements OnInit{ export class CreateCommandComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
createCommandForm: FormGroup<any>; createCommandForm: FormGroup<any>;
commandId: string | null = null; commandId: string | null = null;
@ -56,7 +59,7 @@ export class CreateCommandComponent implements OnInit{
this.commandId = response['@id']; this.commandId = response['@id'];
}, },
error: (err) => { error: (err) => {
console.error('Error fetching remote calendar:', err); console.error(this.translate.instant('errorFetchingRemoteCalendar'), err);
} }
}); });
} }
@ -81,7 +84,7 @@ export class CreateCommandComponent implements OnInit{
if (this.commandId) { if (this.commandId) {
this.http.put(`${this.baseUrl}${this.commandId}`, payload).subscribe( this.http.put(`${this.baseUrl}${this.commandId}`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Comando editado correctamente'); this.toastService.success(this.translate.instant('comandoEditadoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
@ -91,7 +94,7 @@ export class CreateCommandComponent implements OnInit{
} else { } else {
this.http.post(`${this.baseUrl}/commands`, payload).subscribe( this.http.post(`${this.baseUrl}/commands`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Comando añadido correctamente'); this.toastService.success(this.translate.instant('comandoAnadidoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
@ -8,6 +10,7 @@ import { catchError, map } from 'rxjs/operators';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -34,7 +37,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -50,7 +53,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user group', error); console.error(this.translate.instant('errorFetchingUserGroup'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./command-detail.component.css'] styleUrls: ['./command-detail.component.css']
}) })
export class CommandDetailComponent implements OnInit { export class CommandDetailComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
form!: FormGroup; form!: FormGroup;
clients: any[] = []; clients: any[] = [];
@ -56,7 +59,7 @@ export class CommandDetailComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Comando editado'); this.toastService.success(this.translate.instant('comandoEditado'));
this.data.command = result; this.data.command = result;
} }
}); });

View File

@ -68,7 +68,7 @@
</ng-container> </ng-container>
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef !== 'size'"> <ng-container *ngIf="column.columnDef !== 'size'">
{{ column.cell(image) }} {{ column.cell(image) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
@ -11,6 +13,7 @@ import { ToastrService } from "ngx-toastr";
styleUrl: './boot-so-partition.component.css' styleUrl: './boot-so-partition.component.css'
}) })
export class BootSoPartitionComponent implements OnInit { export class BootSoPartitionComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
selectedPartition: any = null; selectedPartition: any = null;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -24,32 +27,32 @@ export class BootSoPartitionComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'diskNumber', columnDef: 'diskNumber',
header: 'Disco', header: 'disco',
cell: (partition: any) => partition.diskNumber cell: (partition: any) => partition.diskNumber
}, },
{ {
columnDef: 'partitionNumber', columnDef: 'partitionNumber',
header: 'Particion', header: 'particion',
cell: (partition: any) => partition.partitionNumber cell: (partition: any) => partition.partitionNumber
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${partition.size} MB` cell: (partition: any) => `${partition.size} MB`
}, },
{ {
columnDef: 'partitionCode', columnDef: 'partitionCode',
header: 'Tipo de partición', header: 'tipoDeParticion',
cell: (partition: any) => partition.partitionCode cell: (partition: any) => partition.partitionCode
}, },
{ {
columnDef: 'filesystem', columnDef: 'filesystem',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => partition.filesystem cell: (partition: any) => partition.filesystem
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO', header: 'so',
cell: (partition: any) => partition.operativeSystem?.name cell: (partition: any) => partition.operativeSystem?.name
} }
]; ];
@ -92,7 +95,7 @@ export class BootSoPartitionComponent implements OnInit {
} }
}, },
(error) => { (error) => {
console.error('Error al cargar los datos del cliente:', error); console.error(this.translate.instant('errorAlCargarLosDatos1'), error);
} }
); );
} }
@ -133,7 +136,7 @@ export class BootSoPartitionComponent implements OnInit {
partition: this.selectedPartition['@id'] partition: this.selectedPartition['@id']
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Cliente actualizado correctamente'); this.toastService.success(this.translate.instant('clienteActualizadoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
this.loading = false; this.loading = false;
}, },

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Router } from "@angular/router"; import { Router } from "@angular/router";
@ -15,6 +17,7 @@ import {SoftwareProfilePartitionComponent} from "./software-profile-partition/so
styleUrls: ['./execute-command.component.css'] styleUrls: ['./execute-command.component.css']
}) })
export class ExecuteCommandComponent implements OnInit { export class ExecuteCommandComponent implements OnInit {
public translate = inject(TranslateService);
@Input() runScriptContext: any = null; @Input() runScriptContext: any = null;
@Input() clientState: string = 'off'; @Input() clientState: string = 'off';
@Input() clientData: any[] = []; @Input() clientData: any[] = [];
@ -197,7 +200,7 @@ export class ExecuteCommandComponent implements OnInit {
clients: this.clientData.map((client: any) => client['@id']) clients: this.clientData.map((client: any) => client['@id'])
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Cliente actualizado correctamente'); this.toastService.success(this.translate.instant('clienteActualizadoCorrectamente'));
}, },
error => { error => {
this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente'); this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente');
@ -210,7 +213,7 @@ export class ExecuteCommandComponent implements OnInit {
clients: this.clientData.map((client: any) => client['@id']) clients: this.clientData.map((client: any) => client['@id'])
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Petición de refresco enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeRefrescoEnviadaCorrectamente'));
}, },
error => { error => {
this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente'); this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente');
@ -237,7 +240,7 @@ export class ExecuteCommandComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Petición de arranque de SO enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeArranqueDeSo'));
} }
}); });
} }
@ -261,14 +264,14 @@ export class ExecuteCommandComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Petición de borrado de caché de imagen enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeBorradoDeCache'));
} }
}); });
} }
hardwareInventory(): void { hardwareInventory(): void {
if (this.clientData.length === 0) { if (this.clientData.length === 0) {
this.toastService.error('No hay clientes seleccionados'); this.toastService.error(this.translate.instant('noHayClientesSeleccionados'));
return; return;
} }
@ -278,7 +281,7 @@ export class ExecuteCommandComponent implements OnInit {
clients: this.clientData.map((client: any) => client['@id']) clients: this.clientData.map((client: any) => client['@id'])
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Inventario de hardware actualizado correctamente'); this.toastService.success(this.translate.instant('inventarioDeHardwareActualizadoCorrectamente'));
}, },
error => { error => {
this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente'); this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente');
@ -288,7 +291,7 @@ export class ExecuteCommandComponent implements OnInit {
softwareInventory(): void { softwareInventory(): void {
if (this.clientData.length === 0) { if (this.clientData.length === 0) {
this.toastService.error('No hay clientes seleccionados'); this.toastService.error(this.translate.instant('noHayClientesSeleccionados'));
return; return;
} }
@ -320,7 +323,7 @@ export class ExecuteCommandComponent implements OnInit {
clients: this.clientData.map((client: any) => client['@id']) clients: this.clientData.map((client: any) => client['@id'])
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Petición de encendido enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeEncendidoEnviadaCorrectamente'));
}, },
error => { error => {
this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente'); this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente');
@ -333,7 +336,7 @@ export class ExecuteCommandComponent implements OnInit {
clients: this.clientData.map((client: any) => client['@id']) clients: this.clientData.map((client: any) => client['@id'])
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Petición de apagado enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeApagadoEnviadaCorrectamente'));
}, },
error => { error => {
this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente'); this.toastService.error(error.error['hydra:description'] || 'Error de conexión con el cliente');
@ -404,7 +407,7 @@ export class ExecuteCommandComponent implements OnInit {
deleteClientLease(): void { deleteClientLease(): void {
if (this.clientData.length === 0) { if (this.clientData.length === 0) {
this.toastService.error('No hay clientes seleccionados'); this.toastService.error(this.translate.instant('noHayClientesSeleccionados'));
return; return;
} }
@ -415,11 +418,11 @@ export class ExecuteCommandComponent implements OnInit {
Promise.allSettled(requests).then(results => { Promise.allSettled(requests).then(results => {
const errors = results.filter(r => r.status === 'rejected'); const errors = results.filter(r => r.status === 'rejected');
if (errors.length === 0) { if (errors.length === 0) {
this.toastService.success('Lease(s) DHCP eliminada(s) correctamente'); this.toastService.success(this.translate.instant('leasesDhcpEliminadasCorrectamente'));
} else if (errors.length < results.length) { } else if (errors.length < results.length) {
this.toastService.warning(`${results.length - errors.length} lease(s) eliminada(s), ${errors.length} con error`); this.toastService.warning(`${results.length - errors.length} lease(s) eliminada(s), ${errors.length} con error`);
} else { } else {
this.toastService.error('Error al eliminar las leases DHCP'); this.toastService.error(this.translate.instant('errorAlEliminarLasLeases'));
} }
}); });
} }

View File

@ -68,7 +68,7 @@
</ng-container> </ng-container>
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef !== 'size' && column.columnDef !== 'operativeSystem'"> <ng-container *ngIf="column.columnDef !== 'size' && column.columnDef !== 'operativeSystem'">
{{ column.cell(image) }} {{ column.cell(image) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject } from '@angular/core'; import {Component, Inject } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@ -11,6 +13,7 @@ import {ToastrService} from "ngx-toastr";
styleUrl: './remove-cache-image.component.css' styleUrl: './remove-cache-image.component.css'
}) })
export class RemoveCacheImageComponent { export class RemoveCacheImageComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
selectedPartition: any = null; selectedPartition: any = null;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -24,32 +27,32 @@ export class RemoveCacheImageComponent {
columns = [ columns = [
{ {
columnDef: 'diskNumber', columnDef: 'diskNumber',
header: 'Disco', header: 'disco',
cell: (partition: any) => partition.diskNumber cell: (partition: any) => partition.diskNumber
}, },
{ {
columnDef: 'partitionNumber', columnDef: 'partitionNumber',
header: 'Particion', header: 'particion',
cell: (partition: any) => partition.partitionNumber cell: (partition: any) => partition.partitionNumber
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${partition.size} MB` cell: (partition: any) => `${partition.size} MB`
}, },
{ {
columnDef: 'partitionCode', columnDef: 'partitionCode',
header: 'Tipo de partición', header: 'tipoDeParticion',
cell: (partition: any) => partition.partitionCode cell: (partition: any) => partition.partitionCode
}, },
{ {
columnDef: 'filesystem', columnDef: 'filesystem',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => partition.filesystem cell: (partition: any) => partition.filesystem
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO', header: 'so',
cell: (partition: any) => partition.operativeSystem?.name cell: (partition: any) => partition.operativeSystem?.name
} }
]; ];
@ -100,7 +103,7 @@ export class RemoveCacheImageComponent {
} }
}, },
(error) => { (error) => {
console.error('Error al cargar los datos del cliente:', error); console.error(this.translate.instant('errorAlCargarLosDatos1'), error);
} }
); );
} }
@ -141,7 +144,7 @@ export class RemoveCacheImageComponent {
partition: this.selectedPartition['@id'] partition: this.selectedPartition['@id']
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Cliente actualizado correctamente'); this.toastService.success(this.translate.instant('clienteActualizadoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
this.loading = false; this.loading = false;
}, },

View File

@ -20,7 +20,7 @@
</ng-container> </ng-container>
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef !== 'size' && column.columnDef !== 'operativeSystem'"> <ng-container *ngIf="column.columnDef !== 'size' && column.columnDef !== 'operativeSystem'">
{{ column.cell(image) }} {{ column.cell(image) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@ -11,6 +13,7 @@ import {ToastrService} from "ngx-toastr";
styleUrl: './software-profile-partition.component.css' styleUrl: './software-profile-partition.component.css'
}) })
export class SoftwareProfilePartitionComponent implements OnInit{ export class SoftwareProfilePartitionComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
selectedPartition: any = null; selectedPartition: any = null;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -24,32 +27,32 @@ export class SoftwareProfilePartitionComponent implements OnInit{
columns = [ columns = [
{ {
columnDef: 'diskNumber', columnDef: 'diskNumber',
header: 'Disco', header: 'disco',
cell: (partition: any) => partition.diskNumber cell: (partition: any) => partition.diskNumber
}, },
{ {
columnDef: 'partitionNumber', columnDef: 'partitionNumber',
header: 'Particion', header: 'particion',
cell: (partition: any) => partition.partitionNumber cell: (partition: any) => partition.partitionNumber
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${partition.size} MB` cell: (partition: any) => `${partition.size} MB`
}, },
{ {
columnDef: 'partitionCode', columnDef: 'partitionCode',
header: 'Tipo de partición', header: 'tipoDeParticion',
cell: (partition: any) => partition.partitionCode cell: (partition: any) => partition.partitionCode
}, },
{ {
columnDef: 'filesystem', columnDef: 'filesystem',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => partition.filesystem cell: (partition: any) => partition.filesystem
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO', header: 'so',
cell: (partition: any) => partition.operativeSystem?.name cell: (partition: any) => partition.operativeSystem?.name
} }
]; ];
@ -80,7 +83,7 @@ export class SoftwareProfilePartitionComponent implements OnInit{
} }
}, },
(error) => { (error) => {
console.error('Error al cargar los datos del cliente:', error); console.error(this.translate.instant('errorAlCargarLosDatos1'), error);
} }
); );
} }
@ -96,7 +99,7 @@ export class SoftwareProfilePartitionComponent implements OnInit{
partition: this.selectedPartition['@id'], partition: this.selectedPartition['@id'],
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Inventario de software actualizado correctamente'); this.toastService.success(this.translate.instant('inventarioDeSoftwareActualizadoCorrectamente'));
this.dialogRef.close(response); this.dialogRef.close(response);
}, },
error => { error => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
@ -9,6 +11,7 @@ import { ToastrService } from "ngx-toastr";
styleUrl: './global-status.component.css' styleUrl: './global-status.component.css'
}) })
export class GlobalStatusComponent implements OnInit { export class GlobalStatusComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loading: boolean = false; loading: boolean = false;
loadingDhcps: boolean = false; loadingDhcps: boolean = false;
@ -81,7 +84,7 @@ export class GlobalStatusComponent implements OnInit {
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
if (!hasError) { if (!hasError) {
this.toastService.error('Error al sincronizar las subredes: tiempo de espera agotado'); this.toastService.error(this.translate.instant('errorAlSincronizarLasSubredes'));
hasError = true; hasError = true;
} }
}, 5000); }, 5000);
@ -92,7 +95,7 @@ export class GlobalStatusComponent implements OnInit {
pending--; pending--;
if (pending === 0 && !hasError) { if (pending === 0 && !hasError) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
this.toastService.success('Sincronización de subredes de servidores DHCP exitosa'); this.toastService.success(this.translate.instant('sincronizacionDeSubredesDeServidores'));
} }
}, },
error: (error) => { error: (error) => {
@ -106,7 +109,7 @@ export class GlobalStatusComponent implements OnInit {
}); });
}); });
}, error => { }, error => {
console.error('Error fetching DHCP servers for subnet sync', error); console.error(this.translate.instant('errorFetchingDhcpServersFor'), error);
}); });
} }
@ -118,7 +121,7 @@ export class GlobalStatusComponent implements OnInit {
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
if (!hasError) { if (!hasError) {
this.toastService.error('Error al sincronizar las plantillas Pxe: tiempo de espera agotado'); this.toastService.error(this.translate.instant('errorAlSincronizarLasPlantillas'));
hasError = true; hasError = true;
} }
}, 5000); }, 5000);
@ -129,7 +132,7 @@ export class GlobalStatusComponent implements OnInit {
pending--; pending--;
if (pending === 0 && !hasError) { if (pending === 0 && !hasError) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
this.toastService.success('Sincronización de plantillas Pxe exitosa'); this.toastService.success(this.translate.instant('sincronizacionDePlantillasPxeExitosa'));
} }
}, },
error: (error) => { error: (error) => {
@ -152,7 +155,7 @@ export class GlobalStatusComponent implements OnInit {
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
if (!hasError) { if (!hasError) {
this.toastService.error('Error al sincronizar imagenes ogLive: tiempo de espera agotado'); this.toastService.error(this.translate.instant('errorAlSincronizarImagenesOglive'));
hasError = true; hasError = true;
} }
}, 5000); }, 5000);
@ -163,7 +166,7 @@ export class GlobalStatusComponent implements OnInit {
pending--; pending--;
if (pending === 0 && !hasError) { if (pending === 0 && !hasError) {
clearTimeout(timeoutId); clearTimeout(timeoutId);
this.toastService.success('Sincronización con ogLives completada'); this.toastService.success(this.translate.instant('sincronizacionConOglivesCompletada'));
} }
}, },
error: (error) => { error: (error) => {
@ -190,7 +193,7 @@ export class GlobalStatusComponent implements OnInit {
this.repositories = []; this.repositories = [];
if (showLoading) this.loadingRepositories = false; if (showLoading) this.loadingRepositories = false;
this.checkOverallLoading(); this.checkOverallLoading();
this.toastService.error('Error al cargar la lista de repositorios'); this.toastService.error(this.translate.instant('errorAlCargarLaLista2'));
} }
}); });
} }
@ -213,7 +216,7 @@ export class GlobalStatusComponent implements OnInit {
this.bootServers = []; this.bootServers = [];
if (showLoading) this.loadingBootServers = false; if (showLoading) this.loadingBootServers = false;
this.checkOverallLoading(); this.checkOverallLoading();
this.toastService.error('Error al cargar la lista de Servidores de Boot'); this.toastService.error(this.translate.instant('errorAlCargarLaLista1'));
} }
}); });
} }
@ -230,7 +233,7 @@ export class GlobalStatusComponent implements OnInit {
this.dhcps = []; this.dhcps = [];
if (showLoading) this.loadingDhcps = false; if (showLoading) this.loadingDhcps = false;
this.checkOverallLoading(); this.checkOverallLoading();
this.toastService.error('Error al cargar la lista de Dhcps'); this.toastService.error(this.translate.instant('errorAlCargarLaLista'));
} }
}); });
} }
@ -250,7 +253,7 @@ export class GlobalStatusComponent implements OnInit {
this.loadDhcps(true); this.loadDhcps(true);
this.loadRepositories(true); this.loadRepositories(true);
this.syncSubnets(); this.syncSubnets();
this.toastService.success('Datos actualizados correctamente'); this.toastService.success(this.translate.instant('datosActualizadosCorrectamente'));
} }
updateLastUpdateTime(): void { updateLastUpdateTime(): void {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
@ -10,6 +12,7 @@ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
styleUrl: './ogboot-status.component.css' styleUrl: './ogboot-status.component.css'
}) })
export class GlobalOgbootStatusComponent implements OnInit { export class GlobalOgbootStatusComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loadingBootServers: boolean = false; loadingBootServers: boolean = false;
@ -117,9 +120,9 @@ export class GlobalOgbootStatusComponent implements OnInit {
this.loadBootServerStatus(bootServerUuid, (errorOccurred: boolean) => { this.loadBootServerStatus(bootServerUuid, (errorOccurred: boolean) => {
this.errorBootServers[bootServerUuid] = errorOccurred; this.errorBootServers[bootServerUuid] = errorOccurred;
if (!errorOccurred) { if (!errorOccurred) {
this.toastService.success('Estado del servidor de boot actualizado correctamente'); this.toastService.success(this.translate.instant('estadoDelServidorDeBoot'));
} else { } else {
this.toastService.error('Error al cargar el estado del servidor de boot'); this.toastService.error(this.translate.instant('errorAlCargarElEstado2'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
@ -10,6 +12,7 @@ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
styleUrl: './ogdhcp-status.component.css' styleUrl: './ogdhcp-status.component.css'
}) })
export class OgdhcpStatusComponent implements OnInit { export class OgdhcpStatusComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loadingDhcps: boolean = false; loadingDhcps: boolean = false;
@ -120,9 +123,9 @@ export class OgdhcpStatusComponent implements OnInit {
this.loadDhcpStatus(dhcpUuid, (errorOccurred: boolean) => { this.loadDhcpStatus(dhcpUuid, (errorOccurred: boolean) => {
this.errorDhcps[dhcpUuid] = errorOccurred; this.errorDhcps[dhcpUuid] = errorOccurred;
if (!errorOccurred) { if (!errorOccurred) {
this.toastService.success('Estado del dhcp actualizado correctamente'); this.toastService.success(this.translate.instant('estadoDelDhcpActualizadoCorrectamente'));
} else { } else {
this.toastService.error('Error al cargar el estado del dhcp'); this.toastService.error(this.translate.instant('errorAlCargarElEstado'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
@ -10,6 +12,7 @@ import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
styleUrl: './ogrepository-status.component.css' styleUrl: './ogrepository-status.component.css'
}) })
export class OgrepositoryStatusComponent implements OnInit { export class OgrepositoryStatusComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loading: boolean = false; loading: boolean = false;
@ -119,9 +122,9 @@ export class OgrepositoryStatusComponent implements OnInit {
this.loadRepositoryStatus(repositoryUuid, (errorOccurred: boolean) => { this.loadRepositoryStatus(repositoryUuid, (errorOccurred: boolean) => {
this.errorRepositories[repositoryUuid] = errorOccurred; this.errorRepositories[repositoryUuid] = errorOccurred;
if (!errorOccurred) { if (!errorOccurred) {
this.toastService.success('Estado del repositorio actualizado correctamente'); this.toastService.success(this.translate.instant('estadoDelRepositorioActualizadoCorrectamente'));
} else { } else {
this.toastService.error('Error al cargar el estado del repositorio'); this.toastService.error(this.translate.instant('errorAlCargarElEstado1'));
} }
}); });
} }

View File

@ -41,7 +41,7 @@
<div class="table-container"> <div class="table-container">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef !== 'size'"> <ng-container *ngIf="column.columnDef !== 'size'">
{{ column.cell(image) }} {{ column.cell(image) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, EventEmitter, OnInit, Output, ViewChild, ElementRef } from '@angular/core'; import {Component, EventEmitter, OnInit, Output, ViewChild, ElementRef } 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";
@ -17,6 +19,7 @@ import {CreateTaskComponent} from "../../../../commands/commands-task/create-tas
styleUrl: './create-image.component.css' styleUrl: './create-image.component.css'
}) })
export class CreateClientImageComponent implements OnInit{ export class CreateClientImageComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@Output() dataChange = new EventEmitter<any>(); @Output() dataChange = new EventEmitter<any>();
@ViewChild('partitionSection', { static: false }) partitionSection!: ElementRef; @ViewChild('partitionSection', { static: false }) partitionSection!: ElementRef;
@ -69,27 +72,27 @@ export class CreateClientImageComponent implements OnInit{
columns = [ columns = [
{ {
columnDef: 'partitionNumber', columnDef: 'partitionNumber',
header: 'Particion', header: 'particion',
cell: (partition: any) => partition.partitionNumber cell: (partition: any) => partition.partitionNumber
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${partition.size} MB` cell: (partition: any) => `${partition.size} MB`
}, },
{ {
columnDef: 'partitionCode', columnDef: 'partitionCode',
header: 'Tipo de partición', header: 'tipoDeParticion',
cell: (partition: any) => partition.partitionCode cell: (partition: any) => partition.partitionCode
}, },
{ {
columnDef: 'filesystem', columnDef: 'filesystem',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => partition.filesystem cell: (partition: any) => partition.filesystem
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO', header: 'so',
cell: (partition: any) => partition.operativeSystem?.name cell: (partition: any) => partition.operativeSystem?.name
} }
]; ];
@ -139,7 +142,7 @@ export class CreateClientImageComponent implements OnInit{
} }
}, },
(error) => { (error) => {
console.error('Error al cargar los datos del cliente:', error); console.error(this.translate.instant('errorAlCargarLosDatos1'), error);
} }
); );
} }
@ -155,7 +158,7 @@ export class CreateClientImageComponent implements OnInit{
this.images = response['hydra:member']; this.images = response['hydra:member'];
}, },
(error) => { (error) => {
console.error('Error al cargar las imágenes:', error); console.error(this.translate.instant('errorAlCargarLasImagenes3'), error);
} }
); );
} }
@ -186,7 +189,7 @@ export class CreateClientImageComponent implements OnInit{
this.checkRepositoryExists(); this.checkRepositoryExists();
}, },
(error) => { (error) => {
console.error('Error al cargar los repositorios git:', error); console.error(this.translate.instant('errorAlCargarLosRepositorios2'), error);
this.loadingGitRepositories = false; this.loadingGitRepositories = false;
} }
); );
@ -201,7 +204,7 @@ export class CreateClientImageComponent implements OnInit{
this.loadingGitImageRepositories = false; this.loadingGitImageRepositories = false;
}, },
(error) => { (error) => {
console.error('Error al cargar las imágenes de repositorio git:', error); console.error(this.translate.instant('errorAlCargarLasImagenes'), error);
this.loadingGitImageRepositories = false; this.loadingGitImageRepositories = false;
} }
); );
@ -237,8 +240,8 @@ export class CreateClientImageComponent implements OnInit{
} }
}, },
error => { error => {
console.error('Error fetching branches', error); console.error(this.translate.instant('errorFetchingBranches'), error);
this.toastService.error('Error al cargar las ramas del repositorio'); this.toastService.error(this.translate.instant('errorAlCargarLasRamas1'));
this.loadingBranches = false; this.loadingBranches = false;
} }
); );
@ -261,7 +264,7 @@ export class CreateClientImageComponent implements OnInit{
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Rama creada correctamente'); this.toastService.success(this.translate.instant('ramaCreadaCorrectamente'));
this.destinationBranch = result.branchName || result; this.destinationBranch = result.branchName || result;
this.loadBranches(); this.loadBranches();
} }
@ -270,7 +273,7 @@ export class CreateClientImageComponent implements OnInit{
} }
if (!this.selectedGitRepository) { if (!this.selectedGitRepository) {
this.toastService.error('Debe seleccionar un repositorio primero'); this.toastService.error(this.translate.instant('debeSeleccionarUnRepositorioPrimero'));
return; return;
} }
@ -285,7 +288,7 @@ export class CreateClientImageComponent implements OnInit{
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Rama creada correctamente'); this.toastService.success(this.translate.instant('ramaCreadaCorrectamente'));
this.destinationBranch = result.branchName || result; this.destinationBranch = result.branchName || result;
this.loadBranches(); this.loadBranches();
} }
@ -319,9 +322,9 @@ export class CreateClientImageComponent implements OnInit{
this.loadingExistingImages = false; this.loadingExistingImages = false;
}, },
(error) => { (error) => {
console.error('Error al cargar las imágenes existentes:', error); console.error(this.translate.instant('errorAlCargarLasImagenes2'), error);
this.loadingExistingImages = false; this.loadingExistingImages = false;
this.toastService.error('Error al cargar las imágenes existentes'); this.toastService.error(this.translate.instant('errorAlCargarLasImagenes1'));
} }
); );
} }
@ -347,18 +350,18 @@ export class CreateClientImageComponent implements OnInit{
save(): void { save(): void {
if (!this.selectedPartition) { if (!this.selectedPartition) {
this.toastService.error('Debes seleccionar una partición'); this.toastService.error(this.translate.instant('debesSeleccionarUnaParticion'));
return; return;
} }
if (this.imageType === 'monolithic') { if (this.imageType === 'monolithic') {
if (this.monolithicAction === 'create' && !this.name) { if (this.monolithicAction === 'create' && !this.name) {
this.toastService.error('Debes introducir un nombre canónico para la imagen'); this.toastService.error(this.translate.instant('debesIntroducirUnNombreCanonico'));
return; return;
} }
if (this.monolithicAction === 'update' && !this.selectedImage) { if (this.monolithicAction === 'update' && !this.selectedImage) {
this.toastService.error('Debes seleccionar una imagen para actualizar'); this.toastService.error(this.translate.instant('debesSeleccionarUnaImagenPara'));
return; return;
} }
} }
@ -572,8 +575,8 @@ export class CreateClientImageComponent implements OnInit{
} }
}, },
error: (error) => { error: (error) => {
console.error('Error al cargar datos de Git:', error); console.error(this.translate.instant('errorAlCargarDatosDe'), error);
this.toastService.error('Error al cargar información de Git'); this.toastService.error(this.translate.instant('errorAlCargarInformacionDe'));
this.loadingGitData = false; this.loadingGitData = false;
} }
}); });
@ -603,7 +606,7 @@ export class CreateClientImageComponent implements OnInit{
this.loadingBranches = false; this.loadingBranches = false;
}, },
error => { error => {
console.error('Error fetching branches for Git data', error); console.error(this.translate.instant('errorFetchingBranchesForGit'), error);
this.loadingBranches = false; this.loadingBranches = false;
} }
); );
@ -643,7 +646,7 @@ export class CreateClientImageComponent implements OnInit{
let scope = 'clients'; let scope = 'clients';
if (!this.client) { if (!this.client) {
this.toastService.error('No se ha cargado la información del cliente'); this.toastService.error(this.translate.instant('noSeHaCargadoLa'));
return; return;
} }
@ -663,7 +666,7 @@ export class CreateClientImageComponent implements OnInit{
dialogRef.afterClosed().subscribe((result: any) => { dialogRef.afterClosed().subscribe((result: any) => {
if (result) { if (result) {
if (!this.selectedPartition) { if (!this.selectedPartition) {
this.toastService.error('Debe seleccionar una partición'); this.toastService.error(this.translate.instant('debeSeleccionarUnaParticion'));
return; return;
} }
@ -699,7 +702,7 @@ export class CreateClientImageComponent implements OnInit{
type: 'create-image', type: 'create-image',
}).subscribe({ }).subscribe({
next: () => { next: () => {
this.toastService.success('Tarea de creación de imagen programada con éxito'); this.toastService.success(this.translate.instant('tareaDeCreacionDeImagen'));
}, },
error: (error) => { error: (error) => {
this.toastService.error(error.error['hydra:description'] || 'Error al programar la tarea'); this.toastService.error(error.error['hydra:description'] || 'Error al programar la tarea');

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './create-repository-modal.component.css' styleUrl: './create-repository-modal.component.css'
}) })
export class CreateRepositoryModalComponent implements OnInit { export class CreateRepositoryModalComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
repositoryForm: FormGroup<any>; repositoryForm: FormGroup<any>;
loading: boolean = false; loading: boolean = false;
@ -45,7 +48,7 @@ export class CreateRepositoryModalComponent implements OnInit {
this.http.post(`${this.baseUrl}/git-repositories`, payload).subscribe({ this.http.post(`${this.baseUrl}/git-repositories`, payload).subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Repositorio creado correctamente'); this.toastService.success(this.translate.instant('repositorioCreadoCorrectamente'));
this.dialogRef.close(response); this.dialogRef.close(response);
}, },
error: (error) => { error: (error) => {
@ -54,7 +57,7 @@ export class CreateRepositoryModalComponent implements OnInit {
} }
}); });
} else { } else {
this.toastService.error('Por favor, complete todos los campos requeridos'); this.toastService.error(this.translate.instant('porFavorCompleteTodosLos'));
} }
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { SelectionModel } from "@angular/cdk/collections"; import { SelectionModel } from "@angular/cdk/collections";
@ -16,6 +18,7 @@ import { QueueConfirmationModalComponent } from "../../../../../shared/queue-con
styleUrl: './deploy-image.component.css' styleUrl: './deploy-image.component.css'
}) })
export class DeployImageComponent implements OnInit { export class DeployImageComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@Output() dataChange = new EventEmitter<any>(); @Output() dataChange = new EventEmitter<any>();
@ -75,22 +78,22 @@ export class DeployImageComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'partitionNumber', columnDef: 'partitionNumber',
header: 'Partición', header: 'particion1',
cell: (partition: any) => `${partition.partitionNumber}` cell: (partition: any) => `${partition.partitionNumber}`
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${partition.size} MB` cell: (partition: any) => `${partition.size} MB`
}, },
{ {
columnDef: 'filesystem', columnDef: 'filesystem',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => `${partition.filesystem}` cell: (partition: any) => `${partition.filesystem}`
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO', header: 'so',
cell: (partition: any) => `${partition.operativeSystem?.name}` cell: (partition: any) => `${partition.operativeSystem?.name}`
} }
]; ];
@ -229,7 +232,7 @@ export class DeployImageComponent implements OnInit {
this.loadImages(); this.loadImages();
}, },
(error) => { (error) => {
console.error('Error al cargar las particiones:', error); console.error(this.translate.instant('errorAlCargarLasParticiones'), error);
} }
); );
} }
@ -261,7 +264,7 @@ export class DeployImageComponent implements OnInit {
this.images = response?.['hydra:member'] || []; this.images = response?.['hydra:member'] || [];
}, },
(error) => { (error) => {
console.error('Error al cargar las imágenes:', error); console.error(this.translate.instant('errorAlCargarLasImagenes3'), error);
} }
); );
} }
@ -350,27 +353,27 @@ export class DeployImageComponent implements OnInit {
const needsPartition = this.deployMode !== 'update-cache'; const needsPartition = this.deployMode !== 'update-cache';
if (!this.selectedClients.length) { if (!this.selectedClients.length) {
this.toastService.error('Debe seleccionar al menos un cliente'); this.toastService.error(this.translate.instant('debeSeleccionarAlMenosUn'));
return; return;
} }
if (!this.selectedImage && this.imageType !== 'git') { if (!this.selectedImage && this.imageType !== 'git') {
this.toastService.error('Debe seleccionar una imagen'); this.toastService.error(this.translate.instant('debeSeleccionarUnaImagen'));
return; return;
} }
if (!this.selectedMethod && this.imageType !== 'git') { if (!this.selectedMethod && this.imageType !== 'git') {
this.toastService.error('Debe seleccionar un método'); this.toastService.error(this.translate.instant('debeSeleccionarUnMetodo'));
return; return;
} }
if (needsPartition && !this.selectedPartition) { if (needsPartition && !this.selectedPartition) {
this.toastService.error('Debe seleccionar una partición'); this.toastService.error(this.translate.instant('debeSeleccionarUnaParticion'));
return; return;
} }
if (this.imageType === 'git' && !this.selectedCommit) { if (this.imageType === 'git' && !this.selectedCommit) {
this.toastService.error('Debe seleccionar un commit'); this.toastService.error(this.translate.instant('debeSeleccionarUnCommit'));
return; return;
} }
@ -381,7 +384,7 @@ export class DeployImageComponent implements OnInit {
backdropClass: 'non-clickable-backdrop' backdropClass: 'non-clickable-backdrop'
}); });
this.toastService.info('Preparando petición de despliegue'); this.toastService.info(this.translate.instant('preparandoPeticionDeDespliegue'));
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result !== undefined) { if (result !== undefined) {
@ -428,7 +431,7 @@ export class DeployImageComponent implements OnInit {
this.http.post(url, payload) this.http.post(url, payload)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Petición de despliegue enviada correctamente'); this.toastService.success(this.translate.instant('peticionDeDespliegueEnviadaCorrectamente'));
this.loading = false; this.loading = false;
this.router.navigate(['/commands-logs']); this.router.navigate(['/commands-logs']);
}, },
@ -573,7 +576,7 @@ export class DeployImageComponent implements OnInit {
type: 'deploy-image', type: 'deploy-image',
}).subscribe({ }).subscribe({
next: () => { next: () => {
this.toastService.success('Script añadido con éxito a la tarea'); this.toastService.success(this.translate.instant('scriptAnadidoConExitoA'));
}, },
error: (error) => { error: (error) => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);
@ -632,7 +635,7 @@ export class DeployImageComponent implements OnInit {
} }
}, },
error => { error => {
this.toastService.error('Error al cargar los repositorios git'); this.toastService.error(this.translate.instant('errorAlCargarLosRepositorios1'));
this.loadingRepositories = false; this.loadingRepositories = false;
} }
); );
@ -662,7 +665,7 @@ export class DeployImageComponent implements OnInit {
} }
}, },
error => { error => {
this.toastService.error('Error al cargar las ramas'); this.toastService.error(this.translate.instant('errorAlCargarLasRamas'));
this.loadingBranches = false; this.loadingBranches = false;
} }
); );
@ -694,7 +697,7 @@ export class DeployImageComponent implements OnInit {
} }
}, },
error => { error => {
this.toastService.error('Error al cargar los commits'); this.toastService.error(this.translate.instant('errorAlCargarLosCommits'));
this.loadingCommits = false; this.loadingCommits = false;
} }
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, EventEmitter, Inject, Input, OnInit, Output, AfterViewInit, OnDestroy, ViewChild, ElementRef, HostListener } from '@angular/core'; import {Component, EventEmitter, Inject, Input, OnInit, Output, AfterViewInit, OnDestroy, ViewChild, ElementRef, HostListener } 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';
@ -32,6 +34,7 @@ interface Partition {
styleUrls: ['./partition-assistant.component.css'] styleUrls: ['./partition-assistant.component.css']
}) })
export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDestroy{ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDestroy{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@Output() dataChange = new EventEmitter<any>(); @Output() dataChange = new EventEmitter<any>();
@ -190,7 +193,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
this.initializeDisks(); this.initializeDisks();
}, },
(error) => { (error) => {
console.error('Error al cargar los datos del cliente:', error); console.error(this.translate.instant('errorAlCargarLosDatos1'), error);
} }
); );
} }
@ -412,7 +415,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
this.resizeChart(); this.resizeChart();
}, 100); }, 100);
} else { } else {
this.toastService.error('No hay suficiente espacio libre en el disco para crear una nueva partición.'); this.toastService.error(this.translate.instant('noHaySuficienteEspacioLibre'));
} }
} }
} }
@ -457,7 +460,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
} }
if (!this.selectedDisk) { if (!this.selectedDisk) {
this.toastService.error('No se ha seleccionado un disco.'); this.toastService.error(this.translate.instant('noSeHaSeleccionadoUn'));
return; return;
} }
@ -466,14 +469,14 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
.reduce((sum: any, partition: any) => sum + partition.size, 0); .reduce((sum: any, partition: any) => sum + partition.size, 0);
if (totalPartitionSize > this.selectedDisk.totalDiskSize) { 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.'); this.toastService.error(this.translate.instant('elTamanoTotalDeLas'));
return; return;
} }
const modifiedPartitions = this.selectedDisk.partitions.filter((partition: { removed: any; format: any; }) => !partition.removed || partition.format); const modifiedPartitions = this.selectedDisk.partitions.filter((partition: { removed: any; format: any; }) => !partition.removed || partition.format);
if (modifiedPartitions.length === 0) { if (modifiedPartitions.length === 0) {
this.toastService.info('No hay cambios para guardar en el disco seleccionado.'); this.toastService.info(this.translate.instant('noHayCambiosParaGuardar'));
return; return;
} }
@ -507,13 +510,13 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
this.http.post(this.apiUrl, bulkPayload).subscribe( this.http.post(this.apiUrl, bulkPayload).subscribe(
(response) => { (response) => {
this.toastService.success('Particiones creadas exitosamente para el disco seleccionado.'); this.toastService.success(this.translate.instant('particionesCreadasExitosamenteParaEl'));
this.loading = false; this.loading = false;
this.router.navigate(['/commands-logs']); this.router.navigate(['/commands-logs']);
}, },
(error) => { (error) => {
this.loading = false; this.loading = false;
this.toastService.error('Error al crear las particiones.'); this.toastService.error(this.translate.instant('errorAlCrearLasParticiones'));
} }
); );
} }
@ -680,7 +683,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
if (modifiedPartitions.length === 0) { if (modifiedPartitions.length === 0) {
this.loading = false; this.loading = false;
this.toastService.info('No hay cambios para guardar en el disco seleccionado.'); this.toastService.info(this.translate.instant('noHayCambiosParaGuardar'));
return; return;
} }
@ -711,7 +714,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
type: 'partition-assistant', type: 'partition-assistant',
}).subscribe({ }).subscribe({
next: () => { next: () => {
this.toastService.success('Script añadido con éxito a la tarea'); this.toastService.success(this.translate.instant('scriptAnadidoConExitoA'));
}, },
error: (error) => { error: (error) => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);
@ -723,7 +726,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
generateInstructions(): void { generateInstructions(): void {
if (!this.selectedModelClient || !this.selectedDisk) { if (!this.selectedModelClient || !this.selectedDisk) {
this.toastService.error('Selecciona un cliente modelo y un disco.'); this.toastService.error(this.translate.instant('seleccionaUnClienteModeloY'));
return; return;
} }
@ -777,8 +780,8 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
copyInstructions(): void { copyInstructions(): void {
if (!this.generatedInstructions) { return; } if (!this.generatedInstructions) { return; }
navigator.clipboard?.writeText(this.generatedInstructions) navigator.clipboard?.writeText(this.generatedInstructions)
.then(() => this.toastService.success('Script copiado al portapapeles')) .then(() => this.toastService.success(this.translate.instant('scriptCopiadoAlPortapapeles')))
.catch(() => this.toastService.error('No se pudo copiar el script.')); .catch(() => this.toastService.error(this.translate.instant('noSePudoCopiarEl')));
} }
@ -837,7 +840,7 @@ export class PartitionAssistantComponent implements OnInit, AfterViewInit, OnDes
}); });
console.log('Scroll hacia botón ejecutar completado'); console.log('Scroll hacia botón ejecutar completado');
} else { } else {
console.error('No se encontró el botón execute-button'); console.error(this.translate.instant('noSeEncontroElBoton'));
} }
} }

View File

@ -125,7 +125,7 @@
[(ngModel)]="newScript" [(ngModel)]="newScript"
(ngModelChange)="onNewScriptChange()" (ngModelChange)="onNewScriptChange()"
rows="8" rows="8"
placeholder="{{'bashScriptBoilerplate'|translate}}" [placeholder]="'bashScriptBoilerplate'|translate"
class="script-textarea"></textarea> class="script-textarea"></textarea>
<mat-hint>{{ 'writeShellCommandsHint' | translate }}</mat-hint> <mat-hint>{{ 'writeShellCommandsHint' | translate }}</mat-hint>
</mat-form-field> </mat-form-field>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, EventEmitter, OnInit, Output } from '@angular/core'; import {Component, EventEmitter, OnInit, Output } from '@angular/core';
import { SelectionModel } from "@angular/cdk/collections"; import { SelectionModel } from "@angular/cdk/collections";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -15,6 +17,7 @@ import {QueueConfirmationModalComponent} from "../../../../../shared/queue-confi
styleUrl: './run-script-assistant.component.css' styleUrl: './run-script-assistant.component.css'
}) })
export class RunScriptAssistantComponent implements OnInit{ export class RunScriptAssistantComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@Output() dataChange = new EventEmitter<any>(); @Output() dataChange = new EventEmitter<any>();
@ -96,7 +99,7 @@ export class RunScriptAssistantComponent implements OnInit{
saveNewScript() { saveNewScript() {
if (!this.newScript.trim()) { if (!this.newScript.trim()) {
this.toastService.error('Debe ingresar un script antes de guardar.'); this.toastService.error(this.translate.instant('debeIngresarUnScriptAntes'));
return; return;
} }
const dialogRef = this.dialog.open(SaveScriptComponent, { const dialogRef = this.dialog.open(SaveScriptComponent, {
@ -106,7 +109,7 @@ export class RunScriptAssistantComponent implements OnInit{
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
this.toastService.success('Script guardado correctamente'); this.toastService.success(this.translate.instant('scriptGuardadoCorrectamente'));
} }
}); });
} }
@ -205,13 +208,13 @@ export class RunScriptAssistantComponent implements OnInit{
runAsAdmin: this.runAsAdmin runAsAdmin: this.runAsAdmin
}).subscribe( }).subscribe(
response => { response => {
this.toastService.success('Script ejecutado correctamente'); this.toastService.success(this.translate.instant('scriptEjecutadoCorrectamente'));
this.dataChange.emit(); this.dataChange.emit();
this.router.navigate(['/commands-logs']); this.router.navigate(['/commands-logs']);
this.loading = false; this.loading = false;
}, },
error => { error => {
this.toastService.error('Error al ejecutar el script'); this.toastService.error(this.translate.instant('errorAlEjecutarElScript'));
this.loading = false; this.loading = false;
} }
); );
@ -258,7 +261,7 @@ export class RunScriptAssistantComponent implements OnInit{
type: 'run-script', type: 'run-script',
}).subscribe({ }).subscribe({
next: () => { next: () => {
this.toastService.success('Script añadido con éxito a la tarea'); this.toastService.success(this.translate.instant('scriptAnadidoConExitoA'));
}, },
error: (error) => { error: (error) => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject } from '@angular/core'; import {Component, Inject } from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {FormBuilder, Validators} from "@angular/forms"; import {FormBuilder, Validators} from "@angular/forms";
@ -12,6 +14,7 @@ import {DataService} from "../../../../../commands/main-commands/data.service";
styleUrl: './save-script.component.css' styleUrl: './save-script.component.css'
}) })
export class SaveScriptComponent { export class SaveScriptComponent {
public translate = inject(TranslateService);
commandName: string = ''; commandName: string = '';
baseUrl: string; baseUrl: string;
@ -36,7 +39,7 @@ export class SaveScriptComponent {
this.http.post(`${this.baseUrl}/commands`, payload).subscribe( this.http.post(`${this.baseUrl}/commands`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Comando añadido correctamente'); this.toastService.success(this.translate.instant('comandoAnadidoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, OnDestroy, ViewChild, QueryList, ViewChildren, ChangeDetectorRef } from '@angular/core'; import { Component, OnInit, OnDestroy, ViewChild, QueryList, ViewChildren, ChangeDetectorRef } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
@ -48,6 +50,7 @@ enum NodeType {
styleUrls: ['./groups.component.css'], styleUrls: ['./groups.component.css'],
}) })
export class GroupsComponent implements OnInit, OnDestroy { export class GroupsComponent implements OnInit, OnDestroy {
public translate = inject(TranslateService);
@ViewChildren(MatMenuTrigger) menuTriggers!: QueryList<MatMenuTrigger>; @ViewChildren(MatMenuTrigger) menuTriggers!: QueryList<MatMenuTrigger>;
isSmallScreen: boolean = false; isSmallScreen: boolean = false;
baseUrl: string; baseUrl: string;
@ -283,7 +286,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
// this.savedFilterNames = data.map((filter: { name: string; uuid: string; }) => [filter.name, filter.uuid]); // this.savedFilterNames = data.map((filter: { name: string; uuid: string; }) => [filter.name, filter.uuid]);
// }, // },
// (error) => { // (error) => {
// console.error('Error fetching filters:', error); // console.error(this.translate.instant('errorFetchingFilters1'), error);
// } // }
// ) // )
// ); // );
@ -297,7 +300,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
this.savedFilterNames = data.map((filter: { name: string; uuid: string; }) => [filter.name, filter.uuid]); this.savedFilterNames = data.map((filter: { name: string; uuid: string; }) => [filter.name, filter.uuid]);
}, },
(error) => { (error) => {
console.error('Error fetching filters:', error); console.error(this.translate.instant('errorFetchingFilters1'), error);
} }
) )
); );
@ -350,8 +353,8 @@ export class GroupsComponent implements OnInit, OnDestroy {
} }
}, },
error: (error) => { error: (error) => {
console.error('Error fetching organizational units', error); console.error(this.translate.instant('errorFetchingOrganizationalUnits'), error);
this.toastr.error('Ocurrió un error al cargar las unidades organizativas'); this.toastr.error(this.translate.instant('ocurrioUnErrorAlCargar'));
}, },
}); });
} }
@ -561,7 +564,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
console.log('Nodo padre encontrado para actualización:', parentNode); console.log('Nodo padre encontrado para actualización:', parentNode);
this.refreshData(parentNode.uuid); this.refreshData(parentNode.uuid);
} else { } else {
console.error('No se encontró el nodo padre después de la creación masiva.'); console.error(this.translate.instant('noSeEncontroElNodo'));
} }
} }
this.loading = false; this.loading = false;
@ -635,7 +638,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
} }
}, },
error: (error) => { error: (error) => {
console.error('Error deleting entity:', error); console.error(this.translate.instant('errorDeletingEntity'), error);
const entityType = type === NodeType.Client ? 'cliente' : 'entidad'; const entityType = type === NodeType.Client ? 'cliente' : 'entidad';
this.toastr.error(`Error al eliminar el ${entityType}`); this.toastr.error(`Error al eliminar el ${entityType}`);
}, },
@ -675,7 +678,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
}); });
}, },
(error) => { (error) => {
console.error('Error fetching room data:', error); console.error(this.translate.instant('errorFetchingRoomData'), error);
} }
) )
); );
@ -685,7 +688,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
executeCommand(command: Command, selectedNode: TreeNode | null): void { executeCommand(command: Command, selectedNode: TreeNode | null): void {
this.loading = true; this.loading = true;
if (!selectedNode) { if (!selectedNode) {
this.toastr.error('No hay un nodo seleccionado.'); this.toastr.error(this.translate.instant('noHayUnNodoSeleccionado'));
return; return;
} else { } else {
this.toastr.success(`Ejecutando comando: ${command.name} en ${selectedNode.name}`); this.toastr.success(`Ejecutando comando: ${command.name} en ${selectedNode.name}`);
@ -834,7 +837,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
this.subscriptions.add( this.subscriptions.add(
this.http.post(`${this.baseUrl}${client['@id']}/agent/status`, {}).subscribe( this.http.post(`${this.baseUrl}${client['@id']}/agent/status`, {}).subscribe(
() => { () => {
this.toastr.success('Cliente actualizado correctamente'); this.toastr.success(this.translate.instant('clienteActualizadoCorrectamente'));
this.syncingClientIds.delete(client.uuid); this.syncingClientIds.delete(client.uuid);
this.refreshData(parentNodeId) this.refreshData(parentNodeId)
}, },
@ -869,12 +872,12 @@ export class GroupsComponent implements OnInit, OnDestroy {
}); });
this.arrayClients = this.selectedClients.data; this.arrayClients = this.selectedClients.data;
this.calculateLocalStats(); this.calculateLocalStats();
this.toastr.success('Estado del aula actualizado'); this.toastr.success(this.translate.instant('estadoDelAulaActualizado'));
}, },
error: () => { error: () => {
this.isCheckingNodeStatus = false; this.isCheckingNodeStatus = false;
this.selectedClients.data.forEach(c => c.uuid && this.syncingClientIds.delete(c.uuid)); this.selectedClients.data.forEach(c => c.uuid && this.syncingClientIds.delete(c.uuid));
this.toastr.error('Error al comprobar el estado del aula'); this.toastr.error(this.translate.instant('errorAlComprobarElEstado'));
}, },
}) })
); );
@ -1054,14 +1057,14 @@ export class GroupsComponent implements OnInit, OnDestroy {
`); `);
} }
} else { } else {
this.toastr.error('No se puede acceder a los logs: IP del cliente no disponible', 'Error'); this.toastr.error(this.translate.instant('noSePuedeAccederA'), 'Error');
} }
} }
openClientLogsModal(event: MouseEvent, client: Client): void { openClientLogsModal(event: MouseEvent, client: Client): void {
event.stopPropagation(); event.stopPropagation();
if (!client.mac) { if (!client.mac) {
this.toastr.error('No se puede acceder a los logs: MAC del cliente no disponible', 'Error'); this.toastr.error(this.translate.instant('noSePuedeAccederA1'), 'Error');
return; return;
} }
@ -1088,7 +1091,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
const allClients = response['hydra:member'] || []; const allClients = response['hydra:member'] || [];
if (allClients.length === 0) { if (allClients.length === 0) {
this.toastr.warning('Esta unidad organizativa no tiene clientes'); this.toastr.warning(this.translate.instant('estaUnidadOrganizativaNoTiene'));
return; return;
} }
@ -1113,8 +1116,8 @@ export class GroupsComponent implements OnInit, OnDestroy {
}); });
}, },
error: (error) => { error: (error) => {
console.error('Error al obtener los clientes de la unidad organizativa:', error); console.error(this.translate.instant('errorAlObtenerLosClientes1'), error);
this.toastr.error('Error al cargar los clientes de la unidad organizativa'); this.toastr.error(this.translate.instant('errorAlCargarLosClientes'));
this.loading = false; this.loading = false;
} }
}); });
@ -1135,7 +1138,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
refreshClientData(): void { refreshClientData(): void {
this.fetchClientsForNode(this.selectedNode); this.fetchClientsForNode(this.selectedNode);
this.toastr.success('Datos actualizados', 'Éxito'); this.toastr.success(this.translate.instant('datosActualizados'), 'Éxito');
} }
exportToCSV(): void { exportToCSV(): void {
@ -1164,7 +1167,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
this.toastr.success('Archivo CSV exportado correctamente', 'Éxito'); this.toastr.success(this.translate.instant('archivoCsvExportadoCorrectamente'), 'Éxito');
} }
private calculateLocalStats(): void { private calculateLocalStats(): void {
@ -1318,7 +1321,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
event.stopPropagation(); event.stopPropagation();
if (this.selection.selected.length === 0) { if (this.selection.selected.length === 0) {
this.toastr.warning('No hay clientes seleccionados para eliminar'); this.toastr.warning(this.translate.instant('noHayClientesSeleccionadosPara'));
return; return;
} }
@ -1355,8 +1358,8 @@ export class GroupsComponent implements OnInit, OnDestroy {
}, },
error: (error) => { error: (error) => {
this.loading = false; this.loading = false;
console.error('Error deleting multiple clients:', error); console.error(this.translate.instant('errorDeletingMultipleClients1'), error);
this.toastr.error('Error al eliminar los clientes seleccionados'); this.toastr.error(this.translate.instant('errorAlEliminarLosClientes'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {HttpClient, HttpParams} from '@angular/common/http'; import {HttpClient, HttpParams} from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -9,6 +11,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -35,7 +38,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching unidades organizativas', error); console.error(this.translate.instant('errorFetchingUnidadesOrganizativas'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -51,7 +54,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching children', error); console.error(this.translate.instant('errorFetchingChildren'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -67,7 +70,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching clients', error); console.error(this.translate.instant('errorFetchingClients'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -84,7 +87,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching clients', error); console.error(this.translate.instant('errorFetchingClients'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -101,7 +104,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching clients', error); console.error(this.translate.instant('errorFetchingClients'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -118,7 +121,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching clients', error); console.error(this.translate.instant('errorFetchingClients'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -132,7 +135,7 @@ export class DataService {
console.log('DELETE URL:', url); // Depuración console.log('DELETE URL:', url); // Depuración
return this.http.delete<void>(url).pipe( return this.http.delete<void>(url).pipe(
catchError(error => { catchError(error => {
console.error('Error deleting element', error); console.error(this.translate.instant('errorDeletingElement'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -144,7 +147,7 @@ export class DataService {
// @ts-ignore // @ts-ignore
return this.http.post<void>(url).pipe( return this.http.post<void>(url).pipe(
catchError(error => { catchError(error => {
console.error('Error deleting element', error); console.error(this.translate.instant('errorDeletingElement'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -185,7 +188,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching data', error); console.error(this.translate.instant('errorFetchingData'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -201,7 +204,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching filters', error); console.error(this.translate.instant('errorFetchingFilters'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -219,7 +222,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching filters', error); console.error(this.translate.instant('errorFetchingFilters'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -229,7 +232,7 @@ export class DataService {
const url = `${this.baseUrl}/organizational-units/${id}`; const url = `${this.baseUrl}/organizational-units/${id}`;
return this.http.get<any>(url).pipe( return this.http.get<any>(url).pipe(
catchError(error => { catchError(error => {
console.error('Error fetching organizational unit', error); console.error(this.translate.instant('errorFetchingOrganizationalUnit'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -255,7 +258,7 @@ export class DataService {
return this.http.post<any>(url, body).pipe( return this.http.post<any>(url, body).pipe(
catchError(error => { catchError(error => {
console.error('Error deleting multiple clients', error); console.error(this.translate.instant('errorDeletingMultipleClients'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, Inject, OnInit } from '@angular/core'; import {Component, Inject, OnInit } from '@angular/core';
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
@ -11,6 +13,7 @@ import {ConfigService} from "@services/config.service";
styleUrl: './change-parent.component.css' styleUrl: './change-parent.component.css'
}) })
export class ChangeParentComponent implements OnInit { export class ChangeParentComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loading: boolean = true; loading: boolean = true;
units: any[] = []; units: any[] = [];
@ -38,7 +41,7 @@ export class ChangeParentComponent implements OnInit {
this.units = response['hydra:member']; this.units = response['hydra:member'];
this.loading = false; this.loading = false;
}, },
error => console.error('Error fetching organizational units:', error) error => console.error(this.translate.instant('errorFetchingOrganizationalUnits1'), error)
); );
} }
@ -48,7 +51,7 @@ export class ChangeParentComponent implements OnInit {
organizationalUnit: this.newOU['@id'] organizationalUnit: this.newOU['@id']
}).subscribe({ }).subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Parent changed successfully'); this.toastService.success(this.translate.instant('parentChangedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: error => { error: error => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Input, OnInit, OnChanges } from '@angular/core'; import { Component, Input, OnInit, OnChanges } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ClientViewComponent } from "../client-view/client-view.component"; import { ClientViewComponent } from "../client-view/client-view.component";
@ -17,6 +19,7 @@ interface GroupedClients {
styleUrls: ['./classroom-view.component.css'] styleUrls: ['./classroom-view.component.css']
}) })
export class ClassroomViewComponent implements OnInit, OnChanges { export class ClassroomViewComponent implements OnInit, OnChanges {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@Input() clients: any[] = []; @Input() clients: any[] = [];
@Input() pcInTable: number = 5; @Input() pcInTable: number = 5;
@ -93,7 +96,7 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
this.http.patch(url, payload).subscribe(response => { this.http.patch(url, payload).subscribe(response => {
this.openSnackBar(false, 'Plano actualizado!'); this.openSnackBar(false, 'Plano actualizado!');
}, error => { }, error => {
console.error('Error al actualizar cliente:', error); console.error(this.translate.instant('errorAlActualizarCliente1'), error);
this.openSnackBar(true, error); this.openSnackBar(true, error);
}); });
}); });
@ -103,8 +106,8 @@ export class ClassroomViewComponent implements OnInit, OnChanges {
openSnackBar(isError: boolean, message: string) { openSnackBar(isError: boolean, message: string) {
if (isError) { if (isError) {
this.toastService.error(' Error al actualizar cliente: ' + message, 'Error'); this.toastService.error(this.translate.instant('errorAlActualizarCliente') + message, 'Error');
} else } else
this.toastService.success('Cliente actualizado!', 'Éxito'); this.toastService.success(this.translate.instant('clienteActualizado'), 'Éxito');
} }
} }

View File

@ -60,7 +60,7 @@
<table mat-table [dataSource]="disk.partitions" class="disk-table"> <table mat-table [dataSource]="disk.partitions" class="disk-table">
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
@if (column.columnDef !== 'size' && column.columnDef !== 'operativeSystem') { @if (column.columnDef !== 'size' && column.columnDef !== 'operativeSystem') {
{{ column.cell(image) }} {{ column.cell(image) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core'; import { Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -20,6 +22,7 @@ interface ClientInfo {
styleUrl: './client-details.component.css' styleUrl: './client-details.component.css'
}) })
export class ClientDetailsComponent { export class ClientDetailsComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
@ViewChild('assistantContainer') assistantContainer!: ElementRef; @ViewChild('assistantContainer') assistantContainer!: ElementRef;
clientUuid: string; clientUuid: string;
@ -43,32 +46,32 @@ export class ClientDetailsComponent {
columns = [ columns = [
{ {
columnDef: 'partition', columnDef: 'partition',
header: 'Partición', header: 'particion1',
cell: (partition: any) => `${partition.partitionNumber}` cell: (partition: any) => `${partition.partitionNumber}`
}, },
{ {
columnDef: 'partitionCode', columnDef: 'partitionCode',
header: 'Tipo de partición', header: 'tipoDeParticion',
cell: (partition: any) => partition.partitionCode cell: (partition: any) => partition.partitionCode
}, },
{ {
columnDef: 'description', columnDef: 'description',
header: 'Sistema de ficheros', header: 'sistemaDeFicheros',
cell: (partition: any) => partition.filesystem cell: (partition: any) => partition.filesystem
}, },
{ {
columnDef: 'size', columnDef: 'size',
header: 'Tamaño', header: 'tamano',
cell: (partition: any) => `${(partition.size / 1024).toFixed(2)} GB` cell: (partition: any) => `${(partition.size / 1024).toFixed(2)} GB`
}, },
{ {
columnDef: 'memoryUsage', columnDef: 'memoryUsage',
header: 'Uso', header: 'uso',
cell: (partition: any) => `${partition.memoryUsage}%` cell: (partition: any) => `${partition.memoryUsage}%`
}, },
{ {
columnDef: 'operativeSystem', columnDef: 'operativeSystem',
header: 'SO/Imagen', header: 'soimagen',
cell: (partition: any) => partition.operativeSystem?.name cell: (partition: any) => partition.operativeSystem?.name
} }
]; ];
@ -99,7 +102,7 @@ export class ClientDetailsComponent {
this.loadPartitions(); this.loadPartitions();
this.loading = false; this.loading = false;
} else { } else {
console.error('No se recibieron datos del cliente.'); console.error(this.translate.instant('noSeRecibieronDatosDel'));
} }
} }
@ -190,7 +193,7 @@ export class ClientDetailsComponent {
this.calculateDiskUsage(); this.calculateDiskUsage();
}, },
error: error => { error: error => {
console.error('Error al obtener las particiones:', error); console.error(this.translate.instant('errorAlObtenerLasParticiones'), error);
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit, Optional } from '@angular/core'; import { Component, Inject, OnInit, Optional } from '@angular/core';
import { MatDialogRef } from "@angular/material/dialog"; import { MatDialogRef } from "@angular/material/dialog";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './create-multiple-client.component.css' styleUrl: './create-multiple-client.component.css'
}) })
export class CreateMultipleClientComponent implements OnInit { export class CreateMultipleClientComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string = this.configService.apiUrl; baseUrl: string = this.configService.apiUrl;
parentUnits: any[] = []; parentUnits: any[] = [];
parentUnitsWithPaths: { id: string, name: string, path: string }[] = []; parentUnitsWithPaths: { id: string, name: string, path: string }[] = [];
@ -56,7 +59,7 @@ export class CreateMultipleClientComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error => { error => {
console.error('Error fetching parent units:', error); console.error(this.translate.instant('errorFetchingParentUnits'), error);
this.loading = false; this.loading = false;
} }
); );
@ -91,10 +94,10 @@ export class CreateMultipleClientComponent implements OnInit {
if (clients.length > 0) { if (clients.length > 0) {
this.uploadedClients = clients; this.uploadedClients = clients;
this.toastService.success('Archivo cargado correctamente, los datos están listos para enviarse.', 'Éxito'); this.toastService.success(this.translate.instant('archivoCargadoCorrectamenteLosDatos'), 'Éxito');
this.showTextarea = false; this.showTextarea = false;
} else { } else {
this.toastService.error('No se encontraron datos válidos', 'Error'); this.toastService.error(this.translate.instant('noSeEncontraronDatosValidos'), 'Error');
this.showTextarea = true; this.showTextarea = true;
} }
}; };
@ -117,10 +120,10 @@ export class CreateMultipleClientComponent implements OnInit {
if (clients.length > 0) { if (clients.length > 0) {
this.uploadedClients = clients; this.uploadedClients = clients;
this.toastService.success('Datos cargados correctamente, los datos están listos para enviarse.', 'Éxito'); this.toastService.success(this.translate.instant('datosCargadosCorrectamenteLosDatos'), 'Éxito');
this.showTextarea = false; this.showTextarea = false;
} else { } else {
this.toastService.error('No se encontraron datos válidos', 'Error'); this.toastService.error(this.translate.instant('noSeEncontraronDatosValidos'), 'Error');
this.showTextarea = true; this.showTextarea = true;
} }
} }
@ -154,7 +157,7 @@ export class CreateMultipleClientComponent implements OnInit {
); );
}); });
} else { } else {
this.toastService.error('No hay clientes cargados para añadir', 'Error'); this.toastService.error(this.translate.instant('noHayClientesCargadosPara'), 'Error');
} }
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./manage-client.component.css'] styleUrls: ['./manage-client.component.css']
}) })
export class ManageClientComponent implements OnInit { export class ManageClientComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
clientForm!: FormGroup; clientForm!: FormGroup;
parentUnits: any[] = []; parentUnits: any[] = [];
@ -66,7 +69,7 @@ export class ManageClientComponent implements OnInit {
this.loading = false; this.loading = false;
} }
}).catch(error => { }).catch(error => {
console.error('Error loading data:', error); console.error(this.translate.instant('errorLoadingData'), error);
this.loading = false; this.loading = false;
}); });
} }
@ -122,7 +125,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching parent units:', error); console.error(this.translate.instant('errorFetchingParentUnits'), error);
reject(error); reject(error);
} }
); );
@ -145,7 +148,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching ogLives by server:', error); console.error(this.translate.instant('errorFetchingOglivesByServer'), error);
this.ogLives = []; this.ogLives = [];
resolve(); // resolve anyway so form doesn't block resolve(); // resolve anyway so form doesn't block
} }
@ -163,7 +166,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching PXE templates by server:', error); console.error(this.translate.instant('errorFetchingPxeTemplatesBy'), error);
this.templates = []; this.templates = [];
resolve(); resolve();
} }
@ -181,7 +184,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching BootServers:', error); console.error(this.translate.instant('errorFetchingBootservers'), error);
reject(error); reject(error);
} }
); );
@ -212,7 +215,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching menus:', error); console.error(this.translate.instant('errorFetchingMenus1'), error);
reject(error); reject(error);
} }
); );
@ -229,7 +232,7 @@ export class ManageClientComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching repositories:', error); console.error(this.translate.instant('errorFetchingRepositories1'), error);
reject(error); reject(error);
} }
); );
@ -313,7 +316,7 @@ export class ManageClientComponent implements OnInit {
} }
}, },
error => { error => {
console.error('Error al cargar datos del cliente:', error); console.error(this.translate.instant('errorAlCargarDatosDel'), error);
reject(error); reject(error);
} }
); );
@ -331,17 +334,17 @@ export class ManageClientComponent implements OnInit {
this.http.patch<any>(putUrl, formData, { headers }).subscribe( this.http.patch<any>(putUrl, formData, { headers }).subscribe(
response => { response => {
this.dialogRef.close({ success: true }); this.dialogRef.close({ success: true });
this.toastService.success('Cliente actualizado exitosamente', 'Éxito'); this.toastService.success(this.translate.instant('clienteActualizadoExitosamente'), 'Éxito');
}, },
error => { error => {
console.error('Error al realizar PUT:', error); console.error(this.translate.instant('errorAlRealizarPut'), error);
this.toastService.error('Error al actualizar el cliente: ' + error.error['hydra:description'], 'Error'); this.toastService.error(this.translate.instant('errorAlActualizarElCliente') + error.error['hydra:description'], 'Error');
} }
); );
} else { } else {
this.http.post(`${this.baseUrl}/clients`, formData).subscribe( this.http.post(`${this.baseUrl}/clients`, formData).subscribe(
(response) => { (response) => {
this.toastService.success('Cliente creado exitosamente', 'Éxito'); this.toastService.success(this.translate.instant('clienteCreadoExitosamente'), 'Éxito');
this.dialogRef.close({ this.dialogRef.close({
success: true, success: true,
client: response, client: response,
@ -354,7 +357,7 @@ export class ManageClientComponent implements OnInit {
); );
} }
} else { } else {
this.toastService.error('Formulario inválido. Por favor, revise los campos obligatorios.', 'Error'); this.toastService.error(this.translate.instant('formularioInvalidoPorFavorRevise'), 'Error');
} }
} }

View File

@ -22,7 +22,7 @@
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let partition"> <td mat-cell *matCellDef="let partition">
@if (column.columnDef === 'size') { @if (column.columnDef === 'size') {
<div style="display: flex; flex-direction: column;"> <div style="display: flex; flex-direction: column;">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./execute-command-ou.component.css'] styleUrls: ['./execute-command-ou.component.css']
}) })
export class ExecuteCommandOuComponent implements OnInit { export class ExecuteCommandOuComponent implements OnInit {
public translate = inject(TranslateService);
form: FormGroup; form: FormGroup;
clients: any[] = []; clients: any[] = [];
commands: any[] = []; commands: any[] = [];
@ -46,7 +49,7 @@ export class ExecuteCommandOuComponent implements OnInit {
const clientIds = this.clients.map(client => client.uuid); const clientIds = this.clients.map(client => client.uuid);
this.form.get('clientSelection')?.setValue(clientIds); this.form.get('clientSelection')?.setValue(clientIds);
}, },
error => console.error('Error al cargar los clientes:', error) error => console.error(this.translate.instant('errorAlCargarLosClientes1'), error)
); );
} }
@ -65,7 +68,7 @@ export class ExecuteCommandOuComponent implements OnInit {
response => { response => {
this.commands = response['hydra:member'] || []; this.commands = response['hydra:member'] || [];
}, },
error => this.toastService.error('Error al cargar comandos:', error) error => this.toastService.error(this.translate.instant('errorAlCargarComandos'), error)
); );
} }
@ -74,7 +77,7 @@ export class ExecuteCommandOuComponent implements OnInit {
response => { response => {
this.commandGroups = response['hydra:member'] || []; this.commandGroups = response['hydra:member'] || [];
}, },
error => this.toastService.error('Error al cargar grupos de comandos:', error) error => this.toastService.error(this.translate.instant('errorAlCargarGruposDe'), error)
); );
} }
@ -107,11 +110,11 @@ export class ExecuteCommandOuComponent implements OnInit {
this.http.post(url, payload) this.http.post(url, payload)
.subscribe({ .subscribe({
next: () => { next: () => {
this.toastService.success('Comando ejecutado con éxito'); this.toastService.success(this.translate.instant('comandoEjecutadoConExito'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error al ejecutar el comando:', error); this.toastService.error(this.translate.instant('errorAlEjecutarElComando'), error);
this.dialogRef.close(false); this.dialogRef.close(false);
} }
}); });

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, Inject, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@ -13,6 +15,7 @@ import { DeleteModalComponent } from '../../../../../shared/delete_modal/delete-
styleUrls: ['./manage-organizational-unit.component.css'] styleUrls: ['./manage-organizational-unit.component.css']
}) })
export class ManageOrganizationalUnitComponent implements OnInit { export class ManageOrganizationalUnitComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
isLinear = true; isLinear = true;
generalFormGroup: FormGroup; generalFormGroup: FormGroup;
@ -128,7 +131,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
this.loading = false; this.loading = false;
} }
}).catch(error => { }).catch(error => {
console.error('Error loading data:', error); console.error(this.translate.instant('errorLoadingData'), error);
this.loading = false; this.loading = false;
}); });
} }
@ -173,7 +176,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching parent units:', error); console.error(this.translate.instant('errorFetchingParentUnits'), error);
reject(error); reject(error);
} }
); );
@ -286,8 +289,8 @@ export class ManageOrganizationalUnitComponent implements OnInit {
}, },
error => { error => {
console.error('Error fetching data for edit:', error); console.error(this.translate.instant('errorFetchingDataForEdit'), error);
this.toastService.error('Error fetching data'); this.toastService.error(this.translate.instant('errorFetchingData'));
reject(error); reject(error);
this.onNoClick(); this.onNoClick();
} }
@ -301,8 +304,8 @@ export class ManageOrganizationalUnitComponent implements OnInit {
const confirmRef = this.dialog.open(DeleteModalComponent, { const confirmRef = this.dialog.open(DeleteModalComponent, {
width: '400px', width: '400px',
data: { data: {
title: 'Propagar parámetros', title : this.translate.instant('propagarParametros'),
message: '¿Desea propagar los parámetros de red (ogLive, repositorio, menú, plantilla PXE, perfil hardware) a todos los clientes de esta unidad organizativa?', message : this.translate.instant('deseaPropagarLosParametrosDe'),
confirmText: 'Sí, propagar', confirmText: 'Sí, propagar',
cancelText: 'No, solo guardar', cancelText: 'No, solo guardar',
} }
@ -351,11 +354,11 @@ export class ManageOrganizationalUnitComponent implements OnInit {
} else { } else {
this.unitAdded.emit(); this.unitAdded.emit();
this.dialogRef.close({ success: true }); this.dialogRef.close({ success: true });
this.toastService.success('Editado exitosamente', 'Éxito'); this.toastService.success(this.translate.instant('editadoExitosamente'), 'Éxito');
} }
}, },
error => { error => {
console.error('Error al realizar PUT:', error); console.error(this.translate.instant('errorAlRealizarPut'), error);
const errorMessages = error.error['hydra:description'].split('\n'); const errorMessages = error.error['hydra:description'].split('\n');
errorMessages.forEach((message: string) => { errorMessages.forEach((message: string) => {
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:'); const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
@ -371,10 +374,10 @@ export class ManageOrganizationalUnitComponent implements OnInit {
response => { response => {
this.unitAdded.emit(response); this.unitAdded.emit(response);
this.dialogRef.close({ success: true }); this.dialogRef.close({ success: true });
this.toastService.success('Creado exitosamente', 'Éxito'); this.toastService.success(this.translate.instant('creadoExitosamente'), 'Éxito');
}, },
error => { error => {
console.error('Error al realizar POST:', error); console.error(this.translate.instant('errorAlRealizarPost'), error);
const errorMessages = error.error['hydra:description'].split('\n'); const errorMessages = error.error['hydra:description'].split('\n');
errorMessages.forEach((message: string) => { errorMessages.forEach((message: string) => {
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:'); const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
@ -393,13 +396,13 @@ export class ManageOrganizationalUnitComponent implements OnInit {
() => { () => {
this.unitAdded.emit(); this.unitAdded.emit();
this.dialogRef.close({ success: true }); this.dialogRef.close({ success: true });
this.toastService.success('Editado y parámetros propagados exitosamente', 'Éxito'); this.toastService.success(this.translate.instant('editadoYParametrosPropagadosExitosamente'), 'Éxito');
}, },
error => { error => {
console.error('Error al propagar parámetros:', error); console.error(this.translate.instant('errorAlPropagarParametros'), error);
this.unitAdded.emit(); this.unitAdded.emit();
this.dialogRef.close({ success: true }); this.dialogRef.close({ success: true });
this.toastService.warning('Guardado, pero hubo un error al propagar los parámetros', 'Aviso'); this.toastService.warning(this.translate.instant('guardadoPeroHuboUnError'), 'Aviso');
} }
); );
} }
@ -419,7 +422,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching BootServers:', error); console.error(this.translate.instant('errorFetchingBootservers'), error);
reject(error); reject(error);
} }
); );
@ -435,7 +438,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching ogLives by server:', error); console.error(this.translate.instant('errorFetchingOglivesByServer'), error);
this.ogLives = []; this.ogLives = [];
resolve(); resolve();
} }
@ -452,7 +455,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching PXE templates by server:', error); console.error(this.translate.instant('errorFetchingPxeTemplatesBy'), error);
this.pxeTemplates = []; this.pxeTemplates = [];
resolve(); resolve();
} }
@ -481,7 +484,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching hardware profiles:', error); console.error(this.translate.instant('errorFetchingHardwareProfiles'), error);
reject(error); reject(error);
} }
); );
@ -500,7 +503,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching menus:', error); console.error(this.translate.instant('errorFetchingMenus1'), error);
reject(error); reject(error);
} }
); );
@ -517,7 +520,7 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error fetching ogLives:', error); console.error(this.translate.instant('errorFetchingOglives'), error);
reject(error); reject(error);
} }
); );
@ -533,8 +536,8 @@ export class ManageOrganizationalUnitComponent implements OnInit {
resolve(); resolve();
}, },
error => { error => {
console.error('Error loading calendars', error); console.error(this.translate.instant('errorLoadingCalendars'), error);
this.toastService.error('Error loading current calendar'); this.toastService.error(this.translate.instant('errorLoadingCurrentCalendar'));
reject(error); reject(error);
} }
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
@ -10,6 +12,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './show-organizational-unit.component.css' styleUrl: './show-organizational-unit.component.css'
}) })
export class ShowOrganizationalUnitComponent implements OnInit { export class ShowOrganizationalUnitComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
displayedColumns: string[] = ['property', 'value']; displayedColumns: string[] = ['property', 'value'];
currentCalendar: any; currentCalendar: any;
@ -50,7 +53,7 @@ export class ShowOrganizationalUnitComponent implements OnInit {
this.initializeData(); this.initializeData();
}, },
error => { error => {
console.error('Error loading organizational unit', error); console.error(this.translate.instant('errorLoadingOrganizationalUnit'), error);
this.initializeData(); this.initializeData();
}); });
} }
@ -63,7 +66,7 @@ export class ShowOrganizationalUnitComponent implements OnInit {
this.initializeData(); this.initializeData();
}, },
error => { error => {
console.error('Error loading current calendar', error); console.error(this.translate.instant('errorLoadingCurrentCalendar'), error);
this.initializeData(); this.initializeData();
} }
); );

View File

@ -11,7 +11,7 @@
<div *ngIf="dataSource.data.length > 0" class="hardware-table-container"> <div *ngIf="dataSource.data.length > 0" class="hardware-table-container">
<table mat-table [dataSource]="dataSource"> <table mat-table [dataSource]="dataSource">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let hardware"> <td mat-cell *matCellDef="let hardware">
{{ column.cell(hardware) }} {{ column.cell(hardware) }}
</td> </td>

View File

@ -14,22 +14,22 @@ export class HardwareCollectionModalComponent {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (hardware: any) => hardware.id || hardware['@id']?.split('/').pop() || 'N/A' cell: (hardware: any) => hardware.id || hardware['@id']?.split('/').pop() || 'N/A'
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (hardware: any) => hardware.name || 'N/A' cell: (hardware: any) => hardware.name || 'N/A'
}, },
{ {
columnDef: 'type', columnDef: 'type',
header: 'Tipo', header: 'tipo',
cell: (hardware: any) => hardware.type || 'N/A' cell: (hardware: any) => hardware.type || 'N/A'
}, },
{ {
columnDef: 'description', columnDef: 'description',
header: 'Descripción', header: 'descripcion',
cell: (hardware: any) => hardware.description || 'N/A' cell: (hardware: any) => hardware.description || 'N/A'
} }
]; ];

View File

@ -39,7 +39,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep" <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep"
text="Aquí se mostrará todo el hardware disponible y sus características."> text="Aquí se mostrará todo el hardware disponible y sus características.">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'"> <ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'">
<mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, signal } from '@angular/core'; import { Component, signal } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
@ -19,6 +21,7 @@ import { FormControl } from '@angular/forms';
styleUrl: './hardware-profile.component.css' styleUrl: './hardware-profile.component.css'
}) })
export class HardwareProfileComponent { export class HardwareProfileComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -37,17 +40,17 @@ export class HardwareProfileComponent {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (hardware: any) => `${hardware.id}`, cell: (hardware: any) => `${hardware.id}`,
}, },
{ {
columnDef: 'description', columnDef: 'description',
header: 'Descripción', header: 'descripcion',
cell: (hardware: any) => hardware.description cell: (hardware: any) => hardware.description
}, },
{ {
columnDef: 'client', columnDef: 'client',
header: 'Cliente', header: 'cliente',
cell: (hardware: any) => hardware.client ? { cell: (hardware: any) => hardware.client ? {
name: hardware.client.name || 'N/A', name: hardware.client.name || 'N/A',
ip: hardware.client.ip || 'N/A', ip: hardware.client.ip || 'N/A',
@ -56,7 +59,7 @@ export class HardwareProfileComponent {
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -91,7 +94,7 @@ export class HardwareProfileComponent {
this.length = data['hydra:totalItems']; this.length = data['hydra:totalItems'];
}, },
(error) => { (error) => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
} }
); );
} }
@ -142,10 +145,10 @@ export class HardwareProfileComponent {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('Hardware deleted successfully'); this.toastService.success(this.translate.instant('hardwareDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error deleting hardware'); this.toastService.error(this.translate.instant('errorDeletingHardware'));
} }
}); });
} else { } else {
@ -185,8 +188,8 @@ export class HardwareProfileComponent {
this.openHardwareCollectionModal(hardwareProfile); this.openHardwareCollectionModal(hardwareProfile);
}, },
error: (error) => { error: (error) => {
console.error('Error fetching hardware profile details:', error); console.error(this.translate.instant('errorFetchingHardwareProfileDetails'), error);
this.toastService.error('Error al obtener los detalles del perfil de hardware'); this.toastService.error(this.translate.instant('errorAlObtenerLosDetalles'));
} }
}); });
} }

View File

@ -36,7 +36,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep" <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep"
text="Aquí se mostrará todo el hardware disponible y sus características."> text="Aquí se mostrará todo el hardware disponible y sus características.">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'"> <ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'">
<mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, signal } from '@angular/core'; import { Component, signal } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
@ -15,6 +17,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './hardware-type.component.css' styleUrl: './hardware-type.component.css'
}) })
export class HardwareTypeComponent { export class HardwareTypeComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -30,27 +33,27 @@ export class HardwareTypeComponent {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (hardware: any) => `${hardware.id}`, cell: (hardware: any) => `${hardware.id}`,
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (hardware: any) => hardware.name cell: (hardware: any) => hardware.name
}, },
{ {
columnDef: 'code', columnDef: 'code',
header: 'Código', header: 'codigo',
cell: (hardware: any) => hardware.code cell: (hardware: any) => hardware.code
}, },
{ {
columnDef: 'description', columnDef: 'description',
header: 'Descripción', header: 'descripcion',
cell: (hardware: any) => hardware.description cell: (hardware: any) => hardware.description
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -78,7 +81,7 @@ export class HardwareTypeComponent {
this.length = data['hydra:totalItems']; this.length = data['hydra:totalItems'];
}, },
(error) => { (error) => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
} }
); );
} }
@ -96,10 +99,10 @@ export class HardwareTypeComponent {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('Hardware deleted successfully'); this.toastService.success(this.translate.instant('hardwareDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error deleting hardware'); this.toastService.error(this.translate.instant('errorDeletingHardware'));
} }
}); });
} else { } else {

View File

@ -36,7 +36,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep" <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyride="tableStep"
text="Aquí se mostrará todo el hardware disponible y sus características."> text="Aquí se mostrará todo el hardware disponible y sus características.">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'"> <ng-container *ngIf="column.columnDef === 'isDefault' || column.columnDef === 'installed'">
<mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, signal } from '@angular/core'; import { Component, signal } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
@ -16,6 +18,7 @@ import { CreateHardwareComponent } from './create-hardware/create-hardware.compo
styleUrl: './hardware.component.css' styleUrl: './hardware.component.css'
}) })
export class HardwareComponent { export class HardwareComponent {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -31,22 +34,22 @@ export class HardwareComponent {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (hardware: any) => `${hardware.id}`, cell: (hardware: any) => `${hardware.id}`,
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (hardware: any) => hardware.name cell: (hardware: any) => hardware.name
}, },
{ {
columnDef: 'type', columnDef: 'type',
header: 'Tipo', header: 'tipo',
cell: (hardware: any) => hardware.type?.name || 'N/A' cell: (hardware: any) => hardware.type?.name || 'N/A'
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`, cell: (hardware: any) => `${this.datePipe.transform(hardware.createdAt, 'dd/MM/yyyy hh:mm:ss')}`,
} }
]; ];
@ -74,7 +77,7 @@ export class HardwareComponent {
this.length = data['hydra:totalItems']; this.length = data['hydra:totalItems'];
}, },
(error) => { (error) => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
} }
); );
} }
@ -92,10 +95,10 @@ export class HardwareComponent {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('Hardware deleted successfully'); this.toastService.success(this.translate.instant('hardwareDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error deleting hardware'); this.toastService.error(this.translate.instant('errorDeletingHardware'));
} }
}); });
} else { } else {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./create-image.component.css'] styleUrls: ['./create-image.component.css']
}) })
export class CreateImageComponent implements OnInit { export class CreateImageComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
imageForm: FormGroup<any>; imageForm: FormGroup<any>;
imageId: string | null = null; imageId: string | null = null;
@ -72,7 +75,7 @@ export class CreateImageComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error: (err) => { error: (err) => {
console.error('Error fetching remote calendar:', err); console.error(this.translate.instant('errorFetchingRemoteCalendar'), err);
this.loading = false; this.loading = false;
} }
}); });
@ -89,7 +92,7 @@ export class CreateImageComponent implements OnInit {
this.softwareProfiles = response['hydra:member']; this.softwareProfiles = response['hydra:member'];
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error al obtener los perfiles de software'); this.toastService.error(this.translate.instant('errorAlObtenerLosPerfiles'));
} }
}); });
} }
@ -101,7 +104,7 @@ export class CreateImageComponent implements OnInit {
this.repositories = response['hydra:member']; this.repositories = response['hydra:member'];
}, },
error: (error) => { error: (error) => {
this.toastService.error('Error al obtener los repositorios de imágenes'); this.toastService.error(this.translate.instant('errorAlObtenerLosRepositorios'));
} }
}); });
} }
@ -120,7 +123,7 @@ export class CreateImageComponent implements OnInit {
if (this.imageId) { if (this.imageId) {
this.http.put(`${this.baseUrl}${this.imageId}`, payload).subscribe( this.http.put(`${this.baseUrl}${this.imageId}`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Imagen editada correctamente'); this.toastService.success(this.translate.instant('imagenEditadaCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
@ -130,7 +133,7 @@ export class CreateImageComponent implements OnInit {
} else { } else {
this.http.post(`${this.baseUrl}/images`, payload).subscribe( this.http.post(`${this.baseUrl}/images`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Imagen añadida correctamente'); this.toastService.success(this.translate.instant('imagenAnadidaCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -8,6 +10,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -31,7 +34,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
return throwError(error); return throwError(error);
}) })
); );
@ -47,7 +50,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching user group', error); console.error(this.translate.instant('errorFetchingUserGroup'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './export-image.component.css' styleUrl: './export-image.component.css'
}) })
export class ExportImageComponent implements OnInit { export class ExportImageComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
loading: boolean = true; loading: boolean = true;
repositories: any[] = []; repositories: any[] = [];
@ -48,7 +51,7 @@ export class ExportImageComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error => { error => {
console.error('Error fetching repositories:', error); console.error(this.translate.instant('errorFetchingRepositories1'), error);
this.loading = false; this.loading = false;
} }
); );
@ -60,14 +63,14 @@ export class ExportImageComponent implements OnInit {
repositories: this.selectedRepositories repositories: this.selectedRepositories
}).subscribe({ }).subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Petición de exportación de imagen realizada correctamente'); this.toastService.success(this.translate.instant('peticionDeExportacionDeImagen'));
this.dialogRef.close(); this.dialogRef.close();
this.loading = false; this.loading = false;
this.router.navigate(['/commands-logs']); this.router.navigate(['/commands-logs']);
}, },
error: error => { error: error => {
this.loading = false; this.loading = false;
this.toastService.error('Error en la petición de exportación de imagen'); this.toastService.error(this.translate.instant('errorEnLaPeticionDe'));
} }
}); });
} }

View File

@ -30,7 +30,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="imagesTable" <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="imagesTable"
text="Esta tabla muestra las imágenes disponibles."> text="Esta tabla muestra las imágenes disponibles.">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
<ng-container *ngIf="column.columnDef === 'remotePc'"> <ng-container *ngIf="column.columnDef === 'remotePc'">
<mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="image[column.columnDef] ? 'primary' : 'warn'">

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -13,6 +15,7 @@ import { JoyrideService } from 'ngx-joyride';
styleUrls: ['./images.component.css'] styleUrls: ['./images.component.css']
}) })
export class ImagesComponent implements OnInit { export class ImagesComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -26,32 +29,32 @@ export class ImagesComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'Id', header: 'id1',
cell: (image: any) => `${image.id}` cell: (image: any) => `${image.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre de imagen', header: 'nombreDeImagen',
cell: (image: any) => `${image.name}` cell: (image: any) => `${image.name}`
}, },
{ {
columnDef: 'imageRepositories', columnDef: 'imageRepositories',
header: 'Repositorios', header: 'repositorios',
cell: (image: any) => `${image.imageRepositories}` cell: (image: any) => `${image.imageRepositories}`
}, },
{ {
columnDef: 'remotePc', columnDef: 'remotePc',
header: 'Remote Pc', header: 'remotePc',
cell: (image: any) => `${image.remotePc}` cell: (image: any) => `${image.remotePc}`
}, },
{ {
columnDef: 'isGlobal', columnDef: 'isGlobal',
header: 'Imagen Global', header: 'imagenGlobal',
cell: (image: any) => `${image.isGlobal}` cell: (image: any) => `${image.isGlobal}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (image: any) => `${this.datePipe.transform(image.createdAt, 'dd/MM/yyyy hh:mm:ss')}` cell: (image: any) => `${this.datePipe.transform(image.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
} }
]; ];
@ -85,7 +88,7 @@ export class ImagesComponent implements OnInit {
this.search(); this.search();
}, },
error => { error => {
console.error('Error fetching image repositories', error); console.error(this.translate.instant('errorFetchingImageRepositories'), error);
} }
) )
} }
@ -109,7 +112,7 @@ export class ImagesComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error => { error => {
console.error('Error fetching images', error); console.error(this.translate.instant('errorFetchingImages'), error);
this.loading = false; this.loading = false;
} }
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatDialogRef, MatDialog } from '@angular/material/dialog'; import { MatDialogRef, MatDialog } from '@angular/material/dialog';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
@ -17,6 +19,7 @@ export interface AssetNode {
styleUrls: ['./asset-manager-modal.component.css'] styleUrls: ['./asset-manager-modal.component.css']
}) })
export class AssetManagerModalComponent implements OnInit { export class AssetManagerModalComponent implements OnInit {
public translate = inject(TranslateService);
currentPath: string = ''; currentPath: string = '';
assets: AssetNode[] = []; assets: AssetNode[] = [];
isLoading: boolean = false; isLoading: boolean = false;
@ -43,7 +46,7 @@ export class AssetManagerModalComponent implements OnInit {
}, },
error: (err) => { error: (err) => {
this.isLoading = false; this.isLoading = false;
this.toastService.error('Error al cargar la ruta actual.'); this.toastService.error(this.translate.instant('errorAlCargarLaRuta'));
console.error(err); console.error(err);
// If we failed traversing down, fallback to root // If we failed traversing down, fallback to root
@ -106,7 +109,7 @@ export class AssetManagerModalComponent implements OnInit {
this.isLoading = true; this.isLoading = true;
this.dataService.deleteAsset(path).subscribe({ this.dataService.deleteAsset(path).subscribe({
next: (res) => { next: (res) => {
this.toastService.success('Elemento eliminado correctamente.'); this.toastService.success(this.translate.instant('elementoEliminadoCorrectamente'));
this.loadAssets(); this.loadAssets();
}, },
error: (err) => { error: (err) => {
@ -124,7 +127,7 @@ export class AssetManagerModalComponent implements OnInit {
navigator.clipboard.writeText(fullUrl).then(() => { navigator.clipboard.writeText(fullUrl).then(() => {
this.toastService.info(`Enlace copiado: ${fullUrl}`); this.toastService.info(`Enlace copiado: ${fullUrl}`);
}).catch(err => { }).catch(err => {
console.error('Error al copiar al portapapeles', err); console.error(this.translate.instant('errorAlCopiarAlPortapapeles'), err);
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -13,6 +15,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './create-menu.component.css' styleUrl: './create-menu.component.css'
}) })
export class CreateMenuComponent implements OnInit { export class CreateMenuComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
menuForm: FormGroup<any>; menuForm: FormGroup<any>;
menuId: string | null = null; menuId: string | null = null;
@ -83,7 +86,7 @@ export class CreateMenuComponent implements OnInit {
} }
this.htmlEditorContent = new TextDecoder('utf-8').decode(bytes); this.htmlEditorContent = new TextDecoder('utf-8').decode(bytes);
} catch (e) { } catch (e) {
console.error('Failed to decode previous fileContent Base64', e); console.error(this.translate.instant('failedToDecodePreviousFilecontent'), e);
this.htmlEditorContent = '<!-- Error decodificando HTML anterior -->'; this.htmlEditorContent = '<!-- Error decodificando HTML anterior -->';
} }
this.isEditingHtml = true; this.isEditingHtml = true;
@ -96,7 +99,7 @@ export class CreateMenuComponent implements OnInit {
this.isEditingHtml = true; this.isEditingHtml = true;
}, },
error: (err) => { error: (err) => {
this.toastService.error('No se pudo descargar el HTML/Twig original del menú para editarlo.'); this.toastService.error(this.translate.instant('noSePudoDescargarEl'));
console.error(err); console.error(err);
} }
}); });
@ -125,18 +128,18 @@ export class CreateMenuComponent implements OnInit {
this.isEditingHtml = false; this.isEditingHtml = false;
const dataUrl = `data:text/html;base64,${renderedBase64}`; const dataUrl = `data:text/html;base64,${renderedBase64}`;
this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(dataUrl); this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(dataUrl);
this.toastService.success('Vista previa generada. Pulsa Guardar para aplicar la plantilla remota permanentemente.'); this.toastService.success(this.translate.instant('vistaPreviaGeneradaPulsaGuardar'));
}, },
error: (err) => { error: (err) => {
console.error('Failed to preview generated HTML', err); console.error(this.translate.instant('failedToPreviewGeneratedHtml'), err);
const msg = err.error?.message || 'Error compilando la plantilla Twig.'; const msg = err.error?.message || 'Error compilando la plantilla Twig.';
this.toastService.error(msg); this.toastService.error(msg);
} }
}); });
} catch (e) { } catch (e) {
console.error('Failed to encode updated HTML to Base64', e); console.error(this.translate.instant('failedToEncodeUpdatedHtml'), e);
this.toastService.error('Hubo un problema procesando los caracteres especiales del HTML.'); this.toastService.error(this.translate.instant('huboUnProblemaProcesandoLos'));
} }
} }
} }
@ -166,7 +169,7 @@ export class CreateMenuComponent implements OnInit {
this.updateSafeUrl() this.updateSafeUrl()
}, },
error: (err) => { error: (err) => {
console.error('Error fetching remote calendar:', err); console.error(this.translate.instant('errorFetchingRemoteCalendar'), err);
} }
}); });
} }
@ -187,23 +190,23 @@ export class CreateMenuComponent implements OnInit {
if (this.menuId) { if (this.menuId) {
this.http.put(`${this.baseUrl}${this.menuId}`, payload).subscribe( this.http.put(`${this.baseUrl}${this.menuId}`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Menu editado correctamente'); this.toastService.success(this.translate.instant('menuEditadoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
this.toastService.error(error['error']['hydra:description']); this.toastService.error(error['error']['hydra:description']);
console.error('Error al editar la imagen', error); console.error(this.translate.instant('errorAlEditarLaImagen'), error);
} }
); );
} else { } else {
this.http.post(`${this.baseUrl}/menus`, payload).subscribe( this.http.post(`${this.baseUrl}/menus`, payload).subscribe(
(response) => { (response) => {
this.toastService.success('Menu añadido correctamente'); this.toastService.success(this.translate.instant('menuAnadidoCorrectamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
(error) => { (error) => {
this.toastService.error(error['error']['hydra:description']); this.toastService.error(error['error']['hydra:description']);
console.error('Error al añadir el menu', error); console.error(this.translate.instant('errorAlAnadirElMenu'), error);
} }
); );
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { ConfigService } from '@services/config.service'; import { ConfigService } from '@services/config.service';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
@ -8,6 +10,7 @@ import { catchError, map } from 'rxjs/operators';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -20,7 +23,7 @@ export class DataService {
const url = `${this.baseUrl}/menu-raw/${publicUrl}`; const url = `${this.baseUrl}/menu-raw/${publicUrl}`;
return this.http.get(url, { responseType: 'text' }).pipe( return this.http.get(url, { responseType: 'text' }).pipe(
catchError(error => { catchError(error => {
console.error('Error fetching raw menu template', error); console.error(this.translate.instant('errorFetchingRawMenuTemplate'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -30,7 +33,7 @@ export class DataService {
const url = `${this.baseUrl}/menu-preview`; const url = `${this.baseUrl}/menu-preview`;
return this.http.post(url, { templateBase64: base64Template }, { responseType: 'text' }).pipe( return this.http.post(url, { templateBase64: base64Template }, { responseType: 'text' }).pipe(
catchError(error => { catchError(error => {
console.error('Error previewing menu template', error); console.error(this.translate.instant('errorPreviewingMenuTemplate'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -51,7 +54,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching commands', error); console.error(this.translate.instant('errorFetchingCommands'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -67,7 +70,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching menus', error); console.error(this.translate.instant('errorFetchingMenus'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -77,7 +80,7 @@ export class DataService {
const params = new HttpParams().set('path', path); const params = new HttpParams().set('path', path);
return this.http.get<any[]>(`${this.baseUrl}/ogassets/list`, { params }).pipe( return this.http.get<any[]>(`${this.baseUrl}/ogassets/list`, { params }).pipe(
catchError(error => { catchError(error => {
console.error('Error fetching assets', error); console.error(this.translate.instant('errorFetchingAssets'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -91,7 +94,7 @@ export class DataService {
return this.http.post<any>(`${this.baseUrl}/ogassets/upload`, formData).pipe( return this.http.post<any>(`${this.baseUrl}/ogassets/upload`, formData).pipe(
catchError(error => { catchError(error => {
console.error('Error uploading assets', error); console.error(this.translate.instant('errorUploadingAssets'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );
@ -102,7 +105,7 @@ export class DataService {
body: { path } body: { path }
}).pipe( }).pipe(
catchError(error => { catchError(error => {
console.error('Error deleting asset', error); console.error(this.translate.instant('errorDeletingAsset'), error);
return throwError(() => error); return throwError(() => error);
}) })
); );

View File

@ -25,7 +25,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<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> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let menu"> <td mat-cell *matCellDef="let menu">
<ng-container *ngIf="column.columnDef !== 'isDefault'"> <ng-container *ngIf="column.columnDef !== 'isDefault'">
{{ column.cell(menu) }} {{ column.cell(menu) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from "@angular/material/table"; import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common"; import { DatePipe } from "@angular/common";
@ -17,6 +19,7 @@ import { ConfigService } from '@services/config.service';
styleUrl: './menus.component.css' styleUrl: './menus.component.css'
}) })
export class MenusComponent implements OnInit { export class MenusComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -29,32 +32,32 @@ export class MenusComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'Id', header: 'id1',
cell: (menu: any) => `${menu.id}` cell: (menu: any) => `${menu.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre de menú', header: 'nombreDeMenu',
cell: (menu: any) => `${menu.name}` cell: (menu: any) => `${menu.name}`
}, },
{ {
columnDef: 'publicUrl', columnDef: 'publicUrl',
header: 'Url pública', header: 'urlPublica',
cell: (menu: any) => `${this.baseUrl}/menu/${menu.publicUrl}` cell: (menu: any) => `${this.baseUrl}/menu/${menu.publicUrl}`
}, },
{ {
columnDef: 'isDefault', columnDef: 'isDefault',
header: 'Por defecto', header: 'porDefecto',
cell: (menu: any) => `${menu.isDefault}` cell: (menu: any) => `${menu.isDefault}`
}, },
{ {
columnDef: 'resolution', columnDef: 'resolution',
header: 'Resolución', header: 'resolucion',
cell: (menu: any) => `${menu.resolution}` cell: (menu: any) => `${menu.resolution}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (menu: any) => `${this.datePipe.transform(menu.createdAt, 'dd/MM/yyyy hh:mm:ss')}` cell: (menu: any) => `${this.datePipe.transform(menu.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
} }
]; ];
@ -106,7 +109,7 @@ export class MenusComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error => { error => {
console.error('Error fetching images', error); console.error(this.translate.instant('errorFetchingImages'), error);
this.loading = false; this.loading = false;
} }
); );
@ -129,11 +132,11 @@ export class MenusComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${menu.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${menu.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Menu eliminado con éxito'); this.toastService.success(this.translate.instant('menuEliminadoConExito'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar el menú:', error); console.error(this.translate.instant('errorAlEliminarElMenu'), error);
} }
}); });
} }

View File

@ -35,7 +35,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableDateStep" text="Tabla de Servidores OgBoot"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableDateStep" text="Tabla de Servidores OgBoot">
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let server"> <td mat-cell *matCellDef="let server">
{{ column.cell(server) }} {{ column.cell(server) }}
</td> </td>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, OnInit } from '@angular/core'; import {Component, OnInit } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {DatePipe} from "@angular/common"; import {DatePipe} from "@angular/common";
@ -17,6 +19,7 @@ import { forkJoin } from 'rxjs';
styleUrl: './boot-servers.component.css' styleUrl: './boot-servers.component.css'
}) })
export class BootServersComponent implements OnInit { export class BootServersComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -29,32 +32,32 @@ export class BootServersComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'Id', header: 'id1',
cell: (server: any) => `${server.id}` cell: (server: any) => `${server.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (server: any) => server.name cell: (server: any) => server.name
}, },
{ {
columnDef: 'ip', columnDef: 'ip',
header: 'Ip', header: 'ip',
cell: (server: any) => server.ip cell: (server: any) => server.ip
}, },
{ {
columnDef: 'apiPort', columnDef: 'apiPort',
header: 'Puerto API', header: 'puertoApi',
cell: (server: any) => server.apiPort cell: (server: any) => server.apiPort
}, },
{ {
columnDef: 'pxePort', columnDef: 'pxePort',
header: 'Puerto PXE', header: 'puertoPxe',
cell: (server: any) => server.pxePort cell: (server: any) => server.pxePort
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (server: any) => `${this.datePipe.transform(server.createdAt, 'dd/MM/yyyy hh:mm:ss')}` cell: (server: any) => `${this.datePipe.transform(server.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
} }
]; ];
@ -123,12 +126,12 @@ export class BootServersComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${server.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${server.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor eliminado con éxito'); this.toastService.success(this.translate.instant('servidorEliminadoConExito'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar servidor:', error); console.error(this.translate.instant('errorAlEliminarServidor'), error);
this.toastService.error('Error al eliminar el servidor'); this.toastService.error(this.translate.instant('errorAlEliminarElServidor'));
} }
}); });
} }
@ -159,13 +162,13 @@ export class BootServersComponent implements OnInit {
forkJoin(syncRequests).subscribe({ forkJoin(syncRequests).subscribe({
next: () => { next: () => {
this.toastService.success('Sincronización completada con éxito'); this.toastService.success(this.translate.instant('sincronizacionCompletadaConExito'));
this.loading = false; this.loading = false;
this.search(); this.search();
}, },
error: (error: any) => { error: (error: any) => {
console.error('Error durante la sincronización:', error); console.error(this.translate.instant('errorDuranteLaSincronizacion1'), error);
this.toastService.error('Error durante la sincronización'); this.toastService.error(this.translate.instant('errorDuranteLaSincronizacion'));
this.loading = false; this.loading = false;
} }
}); });

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -11,6 +13,7 @@ import { ConfigService } from "@services/config.service";
styleUrl: './manage-boot-server.component.css' styleUrl: './manage-boot-server.component.css'
}) })
export class ManageBootServerComponent implements OnInit { export class ManageBootServerComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
bootServerForm: FormGroup<any>; bootServerForm: FormGroup<any>;
serverId: string | null = null; serverId: string | null = null;
@ -52,8 +55,8 @@ export class ManageBootServerComponent implements OnInit {
this.serverId = response['@id']; this.serverId = response['@id'];
}, },
error: (err) => { error: (err) => {
console.error('Error fetching boot server:', err); console.error(this.translate.instant('errorFetchingBootServer'), err);
this.toastService.error('Error cargando los datos del servidor'); this.toastService.error(this.translate.instant('errorCargandoLosDatosDel'));
} }
}); });
} }
@ -70,7 +73,7 @@ export class ManageBootServerComponent implements OnInit {
if (this.serverId) { if (this.serverId) {
this.http.put(`${this.baseUrl}${this.serverId}`, payload).subscribe({ this.http.put(`${this.baseUrl}${this.serverId}`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor Boot actualizado correctamente'); this.toastService.success(this.translate.instant('servidorBootActualizadoCorrectamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {
@ -80,7 +83,7 @@ export class ManageBootServerComponent implements OnInit {
} else { } else {
this.http.post(`${this.baseUrl}/boot-servers`, payload).subscribe({ this.http.post(`${this.baseUrl}/boot-servers`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor Boot añadido correctamente'); this.toastService.success(this.translate.instant('servidorBootAnadidoCorrectamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {HttpClient, HttpParams} from '@angular/common/http'; import {HttpClient, HttpParams} from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -8,6 +10,7 @@ import { DataService as TemplateDataService } from './../pxe/data.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string = this.configService.apiUrl; baseUrl: string = this.configService.apiUrl;
private apiUrl = `${this.baseUrl}/pxe-boot-files?page=1&itemsPerPage=1000`; private apiUrl = `${this.baseUrl}/pxe-boot-files?page=1&itemsPerPage=1000`;
@ -28,7 +31,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching images', error); console.error(this.translate.instant('errorFetchingImages'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -16,6 +18,7 @@ import { forkJoin } from 'rxjs';
styleUrls: ['./pxe-boot-files.component.css'] styleUrls: ['./pxe-boot-files.component.css']
}) })
export class PxeBootFilesComponent implements OnInit { export class PxeBootFilesComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
availableOrganizationalUnits: any[] = []; availableOrganizationalUnits: any[] = [];
@ -80,7 +83,7 @@ export class PxeBootFilesComponent implements OnInit {
} }
}, },
error => { error => {
console.error('Error fetching BootServers:', error); console.error(this.translate.instant('errorFetchingBootservers'), error);
} }
); );
} }
@ -96,7 +99,7 @@ export class PxeBootFilesComponent implements OnInit {
response => { response => {
this.units = response['hydra:member']; this.units = response['hydra:member'];
}, },
error => console.error('Error fetching organizational units:', error) error => console.error(this.translate.instant('errorFetchingOrganizationalUnits1'), error)
); );
} }
@ -108,7 +111,7 @@ export class PxeBootFilesComponent implements OnInit {
this.length = response['hydra:totalItems']; this.length = response['hydra:totalItems'];
}, },
error => { error => {
this.toastService.error('Error al cargar las plantillas'); this.toastService.error(this.translate.instant('errorAlCargarLasPlantillas'));
} }
); );
} }
@ -124,7 +127,7 @@ export class PxeBootFilesComponent implements OnInit {
response => { response => {
this.dataSource.data = response['hydra:member']; this.dataSource.data = response['hydra:member'];
}, },
error => console.error('Error fetching child units:', error) error => console.error(this.translate.instant('errorFetchingChildUnits'), error)
); );
} }
@ -149,8 +152,8 @@ export class PxeBootFilesComponent implements OnInit {
const dialogRef = this.dialog.open(DeleteModalComponent, { const dialogRef = this.dialog.open(DeleteModalComponent, {
width: '500px', width: '500px',
data: { data: {
title: 'Confirmar migración de servidores', title : this.translate.instant('confirmarMigracionDeServidores'),
message: 'Se han detectado ordenadores asociados a otro servidor de boot. ¿Desea moverlos al servidor actual? (Si rechaza, solo se actualizarán los ordenadores que ya pertenecen al servidor actual)', message : this.translate.instant('seHanDetectadoOrdenadoresAsociados'),
confirmText: 'Mover y Guardar', confirmText: 'Mover y Guardar',
cancelText: 'Solo de este servidor' cancelText: 'Solo de este servidor'
} }
@ -186,7 +189,7 @@ export class PxeBootFilesComponent implements OnInit {
const templateIds = Object.keys(groupedByTemplate); const templateIds = Object.keys(groupedByTemplate);
if (templateIds.length === 0) { if (templateIds.length === 0) {
this.toastService.info('No hay cambios pendientes de realizar'); this.toastService.info(this.translate.instant('noHayCambiosPendientesDe'));
return; return;
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
@ -10,6 +12,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./create-image.component.css'] styleUrls: ['./create-image.component.css']
}) })
export class CreatePXEImageComponent implements OnInit { export class CreatePXEImageComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
downloads: any[] = []; downloads: any[] = [];
selectedDownload: any; selectedDownload: any;
@ -46,7 +49,7 @@ export class CreatePXEImageComponent implements OnInit {
this.loading = false; this.loading = false;
}, },
error: (error) => { error: (error) => {
console.error('Error fetching downloads:', error); console.error(this.translate.instant('errorFetchingDownloads'), error);
this.loading = false; this.loading = false;
this.toastService.error(error.error['hydra:description'] || 'Error fetching downloads'); this.toastService.error(error.error['hydra:description'] || 'Error fetching downloads');
} }
@ -66,7 +69,7 @@ export class CreatePXEImageComponent implements OnInit {
this.http.patch(`${this.baseUrl}/og-lives/${this.imageId}`, payload) this.http.patch(`${this.baseUrl}/og-lives/${this.imageId}`, payload)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Image updated successfully'); this.toastService.success(this.translate.instant('imageUpdatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {
@ -78,7 +81,7 @@ export class CreatePXEImageComponent implements OnInit {
this.http.post(`${this.baseUrl}/og-lives`, payload) this.http.post(`${this.baseUrl}/og-lives`, payload)
.subscribe({ .subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Image created successfully'); this.toastService.success(this.translate.instant('imageCreatedSuccessfully'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable, throwError } from 'rxjs'; import { Observable, throwError } from 'rxjs';
@ -8,6 +10,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -28,7 +31,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching images', error); console.error(this.translate.instant('errorFetchingImages'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -73,7 +73,7 @@
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef>{{ column.header }}</th> <th mat-header-cell *matHeaderCellDef>{{ column.header | translate }}</th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
@if (column.columnDef === 'isDefault') { @if (column.columnDef === 'isDefault') {
<mat-chip> <mat-chip>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, signal, Input } from '@angular/core'; import { Component, OnInit, signal, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
@ -21,6 +23,7 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./pxe-images.component.css'] styleUrls: ['./pxe-images.component.css']
}) })
export class PXEimagesComponent implements OnInit { export class PXEimagesComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
images: { downloadUrl: string; name: string; uuid: string }[] = []; images: { downloadUrl: string; name: string; uuid: string }[] = [];
@ -41,27 +44,27 @@ export class PXEimagesComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (user: any) => `${user.id}` cell: (user: any) => `${user.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Og Live', header: 'ogLive',
cell: (user: any) => `${user.name}` cell: (user: any) => `${user.name}`
}, },
{ {
columnDef: 'isDefault', columnDef: 'isDefault',
header: 'Imagen por defecto', header: 'imagenPorDefecto',
cell: (user: any) => `${user.isDefault}` cell: (user: any) => `${user.isDefault}`
}, },
{ {
columnDef: 'status', columnDef: 'status',
header: 'Estado', header: 'estado',
cell: (image: any) => `${image.status}` cell: (image: any) => `${image.status}`
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (user: any) => `${this.datePipe.transform(user.createdAt, 'dd/MM/yyyy hh:mm:ss')}` cell: (user: any) => `${this.datePipe.transform(user.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
} }
]; ];
@ -106,7 +109,7 @@ export class PXEimagesComponent implements OnInit {
} }
}, },
error => { error => {
console.error('Error fetching BootServers:', error); console.error(this.translate.instant('errorFetchingBootservers'), error);
} }
); );
} }
@ -145,7 +148,7 @@ export class PXEimagesComponent implements OnInit {
getStatusLabel(status: string): { label: string; class: string } { getStatusLabel(status: string): { label: string; class: string } {
const statusMap: { [key: string]: { label: string; class: string } } = { const statusMap: { [key: string]: { label: string; class: string } } = {
active: { label: 'Instalada', class: 'status-active' }, active: { label: 'Instalada', class: 'status-active' },
inactive: { label: 'Sin instalar', class: 'status-inactive' }, inactive: { label : this.translate.instant('sinInstalar'), class: 'status-inactive' },
pending: { label: 'Instalando...', class: 'status-installing' }, pending: { label: 'Instalando...', class: 'status-installing' },
failed: { label: 'Fallido', class: 'status-failed' } failed: { label: 'Fallido', class: 'status-failed' }
}; };
@ -159,7 +162,7 @@ export class PXEimagesComponent implements OnInit {
case 'set-default': case 'set-default':
this.http.post(`${this.apiUrl}/server/${image.uuid}/set-default`, {}).subscribe({ this.http.post(`${this.apiUrl}/server/${image.uuid}/set-default`, {}).subscribe({
next: () => { next: () => {
this.toastService.success('Petición de cambio de imagen enviada'); this.toastService.success(this.translate.instant('peticionDeCambioDeImagen'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
@ -171,7 +174,7 @@ export class PXEimagesComponent implements OnInit {
case 'install': case 'install':
this.http.post(`${this.apiUrl}/server/${image.uuid}/install`, {}).subscribe({ this.http.post(`${this.apiUrl}/server/${image.uuid}/install`, {}).subscribe({
next: () => { next: () => {
this.toastService.success('Petición de instalación enviada'); this.toastService.success(this.translate.instant('peticionDeInstalacionEnviada'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
@ -183,7 +186,7 @@ export class PXEimagesComponent implements OnInit {
case 'uninstall': case 'uninstall':
this.http.post(`${this.apiUrl}/server/${image.uuid}/uninstall`, {}).subscribe({ this.http.post(`${this.apiUrl}/server/${image.uuid}/uninstall`, {}).subscribe({
next: () => { next: () => {
this.toastService.success('Petición de desinstalación enviada'); this.toastService.success(this.translate.instant('peticionDeDesinstalacionEnviada'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
@ -193,7 +196,7 @@ export class PXEimagesComponent implements OnInit {
}); });
break; break;
default: default:
console.error('Acción no soportada:', action); console.error(this.translate.instant('accionNoSoportada'), action);
break; break;
} }
} }
@ -211,7 +214,7 @@ export class PXEimagesComponent implements OnInit {
this.http.delete(apiUrl).subscribe({ this.http.delete(apiUrl).subscribe({
next: () => { next: () => {
this.search(); this.search();
this.toastService.success('oG Live deleted successfully'); this.toastService.success(this.translate.instant('ogLiveDeletedSuccessfully'));
}, },
error: (error) => { error: (error) => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);
@ -258,7 +261,7 @@ export class PXEimagesComponent implements OnInit {
}, },
error => { error => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);
console.error('Error al cargar la información del alert', error); console.error(this.translate.instant('errorAlCargarLaInformacion'), error);
this.loading = false; this.loading = false;
} }
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http'; import { HttpClient, HttpParams } from '@angular/common/http';
@ -9,6 +11,7 @@ import { ConfigService } from '@services/config.service';
providedIn: 'root' providedIn: 'root'
}) })
export class DataService { export class DataService {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
@ -29,7 +32,7 @@ export class DataService {
} }
}), }),
catchError(error => { catchError(error => {
console.error('Error fetching pxe templates', error); console.error(this.translate.instant('errorFetchingPxeTemplates'), error);
return throwError(error); return throwError(error);
}) })
); );

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./create-pxe-template.component.css'] styleUrls: ['./create-pxe-template.component.css']
}) })
export class CreatePxeTemplateComponent implements OnInit { export class CreatePxeTemplateComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
templateForm!: FormGroup; templateForm!: FormGroup;
previewContent: string = ''; previewContent: string = '';
@ -91,7 +94,7 @@ export class CreatePxeTemplateComponent implements OnInit {
this.clients = data['hydra:member']; this.clients = data['hydra:member'];
}, },
error: error => { error: error => {
console.error('Error al obtener los clientes PXE:', error); console.error(this.translate.instant('errorAlObtenerLosClientes'), error);
} }
}); });
} }
@ -110,7 +113,7 @@ export class CreatePxeTemplateComponent implements OnInit {
this.http.post<any>(`${this.baseUrl}/pxe-templates`, payload).subscribe({ this.http.post<any>(`${this.baseUrl}/pxe-templates`, payload).subscribe({
next: data => { next: data => {
this.toastService.success('Plantilla PXE creada exitosamente'); this.toastService.success(this.translate.instant('plantillaPxeCreadaExitosamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: error => { error: error => {
@ -129,7 +132,7 @@ export class CreatePxeTemplateComponent implements OnInit {
this.http.patch<any>(`${this.baseUrl}/pxe-templates/${this.data.uuid}`, payload).subscribe({ this.http.patch<any>(`${this.baseUrl}/pxe-templates/${this.data.uuid}`, payload).subscribe({
next: data => { next: data => {
this.toastService.success('Plantilla PXE actualizada exitosamente'); this.toastService.success(this.translate.instant('plantillaPxeActualizadaExitosamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: error => { error: error => {

View File

@ -55,7 +55,7 @@
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef>{{ column.header }}</th> <th mat-header-cell *matHeaderCellDef>{{ column.header | translate }}</th>
<td mat-cell *matCellDef="let image"> <td mat-cell *matCellDef="let image">
@if (column.columnDef === 'synchronized') { @if (column.columnDef === 'synchronized') {
<mat-chip> <mat-chip>

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import {Component, OnInit, Input } from '@angular/core'; import {Component, OnInit, Input } from '@angular/core';
import { CreatePxeTemplateComponent } from './manage-pxeTemplate/create-pxe-template.component'; import { CreatePxeTemplateComponent } from './manage-pxeTemplate/create-pxe-template.component';
@ -20,6 +22,7 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./pxe.component.css'] styleUrls: ['./pxe.component.css']
}) })
export class PxeComponent implements OnInit{ export class PxeComponent implements OnInit{
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
pxeTemplates: any[] = []; pxeTemplates: any[] = [];
@ -42,27 +45,27 @@ export class PxeComponent implements OnInit{
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'ID', header: 'id',
cell: (user: any) => `${user.id}` cell: (user: any) => `${user.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre de la plantilla', header: 'nombreDeLaPlantilla',
cell: (user: any) => user.name cell: (user: any) => user.name
}, },
{ {
columnDef: 'synchronized', columnDef: 'synchronized',
header: 'Sincronizado', header: 'sincronizado',
cell: (user: any) => user.synchronized cell: (user: any) => user.synchronized
}, },
{ {
columnDef: 'isDefault', columnDef: 'isDefault',
header: 'Plantilla por defecto', header: 'plantillaPorDefecto',
cell: (user: any) => user.isDefault cell: (user: any) => user.isDefault
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (user: any) => this.datePipe.transform(user.createdAt, 'dd/MM/yyyy hh:mm:ss') cell: (user: any) => this.datePipe.transform(user.createdAt, 'dd/MM/yyyy hh:mm:ss')
} }
]; ];
@ -107,7 +110,7 @@ export class PxeComponent implements OnInit{
} }
}, },
error => { error => {
console.error('Error fetching BootServers:', error); console.error(this.translate.instant('errorFetchingBootservers'), error);
} }
); );
} }
@ -166,7 +169,7 @@ export class PxeComponent implements OnInit{
if (result) { if (result) {
this.http.post<any>(`${this.apiUrl}/server/${image.uuid}/delete`, {}).subscribe({ this.http.post<any>(`${this.apiUrl}/server/${image.uuid}/delete`, {}).subscribe({
next: (response) => { next: (response) => {
this.toastService.success('Plantilla eliminada exitosamente'); this.toastService.success(this.translate.instant('plantillaEliminadaExitosamente'));
if (response && response.warning) { if (response && response.warning) {
this.toastService.info(response.warning, 'Información', { timeOut: 8000 }); this.toastService.info(response.warning, 'Información', { timeOut: 8000 });
} }
@ -180,7 +183,7 @@ export class PxeComponent implements OnInit{
}) })
break; break;
default: default:
console.error('Acción no soportada:', action); console.error(this.translate.instant('accionNoSoportada'), action);
break; break;
} }
} }
@ -211,7 +214,7 @@ export class PxeComponent implements OnInit{
}, },
error => { error => {
this.toastService.error(error.error['hydra:description']); this.toastService.error(error.error['hydra:description']);
console.error('Error al cargar la información del alert', error); console.error(this.translate.instant('errorAlCargarLaInformacion'), error);
} }
); );
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, OnInit, Inject } from '@angular/core'; import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog'; import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
@ -12,6 +14,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./add-clients-to-subnet.component.css'] styleUrls: ['./add-clients-to-subnet.component.css']
}) })
export class AddClientsToSubnetComponent implements OnInit { export class AddClientsToSubnetComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
units: any[] = []; units: any[] = [];
clients: any[] = []; clients: any[] = [];
@ -43,7 +46,7 @@ export class AddClientsToSubnetComponent implements OnInit {
this.units = response['hydra:member']; this.units = response['hydra:member'];
this.loading = false; this.loading = false;
}, },
error => console.error('Error fetching organizational units:', error) error => console.error(this.translate.instant('errorFetchingOrganizationalUnits1'), error)
); );
} }
@ -52,7 +55,7 @@ export class AddClientsToSubnetComponent implements OnInit {
response => { response => {
this.clients = response['hydra:member']; this.clients = response['hydra:member'];
}, },
error => console.error('Error fetching child units:', error) error => console.error(this.translate.instant('errorFetchingChildUnits'), error)
); );
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
@ -11,6 +13,7 @@ import { ConfigService } from '@services/config.service';
styleUrls: ['./create-subnet.component.css'] styleUrls: ['./create-subnet.component.css']
}) })
export class CreateSubnetComponent implements OnInit { export class CreateSubnetComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
subnetForm: FormGroup; subnetForm: FormGroup;
isEditMode: boolean = false; isEditMode: boolean = false;
@ -63,7 +66,7 @@ export class CreateSubnetComponent implements OnInit {
save(): void { save(): void {
if (this.subnetForm.invalid) { if (this.subnetForm.invalid) {
this.toastService.error('Por favor, revisa los campos del formulario'); this.toastService.error(this.translate.instant('porFavorRevisaLosCampos'));
return; return;
} }
@ -76,7 +79,7 @@ export class CreateSubnetComponent implements OnInit {
if (!this.isEditMode) { if (!this.isEditMode) {
this.http.post(`${this.baseUrl}/subnets`, payload).subscribe({ this.http.post(`${this.baseUrl}/subnets`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Configuración de red añadida exitosamente'); this.toastService.success(this.translate.instant('configuracionDeRedAnadidaExitosamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
error: (error) => { error: (error) => {
@ -86,7 +89,7 @@ export class CreateSubnetComponent implements OnInit {
} else { } else {
this.http.patch(`${this.baseUrl}/subnets/${this.subnetId}`, payload).subscribe({ this.http.patch(`${this.baseUrl}/subnets/${this.subnetId}`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Configuración de red actualizada exitosamente'); this.toastService.success(this.translate.instant('configuracionDeRedActualizadaExitosamente'));
this.dialogRef.close(); this.dialogRef.close();
}, },
error: (error) => { error: (error) => {

View File

@ -35,7 +35,7 @@
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableDateStep" text="Tabla de Servidores DHCP"> <table mat-table [dataSource]="dataSource" class="mat-elevation-z8" joyrideStep="tableDateStep" text="Tabla de Servidores DHCP">
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let server"> <td mat-cell *matCellDef="let server">
@if (column.columnDef !== 'subnets') { @if (column.columnDef !== 'subnets') {
{{ column.cell(server) }} {{ column.cell(server) }}

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import {Component, OnInit } from '@angular/core'; import {Component, OnInit } from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {DatePipe} from "@angular/common"; import {DatePipe} from "@angular/common";
@ -16,6 +18,7 @@ import {ManageDhcpServerComponent} from "../manage-dhcp-server/manage-dhcp-serve
styleUrl: './dhcp-servers.component.css' styleUrl: './dhcp-servers.component.css'
}) })
export class DhcpServersComponent implements OnInit { export class DhcpServersComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
private apiUrl: string; private apiUrl: string;
dataSource = new MatTableDataSource<any>(); dataSource = new MatTableDataSource<any>();
@ -28,32 +31,32 @@ export class DhcpServersComponent implements OnInit {
columns = [ columns = [
{ {
columnDef: 'id', columnDef: 'id',
header: 'Id', header: 'id1',
cell: (server: any) => `${server.id}` cell: (server: any) => `${server.id}`
}, },
{ {
columnDef: 'name', columnDef: 'name',
header: 'Nombre', header: 'nombre',
cell: (server: any) => server.name cell: (server: any) => server.name
}, },
{ {
columnDef: 'ip', columnDef: 'ip',
header: 'Ip', header: 'ip',
cell: (server: any) => server.ip cell: (server: any) => server.ip
}, },
{ {
columnDef: 'apiPort', columnDef: 'apiPort',
header: 'Puerto API', header: 'puertoApi',
cell: (server: any) => server.apiPort cell: (server: any) => server.apiPort
}, },
{ {
columnDef: 'subnets', columnDef: 'subnets',
header: 'Subredes', header: 'subredes',
cell: (server: any) => server.subnets cell: (server: any) => server.subnets
}, },
{ {
columnDef: 'createdAt', columnDef: 'createdAt',
header: 'Fecha de creación', header: 'fechaDeCreacion',
cell: (server: any) => `${this.datePipe.transform(server.createdAt, 'dd/MM/yyyy hh:mm:ss')}` cell: (server: any) => `${this.datePipe.transform(server.createdAt, 'dd/MM/yyyy hh:mm:ss')}`
} }
]; ];
@ -122,12 +125,12 @@ export class DhcpServersComponent implements OnInit {
if (result) { if (result) {
this.http.delete(`${this.apiUrl}/${server.uuid}`).subscribe({ this.http.delete(`${this.apiUrl}/${server.uuid}`).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor eliminado con éxito'); this.toastService.success(this.translate.instant('servidorEliminadoConExito'));
this.search(); this.search();
}, },
error: (error) => { error: (error) => {
console.error('Error al eliminar servidor:', error); console.error(this.translate.instant('errorAlEliminarServidor'), error);
this.toastService.error('Error al eliminar el servidor'); this.toastService.error(this.translate.instant('errorAlEliminarElServidor'));
} }
}); });
} }

View File

@ -1,3 +1,5 @@
import { inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Component, Inject, OnInit } from '@angular/core'; import { Component, Inject, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { HttpClient } from "@angular/common/http"; import { HttpClient } from "@angular/common/http";
@ -11,6 +13,7 @@ import { ConfigService } from "@services/config.service";
styleUrl: './manage-dhcp-server.component.css' styleUrl: './manage-dhcp-server.component.css'
}) })
export class ManageDhcpServerComponent implements OnInit { export class ManageDhcpServerComponent implements OnInit {
public translate = inject(TranslateService);
baseUrl: string; baseUrl: string;
dhcpServerForm: FormGroup<any>; dhcpServerForm: FormGroup<any>;
serverId: string | null = null; serverId: string | null = null;
@ -51,8 +54,8 @@ export class ManageDhcpServerComponent implements OnInit {
this.serverId = response['@id']; this.serverId = response['@id'];
}, },
error: (err) => { error: (err) => {
console.error('Error fetching dhcp server:', err); console.error(this.translate.instant('errorFetchingDhcpServer'), err);
this.toastService.error('Error cargando los datos'); this.toastService.error(this.translate.instant('errorCargandoLosDatos'));
} }
}); });
} }
@ -68,7 +71,7 @@ export class ManageDhcpServerComponent implements OnInit {
if (this.serverId) { if (this.serverId) {
this.http.put(`${this.baseUrl}${this.serverId}`, payload).subscribe({ this.http.put(`${this.baseUrl}${this.serverId}`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor DHCP actualizado correctamente'); this.toastService.success(this.translate.instant('servidorDhcpActualizadoCorrectamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {
@ -78,7 +81,7 @@ export class ManageDhcpServerComponent implements OnInit {
} else { } else {
this.http.post(`${this.baseUrl}/dhcp-servers`, payload).subscribe({ this.http.post(`${this.baseUrl}/dhcp-servers`, payload).subscribe({
next: () => { next: () => {
this.toastService.success('Servidor DHCP añadido correctamente'); this.toastService.success(this.translate.instant('servidorDhcpAnadidoCorrectamente'));
this.dialogRef.close(true); this.dialogRef.close(true);
}, },
error: (error) => { error: (error) => {

View File

@ -48,7 +48,7 @@
text="Visualiza y administra las subredes listadas según los filtros aplicados."> text="Visualiza y administra las subredes listadas según los filtros aplicados.">
@for (column of columns; track column.columnDef) { @for (column of columns; track column.columnDef) {
<ng-container [matColumnDef]="column.columnDef"> <ng-container [matColumnDef]="column.columnDef">
<th mat-header-cell *matHeaderCellDef> {{ column.header }} </th> <th mat-header-cell *matHeaderCellDef> {{ column.header | translate }} </th>
<td mat-cell *matCellDef="let subnet"> <td mat-cell *matCellDef="let subnet">
@if (column.columnDef === 'synchronized') { @if (column.columnDef === 'synchronized') {
<mat-icon [color]="subnet[column.columnDef] ? 'primary' : 'warn'"> <mat-icon [color]="subnet[column.columnDef] ? 'primary' : 'warn'">

Some files were not shown because too many files have changed in this diff Show More