diff --git a/Server/Pages/_DataGrid.cshtml b/Server/Pages/_DataGrid.cshtml index f8f8c8c4..a2383280 100644 --- a/Server/Pages/_DataGrid.cshtml +++ b/Server/Pages/_DataGrid.cshtml @@ -5,7 +5,7 @@
-
diff --git a/Server/wwwroot/scripts/DataGrid.ts b/Server/wwwroot/scripts/DataGrid.ts index 29f2cc57..d7c0e693 100644 --- a/Server/wwwroot/scripts/DataGrid.ts +++ b/Server/wwwroot/scripts/DataGrid.ts @@ -65,7 +65,18 @@ export function AddOrUpdateDevice(device: Device) { }; UpdateDeviceCounts(); } -export function ApplyFilter(filterString: string) { +export function ApplyGroupFilter(groupID: string) { + for (var i = 0; i < DataSource.length; i++) { + var row = document.getElementById(DataSource[i].ID); + if (!groupID || DataSource[i].DeviceGroupID == groupID) { + row.classList.remove("hidden"); + } + else { + row.classList.add("hidden"); + } + } +} +export function ApplySearchFilter(filterString: string) { for (var i = 0; i < DataSource.length; i++) { for (var key in DataSource[i]) { var value = DataSource[i][key]; @@ -74,7 +85,7 @@ export function ApplyFilter(filterString: string) { } var row = document.getElementById(DataSource[i].ID); - if (DataSource[i][key].toString().toLowerCase().includes(filterString)) { + if (value.toString().toLowerCase().includes(filterString)) { row.classList.remove("hidden"); break; } diff --git a/Server/wwwroot/scripts/InputEventHandlers.ts b/Server/wwwroot/scripts/InputEventHandlers.ts index 3629a74c..45d1d7bd 100644 --- a/Server/wwwroot/scripts/InputEventHandlers.ts +++ b/Server/wwwroot/scripts/InputEventHandlers.ts @@ -15,6 +15,7 @@ export function ApplyInputEventHandlers() { clickToggleAllDevices(); clickStartRemoteControlButton(); consoleTabSelected(); + deviceGroupSelectChanged(); window.addEventListener("resize", ev => { PositionCommandCompletionWindow(); @@ -152,7 +153,7 @@ function inputOnCommandTextArea() { function inputOnFilterTextBox() { document.querySelector("#gridFilter").addEventListener("input", (e) => { var currentText = (e.currentTarget as HTMLInputElement).value.toLowerCase(); - DataGrid.ApplyFilter(currentText); + DataGrid.ApplySearchFilter(currentText); }) } function consoleTabSelected() { @@ -179,4 +180,10 @@ function clickStartRemoteControlButton() { WebCommands.find(x => x.Name == "RemoteControl").Execute([]); } }) +} + +function deviceGroupSelectChanged() { + UI.DeviceGroupSelect.addEventListener("change", (ev) => { + DataGrid.ApplyGroupFilter(UI.DeviceGroupSelect.value); + }); } \ No newline at end of file diff --git a/Server/wwwroot/scripts/UI.ts b/Server/wwwroot/scripts/UI.ts index 067b4a3e..209b6a2c 100644 --- a/Server/wwwroot/scripts/UI.ts +++ b/Server/wwwroot/scripts/UI.ts @@ -18,6 +18,7 @@ export var TabContentWrapper = document.getElementById("tabContentWrapper") as H export var ConsoleFrame = document.getElementById("consoleFrame") as HTMLDivElement; export var ConsoleTab = document.getElementById("consoleTab") as HTMLAnchorElement; export var ConsoleAlert = document.getElementById("consoleAlert") as HTMLAnchorElement; +export var DeviceGroupSelect = document.getElementById("deviceGroupSelect") as HTMLSelectElement; export function AddConsoleOutput(strOutputMessage:string) {