Skip to content

Commit

Permalink
Edit item status (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Feb 18, 2024
1 parent 8cf98b7 commit 1f422a3
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/app/item-detail/item-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class="fas fa-bars"></i></button>
<div class="dropdown-menu jtl-dropdown-control-menu" ngbDropdownMenu>
<app-edit-item *ngIf="itemData.environment"
[itemDetailData]="{note: itemData.note, resourcesLink: itemData.resourcesLink, environment: itemData.environment, hostname: itemData.hostname, isBase: itemData.isBase, params: itemParams, name: itemData.name}"
[itemDetailData]="{note: itemData.note, resourcesLink: itemData.resourcesLink, environment: itemData.environment, hostname: itemData.hostname, isBase: itemData.isBase, status: itemData.status, params: itemParams, name: itemData.name}"
(itemDetailChange)="itemDetailChanged($event)"></app-edit-item>
<app-share [params]=itemParams></app-share>
<app-delete-item *ngIf="itemData.reportStatus !== 'in_progress'" [itemData]="itemParams"></app-delete-item>
Expand Down
3 changes: 2 additions & 1 deletion src/app/item-detail/item-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export class ItemDetailComponent implements OnInit, OnDestroy {
zeroErrorToleranceEnabled: null,
topMetricsSettings: null,
userSettings: null,
errorSummary: null
errorSummary: null,
status: null,
};
overallChartOptions;
scatterChartOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe("RequestStatsCompareComponent", () => {
reportStatus: undefined,
topMetricsSettings: undefined,
zeroErrorToleranceEnabled: false,
status: "10",
overview: {
maxVu: 100,
avgConnect: 100,
Expand Down Expand Up @@ -84,7 +85,6 @@ describe("RequestStatsCompareComponent", () => {
}
},
baseId: "",

statistics: [{
avgResponseTime: 10,
bytes: 758,
Expand Down Expand Up @@ -124,26 +124,26 @@ describe("RequestStatsCompareComponent", () => {
satisfaction: 4,
}
},
{
avgResponseTime: 10,
bytes: 758,
errorRate: 0,
label: "03 - Click_Log_In-20",
maxResponseTime: 38,
minResponseTime: 8,
n0: 33,
n5: 34,
n9: 37,
samples: 200,
throughput: 0.17,
responseMessageFailures: [
{ responseMessage: "error", count: 1 }
],
apdex: {
toleration: 10,
satisfaction: 40,
}
}, ],
{
avgResponseTime: 10,
bytes: 758,
errorRate: 0,
label: "03 - Click_Log_In-20",
maxResponseTime: 38,
minResponseTime: 8,
n0: 33,
n5: 34,
n9: 37,
samples: 200,
throughput: 0.17,
responseMessageFailures: [
{ responseMessage: "error", count: 1 }
],
apdex: {
toleration: 10,
satisfaction: 40,
}
},],
errorSummary: {
groupedErrors: [],
topErrorsByLabel: []
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("RequestStatsCompareComponent", () => {
throughput: 0.17,
}],
plot: {
responseTime: [{ data: [], name: "label" } ],
responseTime: [{ data: [], name: "label" }],
throughput: [{ data: [], name: "label" }]
},
extraPlotData: {},
Expand All @@ -199,5 +199,4 @@ describe("RequestStatsCompareComponent", () => {
.toEqual(["02 - Click_Log_In-22", "03 - Click_Log_In-20"]);
});
});

});
1 change: 1 addition & 0 deletions src/app/items.service.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface ItemDetail {
requestStats: RequestStats
};
errorSummary: ErrorSummary
status: string
}

