From 35e3dfe351cc756d593e535c5878be03f8297660 Mon Sep 17 00:00:00 2001 From: gpascal123 Date: Wed, 1 Oct 2025 15:43:15 +0200 Subject: [PATCH] Assigned agents are now displayed in the table. If an agent becomes unassigned, it is removed from the table and becomes available again in the selection box. --- .../tasks-agents-table.component.ts | 19 +++++++++++-------- .../core/_datasources/agents.datasource.ts | 3 +++ .../edit-tasks/edit-tasks.component.html | 4 ++-- .../tasks/edit-tasks/edit-tasks.component.ts | 10 +++++++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/app/core/_components/tables/tasks-agents-table/tasks-agents-table.component.ts b/src/app/core/_components/tables/tasks-agents-table/tasks-agents-table.component.ts index d40212a9..f35becf6 100644 --- a/src/app/core/_components/tables/tasks-agents-table/tasks-agents-table.component.ts +++ b/src/app/core/_components/tables/tasks-agents-table/tasks-agents-table.component.ts @@ -1,7 +1,6 @@ - import { Observable, catchError, of } from 'rxjs'; -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { SafeHtml } from '@angular/platform-browser'; import { JAgent } from '@models/agent.model'; @@ -12,11 +11,6 @@ import { SERV } from '@services/main.config'; import { ActionMenuEvent } from '@components/menus/action-menu/action-menu.model'; import { BulkActionMenuAction } from '@components/menus/bulk-action-menu/bulk-action-menu.constants'; import { RowActionMenuAction } from '@components/menus/row-action-menu/row-action-menu.constants'; -import { - AgentTableEditableAction, - TasksAgentsTableCol, - TasksAgentsTableColumnLabel -} from '@components/tables/tasks-agents-table/tasks-agents-table.constants'; import { BaseTableComponent } from '@components/tables/base-table/base-table.component'; import { DataType, @@ -27,6 +21,11 @@ import { } from '@components/tables/ht-table/ht-table.models'; import { TableDialogComponent } from '@components/tables/table-dialog/table-dialog.component'; import { DialogData } from '@components/tables/table-dialog/table-dialog.model'; +import { + AgentTableEditableAction, + TasksAgentsTableCol, + TasksAgentsTableColumnLabel +} from '@components/tables/tasks-agents-table/tasks-agents-table.constants'; import { AgentsDataSource } from '@datasources/agents.datasource'; @@ -60,6 +59,8 @@ export class TasksAgentsTableComponent extends BaseTableComponent implements OnI } } + @Output() assignedAgentsChanged = new EventEmitter(); + tableColumns: HTTableColumn[] = []; dataSource: AgentsDataSource; selectedFilterColumn: string = 'all'; @@ -204,7 +205,7 @@ export class TasksAgentsTableComponent extends BaseTableComponent implements OnI render: (agent: JAgent) => this.renderCracked(agent), isSortable: true, export: async (agent: JAgent) => this.renderCracked(agent) + '' - }, + }, { id: TasksAgentsTableCol.BENCHMARK, dataKey: 'benchmark', @@ -527,6 +528,7 @@ export class TasksAgentsTableComponent extends BaseTableComponent implements OnI this.gs.delete(SERV.AGENT_ASSIGN, agent[0].assignmentId).subscribe(() => { this.alertService.showSuccessMessage('Successfully unassigned agent!'); this.dataSource.reload(); + this.assignedAgentsChanged.emit(); // Signals change that the Agents ComboBox is being updated }) ); } else { @@ -534,6 +536,7 @@ export class TasksAgentsTableComponent extends BaseTableComponent implements OnI this.gs.delete(SERV.AGENTS, agent[0].id).subscribe(() => { this.alertService.showSuccessMessage('Successfully deleted agent!'); this.dataSource.reload(); + this.assignedAgentsChanged.emit(); // Signals change that the Agents ComboBox is being updated }) ); } diff --git a/src/app/core/_datasources/agents.datasource.ts b/src/app/core/_datasources/agents.datasource.ts index d448e164..4fe81b47 100644 --- a/src/app/core/_datasources/agents.datasource.ts +++ b/src/app/core/_datasources/agents.datasource.ts @@ -175,6 +175,9 @@ export class AgentsDataSource extends BaseDataSource { this.setPaginationConfig(this.pageSize, length, after, before, this.index); this.setData(agents); + } else { + const agents: JAgent[] = []; + this.setData(agents); } }); } diff --git a/src/app/tasks/edit-tasks/edit-tasks.component.html b/src/app/tasks/edit-tasks/edit-tasks.component.html index ee768100..c35d4f81 100644 --- a/src/app/tasks/edit-tasks/edit-tasks.component.html +++ b/src/app/tasks/edit-tasks/edit-tasks.component.html @@ -163,8 +163,8 @@

Description

- + diff --git a/src/app/tasks/edit-tasks/edit-tasks.component.ts b/src/app/tasks/edit-tasks/edit-tasks.component.ts index 8daf8c75..a53ae066 100644 --- a/src/app/tasks/edit-tasks/edit-tasks.component.ts +++ b/src/app/tasks/edit-tasks/edit-tasks.component.ts @@ -55,7 +55,7 @@ export class EditTasksComponent implements OnInit, OnDestroy { crackerinfo: JCrackerBinary; tkeyspace: number; - @ViewChild('tasksAgentsTable') agentsTable: TasksAgentsTableComponent; + @ViewChild('assignedAgentsTable') agentsTable: TasksAgentsTableComponent; @ViewChild('slideToggle', { static: false }) slideToggle: MatSlideToggle; @ViewChild(TasksChunksTableComponent) chunkTable!: TasksChunksTableComponent; @@ -107,6 +107,14 @@ export class EditTasksComponent implements OnInit, OnDestroy { }); } + /** + * Reload data + */ + refresh(): void { + this.onInitialize(); + this.agentsTable.reload(); + } + buildForm() { this.updateForm = new FormGroup({ taskId: new FormControl({ value: '', disabled: true }),