From 9627680cb732dcfe9cea911200457d63a45c67c0 Mon Sep 17 00:00:00 2001 From: eostermueller Date: Sun, 18 Oct 2020 15:37:58 -0500 Subject: [PATCH] ugly initial code for workloadKey is working! --- frontend/src/main/web/package.json | 2 +- frontend/src/main/web/proxy.conf.json | 7 +++ .../src/app/use-cases/use-cases.component.ts | 20 +++++++++ .../workload-key/workload-key.component.html | 3 +- .../workload-key/workload-key.component.ts | 43 +++++++++++++++---- 5 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 frontend/src/main/web/proxy.conf.json diff --git a/frontend/src/main/web/package.json b/frontend/src/main/web/package.json index 6b7e1e5..4bb1eca 100644 --- a/frontend/src/main/web/package.json +++ b/frontend/src/main/web/package.json @@ -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", diff --git a/frontend/src/main/web/proxy.conf.json b/frontend/src/main/web/proxy.conf.json new file mode 100644 index 0000000..e58801e --- /dev/null +++ b/frontend/src/main/web/proxy.conf.json @@ -0,0 +1,7 @@ + +{ + "/" :{ + "target" : "http://localhost:8675", + "secure" : false + } +} diff --git a/frontend/src/main/web/src/app/use-cases/use-cases.component.ts b/frontend/src/main/web/src/app/use-cases/use-cases.component.ts index 2646081..8eb610c 100644 --- a/frontend/src/main/web/src/app/use-cases/use-cases.component.ts +++ b/frontend/src/main/web/src/app/use-cases/use-cases.component.ts @@ -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, diff --git a/frontend/src/main/web/src/app/workload-key/workload-key.component.html b/frontend/src/main/web/src/app/workload-key/workload-key.component.html index 8f5754f..18a7b3c 100644 --- a/frontend/src/main/web/src/app/workload-key/workload-key.component.html +++ b/frontend/src/main/web/src/app/workload-key/workload-key.component.html @@ -11,11 +11,12 @@ Workload Key

diff --git a/frontend/src/main/web/src/app/workload-key/workload-key.component.ts b/frontend/src/main/web/src/app/workload-key/workload-key.component.ts index 2725f5a..f42776c 100644 --- a/frontend/src/main/web/src/app/workload-key/workload-key.component.ts +++ b/frontend/src/main/web/src/app/workload-key/workload-key.component.ts @@ -2,6 +2,8 @@ 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', @@ -9,36 +11,61 @@ import { FormBuilder, FormGroup, Validators} from '@angular/forms'; 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 ]); + } ); }