Skip to content

Commit

Permalink
external link (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Apr 7, 2023
1 parent 6735fcc commit 4cfe74c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/app/item-detail/item-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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, 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, 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 Expand Up @@ -273,6 +273,12 @@ <h6 class="card-header bg-white border-0">Summary</h6>
<div class="col-sm mb-1 summary-bold">Note</div>
<div class="col-sm mb-1">{{itemData.note}}</div>
</div>
<div class="row">
<i class="fas fa-external-link text-carrot"></i>
<div class="col-sm mb-1 summary-bold">External Link</div>
<div class="col-sm mb-1"><a target="_blank" href="{{itemData.resourcesLink}}"><i class="fas fa-link"></i> <span> Resources</span>
</a></div>
</div>
<div class="row" *ngIf="itemData.monitoring.cpu.data.length > 0">
<div class="col-sm mb-1 summary-bold">Max CPU usage</div>
<div class="col-sm mb-1">{{itemData.monitoring.cpu.max}}% <app-monitoring-stats [data]="itemData.monitoring.cpu.data">
Expand Down
4 changes: 1 addition & 3 deletions src/app/item-detail/item-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class ItemDetailComponent implements OnInit, OnDestroy {
baseId: null,
note: null,
plot: null,
resourcesLink: null,
extraPlotData: null,
reportStatus: null,
histogramPlotData: null,
Expand All @@ -56,9 +57,7 @@ export class ItemDetailComponent implements OnInit, OnDestroy {
statusChartOptions;
updateChartFlag = false;
updateScatterChartFlag = false;
monitoringChart;
itemParams;
hasErrorsAttachment;
Math: any;
token: string;
isAnonymous = false;
Expand All @@ -68,7 +67,6 @@ export class ItemDetailComponent implements OnInit, OnDestroy {
performanceAnalysisLines = null;
externalSearchTerm = null;
totalRequests = null;
overallChart = null;


constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/app/items-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ItemsApiService {
}

addNewTestItem(projectName: string, scenarioName: string,
environment: string = null, note, hostname, status, kpiFile, name, errorFile?, monitoringFile?) {
environment: string = null, note, hostname, status, kpiFile, name, resourcesLink, errorFile?, monitoringFile?) {
const headers = new HttpHeaders();
headers.set("Content-Type", null);
headers.set("Accept", "multipart/form-data");
Expand All @@ -41,6 +41,7 @@ export class ItemsApiService {
formData.append("hostname", hostname);
formData.append("status", status);
formData.append("name", name);
formData.append("resourcesLink", resourcesLink);
if (errorFile) {
formData.append("errors", errorFile);
}
Expand Down
1 change: 1 addition & 0 deletions src/app/items.service.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface ItemDetail {
baseId: string;
name: string;
note: string;
resourcesLink?: string;
hostname: string;
environment: string;
plot: ItemDataPlot;
Expand Down
9 changes: 9 additions & 0 deletions src/app/scenario/add-new-item/add-new-item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ <h5 class="modal-title" id="modal-basic-title">Add test run</h5>
aria-describedby="inputGroup-sizing-default">
</div>

<div class="form-group mb-3">
<label for="resourcesLink">External Link</label>
<input type="hostname" id="resourcesLink" class="form-control" formControlName="resourcesLink" aria-label="Default"
aria-describedby="inputGroup-sizing-default">
<div class="form-control-feedback" *ngIf="resourcesLink.errors && (resourcesLink.dirty || resourcesLink.touched)">
<p class="form-validation-error" *ngIf="resourcesLink.errors.maxlenght">Link is too long. Max length is 350.</p>
</div>
</div>

<div class="form-group mb-3">
<label for="status">Status</label>
<select id="status" class="form-control custom-select" formControlName="status">
Expand Down
10 changes: 6 additions & 4 deletions src/app/scenario/add-new-item/add-new-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { ScenarioService } from "src/app/scenario.service";

})
export class AddNewItemComponent implements OnInit {
closeResult: string;
addItemForm: FormGroup;
kpiFile: FormControl;
monitoringFile: FormControl;
Expand All @@ -28,6 +27,7 @@ export class AddNewItemComponent implements OnInit {
status: FormControl;
hostname: FormControl;
name: FormControl;
resourcesLink: FormControl;
routeParams;
statuses = Object.values(ItemStatus);
DEFAULT_STATUS = ItemStatus.None;
Expand Down Expand Up @@ -67,6 +67,7 @@ export class AddNewItemComponent implements OnInit {
this.name = new FormControl("", [
Validators.maxLength(200)
])
this.resourcesLink = new FormControl("", [Validators.maxLength(350)])
}

createForm() {
Expand All @@ -77,7 +78,8 @@ export class AddNewItemComponent implements OnInit {
note: this.note,
hostname: this.hostname,
status: this.status,
name: this.name
name: this.name,
resourcesLink: this.resourcesLink
});
}

Expand All @@ -96,12 +98,12 @@ export class AddNewItemComponent implements OnInit {
this.formCheck();
if (this.addItemForm.valid) {
this.spinner.show();
const { kpiFile, errorFile, monitoringFile, environment, note, hostname, status, name } = this.addItemForm.value;
const { kpiFile, errorFile, monitoringFile, environment, note, hostname, status, name, resourcesLink } = this.addItemForm.value;
this.itemsApiService.addNewTestItem(
this.routeParams.projectName,
this.routeParams.scenarioName,
environment, note, hostname, ItemStatusValue[status],
kpiFile, name, errorFile, monitoringFile)
kpiFile, name, resourcesLink, errorFile, monitoringFile)
.pipe(catchError(r => of(r)))
.subscribe(_ => {
const message = this.notification.newTestItemNotificationMessage(_);
Expand Down
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 @@ -11,4 +11,5 @@ export interface ItemInput {
hostname?: string;
params: ItemParams;
name: string;
resourcesLink?: string;
}
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 @@ -17,6 +17,14 @@ <h5 class="modal-title" id="modal-basic-title">Edit test item</h5>
<input type="input" id="note" class="form-control" formControlName="note" aria-label="Default"
aria-describedby="inputGroup-sizing-default">
</div>
<div class="form-group mb-3">
<label for="resourcesLink">External Link</label>
<input type="input" id="resourcesLink" class="form-control" formControlName="resourcesLink" aria-label="Default"
aria-describedby="inputGroup-sizing-default">
<div class="form-control-feedback" *ngIf="resourcesLink.errors && (resourcesLink.dirty || resourcesLink.touched)">
<p class="form-validation-error" *ngIf="resourcesLink.errors.maxlength">Link is too long. Max length is 350.</p>
</div>
</div>
<div class="form-group mb-3">
<label for="environment">Environment <span class="text-danger">*</span></label>
<input type="testName" id="environment" class="form-control" formControlName="environment" aria-label="Default"
Expand Down
11 changes: 8 additions & 3 deletions src/app/shared/shared-item/edit-item/edit-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class EditItemComponent implements OnInit {
isBase;
disabled;
name;
resourcesLink;

@Input() reloadItems: boolean;
@Input() itemDetailData: ItemInput;
Expand Down Expand Up @@ -59,6 +60,8 @@ export class EditItemComponent implements OnInit {
this.name = new FormControl(this.itemDetailData.name, [
Validators.maxLength(200)
])
this.resourcesLink = new FormControl(this.itemDetailData.resourcesLink,
[Validators.maxLength(350)])
}

createForm() {
Expand All @@ -67,7 +70,8 @@ export class EditItemComponent implements OnInit {
environment: this.environment,
hostname: this.hostname,
base: this.base,
name: this.name
name: this.name,
resourcesLink: this.resourcesLink,
});
}

Expand All @@ -77,9 +81,10 @@ export class EditItemComponent implements OnInit {

onSubmit() {
if (this.myform.valid) {
const { note, environment, base, hostname, name } = this.myform.value;
const { note, environment, base, hostname, name, resourcesLink } = this.myform.value;
const { projectName, id, scenarioName } = this.itemDetailData.params;
this.itemsApiService.updateItemInfo(id, projectName, scenarioName, { environment, note, base, hostname, name })
this.itemsApiService.updateItemInfo(id, projectName, scenarioName,
{ environment, note, base, hostname, name, resourcesLink })
.pipe(catchError(r => of(r)))
.subscribe(_ => {
this.itemDetailChange.emit({ note, environment, hostname, name });
Expand Down

0 comments on commit 4cfe74c

Please sign in to comment.