1
+ import { LineChart , LineSeriesOption } from 'echarts/charts' ;
1
2
import {
2
3
DataZoomComponent ,
3
4
DataZoomComponentOption ,
@@ -14,76 +15,78 @@ import {
14
15
VisualMapComponent ,
15
16
VisualMapComponentOption
16
17
} from 'echarts/components' ;
17
- import { Component , OnInit , ViewChild } from '@angular/core' ;
18
- import { ActivatedRoute , Params , Router } from '@angular/router' ;
19
- import { LineChart , LineSeriesOption } from 'echarts/charts' ;
20
- import { FormControl , FormGroup } from '@angular/forms' ;
18
+ import * as echarts from 'echarts/core' ;
21
19
import { UniversalTransition } from 'echarts/features' ;
22
20
import { CanvasRenderer } from 'echarts/renderers' ;
21
+ import { finalize } from 'rxjs' ;
23
22
import Swal from 'sweetalert2/dist/sweetalert2.js' ;
24
- import * as echarts from 'echarts/core' ;
25
23
26
- import { AgentsTableComponent } from 'src/app/core/_components/tables/agents-table/agents-table.component' ;
27
- import { UIConfigService } from 'src/app/core/_services/shared/storage.service' ;
28
- import { AlertService } from 'src/app/core/_services/shared/alert.service' ;
29
- import { GlobalService } from 'src/app/core/_services/main.service' ;
30
- import { FileSizePipe } from 'src/app/core/_pipes/file-size.pipe' ;
31
- import { SERV } from '../../core/_services/main.config' ;
32
- import { MatSnackBar } from '@angular/material/snack-bar' ;
33
- import { AutoTitleService } from 'src/app/core/_services/shared/autotitle.service' ;
24
+ import { Component , OnInit , ViewChild } from '@angular/core' ;
25
+ import { FormControl , FormGroup } from '@angular/forms' ;
34
26
import { MatSlideToggle } from '@angular/material/slide-toggle' ;
35
- import { finalize } from 'rxjs' ;
36
- import { FilterType } from 'src/app/core/_models/request-params.model' ;
37
- import { JsonAPISerializer } from '@services/api/serializer-service' ;
38
- import { ResponseWrapper } from '@models/response.model' ;
39
- import { JTask } from '@models/task.model' ;
40
- import { RequestParamBuilder } from '@services/params/builder-implementation.service' ;
41
- import { JHashtype } from '@models/hashtype.model' ;
27
+ import { MatSnackBar } from '@angular/material/snack-bar' ;
28
+ import { ActivatedRoute , Params , Router } from '@angular/router' ;
29
+
42
30
import { JAgentAssignment } from '@models/agent-assignment.model' ;
43
31
import { JAgent } from '@models/agent.model' ;
44
32
import { JChunk } from '@models/chunk.model' ;
33
+ import { JCrackerBinary } from '@models/cracker-binary.model' ;
34
+ import { JHashlist } from '@models/hashlist.model' ;
35
+ import { JHashtype } from '@models/hashtype.model' ;
36
+ import { FilterType } from '@models/request-params.model' ;
37
+ import { ResponseWrapper } from '@models/response.model' ;
38
+ import { JTask } from '@models/task.model' ;
39
+
40
+ import { JsonAPISerializer } from '@services/api/serializer-service' ;
41
+ import { SERV } from '@services/main.config' ;
42
+ import { GlobalService } from '@services/main.service' ;
43
+ import { RequestParamBuilder } from '@services/params/builder-implementation.service' ;
44
+ import { AlertService } from '@services/shared/alert.service' ;
45
+ import { AutoTitleService } from '@services/shared/autotitle.service' ;
46
+ import { UIConfigService } from '@services/shared/storage.service' ;
47
+
48
+ import { AgentsTableComponent } from '@components/tables/agents-table/agents-table.component' ;
49
+
50
+ import { FileSizePipe } from '@src/app/core/_pipes/file-size.pipe' ;
45
51
46
52
@Component ( {
47
- selector : 'app-edit-tasks' ,
48
- templateUrl : './edit-tasks.component.html' ,
49
- providers : [ FileSizePipe ] ,
50
- standalone : false
53
+ selector : 'app-edit-tasks' ,
54
+ templateUrl : './edit-tasks.component.html' ,
55
+ providers : [ FileSizePipe ] ,
56
+ standalone : false
51
57
} )
52
58
export class EditTasksComponent implements OnInit {
53
59
editMode = false ;
54
60
editedTaskIndex : number ;
55
61
taskWrapperId : number ;
56
- editedTask : any ; // Change to Model
57
- originalValue : any ; // Change to Model
62
+ originalValue : JTask ;
58
63
59
64
updateForm : FormGroup ;
60
65
createForm : FormGroup ; // Assign Agent
61
66
/** On form update show a spinner loading */
62
67
isUpdatingLoading = false ;
63
68
64
69
color = '' ;
65
- tusepreprocessor : any ;
66
- hashlistDescrip : any ;
67
- hashlistinform : any ;
68
- assigAgents : any ;
69
- availAgents = [ ] ;
70
- crackerinfo : any ;
71
- tkeyspace : any ;
70
+ tusepreprocessor : number ;
71
+ hashlistDescrip : string ;
72
+ hashlistinform : JHashlist ;
73
+ availAgents : JAgent [ ] = [ ] ;
74
+ crackerinfo : JCrackerBinary ;
75
+ tkeyspace : number ;
72
76
73
77
@ViewChild ( 'agentsTable' ) agentsTable : AgentsTableComponent ;
74
78
@ViewChild ( 'slideToggle' , { static : false } ) slideToggle : MatSlideToggle ;
75
79
76
80
//Time calculation
77
- cprogress : any ; // Keyspace searched
78
- ctimespent : any ; // Time Spent
81
+ cprogress ; // Keyspace searched
82
+ ctimespent ; // Time Spent
79
83
80
84
// Chunk View
81
85
chunkview : number ;
82
86
chunktitle : string ;
83
87
isactive = 0 ;
84
88
currenspeed = 0 ;
85
89
chunkresults : number ;
86
- activechunks : Object ;
87
90
88
91
constructor (
89
92
private titleService : AutoTitleService ,
@@ -103,7 +106,7 @@ export class EditTasksComponent implements OnInit {
103
106
this . onInitialize ( ) ;
104
107
this . buildForm ( ) ;
105
108
this . initForm ( ) ;
106
- this . assignChunksInit ( this . editedTaskIndex ) ;
109
+ this . assignChunksInit ( ) ;
107
110
}
108
111
109
112
onInitialize ( ) {
@@ -140,12 +143,6 @@ export class EditTasksComponent implements OnInit {
140
143
} ) ;
141
144
}
142
145
143
- OnChangeValue ( value ) {
144
- this . updateForm . patchValue ( {
145
- updateData : { color : value }
146
- } ) ;
147
- }
148
-
149
146
onSubmit ( ) {
150
147
if ( this . updateForm . valid ) {
151
148
// Check if attackCmd has been modified
@@ -194,13 +191,12 @@ export class EditTasksComponent implements OnInit {
194
191
this . originalValue = task ;
195
192
this . color = task . color ;
196
193
this . crackerinfo = task . crackerBinary ;
197
- this . taskWrapperId - task . taskWrapperId ;
194
+ this . taskWrapperId = task . taskWrapperId ;
198
195
// Graph Speed
199
196
this . initTaskSpeed ( task . speeds ) ;
200
197
// Assigned Agents init
201
198
this . assingAgentInit ( ) ;
202
199
// Hashlist Description and Type
203
- this . hashlistinform = '' ;
204
200
if ( task . hashlist ) {
205
201
this . hashlistinform = task . hashlist ;
206
202
if ( this . hashlistinform ) {
@@ -217,44 +213,26 @@ export class EditTasksComponent implements OnInit {
217
213
}
218
214
this . tkeyspace = task . keyspace ;
219
215
this . tusepreprocessor = task . preprocessorId ;
220
- this . updateForm = new FormGroup ( {
221
- taskId : new FormControl ( {
222
- value : task . id ,
223
- disabled : true
224
- } ) ,
225
- forcePipe : new FormControl ( {
226
- value : task . forcePipe == true ? 'Yes' : 'No' ,
227
- disabled : true
228
- } ) ,
229
- skipKeyspace : new FormControl ( {
230
- value : task . skipKeyspace > 0 ? task . skipKeyspace : 'N/A' ,
231
- disabled : true
232
- } ) ,
233
- keyspace : new FormControl ( {
234
- value : task . keyspace ,
235
- disabled : true
236
- } ) ,
237
- keyspaceProgress : new FormControl ( {
238
- value : task . keyspaceProgress ,
239
- disabled : true
240
- } ) ,
241
- crackerBinaryId : new FormControl ( task . crackerBinaryId ) ,
242
- chunkSize : new FormControl ( {
243
- value : task . chunkSize ,
244
- disabled : true
245
- } ) ,
246
- updateData : new FormGroup ( {
247
- taskName : new FormControl ( task . taskName ) ,
248
- attackCmd : new FormControl ( task . attackCmd ) ,
249
- notes : new FormControl ( task . notes ) ,
250
- color : new FormControl ( task . color ) ,
251
- chunkTime : new FormControl ( Number ( task . chunkTime ) ) ,
252
- statusTimer : new FormControl ( task . statusTimer ) ,
253
- priority : new FormControl ( task . priority ) ,
254
- maxAgents : new FormControl ( task . maxAgents ) ,
255
- isCpuTask : new FormControl ( task . isCpuTask ) ,
256
- isSmall : new FormControl ( task . isSmall )
257
- } )
216
+ this . updateForm . setValue ( {
217
+ taskId : task . id ,
218
+ forcePipe : task . forcePipe === true ? 'Yes' : 'No' ,
219
+ skipKeyspace : task . skipKeyspace > 0 ? task . skipKeyspace : 'N/A' ,
220
+ keyspace : task . keyspace ,
221
+ keyspaceProgress : task . keyspaceProgress ,
222
+ crackerBinaryId : task . crackerBinaryId ,
223
+ chunkSize : task . chunkSize ,
224
+ updateData : {
225
+ taskName : task . taskName ,
226
+ attackCmd : task . attackCmd ,
227
+ notes : task . notes ,
228
+ color : task . color ,
229
+ chunkTime : Number ( task . chunkTime ) ,
230
+ statusTimer : task . statusTimer ,
231
+ priority : task . priority ,
232
+ maxAgents : task . maxAgents ,
233
+ isCpuTask : task . isCpuTask ,
234
+ isSmall : task . isSmall
235
+ }
258
236
} ) ;
259
237
} ) ;
260
238
}
@@ -279,13 +257,7 @@ export class EditTasksComponent implements OnInit {
279
257
280
258
this . gs . getAll ( SERV . AGENTS , params . create ( ) ) . subscribe ( ( responseAgents : ResponseWrapper ) => {
281
259
const responseBodyAgents = { data : responseAgents . data , included : responseAgents . included } ;
282
- const agents = this . serializer . deserialize < JAgent [ ] > ( responseBodyAgents ) ;
283
- this . availAgents = agents ;
284
-
285
- // this.assigAgents = res.values.map((mainObject) => {
286
- // const matchObject = agents.values.find((element) => element.agentId === mainObject.agentId);
287
- // return { ...mainObject, ...matchObject };
288
- // });
260
+ this . availAgents = this . serializer . deserialize < JAgent [ ] > ( responseBodyAgents ) ;
289
261
} ) ;
290
262
} ) ;
291
263
}
@@ -331,7 +303,7 @@ export class EditTasksComponent implements OnInit {
331
303
this . ctimespent = timespent . reduce ( ( a , i ) => a + i ) ;
332
304
}
333
305
334
- assignChunksInit ( id : number ) {
306
+ assignChunksInit ( ) {
335
307
this . route . data . subscribe ( ( data ) => {
336
308
switch ( data [ 'kind' ] ) {
337
309
case 'edit-task' :
@@ -350,8 +322,6 @@ export class EditTasksComponent implements OnInit {
350
322
} ) ;
351
323
352
324
//TODO. It is repeting code to get the speed
353
- const page = { size : this . chunkresults } ;
354
-
355
325
const paramsChunks = new RequestParamBuilder ( )
356
326
. addFilter ( { field : 'taskId' , operator : FilterType . EQUAL , value : this . editedTaskIndex } )
357
327
. create ( ) ;
@@ -394,7 +364,7 @@ export class EditTasksComponent implements OnInit {
394
364
} ) ;
395
365
}
396
366
397
- toggleIsAll ( event ) {
367
+ toggleIsAll ( ) {
398
368
if ( this . chunkview === 0 ) {
399
369
this . router . navigate ( [ '/tasks/show-tasks' , this . editedTaskIndex , 'edit' , 'show-all-chunks' ] ) ;
400
370
} else {
@@ -504,11 +474,10 @@ export class EditTasksComponent implements OnInit {
504
474
505
475
const chartDom = document . getElementById ( 'tspeed' ) ;
506
476
const myChart = echarts . init ( chartDom ) ;
507
- let option : EChartsOption ;
508
477
509
478
const self = this ;
510
479
511
- option = {
480
+ const option : EChartsOption = {
512
481
title : {
513
482
subtext : 'Last record: ' + datelabel
514
483
} ,
0 commit comments