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,17 +1,17 @@
import { Observable, catchError, of } from 'rxjs';

Check failure on line 1 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`

import { AfterViewInit, Component, Input, OnDestroy, OnInit } from '@angular/core';

Check failure on line 3 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { SafeHtml } from '@angular/platform-browser';

Check failure on line 4 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`

import { ChunkData } from '@models/chunk.model';

Check failure on line 6 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { JHashlist } from '@models/hashlist.model';

Check failure on line 7 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { JTask, JTaskWrapper, TaskType } from '@models/task.model';

Check failure on line 8 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`

import { TaskContextMenuService } from '@services/context-menu/tasks/task-menu.service';

Check failure on line 10 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { SERV } from '@services/main.config';

Check failure on line 11 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`

import { ActionMenuEvent } from '@components/menus/action-menu/action-menu.model';

Check failure on line 13 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { BulkActionMenuAction } from '@components/menus/bulk-action-menu/bulk-action-menu.constants';

Check failure on line 14 in src/app/core/_components/tables/tasks-table/tasks-table.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Delete `;`
import { RowActionMenuAction } from '@components/menus/row-action-menu/row-action-menu.constants';
import { BaseTableComponent } from '@components/tables/base-table/base-table.component';
import {
Expand Down Expand Up @@ -128,11 +128,10 @@
{
id: TaskTableCol.STATUS,
dataKey: 'keyspaceProgress',
render: (wrapper: JTaskWrapper) => this.renderSpeed(wrapper),
icon: (wrapper: JTaskWrapper) => this.renderStatusIcons(wrapper),
isSortable: false,
export: async (wrapper: JTaskWrapper) => {
const status = this.getTaskStatus(wrapper);
const status = wrapper.tasks[0]?.status;
switch (status) {
case TaskStatus.RUNNING:
return 'Running';
Expand Down Expand Up @@ -183,16 +182,21 @@
{
id: TaskTableCol.AGENTS,
dataKey: 'agents',
render: (wrapper: JTaskWrapper) => this.renderAgents(wrapper),
isSortable: false,
export: async (wrapper: JTaskWrapper) => this.getNumAgents(wrapper) + ''
render: (wrapper: JTaskWrapper) => {
if (wrapper.taskType === TaskType.TASK) {
return wrapper.tasks[0]?.activeAgents + ''
} else {
return '';
}
},
export: async (wrapper: JTaskWrapper) => (wrapper.tasks[0]?.activeAgents ?? 0) + ''
},
{
id: TaskTableCol.ACCESS_GROUP,
dataKey: 'accessGroupName',
routerLink: (wrapper: JTaskWrapper) => this.renderAccessGroupLink(wrapper.accessGroup),
isSortable: false,

export: async (wrapper: JTaskWrapper) => wrapper.accessGroup.groupName
},
{
Expand Down Expand Up @@ -492,26 +496,6 @@
return this.sanitize(html);
}

getNumAgents(wrapper: JTaskWrapper): number {
return wrapper.taskType === TaskType.TASK && wrapper.chunkData ? wrapper.chunkData.agents.length : 0;
}

renderAgents(wrapper: JTaskWrapper): SafeHtml {
const numAgents = this.getNumAgents(wrapper);
return this.sanitize(`${numAgents}`);
}

renderSpeed(wrapper: JTaskWrapper): SafeHtml {
let html = '';
if (wrapper.taskType === TaskType.TASK) {
const chunkData: ChunkData = wrapper.chunkData;
if (chunkData && 'speed' in chunkData && chunkData.speed > 0) {
html = `${convertCrackingSpeed(chunkData.speed)}`;
}
}
return this.sanitize(html);
}

editableSaved(editable: HTTableEditable<JTaskWrapper>): void {
switch (editable.action) {
case TaskTableEditableAction.CHANGE_PRIORITY:
Expand Down
30 changes: 2 additions & 28 deletions src/app/core/_datasources/tasks.datasource.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { catchError, of } from 'rxjs';
import { finalize } from 'rxjs/operators';

import { JChunk } from '@models/chunk.model';
import { Filter, FilterType } from '@models/request-params.model';
import { ResponseWrapper } from '@models/response.model';
import { JTask, JTaskWrapper } from '@models/task.model';
import { JTaskWrapper } from '@models/task.model';

import { SERV } from '@services/main.config';
import { RequestParamBuilder } from '@services/params/builder-implementation.service';
Expand Down Expand Up @@ -75,32 +74,7 @@ export class TasksDataSource extends BaseDataSource<JTaskWrapper> {
const before = prevLink ? new URL(response.links.prev).searchParams.get('page[before]') : null;

this.setPaginationConfig(this.pageSize, length, after, before, this.index);
if (taskWrappers.length > 0) {
const chunkParams = new RequestParamBuilder().addFilter({
field: 'taskId',
operator: FilterType.IN,
value: taskWrappers.filter((x) => x?.tasks[0] != null).map((wrapper) => wrapper.tasks[0].id)
});
this.subscriptions.push(
this.service
.getAll(SERV.CHUNKS, chunkParams.create())
.pipe(finalize(() => this.setData(taskWrappers)))
.subscribe((chunkResponse: ResponseWrapper) => {
const chunks = this.serializer.deserialize<JChunk[]>({
data: chunkResponse.data,
included: chunkResponse.included
});
taskWrappers.forEach((taskWrapper) => {
const task: JTask = taskWrapper.tasks[0];
if (task != null) {
taskWrapper.chunkData = this.convertChunks(task.id, chunks, false, task.keyspace);
}
});
})
);
} else {
this.setData(taskWrappers);
}
this.setData(taskWrappers);
})
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/_models/task.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum TaskType {
export interface JTask extends BaseModel {
taskName: string;
attackCmd: string;
activeAgents: number;
chunkTime: number;
statusTimer: number;
keyspace: number;
Expand Down Expand Up @@ -52,6 +53,7 @@ export interface JTask extends BaseModel {
searched: string;
speeds: SpeedStat[];
chunkData?: ChunkData;
status: number;
}

/**
Expand Down