<<<<<<< Updated upstream
Acciones |
-
+ |
=======
diff --git a/ogWebconsole/src/app/components/commands/commands-groups/commands-groups.component.ts b/ogWebconsole/src/app/components/commands/commands-groups/commands-groups.component.ts
index b0437ab..233780b 100644
--- a/ogWebconsole/src/app/components/commands/commands-groups/commands-groups.component.ts
+++ b/ogWebconsole/src/app/components/commands/commands-groups/commands-groups.component.ts
@@ -7,6 +7,7 @@ import { DetailCommandGroupComponent } from './detail-command-group/detail-comma
import { DeleteModalComponent } from '../../../shared/delete_modal/delete-modal/delete-modal.component';
import { MatTableDataSource } from "@angular/material/table";
import { DatePipe } from "@angular/common";
+import { JoyrideService } from 'ngx-joyride';
@Component({
selector: 'app-commands-groups',
@@ -48,7 +49,8 @@ export class CommandsGroupsComponent implements OnInit {
displayedColumns = [...this.columns.map(column => column.columnDef), 'actions'];
private apiUrl = `${this.baseUrl}/command-groups`;
- constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService) {}
+ constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService,
+ private joyrideService: JoyrideService) {}
ngOnInit(): void {
this.search();
@@ -114,4 +116,21 @@ export class CommandsGroupsComponent implements OnInit {
this.length = event.length;
this.search();
}
+
+ iniciarTour(): void {
+ this.joyrideService.startTour({
+ steps: [
+ 'titleStep',
+ 'addCommandGroupStep',
+ 'searchStep',
+ 'tableStep',
+ 'viewCommandsStep',
+ 'actionsStep',
+ 'paginationStep'
+ ],
+ showPrevButton: true,
+ themeColor: '#3f51b5'
+ });
+ }
+
}
diff --git a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.css b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.css
index a5fe09a..1f69044 100644
--- a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.css
+++ b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.css
@@ -1,8 +1,8 @@
.create-command-group-container {
padding: 20px;
- max-width: 800px; /* Ancho máximo del contenedor */
- margin: auto; /* Centra el contenedor en la pantalla */
- background-color: #fff; /* Fondo blanco para el contenedor */
+ max-width: 800px;
+ margin: auto;
+ background-color: #fff;
}
.form-container {
@@ -24,14 +24,14 @@
width: 48%;
display: flex;
flex-direction: column;
- max-height: 200px; /* Limita la altura máxima para evitar desbordamiento */
+ max-height: 200px;
}
.table-wrapper {
flex: 1;
- overflow-y: auto; /* Scroll para la tabla si hay demasiados comandos */
- border: 1px solid #ccc; /* Borde para la tabla */
- border-radius: 4px; /* Bordes redondeados */
+ overflow-y: auto;
+ border: 1px solid #ccc;
+ border-radius: 4px;
}
.selected-commands-list {
@@ -40,7 +40,7 @@
padding: 10px;
background-color: #f9f9f9;
flex: 1;
- overflow-y: auto; /* Scroll para los comandos seleccionados */
+ overflow-y: auto;
}
.commands-container {
@@ -60,7 +60,7 @@
.remove-icon {
cursor: pointer;
- color: #f44336; /* Rojo para eliminar */
+ color: #f44336;
}
.chevron-icon {
@@ -74,29 +74,27 @@
justify-content: space-between;
}
-
.available-commands, .selected-commands {
width: 48%;
display: flex;
flex-direction: column;
- max-height: 500px; /* Limita la altura máxima para evitar desbordamiento */
+ max-height: 500px;
}
.table-wrapper {
flex: 1;
- overflow-y: auto; /* Scroll para la tabla si hay demasiados comandos */
- border: 1px solid #ccc; /* Borde para la tabla */
- border-radius: 4px; /* Bordes redondeados */
- max-height: 400px; /* Establece la altura máxima */
+ overflow-y: auto;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ max-height: 400px;
}
-/* Para asegurar que el componente sea responsivo en pantallas pequeñas */
@media (max-width: 600px) {
.command-selection {
- flex-direction: column; /* Cambia a columna en pantallas pequeñas */
+ flex-direction: column;
}
.available-commands, .selected-commands {
- width: 100%; /* Ocupa el ancho completo */
- margin-bottom: 20px; /* Espacio entre elementos */
+ width: 100%;
+ margin-bottom: 20px;
}
}
diff --git a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html
index 2b75e99..e5b8a8f 100644
--- a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html
+++ b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html
@@ -46,15 +46,13 @@
>>>>>>> Stashed changes
-
+
+ drag_indicator
{{ command.name }}
close
-
- chevron_right
-
-
+
diff --git a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.ts b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.ts
index 0a50702..048bf5a 100644
--- a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.ts
+++ b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ToastrService } from 'ngx-toastr';
+import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
@Component({
selector: 'app-create-command-group',
@@ -55,7 +56,9 @@ export class CreateCommandGroupComponent implements OnInit {
}
addCommand(command: any): void {
- this.selectedCommands.push(command);
+ if (!this.selectedCommands.includes(command)) {
+ this.selectedCommands.push(command);
+ }
}
removeCommand(command: any): void {
@@ -65,6 +68,10 @@ export class CreateCommandGroupComponent implements OnInit {
}
}
+ drop(event: CdkDragDrop): void {
+ moveItemInArray(this.selectedCommands, event.previousIndex, event.currentIndex);
+ }
+
onSubmit(): void {
const payload = {
name: this.groupName,
@@ -81,6 +88,7 @@ export class CreateCommandGroupComponent implements OnInit {
},
error: (error) => {
console.error('Error actualizando el grupo de comandos', error);
+ this.toastService.error('Error al actualizar el grupo de comandos');
}
});
} else {
@@ -91,6 +99,7 @@ export class CreateCommandGroupComponent implements OnInit {
},
error: (error) => {
console.error('Error creando el grupo de comandos', error);
+ this.toastService.error('Error al crear el grupo de comandos');
}
});
}
diff --git a/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.html b/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.html
index 379a165..aa263eb 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.html
+++ b/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.html
@@ -31,10 +31,6 @@
-
-
-
-
<<<<<<< Updated upstream
@@ -69,7 +65,7 @@
<<<<<<< Updated upstream
Acciones |
-
+ |
=======
diff --git a/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.ts b/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.ts
index 0e9312b..ae7904e 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.ts
+++ b/ogWebconsole/src/app/components/commands/commands-task/commands-task.component.ts
@@ -5,6 +5,7 @@ import { ToastrService } from 'ngx-toastr';
import { CreateTaskComponent } from './create-task/create-task.component';
import { DetailTaskComponent } from './detail-task/detail-task.component';
import { DeleteModalComponent } from '../../../shared/delete_modal/delete-modal/delete-modal.component';
+import { JoyrideService } from 'ngx-joyride';
@Component({
selector: 'app-commands-task',
@@ -23,7 +24,8 @@ export class CommandsTaskComponent implements OnInit {
loading: boolean = false;
private apiUrl = `${this.baseUrl}/command-tasks`;
- constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService) {}
+ constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService,
+ private joyrideService: JoyrideService) {}
ngOnInit(): void {
this.loadTasks();
@@ -93,4 +95,20 @@ export class CommandsTaskComponent implements OnInit {
this.itemsPerPage = event.pageSize;
this.loadTasks();
}
+
+ iniciarTour(): void {
+ this.joyrideService.startTour({
+ steps: [
+ 'titleStep',
+ 'addTaskStep',
+ 'searchStep',
+ 'tableStep',
+ 'actionsStep',
+ 'paginationStep'
+ ],
+ showPrevButton: true,
+ themeColor: '#3f51b5'
+ });
+ }
+
}
diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css
index d5dad12..3c41e87 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css
+++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.css
@@ -12,10 +12,16 @@
.button-container {
display: flex;
- justify-content: space-between;
+ justify-content: flex-end;
margin-top: 20px;
}
mat-form-field {
- margin-bottom: 16px; /* Espaciado entre campos */
+ margin-bottom: 16px;
+}
+
+.section-title {
+ margin-top: 24px;
+ margin-bottom: 8px;
+ font-weight: 500;
}
diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html
index 6a7bc70..a65d937 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html
+++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.html
@@ -2,13 +2,13 @@
diff --git a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts
index 4b06e85..8a90f7e 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts
+++ b/ogWebconsole/src/app/components/commands/commands-task/create-task/create-task.component.ts
@@ -49,8 +49,6 @@ export class CreateTaskComponent implements OnInit {
this.editing = true;
this.loadTaskData(this.data.task);
}
-
- console.log(this.data);
}
loadCommandGroups(): void {
@@ -101,6 +99,76 @@ export class CreateTaskComponent implements OnInit {
}
}
+ private collectClassrooms(unit: any): any[] {
+ let classrooms = [];
+ if (unit.type === 'classroom') {
+ classrooms.push(unit);
+ }
+ if (unit.children && unit.children.length > 0) {
+ for (let child of unit.children) {
+ classrooms = classrooms.concat(this.collectClassrooms(child));
+ }
+ }
+ return classrooms;
+ }
+
+ onOrganizationalUnitChange(): void {
+ const selectedUnitId = this.taskForm.get('organizationalUnit')?.value;
+ const selectedUnit = this.availableOrganizationalUnits.find(unit => unit['@id'] === selectedUnitId);
+
+ if (selectedUnit) {
+ this.selectedUnitChildren = this.collectClassrooms(selectedUnit);
+ } else {
+ this.selectedUnitChildren = [];
+ }
+
+ this.taskForm.patchValue({ selectedChild: '', selectedClients: [] });
+ this.selectedClients = [];
+ this.selectedClientIds.clear();
+ }
+
+ onChildChange(): void {
+ const selectedChildId = this.taskForm.get('selectedChild')?.value;
+
+ if (!selectedChildId) {
+ this.selectedClients = [];
+ return;
+ }
+
+ const url = `${this.baseUrl}${selectedChildId}`.replace(/([^:]\/)\/+/g, '$1');
+
+ this.http.get(url).subscribe(
+ (data) => {
+ if (Array.isArray(data.clients) && data.clients.length > 0) {
+ this.selectedClients = data.clients;
+ } else {
+ this.selectedClients = [];
+ this.toastr.warning('El aula seleccionada no tiene clientes.');
+ }
+
+ this.taskForm.patchValue({ selectedClients: [] });
+ this.selectedClientIds.clear();
+ },
+ (error) => {
+ this.toastr.error('Error al cargar los detalles del aula seleccionada');
+ }
+ );
+ }
+
+ toggleSelectAll() {
+ const allSelected = this.areAllSelected();
+ if (allSelected) {
+ this.selectedClientIds.clear();
+ } else {
+ this.selectedClients.forEach(client => this.selectedClientIds.add(client.uuid));
+ }
+ this.taskForm.get('selectedClients')!.setValue(Array.from(this.selectedClientIds));
+ }
+
+ areAllSelected(): boolean {
+ return this.selectedClients.length > 0 && this.selectedClients.every(client => this.selectedClientIds.has(client.uuid));
+ }
+
onCommandGroupChange(): void {
const selectedGroupId = this.taskForm.get('commandGroup')?.value;
this.http.get(`${this.baseUrl}/command-groups/${selectedGroupId}`).subscribe(
@@ -113,40 +181,6 @@ export class CreateTaskComponent implements OnInit {
);
}
- onOrganizationalUnitChange(): void {
- const selectedUnitId = this.taskForm.get('organizationalUnit')?.value;
- const selectedUnit = this.availableOrganizationalUnits.find(unit => unit['@id'] === selectedUnitId);
- this.selectedUnitChildren = selectedUnit ? selectedUnit.children : [];
- }
-
- onChildChange(): void {
- const selectedChildId = this.taskForm.get('selectedChild')?.value;
- this.http.get(`${this.baseUrl}${selectedChildId}`).subscribe(
- (data) => {
- this.selectedClients = data.clients;
- this.taskForm.patchValue({ selectedClients: [] });
- this.selectedClientIds.clear();
- },
- (error) => {
- this.toastr.error('Error al cargar los detalles del aula seleccionada');
- }
- );
- }
-
- toggleSelectAll() {
- const allSelected = this.areAllSelected();
- if (allSelected) {
- this.selectedClientIds.clear();
- } else {
- this.selectedClients.forEach(client => this.selectedClientIds.add(client.uuid));
- }
- this.taskForm.get('selectedClients')!.setValue(Array.from(this.selectedClientIds));
- }
-
- areAllSelected(): boolean {
- return this.selectedClients.length > 0 && this.selectedClients.every(client => this.selectedClientIds.has(client.uuid));
- }
-
saveTask(): void {
if (this.taskForm.invalid) {
this.toastr.error('Por favor, rellene todos los campos obligatorios');
@@ -156,14 +190,14 @@ export class CreateTaskComponent implements OnInit {
const formData = this.taskForm.value;
const dateTime = this.combineDateAndTime(formData.date, formData.time);
const selectedCommands = formData.extraCommands && formData.extraCommands.length > 0
- ? formData.extraCommands.map((id: any) => `/commands/${id}`)
- : null;
+ ? formData.extraCommands.map((id: any) => `/commands/${id}`)
+ : null;
const payload: any = {
commandGroups: formData.commandGroup ? [`/command-groups/${formData.commandGroup}`] : null,
dateTime: dateTime,
notes: formData.notes || '',
- clients: Array.from(this.selectedClientIds).map((uuid: string) => `/clients/${uuid}`),
+ clients: Array.from(this.selectedClientIds).map((uuid: string) => `/clients/${uuid}`),
};
if (selectedCommands) {
diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html
index 5a05c3b..a72035a 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html
+++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html
@@ -15,6 +15,7 @@
>>>>>>> Stashed changes
+
@@ -47,12 +48,10 @@
-
-
<<<<<<< Updated upstream
diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts
index 1ea67e0..a272055 100644
--- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts
+++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts
@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { FormControl } from '@angular/forms';
import { map, startWith } from 'rxjs/operators';
import { DatePipe } from '@angular/common';
+import { JoyrideService } from 'ngx-joyride';
@Component({
selector: 'app-task-logs',
@@ -63,7 +64,8 @@ export class TaskLogsComponent implements OnInit {
filteredCommands!: Observable;
commandControl = new FormControl();
- constructor(private http: HttpClient) {}
+ constructor(private http: HttpClient,
+ private joyrideService: JoyrideService) {}
ngOnInit(): void {
this.loadTraces();
@@ -183,4 +185,20 @@ export class TaskLogsComponent implements OnInit {
this.length = event.length;
this.loadTraces();
}
+
+ iniciarTour(): void {
+ this.joyrideService.startTour({
+ steps: [
+ 'titleStep',
+ 'resetFiltersStep',
+ 'clientSelectStep',
+ 'commandSelectStep',
+ 'tableStep',
+ 'paginationStep'
+ ],
+ showPrevButton: true,
+ themeColor: '#3f51b5'
+ });
+ }
+
}
diff --git a/ogWebconsole/src/app/components/commands/main-commands/commands.component.html b/ogWebconsole/src/app/components/commands/main-commands/commands.component.html
index 0d541bf..bee4673 100644
--- a/ogWebconsole/src/app/components/commands/main-commands/commands.component.html
+++ b/ogWebconsole/src/app/components/commands/main-commands/commands.component.html
@@ -13,6 +13,7 @@
>>>>>>> Stashed changes
+
<<<<<<< Updated upstream
diff --git a/ogWebconsole/src/app/components/commands/main-commands/commands.component.ts b/ogWebconsole/src/app/components/commands/main-commands/commands.component.ts
index 2a3f283..903b606 100644
--- a/ogWebconsole/src/app/components/commands/main-commands/commands.component.ts
+++ b/ogWebconsole/src/app/components/commands/main-commands/commands.component.ts
@@ -7,6 +7,8 @@ import { CreateCommandComponent } from './create-command/create-command.componen
import { DeleteModalComponent } from '../../../shared/delete_modal/delete-modal/delete-modal.component';
import { MatTableDataSource } from '@angular/material/table';
import { DatePipe } from '@angular/common';
+import { ExecuteCommandComponent } from './execute-command/execute-command.component';
+import { JoyrideService } from 'ngx-joyride';
@Component({
selector: 'app-commands',
@@ -48,7 +50,8 @@ export class CommandsComponent implements OnInit {
displayedColumns = [...this.columns.map(column => column.columnDef), 'actions'];
private apiUrl = `${this.baseUrl}/commands`;
- constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService) {}
+ constructor(private http: HttpClient, private dialog: MatDialog, private toastService: ToastrService,
+ private joyrideService: JoyrideService) {}
ngOnInit(): void {
this.search();
@@ -74,7 +77,7 @@ export class CommandsComponent implements OnInit {
this.dialog.open(CommandDetailComponent, {
width: '800px',
data: command,
- }).afterClosed().subscribe(() => this.search());
+ });
}
openCreateCommandModal(): void {
@@ -111,10 +114,38 @@ export class CommandsComponent implements OnInit {
});
}
+ executeCommand(event: MouseEvent, command: any): void {
+ this.dialog.open(ExecuteCommandComponent, {
+ width: '50%',
+ data: { commandData: command }
+ }).afterClosed().subscribe((result) => {
+ if (result) {
+ console.log('Comando ejecutado con éxito');
+ } else {
+ console.log('Ejecución de comando cancelada');
+ }
+ });
+ }
+
onPageChange(event: any): void {
this.page = event.pageIndex;
this.itemsPerPage = event.pageSize;
this.length = event.length;
this.search();
}
+
+ iniciarTour(): void {
+ this.joyrideService.startTour({
+ steps: [
+ 'titleStep',
+ 'addCommandStep',
+ 'searchStep',
+ 'tableStep',
+ 'actionsStep'
+ ],
+ showPrevButton: true,
+ themeColor: '#3f51b5'
+ });
+ }
+
}
diff --git a/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.html b/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.html
index 1214208..2609549 100644
--- a/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.html
+++ b/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.html
@@ -28,11 +28,4 @@
-
-
-
-
-
diff --git a/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.ts b/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.ts
index 0e9690e..7df79bf 100644
--- a/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.ts
+++ b/ogWebconsole/src/app/components/commands/main-commands/detail-command/command-detail.component.ts
@@ -38,54 +38,12 @@ export class CommandDetailComponent implements OnInit {
this.http.get(`${this.baseUrl}/clients?page=1&itemsPerPage=30`).subscribe(response => {
this.clients = response['hydra:member'];
});
-
- }
-
- execute(): void {
- if (!this.showClientSelect) {
- this.showClientSelect = true;
- } else {
- if (this.form.get('selectedClients')?.value.length > 0) {
-
- const payload = {
- clients: this.form.value.selectedClients.map((uuid: any) => `/clients/${uuid}`)
- };
-
- const apiUrl = `${this.baseUrl}/commands/${this.data.uuid}/execute`;
- this.http.post(apiUrl, payload).subscribe({
- next: () => {
- this.dialogRef.close();
- this.toastService.success('Command executed successfully');
- },
- error: (error) => {
- console.error('Error executing command:', error);
- }
- });
-
- this.dialogRef.close();
- } else {
- this.form.get('selectedClients')?.markAsTouched();
- }
- }
}
onClientSelectionChange(event: any): void {
this.canExecute = this.form.get('selectedClients')?.value.length > 0;
}
- onScheduleChange(event: any): void {
- this.showDatePicker = event.checked;
- if (event.checked) {
- this.form.get('scheduleDate')?.setValidators(Validators.required);
- this.form.get('scheduleTime')?.setValidators(Validators.required);
- } else {
- this.form.get('scheduleDate')?.clearValidators();
- this.form.get('scheduleTime')?.clearValidators();
- }
- this.form.get('scheduleDate')?.updateValueAndValidity();
- this.form.get('scheduleTime')?.updateValueAndValidity();
- }
-
edit(): void {
const dialogRef = this.dialog.open(CreateCommandComponent, {
width: '600px',
diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.css b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.css
new file mode 100644
index 0000000..1527804
--- /dev/null
+++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.css
@@ -0,0 +1,32 @@
+.form-container {
+ padding: 20px 24px;
+ width: 100%; /* Asegura que el formulario ocupe el ancho completo */
+ }
+
+ .command-form {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ }
+
+ .full-width {
+ width: 100%;
+ margin-bottom: 16px;
+ }
+
+ .checkbox-group {
+ display: flex;
+ flex-direction: column;
+ margin: 15px 0;
+ align-items: flex-start;
+ }
+
+ .mat-dialog-content {
+ padding: 24px;
+ width: 100%; /* Ocupar el ancho completo del modal */
+ }
+
+ .mat-dialog-actions {
+ padding: 16px 24px;
+ }
+
\ No newline at end of file
diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.spec.ts b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.spec.ts
new file mode 100644
index 0000000..e951b90
--- /dev/null
+++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ExecuteCommandComponent } from './execute-command.component';
+
+describe('ExecuteCommandComponent', () => {
+ let component: ExecuteCommandComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ExecuteCommandComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(ExecuteCommandComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts
new file mode 100644
index 0000000..ceeaf2c
--- /dev/null
+++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts
@@ -0,0 +1,100 @@
+import { Component, Inject, OnInit } from '@angular/core';
+import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
+import { HttpClient } from '@angular/common/http';
+import { FormBuilder, FormGroup } from '@angular/forms';
+
+@Component({
+ selector: 'app-execute-command',
+ templateUrl: './execute-command.component.html',
+ styleUrls: ['./execute-command.component.css']
+})
+export class ExecuteCommandComponent implements OnInit {
+ form: FormGroup;
+ units: any[] = [];
+ childUnits: any[] = [];
+ clients: any[] = [];
+ selectedClients: any[] = [];
+ baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
+
+ constructor(
+ private dialogRef: MatDialogRef,
+ @Inject(MAT_DIALOG_DATA) public data: any,
+ private http: HttpClient,
+ private fb: FormBuilder
+ ) {
+ this.form = this.fb.group({
+ unit: [null],
+ childUnit: [null],
+ clientSelection: [[]]
+ });
+ }
+
+ ngOnInit(): void {
+ this.loadUnits();
+ this.form.get('unit')?.valueChanges.subscribe(value => this.onUnitChange(value));
+ this.form.get('childUnit')?.valueChanges.subscribe(value => this.onChildUnitChange(value));
+ }
+
+ loadUnits(): void {
+ this.http.get(`${this.baseUrl}/organizational-units?page=1&itemsPerPage=30`).subscribe(
+ response => {
+ this.units = response['hydra:member'].filter((unit: { type: string; }) => unit.type === 'organizational-unit');
+ },
+ error => console.error('Error fetching organizational units:', error)
+ );
+ }
+
+ onUnitChange(unitId: string): void {
+ const unit = this.units.find(unit => unit.uuid === unitId);
+ this.childUnits = unit ? this.getAllChildren(unit) : [];
+ this.clients = [];
+ this.form.patchValue({ childUnit: null, clientSelection: [] });
+ }
+
+ getAllChildren(unit: any): any[] {
+ let allChildren = [];
+ if (unit.children && unit.children.length > 0) {
+ for (const child of unit.children) {
+ allChildren.push(child);
+ allChildren = allChildren.concat(this.getAllChildren(child));
+ }
+ }
+ return allChildren;
+ }
+
+ onChildUnitChange(childUnitId: string): void {
+ const childUnit = this.childUnits.find(unit => unit.uuid === childUnitId);
+ this.clients = childUnit && childUnit.clients ? childUnit.clients : [];
+ this.form.patchValue({ clientSelection: [] });
+ }
+
+ executeCommand(): void {
+ const payload = {
+ clients: ['/clients/'+this.form.get('clientSelection')?.value]
+ };
+
+ this.http.post(`${this.baseUrl}/commands/${this.data.commandData.uuid}/execute`, payload)
+ .subscribe({
+ next: () => {
+ console.log('Comando ejecutado con éxito');
+ this.dialogRef.close(true);
+ },
+ error: (error) => {
+ console.error('Error al ejecutar el comando:', error);
+ }
+ });
+ }
+
+ closeModal(): void {
+ this.dialogRef.close(false);
+ }
+
+ toggleClientSelection(clientId: string): void {
+ const selectedClients = this.form.get('clientSelection')?.value;
+ if (selectedClients.includes(clientId)) {
+ this.form.get('clientSelection')?.setValue(selectedClients.filter((id: string) => id !== clientId));
+ } else {
+ this.form.get('clientSelection')?.setValue([...selectedClients, clientId]);
+ }
+ }
+}
diff --git a/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.css b/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.css
index eec44f6..b7adc08 100644
--- a/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.css
+++ b/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.css
@@ -21,7 +21,11 @@
}
.header-container {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
height: 100px;
+ padding: 10px;
}
.unidad-card, .elements-card {
@@ -124,11 +128,6 @@ mat-spinner {
align-self: center;
}
-.container {
- display: flex;
- justify-content: flex-end;
-}
-
.classroomBtn-container {
display: flex;
justify-content: flex-end;
@@ -174,62 +173,61 @@ mat-spinner {
width: 100%;
}
-.results-container {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: 16px;
- margin-bottom: 16px;
-}
-
.result-card {
width: 100%;
max-width: 250px;
- height: 250px;
+ height: auto;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
padding: 15px;
- margin: 10px 0;
+ margin: 10px 10px;
+}
+
+.result-card.small-card {
+ width: 100%;
+ max-width: 180px;
+ height: auto;
+ min-height: 130px;
+ padding: 10px;
+ margin: 5px;
+ border-radius: 8px;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+}
+
+.result-title {
+ font-size: 1rem;
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 5px;
+}
+
+.result-content {
+ padding-top: 5px;
+ color: #555;
+ font-size: 0.85rem;
+}
+
+.result-type, .result-ip, .result-mac, .result-status, .result-internal-units, .result-clients {
+ font-size: 0.8rem;
+ margin: 2px 0;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.result-checkbox {
+ align-self: flex-start;
+ margin: 0 0 5px 0;
}
.result-card:hover {
transform: translateY(-2px);
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
-}
-
-.result-checkbox {
- float: right;
- margin: 0;
-}
-
-.result-title {
- font-size: 1.2rem;
- font-weight: 600;
- color: #333;
-}
-
-.result-content {
- padding-top: 10px;
- color: #555;
-}
-
-.result-type {
- font-size: 1rem;
- font-weight: 500;
- margin: 0;
-}
-
-.result-ip, .result-mac, .result-status {
- font-size: 0.9rem;
- margin: 5px 0;
-}
-
-.result-internal-units,
-.result-clients {
- font-size: 0.9rem;
- color: #007bff;
- margin: 5px 0;
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.paginator-container {
@@ -251,13 +249,13 @@ mat-card {
}
.red-card {
- background-color: #f35f53;
+ background-color: #f35f53;
color: white;
}
.green-card {
- background-color: #4caf50;
- color: white;
+ background-color: #4caf50;
+ color: white;
}
.view-mode-buttons button.active {
@@ -265,16 +263,12 @@ mat-card {
color: #3f51b5;
}
-.result-card {
- width: 100%;
-}
-
.result-card-list {
display: flex;
flex-direction: row;
align-items: center;
padding: 5px;
- margin-bottom: 4px;
+ margin-bottom: 2px;
border: 1px solid #ddd;
}
@@ -283,7 +277,7 @@ mat-card {
}
.result-card-list .result-title {
- font-size: 14px;
+ font-size: 14px;
font-weight: bold;
margin-right: 8px;
}
@@ -292,11 +286,11 @@ mat-card {
display: flex;
flex-direction: row;
gap: 8px;
- font-size: 12px;
+ font-size: 12px;
}
.result-card-list p {
- margin: 0;
+ margin: 0;
}
.result-list {
diff --git a/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.html b/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.html
index e558cea..8f61a32 100644
--- a/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.html
+++ b/ogWebconsole/src/app/components/groups/components/advanced-search/advanced-search.component.html
@@ -10,7 +10,7 @@
>>>>>>> Stashed changes
- | |