Skip to content

Commit a3a8e92

Browse files
committed
#30 is primitive but working
1 parent 9627680 commit a3a8e92

File tree

11 files changed

+77
-49
lines changed

11 files changed

+77
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
export class Workload {
2-
useCases: any[] = new Array();
3-
}
2+
3+
useCases: any[] = new Array();
4+
5+
/**
6+
* 0 = end user selected workload using check boxes and radio buttons
7+
* 1 = clear text json workload key
8+
* 2 = encrypted version of above key.
9+
*/
10+
origin: number = 0;
11+
}

frontend/src/main/web/src/app/services/workload-change.service.spec.ts

-16
This file was deleted.

frontend/src/main/web/src/app/services/workload-change.service.ts

-18
This file was deleted.

frontend/src/main/web/src/app/use-case.service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Observable } from 'rxjs';
55
import {ApiResponse} from './model/api.response';
66
import {Workload} from './model/workload';
77
import { ApiResponseInterface } from './model/api.response.interface';
8-
import { WorkloadChangeService } from './services/workload-change.service';
98
import { BehaviorSubject } from 'rxjs';
109

1110
@Injectable({

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ dispUseCases(ctx:string) {
199199
useCaseCardComponent.setSelectionState(true,selectedIndex);
200200
console.log('Found card 0 ' + useCaseCardsAry[i].constructor.name);
201201
console.log('Found card: ' + i + ' : ' + useCaseCardsAry[i].getName() );
202-
break;
202+
//2020-11-06 break;
203203
}
204204
}
205205
console.log("after ary");
@@ -229,7 +229,10 @@ dispUseCases(ctx:string) {
229229

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

232-
/** The following works......however.
232+
/**
233+
* Refresh the checkbox/combobox selection with the newly applied WorkloadKey -- a text one.
234+
*
235+
* The following works......however.
233236
* when checkboxes are changed, then the following executes UNNECESSARILY.
234237
* Without this load() call, the new workload paints/renders/displays just fine.
235238
*
@@ -241,8 +244,17 @@ dispUseCases(ctx:string) {
241244
* when the workloadKey(aka text) changes, set the dirty flag.....
242245
* and only execute this load() when the dirty flag is set.
243246
* .....and of course reset the dirty() flag when it is detected.
247+
*
248+
* ....or perhaps (and of course this is the right way) make a custom service specifically for:
249+
* - clearTextWorkloadChange()
250+
* - encryptedTextWorkloadChange()
251+
*
244252
*/
245-
this.load();
253+
if (workloadObj.origin==1)
254+
//calling load() with origin==0 causes unnecessary and irritating page reload
255+
this.load();
256+
//this.reSetUseCaseSelection(workloadObj);
257+
246258
}
247259
);
248260

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

+8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010

1111
<mat-label>Workload Key</mat-label>
1212
<p></p>
13+
<!--
14+
Autosize parms @stolenFrom: https://stackoverflow.com/a/56694453/2377579
15+
-->
1316
<textarea
17+
class="overflow:auto"
1418
name="workloadKey"
1519
matInput
1620
placeholder="(snail4j workload json, plaintext or encrypted)"
1721
formControlName="workloadKey"
1822
required
23+
cdkTextareaAutosize
24+
#autosize="cdkTextareaAutosize"
25+
cdkAutosizeMinRows="1"
26+
cdkAutosizeMaxRows="5"
1927
>
2028
</textarea>
2129

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

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class WorkloadKeyComponent implements OnInit {
4141
private updateWorkload() {
4242
console.log("nnnnn about to parse selected workload:" + this.workloadKeyString);
4343
var workload:Workload = JSON.parse(this.workloadKeyString);
44+
workload.origin = 1;
4445
this.useCaseService.updateWorkload(
4546
this.config.sutAppHostname,
4647
this.config.sutAppPort,

frontend/src/main/web/src/app/workload-selection/workload-selection.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
</mat-tab>
8282
<mat-tab [disabled]="workloadTabDisabled" label="Step 2: Choose Workload">
83-
<mat-tab-group mat-align-tabs="end">
83+
<mat-tab-group mat-align-tabs="start">
8484
<mat-tab label="@Load Annotations">
8585
<app-use-cases></app-use-cases>
8686
</mat-tab>

workload/src/main/java/com/github/eostermueller/snail4j/workload/model/UseCases.java

+8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@
88
import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException;
99

1010
public class UseCases {
11+
int origin = 0;
12+
1113

14+
public int getOrigin() {
15+
return origin;
16+
}
17+
public void setOrigin(int origin) {
18+
this.origin = origin;
19+
}
1220
public UseCases sort(Comparator<UseCase> c) {
1321
useCases.sort(c);
1422
return this;

workload/src/main/java/com/github/eostermueller/snail4j/workload/model/json/DefaultSerializationUtil.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55

66
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.MapperFeature;
78
import com.fasterxml.jackson.databind.ObjectMapper;
89
import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException;
910
import com.github.eostermueller.snail4j.workload.model.UseCases;
@@ -45,8 +46,10 @@ public UseCases unmmarshalUseCases(String json) throws Snail4jWorkloadException
4546
UseCases useCases = null;
4647
try {
4748
useCases = this.getMapper()
49+
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
4850
.readerFor(UseCases.class)
4951
.readValue(json);
52+
5053
} catch (IOException e) {
5154
Snail4jWorkloadException he = new Snail4jWorkloadException(e,"Unable to unmarshal UseCases");
5255
throw he;

0 commit comments

Comments
 (0)