Skip to content

Commit

Permalink
#30 is primitive but working
Browse files Browse the repository at this point in the history
  • Loading branch information
eostermueller committed Nov 6, 2020
1 parent 9627680 commit a3a8e92
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 49 deletions.
12 changes: 10 additions & 2 deletions frontend/src/main/web/src/app/model/workload.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export class Workload {
useCases: any[] = new Array();
}

useCases: any[] = new Array();

/**
* 0 = end user selected workload using check boxes and radio buttons
* 1 = clear text json workload key
* 2 = encrypted version of above key.
*/
origin: number = 0;
}

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/main/web/src/app/services/workload-change.service.ts

This file was deleted.

1 change: 0 additions & 1 deletion frontend/src/main/web/src/app/use-case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Observable } from 'rxjs';
import {ApiResponse} from './model/api.response';
import {Workload} from './model/workload';
import { ApiResponseInterface } from './model/api.response.interface';
import { WorkloadChangeService } from './services/workload-change.service';
import { BehaviorSubject } from 'rxjs';

@Injectable({
Expand Down
18 changes: 15 additions & 3 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 @@ -199,7 +199,7 @@ dispUseCases(ctx:string) {
useCaseCardComponent.setSelectionState(true,selectedIndex);
console.log('Found card 0 ' + useCaseCardsAry[i].constructor.name);
console.log('Found card: ' + i + ' : ' + useCaseCardsAry[i].getName() );
break;
//2020-11-06 break;
}
}
console.log("after ary");
Expand Down Expand Up @@ -229,7 +229,10 @@ dispUseCases(ctx:string) {

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

/** The following works......however.
/**
* Refresh the checkbox/combobox selection with the newly applied WorkloadKey -- a text one.
*
* 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.
*
Expand All @@ -241,8 +244,17 @@ dispUseCases(ctx:string) {
* 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.
*
* ....or perhaps (and of course this is the right way) make a custom service specifically for:
* - clearTextWorkloadChange()
* - encryptedTextWorkloadChange()
*
*/
this.load();
if (workloadObj.origin==1)
//calling load() with origin==0 causes unnecessary and irritating page reload
this.load();
//this.reSetUseCaseSelection(workloadObj);

}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@

<mat-label>Workload Key</mat-label>
<p></p>
<!--
Autosize parms @stolenFrom: https://stackoverflow.com/a/56694453/2377579
-->
<textarea
class="overflow:auto"
name="workloadKey"
matInput
placeholder="(snail4j workload json, plaintext or encrypted)"
formControlName="workloadKey"
required
cdkTextareaAutosize
#autosize="cdkTextareaAutosize"
cdkAutosizeMinRows="1"
cdkAutosizeMaxRows="5"
>
</textarea>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class WorkloadKeyComponent implements OnInit {
private updateWorkload() {
console.log("nnnnn about to parse selected workload:" + this.workloadKeyString);
var workload:Workload = JSON.parse(this.workloadKeyString);
workload.origin = 1;
this.useCaseService.updateWorkload(
this.config.sutAppHostname,
this.config.sutAppPort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

</mat-tab>
<mat-tab [disabled]="workloadTabDisabled" label="Step 2: Choose Workload">
<mat-tab-group mat-align-tabs="end">
<mat-tab-group mat-align-tabs="start">
<mat-tab label="@Load Annotations">
<app-use-cases></app-use-cases>
</mat-tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException;

public class UseCases {
int origin = 0;


public int getOrigin() {
return origin;
}
public void setOrigin(int origin) {
this.origin = origin;
}
public UseCases sort(Comparator<UseCase> c) {
useCases.sort(c);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException;
import com.github.eostermueller.snail4j.workload.model.UseCases;
Expand Down Expand Up @@ -45,8 +46,10 @@ public UseCases unmmarshalUseCases(String json) throws Snail4jWorkloadException
UseCases useCases = null;
try {
useCases = this.getMapper()
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
.readerFor(UseCases.class)
.readValue(json);

} catch (IOException e) {
Snail4jWorkloadException he = new Snail4jWorkloadException(e,"Unable to unmarshal UseCases");
throw he;
Expand Down
Loading

0 comments on commit a3a8e92

Please sign in to comment.