Sc 115 add pagination to all tables that do not have it#873
Sc 115 add pagination to all tables that do not have it#873nbeatty-gpa wants to merge 65 commits into
Conversation
9b18228 to
de09c01
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds pagination support across multiple SystemCenter UI tables (especially “info”/detail tabs) by wiring table views to paged search endpoints and introducing/using paged APIs on the backend where needed.
Changes:
- Add
<Paging />controls to many TSX table views and update sorting/page state handling. - Introduce/extend paged API endpoints for several resources (e.g., security group users, asset group members, asset connections/channels, location images).
- Extend Redux/EventChannel slice state to support paged results and update store typing setup.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/ValueListGroup/ValueListGroupItem.tsx | Adds paging and server-side sort/page flow for value list items. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/User/UserGroup/GroupUsers.tsx | Switches group user listing to a paged backend endpoint and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/User/UserGroup/ByUserGroup.tsx | Refactors to GenericController paged search and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/User/User/ByUser.tsx | Refactors to GenericController paged search and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Store/Store.ts | Updates store typing and reducer composition structure. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Store/EventChannelSlice.ts | Adds paged-search thunk/state/selectors for event channels. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/RemoteXDA/RemoteMeterTab.tsx | Adds paging support to remote meter table search results. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/RemoteXDA/RemoteAssetTab.tsx | Adds paging support to remote asset table search results. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Meter/MeterTrendChannel.tsx | Adds paging to trend channel table. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Meter/MeterEventChannel.tsx | Adds paging to event channel table using new paged slice data. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Meter/ChannelScaling/ChannelScalingForm.tsx | Adds client-side paging for scaling wrappers table. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Location/LocationImages.tsx | Adds paging UI for location image lists and updates API call shape. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/ExternalDB/ExternalDBTables.tsx | Adds paging UI and paged search for external DB tables listing. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/ExternalDB/ExternalDBTableFields.tsx | Moves additional-field table to paged backend query and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Customer/CustomerMeter.tsx | Switches customer meter listing to paged search and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Customer/CustomerAsset.tsx | Switches customer asset listing to paged search and adds paging UI. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/CommonComponents/ExternalDBUpdate.tsx | Updates UI message strings during external DB updates. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/ChannelGroup/ChannelGroupItem.tsx | Adds paging and server-side sort/page flow for channel group details. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AssetGroups/MeterAssetGroup.tsx | Adds paging UI and paged backend calls for meters in an asset group. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AssetGroups/ByAssetGroup.tsx | Adds paging UI and paged searching for asset group listing. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AssetGroups/AssetGroupAssetGroup.tsx | Adds paging UI and paged backend calls for subgroups in an asset group. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AssetGroups/AssetAssetGroup.tsx | Adds paging UI and paged backend calls for assets in an asset group. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Asset/AssetMeter.tsx | Adds paging UI and paged backend calls for meters tied to an asset. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Asset/AssetLocation.tsx | Adds paging UI and paged backend calls for locations tied to an asset. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Asset/AssetConnection.tsx | Adds paging UI and paged backend calls for asset connections. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/Asset/AssetChannel.tsx | Adds paging UI and paged backend calls for connected channels. |
| Source/Applications/SystemCenter/wwwroot/Scripts/TSX/SystemCenter/AdditionalFields/ByAdditionalField.tsx | Uses paged status/results and adds paging-aware sorting. |
| Source/Applications/SystemCenter/Model/Security/SecurityGroup.cs | Adds paged users endpoint for security groups. |
| Source/Applications/SystemCenter/Controllers/OpenXDA/OpenXDALocationController.cs | Adds paged location images endpoint and paging helper. |
| Source/Applications/SystemCenter/Controllers/OpenXDA/Assets/OpenXDAAssetController.cs | Adds paged endpoints for asset locations/meters/connections/channels. |
| Source/Applications/SystemCenter/Controllers/OpenXDA/AssetGroups/OpenXDAAssetGroupsController.cs | Adds paged endpoints for asset group members and subgroups. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1b6cf70 to
c9e499c
Compare
940fd43 to
c8adc11
Compare
| React.useEffect(() => { | ||
| if (status == 'uninitiated' || status == 'changed' || parentID != props.Record.ID) | ||
| dispatch(ValueListSlice.Fetch(props.Record.ID)); | ||
| }, [status, parentID, props.Record.ID]); | ||
| pagedSearch() | ||
| }, [pagedSearch, sortField, ascending, page, props.Record.ID]); |
There was a problem hiding this comment.
comment makes sense but the suggestion is unrelated, which is... interesting
There was a problem hiding this comment.
This is actually problemativ for another reason. IF pagedSearch ever change multiple Effects will fire off the same call, which is a potential problem. It also defeats the need for the cleanup function....
47f6bcf to
f155122
Compare
f155122 to
2f0ba8c
Compare
| React.useEffect(() => { | ||
| if (status == 'uninitiated' || status == 'changed' || parentID != props.Record.ID) | ||
| dispatch(ValueListSlice.Fetch(props.Record.ID)); | ||
| }, [status, parentID, props.Record.ID]); | ||
| pagedSearch() | ||
| }, [pagedSearch, sortField, ascending, page, props.Record.ID]); |
There was a problem hiding this comment.
This is actually problemativ for another reason. IF pagedSearch ever change multiple Effects will fire off the same call, which is a potential problem. It also defeats the need for the cleanup function....
| const pagedSearch = React.useCallback(() => { | ||
| const filters = [{ FieldName: "GroupID", SearchText: props.Record.ID.toString(), Operator: "=" as Search.OperatorType, IsPivotColumn: false, Type: "number" as Search.FieldType }]; | ||
| setStatus('loading') | ||
| const h = controller.PagedSearch(filters, sortField, ascending, page); | ||
| h.done((d) => { | ||
| setData(JSON.parse(d.Data as unknown as string)) | ||
| setTotalPages(d.NumberOfPages) | ||
| setStatus('idle') | ||
| }).fail((d) => { | ||
| setStatus('error') | ||
| }) | ||
| return () => { | ||
| if (h.abort != undefined) h.abort(); | ||
| } | ||
| }, [props.Record.ID, sortField, ascending, page, controller.PagedSearch]) |
There was a problem hiding this comment.
This is problematic per comment below. You probably should feed these things into the function as parameter and drop the whole callBack
| const parentID= useAppSelector(ValueListSlice.ParentID); | ||
|
|
||
| const [data, setData] = React.useState<SystemCenter.Types.ValueListItem[]>([]) | ||
| const parentID = useAppSelector(ValueListSlice.ParentID); |
There was a problem hiding this comment.
ParentID is used to ensure the slice loads the correct dataset. With the slice gone, you should not be using this anymore.
| import { useAppSelector, useAppDispatch } from '../hooks'; | ||
| import { SystemCenter, Application } from '@gpa-gemstone/application-typings'; | ||
| import { useAppSelector } from '../hooks'; | ||
| import { ValueListSlice } from '../Store/Store'; |
There was a problem hiding this comment.
most likely a change to Controllers allows you to drop the Slice completely,. Mixing slice and controllers is a potential recipe for issues, so I would double check all files and make sure they are really still needed.
| setUsers(_.orderBy(d, [sortField], asc ? 'asc' : 'desc')); | ||
| setStatus('idle'); | ||
| getUsers() |
There was a problem hiding this comment.
this defeats the use of cleanup functions.
| { ...newGroup, Name: ((newGroup.Name?.length ?? 0) > 0 ? newGroup.Name : newGroup.DisplayName) } | ||
| ) | ||
| setStatus('changed') | ||
| pagedSearch() |
There was a problem hiding this comment.
defeats the use of cleanup functions and most likely doesn't really grab the latest record since DBAction may not be done yet.
| </div>; | ||
|
|
||
| useBoundPaging(currentPage, totalPages, setPage) | ||
| const pagedSearch = React.useCallback(() => { |
There was a problem hiding this comment.
see other comments. This is not a great pattern to get into.
Adds pagination to tables, especially in "info" tabs
Jira Work Item(s)