diff --git a/src/app/agents/agent.module.ts b/src/app/agents/agent.module.ts
index 1403d50f..1e026feb 100644
--- a/src/app/agents/agent.module.ts
+++ b/src/app/agents/agent.module.ts
@@ -14,13 +14,15 @@ import { DirectivesModule } from "../shared/directives.module";
import { ComponentsModule } from "../shared/components.module";
import { AgentsRoutingModule } from "./agents-routing.module";
import { PipesModule } from "../shared/pipes.module";
+import { BenchmarkComponent } from './benchmarks/benchmarks.component';
@NgModule({
declarations:[
AgentStatusComponent,
ShowAgentsComponent,
EditAgentComponent,
- NewAgentComponent
+ NewAgentComponent,
+ BenchmarkComponent
],
imports:[
ReactiveFormsModule,
diff --git a/src/app/agents/agents-routing.module.ts b/src/app/agents/agents-routing.module.ts
index fae553e7..cf1a90d9 100644
--- a/src/app/agents/agents-routing.module.ts
+++ b/src/app/agents/agents-routing.module.ts
@@ -5,6 +5,7 @@ import { Routes, RouterModule } from '@angular/router';
import { AgentStatusComponent } from "./agent-status/agent-status.component";
import { PendingChangesGuard } from "../core/_guards/pendingchanges.guard";
import { ShowAgentsComponent } from "./show-agents/show-agents.component";
+import { BenchmarkComponent } from "./benchmarks/benchmarks.component"
import { EditAgentComponent } from "./edit-agent/edit-agent.component";
import { NewAgentComponent } from "./new-agent/new-agent.component";
import { AgentGuard } from "../core/_guards/agent.guard";
@@ -41,6 +42,13 @@ const routes: Routes = [
breadcrumb: 'Edit Agent'
},
canActivate: [AuthGuard,AgentGuard]},
+ {
+ path: 'benchmarks', component: BenchmarkComponent,
+ data: {
+ kind: 'edit-agent',
+ breadcrumb: 'Edit Agent'
+ },
+ canActivate: [AuthGuard,AgentGuard]},
]
},
];
diff --git a/src/app/agents/benchmarks/benchmarks.component.html b/src/app/agents/benchmarks/benchmarks.component.html
new file mode 100644
index 00000000..2484db09
--- /dev/null
+++ b/src/app/agents/benchmarks/benchmarks.component.html
@@ -0,0 +1,48 @@
+
+
+
Benchmarks
+
Section to view and manage cached benchmarks.
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/agents/benchmarks/benchmarks.component.spec.ts b/src/app/agents/benchmarks/benchmarks.component.spec.ts
new file mode 100644
index 00000000..e69de29b
diff --git a/src/app/agents/benchmarks/benchmarks.component.ts b/src/app/agents/benchmarks/benchmarks.component.ts
new file mode 100644
index 00000000..f8ab010f
--- /dev/null
+++ b/src/app/agents/benchmarks/benchmarks.component.ts
@@ -0,0 +1,238 @@
+import { faRefresh, faPauseCircle, faEdit, faTrash, faLock, faFileImport, faFileExport, faPlus, faHomeAlt, faArchive, faCopy, faBookmark, faEye } from '@fortawesome/free-solid-svg-icons';
+import { Component, Inject, OnInit, ViewChild } from '@angular/core';
+import { environment } from './../../../environments/environment';
+import { ActivatedRoute, Router } from '@angular/router';
+import { DataTableDirective } from 'angular-datatables';
+import Swal from 'sweetalert2/dist/sweetalert2.js';
+import { interval, Subject, Subscription } from 'rxjs';
+import { UIConfigService } from 'src/app/core/_services/shared/storage.service';
+
+
+import { CookieService } from 'src/app/core/_services/shared/cookies.service';
+import { ChunkService } from 'src/app/core/_services/tasks/chunks.service';
+import { UsersService } from 'src/app/core/_services/users/users.service';
+import { TasksService } from '../../core/_services/tasks/tasks.sevice';
+
+import { BenchmarkService } from 'src/app/core/_services/agents/benchmark.service';
+
+@Component({
+ selector: 'app-benchmark',
+ templateUrl: './benchmarks.component.html'
+ })
+
+ export class BenchmarkComponent implements OnInit {
+ faPauseCircle=faPauseCircle;
+ faFileImport=faFileImport;
+ faFileExport=faFileExport;
+ faBookmark=faBookmark;
+ faArchive=faArchive;
+ faRefresh=faRefresh;
+ faHome=faHomeAlt;
+ faTrash=faTrash;
+ faEdit=faEdit;
+ faLock=faLock;
+ faPlus=faPlus;
+ faCopy=faCopy;
+ faEye=faEye;
+
+ storedAutorefresh: any =[]
+
+ @ViewChild(DataTableDirective)
+ dtElement: DataTableDirective;
+
+ dtTrigger: Subject = new Subject();
+ dtOptions: any = {};
+
+ benchmarks: any = []; //Change to Interface
+
+ uidateformat:any;
+
+ isChecked:boolean =false;
+ private maxResults = environment.config.prodApiMaxResults
+
+ constructor(
+ private benchmarkService: BenchmarkService,
+ private route: ActivatedRoute,
+ private users: UsersService,
+ private uiService: UIConfigService,
+ ) { }
+
+ ngOnInit(): void {
+
+ this.getBenchmarks();
+ this.setAccessPermissions();
+
+ this.uidateformat = this.uiService.getUIsettings('timefmt').value;
+
+ this.dtOptions = {
+ dom: 'Bfrtip',
+ scrollY: true,
+ bDestroy: true,
+ columnDefs: [
+ {
+ targets: 0,
+ className: 'noVis'
+ }
+ ],
+ order: [[0, 'desc']],
+ bStateSave:true,
+ select: {
+ style: 'multi',
+ },
+ buttons: {
+ dom: {
+ button: {
+ className: 'dt-button buttons-collection btn btn-sm-dt btn-outline-gray-600-dt',
+ }
+ },
+ buttons: [
+ {
+ extend: 'collection',
+ text: 'Export',
+ buttons: [
+ {
+ extend: 'excelHtml5',
+ exportOptions: {
+ columns: [0, 1, 2, 3, 4]
+ },
+ },
+ {
+ extend: 'print',
+ exportOptions: {
+ columns: [0, 1, 2, 3, 4]
+ },
+ customize: function ( win ) {
+ $(win.document.body)
+ .css( 'font-size', '10pt' )
+ $(win.document.body).find( 'table' )
+ .addClass( 'compact' )
+ .css( 'font-size', 'inherit' );
+ }
+ },
+ {
+ extend: 'csvHtml5',
+ exportOptions: {modifier: {selected: true}},
+ select: true,
+ customize: function (dt, csv) {
+ var data = "";
+ for (var i = 0; i < dt.length; i++) {
+ data = "Benchmark\n\n"+ dt;
+ }
+ return data;
+ }
+ },
+ 'copy'
+ ]
+ },
+ {
+ extend: 'colvis',
+ text: 'Column View',
+ columns: [ 1,2,3,4,5,6 ],
+ },
+ {
+ extend: "pageLength",
+ className: "btn-sm"
+ },
+ ],
+ }
+ }
+ }
+
+ rerender(): void {
+ this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
+ // Destroy the table first
+ dtInstance.destroy();
+ // Call the dtTrigger to rerender again
+ setTimeout(() => {
+ this.dtTrigger['new'].next();
+ });
+ });
+ }
+
+ getBenchmarks():void {
+ let params = {'maxResults': this.maxResults, 'expand': 'crackerBinary,hardwareGroup'}
+ this.benchmarks = [];
+
+ this.benchmarkService.getAllbenchmarks(params).subscribe((benchmarks: any) => {
+ this.benchmarks = benchmarks.values;
+ this.dtTrigger.next(void 0);
+ });
+ }
+
+ setCheckAll(){
+ let chkBoxlength = $(".checkboxCls:checked").length;
+ if (this.isChecked == true) {
+ $(".checkboxCls").prop("checked", false);
+ this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
+ dtInstance.rows( ).deselect();
+ this.isChecked = false;
+ });
+ } else {
+ $(".checkboxCls").prop("checked", true);
+ this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
+ dtInstance.rows( ).select();
+ this.isChecked = true;
+ });
+ }
+ }
+
+ // Set permissions
+ manageBenchmarkAccess: any;
+
+ setAccessPermissions(){
+ this.users.getUser(this.users.userId,{'expand':'globalPermissionGroup'}).subscribe((perm: any) => {
+ this.manageBenchmarkAccess = perm.globalPermissionGroup.permissions.manageTaskAccess;
+ });
+ }
+
+ onDelete(id: number){
+ if(this.manageBenchmarkAccess || typeof this.manageBenchmarkAccess == 'undefined'){
+ const swalWithBootstrapButtons = Swal.mixin({
+ customClass: {
+ confirmButton: 'btn btn-success',
+ cancelButton: 'btn btn-danger'
+ },
+ buttonsStyling: false
+ })
+ Swal.fire({
+ title: "Are you sure?",
+ text: "Once deleted, it can not be recovered!",
+ icon: "warning",
+ showCancelButton: true,
+ confirmButtonColor: '#4B5563',
+ cancelButtonColor: '#d33',
+ confirmButtonText: 'Yes, delete it!'
+ })
+ .then((result) => {
+ if (result.isConfirmed) {
+ this.benchmarkService.deleteBenchmark(id).subscribe(() => {
+ Swal.fire(
+ "Benchmark has been deleted!",
+ {
+ icon: "success",
+ showConfirmButton: false,
+ timer: 1500
+ });
+ this.ngOnInit();
+ this.rerender(); // rerender datatables
+ });
+ } else {
+ swalWithBootstrapButtons.fire(
+ 'Cancelled',
+ 'No worries, your Task is safe!',
+ 'error'
+ )
+ }
+ });
+ }else{
+ Swal.fire({
+ title: "ACTION DENIED",
+ text: "Please contact your Administrator.",
+ icon: "error",
+ showConfirmButton: false,
+ timer: 2000
+ })
+ }
+ }
+
+ }
diff --git a/src/app/agents/edit-agent/edit-agent.component.html b/src/app/agents/edit-agent/edit-agent.component.html
index 8b51f5a4..a5d46e5b 100644
--- a/src/app/agents/edit-agent/edit-agent.component.html
+++ b/src/app/agents/edit-agent/edit-agent.component.html
@@ -252,7 +252,7 @@ Agent Detailed Information
- {{ showagent['devices'] }}
+ {{ showagent['hardwareGroup']['devices'] }}
|
diff --git a/src/app/agents/show-agents/show-agents.component.html b/src/app/agents/show-agents/show-agents.component.html
index 3eef7179..32de6814 100644
--- a/src/app/agents/show-agents/show-agents.component.html
+++ b/src/app/agents/show-agents/show-agents.component.html
@@ -45,7 +45,7 @@ Show Agents
notes
- {{ agent.devices }} |
+ {{ agent.hardwareGroup.devices }} |
{{ agent.cpuOnly == true ? "Yes" : "No" }} |
{{ agent.lastAct }} at
diff --git a/src/app/agents/show-agents/show-agents.component.ts b/src/app/agents/show-agents/show-agents.component.ts
index ac150b0f..021dca06 100644
--- a/src/app/agents/show-agents/show-agents.component.ts
+++ b/src/app/agents/show-agents/show-agents.component.ts
@@ -55,7 +55,7 @@ export class ShowAgentsComponent implements OnInit, OnDestroy {
this.setAccessPermissions();
- let params = {'maxResults': this.maxResults}
+ let params = {'maxResults': this.maxResults, 'expand': 'hardwareGroup'}
this.agentsService.getAgents(params).subscribe((agents: any) => {
this.showagents = agents.values;
diff --git a/src/app/core/_models/benchmark.ts b/src/app/core/_models/benchmark.ts
new file mode 100644
index 00000000..3ffdc899
--- /dev/null
+++ b/src/app/core/_models/benchmark.ts
@@ -0,0 +1,10 @@
+export interface IBenchmark {
+ benchmarkId: number;
+ benchmarkValue: string;
+ hardwareGroupId: number;
+ crackerBinaryId: number;
+ attackParameters: string;
+ ttl: number;
+ hashMode: number;
+ benchmarkType: string;
+}
\ No newline at end of file
diff --git a/src/app/core/_services/agents/agents.service.ts b/src/app/core/_services/agents/agents.service.ts
index f231b244..a7579b7a 100644
--- a/src/app/core/_services/agents/agents.service.ts
+++ b/src/app/core/_services/agents/agents.service.ts
@@ -36,7 +36,7 @@ export class AgentsService {
* @returns Object
**/
getAgent(id: number):Observable {
- return this.http.get(`${this.endpoint}/${id}`)
+ return this.http.get(`${this.endpoint}/${id}?expand=hardwareGroup`)
}
/**
diff --git a/src/app/core/_services/agents/benchmark.service.ts b/src/app/core/_services/agents/benchmark.service.ts
new file mode 100644
index 00000000..6e913953
--- /dev/null
+++ b/src/app/core/_services/agents/benchmark.service.ts
@@ -0,0 +1,40 @@
+import { environment } from './../../../../environments/environment';
+import { HttpClient } from '@angular/common/http';
+import { setParameter } from '../buildparams';
+import { Injectable } from '@angular/core';
+import { Params } from '@angular/router';
+import { Observable, tap } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class BenchmarkService {
+
+ private endpoint = environment.config.prodApiEndpoint + '/ui/benchmarks';
+
+ constructor(private http: HttpClient) { }
+
+/**
+ * Returns all the benchmarks
+ * @param routerParams - to include multiple options such as Max number of results or filtering
+ * @returns Object
+**/
+ getAllbenchmarks(routerParams?: Params):Observable {
+ let queryParams: Params = {};
+ if (routerParams) {
+ queryParams = setParameter(routerParams);
+ }
+ return this.http.get(this.endpoint, {params: queryParams})
+ }
+
+
+/**
+ * Deletes a benchmark
+ * @param id - task id
+ * @returns Object
+**/
+ deleteBenchmark(id:number):Observable {
+ return this.http.delete(this.endpoint +'/'+ id);
+ }
+
+}
\ No newline at end of file
diff --git a/src/app/layout/header/header.component.html b/src/app/layout/header/header.component.html
index 361a3208..e245207e 100644
--- a/src/app/layout/header/header.component.html
+++ b/src/app/layout/header/header.component.html
@@ -44,6 +44,7 @@
|