Skip to content

Commit 5580bb8

Browse files
Profiler Teamcopybara-github
authored andcommitted
Add support for extra options in the capture profile dialog.
This change allows users to add arbitrary key-value pairs as extra options when initiating a profile capture. PiperOrigin-RevId: 813385389
1 parent 372a686 commit 5580bb8

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

frontend/app/components/capture_profile/capture_profile_dialog/capture_profile_dialog.ng.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@
116116
/>
117117
</mat-form-field>
118118
</div>
119+
120+
<div>
121+
Extra Options:
122+
<div *ngFor="let option of extraOptions; let i = index">
123+
<mat-form-field>
124+
<input matInput placeholder="Key" [(ngModel)]="option.key" />
125+
</mat-form-field>
126+
<mat-form-field>
127+
<input matInput placeholder="Value" [(ngModel)]="option.value" />
128+
</mat-form-field>
129+
<button mat-button (click)="removeExtraOption(i)">Remove</button>
130+
</div>
131+
<button mat-button (click)="addExtraOption()">Add Option</button>
132+
</div>
119133
</mat-expansion-panel>
120134
</div>
121135
</mat-dialog-content>

frontend/app/components/capture_profile/capture_profile_dialog/capture_profile_dialog.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class CaptureProfileDialog {
2424
deviceTracerLevel = '1';
2525
pythonTracerLevel = '0';
2626
delay = 0;
27+
extraOptions: Array<{key: string, value: string}> = [];
2728

2829
constructor(private readonly dialogRef:
2930
MatDialogRef<CaptureProfileDialog>) {}
@@ -37,7 +38,7 @@ export class CaptureProfileDialog {
3738
}
3839

3940
captureProfile() {
40-
this.dialogRef.close({
41+
const options: {[key: string]: string|number|boolean} = {
4142
serviceAddr: this.serviceAddr,
4243
isTpuName: this.isTpuName,
4344
duration: this.duration,
@@ -47,10 +48,24 @@ export class CaptureProfileDialog {
4748
deviceTracerLevel: Number(this.deviceTracerLevel),
4849
pythonTracerLevel: Number(this.pythonTracerLevel),
4950
delay: this.delay,
50-
});
51+
};
52+
53+
for (const option of this.extraOptions) {
54+
options[option.key] = option.value;
55+
}
56+
57+
this.dialogRef.close(options);
5158
}
5259

5360
close() {
5461
this.dialogRef.close();
5562
}
63+
64+
addExtraOption() {
65+
this.extraOptions.push({key: '', value: ''});
66+
}
67+
68+
removeExtraOption(index: number) {
69+
this.extraOptions.splice(index, 1);
70+
}
5671
}

0 commit comments

Comments
 (0)