Skip to content

Commit

Permalink
ugly initial code for workloadKey is working!
Browse files Browse the repository at this point in the history
  • Loading branch information
eostermueller committed Oct 18, 2020
1 parent 84b2cd8 commit 9627680
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/src/main/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start": "ng serve --liveReload --open --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/main/web/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

{
"/" :{
"target" : "http://localhost:8675",
"secure" : false
}
}
20 changes: 20 additions & 0 deletions frontend/src/main/web/src/app/use-cases/use-cases.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,26 @@ dispUseCases(ctx:string) {
}
ngOnInit() {

this.useCaseService.currentWorkload.subscribe(workloadObj => {

/** The following works......however.
* when checkboxes are changed, then the following executes UNNECESSARILY.
* Without this load() call, the new workload paints/renders/displays just fine.
*
* THis line is required to update/correct/display the workload when TEXT is pasted into the workloadKey screen.
* One way around this: perhaps start a timer when any workload checkboxes change.
* If we're about to execute this load() w/o 5 ms of the timer, DON'T CALL THIS load()!!!!!
*
* ....or perhaps share a variable between the two screens, and share a 'dirty' variable.
* when the workloadKey(aka text) changes, set the dirty flag.....
* and only execute this load() when the dirty flag is set.
* .....and of course reset the dirty() flag when it is detected.
*/
this.load();
}
);


this.sutLaunchStatusService.currentStatus.subscribe(
status => {
this.forceHttpWorkloadRq = true; //check whether there's new stuff on the classpath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
<mat-label>Workload Key</mat-label>
<p></p>
<textarea
name="workloadKey"
matInput
placeholder="(snail4j workload json, plaintext or encrypted)"
formControlName="workloadKey"
required
>
{{ this.getWorkloadKeyJson() }}
</textarea>

<mat-error *ngIf="form.get('workloadKey').hasError('required')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,70 @@ import { Component, OnInit } from '@angular/core';
import {UseCaseService} from '../use-case.service';
import { Workload } from '../model/workload';
import { FormBuilder, FormGroup, Validators} from '@angular/forms';
import {ConfigService} from '../services/config.service';
import {ConfigModel} from '../services/config.model';

@Component({
selector: 'app-workload-key',
templateUrl: './workload-key.component.html',
styleUrls: ['./workload-key.component.css']
})
export class WorkloadKeyComponent implements OnInit {
config: ConfigModel = this.configService.config;
form: FormGroup = new FormGroup({});

workloadKey:Workload = null;
workloadKeyString:string = null;
constructor(
private useCaseService : UseCaseService,
private configService: ConfigService,
private fb: FormBuilder
) {

console.log("ctor for workload-key.components.tx");
this.form = fb.group({

workloadKey: ['', [Validators.required]]
workloadKey: ['', [Validators.required] ]

})


})
}
private onFormValueChange(data) {
this.workloadKeyString = this.form.get("workloadKey").value;
console.log("in workload-key form, found changed data:" + this.workloadKeyString)
}

submit() {
console.log("Submit!");
this.updateWorkload();
}
private updateWorkload() {
console.log("nnnnn about to parse selected workload:" + this.workloadKeyString);
var workload:Workload = JSON.parse(this.workloadKeyString);
this.useCaseService.updateWorkload(
this.config.sutAppHostname,
this.config.sutAppPort,
workload).subscribe();

getWorkloadKeyJson() : string {
}

public getWorkloadKeyJson() : string {
return JSON.stringify(this.workloadKey);
}
ngOnInit(): void {
this.form.valueChanges.subscribe(data => this.onFormValueChange(data));

console.log("top of ngOnInit workload-key.component.ts [" + this.getWorkloadKeyJson() + "]"); // prints 'object Object' without stringify

this.useCaseService.currentWorkload.subscribe(workloadObj => {
this.workloadKey = workloadObj;
console.log("workloadKey form valid?" + this.form.valid);
console.log("xGot new workload [" + this.getWorkloadKeyJson() + "]"); // prints 'object Object' without stringify
//this.workloadKey = workloadObj;
this.workloadKeyString = JSON.stringify(workloadObj);
console.log("nnnnn workloadKey form valid?" + this.form.valid);
console.log("nnnnn xGot new workload [" + this.workloadKeyString + "]"); // prints 'object Object' without stringify
//this.updateWorkload();

this.form.controls['workloadKey'].setValue( this.workloadKeyString );
//this.form.setValue([ this.workloadKeyString ]);

}
);
}
Expand Down

0 comments on commit 9627680

Please sign in to comment.