From 9303f4d2744d5ad7a84fd9af4e60f82a0feb4f26 Mon Sep 17 00:00:00 2001 From: thom776g Date: Thu, 7 Dec 2023 09:18:39 +0100 Subject: [PATCH] Renaming of badly named variables --- CentralHub.WebUI/Pages/Rooms.razor | 126 ++++++++++++++--------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/CentralHub.WebUI/Pages/Rooms.razor b/CentralHub.WebUI/Pages/Rooms.razor index d88852f..d6bf5a0 100644 --- a/CentralHub.WebUI/Pages/Rooms.razor +++ b/CentralHub.WebUI/Pages/Rooms.razor @@ -15,7 +15,7 @@

This component demonstrates fetching data from a service.

-@if (_treeRoomItems == null) +@if (_wRooms == null) {

Loading... @@ -28,29 +28,29 @@ else - @foreach (var item in _treeRoomItems) + @foreach (var wRoom in _wRooms) { - @if (item.IsExpanded) + @if (wRoom.IsExpanded) {
- @item.ItemsRoom.Name + @wRoom.Room.Name
- - - - + + + +
- @foreach (var tracker in item.Children) + @foreach (var tracker in wRoom.Children) { @@ -143,7 +143,7 @@ else @@ -161,9 +161,9 @@ else @@ -205,9 +205,9 @@ else @@ -270,9 +270,9 @@ else @@ -296,7 +296,7 @@ else @@ -307,9 +307,9 @@ else @code { private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); private List _rooms = new List(); - private List _treeRoomItems = new List(); + private List _wRooms = new List(); private UnregisteredTracker[] _unregisteredTrackers = new UnregisteredTracker[0]; - private TreeItem? _selectedRoomItem; + private RoomWrapper? _selectedWRoom; private Tracker? _selectedTracker; private int _selectedRoomId = -1; private String _roomName = "Your room name"; @@ -338,14 +338,14 @@ else } } - async Task EditRoomModal(TreeItem item) + async Task EditRoomModal(RoomWrapper wRoom) { - if(item != null) + if(wRoom != null) { - _selectedRoomItem = item; - _roomName = _selectedRoomItem!.ItemsRoom.Name; - _roomDescription = _selectedRoomItem.ItemsRoom.Description; - item!.TrackerCount = await GetTrackerCountAsync(item.ItemsRoom); + _selectedWRoom = wRoom; + _roomName = _selectedWRoom!.Room.Name; + _roomDescription = _selectedWRoom.Room.Description; + wRoom!.TrackerCount = await GetTrackerCountAsync(wRoom.Room); await ShowModal("editRoomModal"); StateHasChanged(); } @@ -355,11 +355,11 @@ else } } - async Task DeleteRoomModal(TreeItem item) + async Task DeleteRoomModal(RoomWrapper wRoom) { - if(item != null) + if(wRoom != null) { - await DeleteRoom(item!); + await DeleteRoom(wRoom!); await HideModal("editRoomModal"); StateHasChanged(); } @@ -369,15 +369,15 @@ else } } - async Task ConfirmEditRoom(TreeItem item, String name, String description) + async Task ConfirmEditRoom(RoomWrapper wRoom, String name, String description) { - if(item != null && name != "" && name != null) + if(wRoom != null && name != "" && name != null) { - await RoomService.UpdateRoomAsync(item!.ItemsRoom, name!, description, _cancellationTokenSource.Token); + await RoomService.UpdateRoomAsync(wRoom!.Room, name!, description, _cancellationTokenSource.Token); await HideModal("editRoomModal"); NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true); } - else if(item == null) + else if(wRoom == null) { await JSRuntime.InvokeVoidAsync("alert", "Room is null"); } @@ -387,12 +387,12 @@ else } } - async Task AddTrackerModal(TreeItem item) + async Task AddTrackerModal(RoomWrapper wRoom) { - if(item != null) + if(wRoom != null) { - _selectedRoomItem = item; - _selectedRoomId = item!.ItemsRoom.RoomId; + _selectedWRoom = wRoom; + _selectedRoomId = wRoom!.Room.RoomId; _unregisteredTrackers = await TrackerService.GetUnregisteredTrackersAsync(_cancellationTokenSource.Token); _selectedTrackerMacAdress = _unregisteredTrackers[0].WifiMacAddress; await ShowModal("addTrackerModal"); @@ -428,19 +428,19 @@ else } } - async Task EditTrackerModal(TreeItem item, Tracker tracker) + async Task EditTrackerModal(RoomWrapper wRoom, Tracker tracker) { - if(item != null && tracker != null) + if(wRoom != null && tracker != null) { - _selectedRoomItem = item; - _selectedRoomId = item!.ItemsRoom.RoomId; + _selectedWRoom = wRoom; + _selectedRoomId = wRoom!.Room.RoomId; _selectedTracker = tracker; _trackerName = tracker!.Name; _trackerDescription = tracker.Description; await ShowModal("editTrackerModal"); StateHasChanged(); } - else if(item == null) + else if(wRoom == null) { await JSRuntime.InvokeVoidAsync("alert", "Room is null"); } @@ -473,15 +473,15 @@ else } } - async Task DeleteTrackerModal(TreeItem item, Tracker tracker) + async Task DeleteTrackerModal(RoomWrapper wRoom, Tracker tracker) { - if(item != null && tracker != null) + if(wRoom != null && tracker != null) { - await DeleteTracker(item!, tracker!); + await DeleteTracker(wRoom!, tracker!); await HideModal("editTrackerModal"); StateHasChanged(); } - else if(item == null) + else if(wRoom == null) { await JSRuntime.InvokeVoidAsync("alert", "Room is null"); } @@ -491,15 +491,15 @@ else } } - protected class TreeItem + protected class RoomWrapper { - public TreeItem(Room room, Tracker[] children, bool isExpanded = false) + public RoomWrapper(Room room, Tracker[] children, bool isExpanded = false) { - ItemsRoom = room; + Room = room; Children = children; TrackerCount = children.Length; } - public Room ItemsRoom { get; set; } + public Room Room { get; set; } public Tracker[] Children { get; set; } public int TrackerCount { get; set; } public bool IsExpanded { get; set; } @@ -510,15 +510,15 @@ else _rooms = (await RoomService.GetRoomsAsync(_cancellationTokenSource.Token)).ToList(); _unregisteredTrackers = await TrackerService.GetUnregisteredTrackersAsync(_cancellationTokenSource.Token); - List treeItems = new List(); + List RoomWrappers = new List(); foreach (var room in _rooms) { - treeItems.Add(new TreeItem( + RoomWrappers.Add(new RoomWrapper( room, await TrackerService.GetTrackersAsync(room, _cancellationTokenSource.Token) )); } - _treeRoomItems = treeItems; + _wRooms = RoomWrappers; AssignStandardValues(); } private async Task GetTrackerCountAsync(Room room) @@ -528,24 +528,24 @@ else return trackers.Length; } - protected async Task DeleteRoom(TreeItem item) + protected async Task DeleteRoom(RoomWrapper wRoom) { // Remove the room on the server - await RoomService.RemoveRoomAsync(item.ItemsRoom, _cancellationTokenSource.Token); + await RoomService.RemoveRoomAsync(wRoom.Room, _cancellationTokenSource.Token); // Remove the room in memory - _rooms!.Remove(item.ItemsRoom); - _treeRoomItems!.Remove(item); + _rooms!.Remove(wRoom.Room); + _wRooms!.Remove(wRoom); StateHasChanged(); } - protected async Task DeleteTracker(TreeItem item, Tracker tracker) + protected async Task DeleteTracker(RoomWrapper wRoom, Tracker tracker) { // Remove the tracker on the server await TrackerService.RemoveTrackerAsync(tracker, _cancellationTokenSource.Token); // Remove the tracker in memory - Tracker[] newTrackers = await TrackerService.GetTrackersAsync(item.ItemsRoom, _cancellationTokenSource.Token); - item.Children = newTrackers; + Tracker[] newTrackers = await TrackerService.GetTrackersAsync(wRoom.Room, _cancellationTokenSource.Token); + wRoom.Children = newTrackers; StateHasChanged(); } @@ -556,9 +556,9 @@ else _cancellationTokenSource.Dispose(); } -void ToggleNode(TreeItem item) +void ToggleNode(RoomWrapper wRoom) { - item.IsExpanded = !item.IsExpanded; + wRoom.IsExpanded = !wRoom.IsExpanded; } async Task HideModal(String modalId) @@ -575,7 +575,7 @@ async Task HideModal(String modalId) void AssignStandardValues() { - _selectedRoomItem = null; + _selectedWRoom = null; _selectedTracker = null; _selectedRoomId = -1;
@@ -59,7 +59,7 @@ else
- +
- @_selectedRoomItem?.TrackerCount + @_selectedWRoom?.TrackerCount