Skip to content

Commit c7ada40

Browse files
committed
add search text box for the pods table
1 parent ac7e101 commit c7ada40

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,6 @@ certs/
363363

364364
coverage.cobertura.xml
365365

366-
AzureDevOpsTeamMembersVelocity_*.log
366+
AzureDevOpsTeamMembersVelocity_*.log
367+
368+
.vscode/

AzureDevOpsTeamMembersVelocity/Pages/KubernetesDashboard.razor

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,29 @@
106106
<hr />
107107

108108
<div class="row">
109-
<button class="btn btn-primary"
110-
type="button"
111-
@onclick='() => Collapsing("collapsePods")'>
112-
Pods
113-
</button>
109+
<div class="col-1">
110+
<button class="btn btn-primary"
111+
type="button"
112+
@onclick='() => Collapsing("collapsePods")'>
113+
Pods
114+
</button>
115+
</div>
116+
<div class="col-11 @Settings.PodsCollapseClass">
117+
<div class="input-group mb-3">
118+
<input id="search-pods"
119+
type="text"
120+
class="form-control"
121+
placeholder="Search pods"
122+
@bind="SearchPods" />
123+
<div class="input-group-append">
124+
<button class="btn btn-outline-secondary"
125+
type="button"
126+
@onclick="() => ClearSearchPods()">
127+
Clear
128+
</button>
129+
</div>
130+
</div>
131+
</div>
114132
</div>
115133

116134
<div class="@Settings.PodsCollapseClass" id="collapsePods">
@@ -127,7 +145,7 @@
127145
</tr>
128146
</thead>
129147
<tbody>
130-
@foreach (var pod in Pods.Values)
148+
@foreach (var pod in Pods.Values.Where(p => SearchPods == "" || p.Name()?.Contains(SearchPods, StringComparison.InvariantCulture) == true))
131149
{
132150
var podNamespace = pod.Namespace();
133151
var podName = pod.Name();

AzureDevOpsTeamMembersVelocity/Pages/KubernetesDashboard.razor.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,5 +621,27 @@ public void Collapsing(string collapseId)
621621

622622
UserPreference.SetAsync(Settings);
623623
}
624+
625+
/// <summary>
626+
/// Property use to filter the pods table
627+
/// </summary>
628+
public string SearchPods {get;set;} = string.Empty;
629+
630+
/// <summary>
631+
/// Set the search pods property to empty string
632+
/// </summary>
633+
public void ClearSearchPods()
634+
{
635+
SearchPods = string.Empty;
636+
}
637+
638+
/// <summary>
639+
/// Append when user type in the search pods input
640+
/// </summary>
641+
public Task OnSearchPods(ChangeEventArgs args)
642+
{
643+
SearchPods = args.Value?.ToString() ?? string.Empty;
644+
return Task.CompletedTask;
645+
}
624646
}
625647
}

0 commit comments

Comments
 (0)