Skip to content

Commit ed963b3

Browse files
committed
ugly initial code for workloadKey is working!
1 parent db23dca commit ed963b3

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

frontend/src/main/web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.0.0",
44
"scripts": {
55
"ng": "ng",
6-
"start": "ng serve",
6+
"start": "ng serve --liveReload --open --proxy-config proxy.conf.json",
77
"build": "ng build",
88
"test": "ng test",
99
"lint": "ng lint",

frontend/src/main/web/proxy.conf.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
{
3+
"/" :{
4+
"target" : "http://localhost:8675",
5+
"secure" : false
6+
}
7+
}

frontend/src/main/web/src/app/use-cases/use-cases.component.ts

+20
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,26 @@ dispUseCases(ctx:string) {
227227
}
228228
ngOnInit() {
229229

230+
this.useCaseService.currentWorkload.subscribe(workloadObj => {
231+
232+
/** The following works......however.
233+
* when checkboxes are changed, then the following executes UNNECESSARILY.
234+
* Without this load() call, the new workload paints/renders/displays just fine.
235+
*
236+
* THis line is required to update/correct/display the workload when TEXT is pasted into the workloadKey screen.
237+
* One way around this: perhaps start a timer when any workload checkboxes change.
238+
* If we're about to execute this load() w/o 5 ms of the timer, DON'T CALL THIS load()!!!!!
239+
*
240+
* ....or perhaps share a variable between the two screens, and share a 'dirty' variable.
241+
* when the workloadKey(aka text) changes, set the dirty flag.....
242+
* and only execute this load() when the dirty flag is set.
243+
* .....and of course reset the dirty() flag when it is detected.
244+
*/
245+
this.load();
246+
}
247+
);
248+
249+
230250
this.sutLaunchStatusService.currentStatus.subscribe(
231251
status => {
232252
this.forceHttpWorkloadRq = true; //check whether there's new stuff on the classpath,

frontend/src/main/web/src/app/workload-key/workload-key.component.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
<mat-label>Workload Key</mat-label>
1212
<p></p>
1313
<textarea
14+
name="workloadKey"
1415
matInput
1516
placeholder="(snail4j workload json, plaintext or encrypted)"
1617
formControlName="workloadKey"
18+
required
1719
>
18-
{{ this.getWorkloadKeyJson() }}
1920
</textarea>
2021

2122
<mat-error *ngIf="form.get('workloadKey').hasError('required')">

frontend/src/main/web/src/app/workload-key/workload-key.component.ts

+35-8
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,70 @@ import { Component, OnInit } from '@angular/core';
22
import {UseCaseService} from '../use-case.service';
33
import { Workload } from '../model/workload';
44
import { FormBuilder, FormGroup, Validators} from '@angular/forms';
5+
import {ConfigService} from '../services/config.service';
6+
import {ConfigModel} from '../services/config.model';
57

68
@Component({
79
selector: 'app-workload-key',
810
templateUrl: './workload-key.component.html',
911
styleUrls: ['./workload-key.component.css']
1012
})
1113
export class WorkloadKeyComponent implements OnInit {
14+
config: ConfigModel = this.configService.config;
1215
form: FormGroup = new FormGroup({});
16+
1317
workloadKey:Workload = null;
18+
workloadKeyString:string = null;
1419
constructor(
1520
private useCaseService : UseCaseService,
21+
private configService: ConfigService,
1622
private fb: FormBuilder
1723
) {
18-
24+
console.log("ctor for workload-key.components.tx");
1925
this.form = fb.group({
2026

21-
workloadKey: ['', [Validators.required]]
27+
workloadKey: ['', [Validators.required] ]
2228

23-
})
2429

25-
30+
})
31+
}
32+
private onFormValueChange(data) {
33+
this.workloadKeyString = this.form.get("workloadKey").value;
34+
console.log("in workload-key form, found changed data:" + this.workloadKeyString)
2635
}
2736

2837
submit() {
2938
console.log("Submit!");
39+
this.updateWorkload();
3040
}
41+
private updateWorkload() {
42+
console.log("nnnnn about to parse selected workload:" + this.workloadKeyString);
43+
var workload:Workload = JSON.parse(this.workloadKeyString);
44+
this.useCaseService.updateWorkload(
45+
this.config.sutAppHostname,
46+
this.config.sutAppPort,
47+
workload).subscribe();
3148

32-
getWorkloadKeyJson() : string {
49+
}
50+
51+
public getWorkloadKeyJson() : string {
3352
return JSON.stringify(this.workloadKey);
3453
}
3554
ngOnInit(): void {
55+
this.form.valueChanges.subscribe(data => this.onFormValueChange(data));
56+
3657
console.log("top of ngOnInit workload-key.component.ts [" + this.getWorkloadKeyJson() + "]"); // prints 'object Object' without stringify
3758

3859
this.useCaseService.currentWorkload.subscribe(workloadObj => {
39-
this.workloadKey = workloadObj;
40-
console.log("workloadKey form valid?" + this.form.valid);
41-
console.log("xGot new workload [" + this.getWorkloadKeyJson() + "]"); // prints 'object Object' without stringify
60+
//this.workloadKey = workloadObj;
61+
this.workloadKeyString = JSON.stringify(workloadObj);
62+
console.log("nnnnn workloadKey form valid?" + this.form.valid);
63+
console.log("nnnnn xGot new workload [" + this.workloadKeyString + "]"); // prints 'object Object' without stringify
64+
//this.updateWorkload();
65+
66+
this.form.controls['workloadKey'].setValue( this.workloadKeyString );
67+
//this.form.setValue([ this.workloadKeyString ]);
68+
4269
}
4370
);
4471
}

0 commit comments

Comments
 (0)