interface TopMetricsSettings {
Expand Down
3 changes: 2 additions & 1 deletion src/app/scenario/add-new-item/add-new-item.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export enum ItemStatus {
Passed = "passed",
Failed = "failed",
Terminated = "terminated",
None = "none"
Error = "error",
None = "none",
}
1 change: 1 addition & 0 deletions src/app/scenario/item-controls/item-controls.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export interface ItemInput {
params: ItemParams;
name: string;
resourcesLink?: string;
status: string;
}
2 changes: 1 addition & 1 deletion src/app/scenario/scenario.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h6 class="card-header bg-transparent">Test Runs
</td>
<td class="text-right">
<app-item-controls
[item]="{note: _.note, environment: _.environment, name: _.name, hostname: _.hostname, isBase: _.base, params: { id: _.id, scenarioName: params.scenarioName, projectName: params.projectName }}">
[item]="{note: _.note, environment: _.environment, name: _.name, hostname: _.hostname, isBase: _.base, status: _.status, params: { id: _.id, scenarioName: params.scenarioName, projectName: params.projectName }}">
</app-item-controls>
</td>
</tr>
Expand Down
8 changes: 8 additions & 0 deletions src/app/shared/shared-item/edit-item/edit-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ <h5 class="modal-title" id="modal-basic-title">Edit test item</h5>
<input type="testName" id="hostname" class="form-control" formControlName="hostname" aria-label="Default"
aria-describedby="inputGroup-sizing-default">
</div>
<div class="form-group mb-3">
<label for="status">Status</label>
<select id="status" class="form-control custom-select" formControlName="status">
<option *ngFor="let s of statuses" [value]="s">
{{s}}
</option>
</select>
</div>
<div class="form-group mb-3">
<div>
<input type="checkbox" id="base-check" [attr.disabled]="disabled ? '' : null" formControlName="base" [(ngModel)]="isBase"
Expand Down
30 changes: 20 additions & 10 deletions src/app/shared/shared-item/edit-item/edit-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { of } from "rxjs";
import { NotificationMessage } from "src/app/notification/notification-messages";
import { ItemInput } from "src/app/scenario/item-controls/item-controls.model";
import { ItemsService } from "src/app/items.service";
import { ItemStatus } from "../../../scenario/add-new-item/add-new-item.model";
import { ItemStatusValue } from "../../../item-detail/item-detail.model";

@Component({
selector: "app-edit-item",
Expand All @@ -25,18 +27,23 @@ export class EditItemComponent implements OnInit {
disabled;
name;
resourcesLink;
status;
statuses = Object.values(ItemStatus);


@Input() reloadItems: boolean;
@Input() itemDetailData: ItemInput;
@Output() itemDetailChange = new EventEmitter<{
note: string, environment: string, hostname: string, name: string }>();
note: string, environment: string, hostname: string, name: string
}>();

constructor(
private modalService: NgbModal,
private itemsApiService: ItemsApiService,
private itemsService: ItemsService,
private notification: NotificationMessage
) { }
) {
}

ngOnInit(): void {
this.isBase = this.itemDetailData.isBase;
Expand All @@ -59,9 +66,11 @@ export class EditItemComponent implements OnInit {
this.base = new FormControl(this.itemDetailData.isBase, []);
this.name = new FormControl(this.itemDetailData.name, [
Validators.maxLength(200)
])
]);
this.resourcesLink = new FormControl(this.itemDetailData.resourcesLink,
[Validators.maxLength(350)])
[Validators.maxLength(350)]);
this.status = new FormControl(Object.keys(ItemStatusValue).find(x => ItemStatusValue[x] === this.itemDetailData.status), [
]);
}

createForm() {
Expand All @@ -72,6 +81,7 @@ export class EditItemComponent implements OnInit {
base: this.base,
name: this.name,
resourcesLink: this.resourcesLink,
status: this.status,
});
}

Expand All @@ -81,20 +91,20 @@ export class EditItemComponent implements OnInit {

onSubmit() {
if (this.myform.valid) {
const { note, environment, base, hostname, name, resourcesLink } = this.myform.value;
const { note, environment, base, hostname, name, resourcesLink, status } = this.myform.value;
const { projectName, id, scenarioName } = this.itemDetailData.params;
this.itemsApiService.updateItemInfo(id, projectName, scenarioName,
{ environment, note, base, hostname, name, resourcesLink })
{ environment, note, base, hostname, name, resourcesLink, status: ItemStatusValue[status] })
.pipe(catchError(r => of(r)))
.subscribe(_ => {
this.itemDetailChange.emit({ note, environment, hostname, name });
const message = this.notification.itemUpdate(_);
return this.itemsApiService.setData(message);
}).add((_) => {
if (this.reloadItems) {
this.itemsService.fetchItems(projectName, scenarioName);
}
});
if (this.reloadItems) {
this.itemsService.fetchItems(projectName, scenarioName);
}
});
this.modalService.dismissAll();
}
}
Expand Down

0 comments on commit 1f422a3

Please sign in to comment.