Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand All @@ -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';

Expand Down Expand Up @@ -60,6 +59,8 @@ export class TasksAgentsTableComponent extends BaseTableComponent implements OnI
}
}

@Output() assignedAgentsChanged = new EventEmitter<void>();

tableColumns: HTTableColumn[] = [];
dataSource: AgentsDataSource;
selectedFilterColumn: string = 'all';
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -527,13 +528,15 @@ 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 {
this.subscriptions.push(
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
})
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/core/_datasources/agents.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export class AgentsDataSource extends BaseDataSource<JAgent> {

this.setPaginationConfig(this.pageSize, length, after, before, this.index);
this.setData(agents);
} else {
const agents: JAgent[] = [];
this.setData(agents);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/tasks/edit-tasks/edit-tasks.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ <h4 style="margin-top: 0;">Description</h4>
</button>
</mat-form-field>
</form>
<tasks-agents-table #agentsTable name="assignedAgentsTable" datatype="agents-assign" [taskId]="editedTaskIndex"
[assignAgents]="true"></tasks-agents-table>
<tasks-agents-table #assignedAgentsTable name="assignedAgentsTable" datatype="agents-assign" [taskId]="editedTaskIndex"
[assignAgents]="true" (assignedAgentsChanged)="refresh()"></tasks-agents-table>
</app-table>
<!-- Task speed -->
<app-table>
Expand Down
10 changes: 9 additions & 1 deletion src/app/tasks/edit-tasks/edit-tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 }),
Expand Down