Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Add runs overview page for admins #1238

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lamppu
Copy link
Contributor

@lamppu lamppu commented Oct 16, 2024

Add runs overview page for superusers to get a quick overview of the runs on the server instance.

Screenshot from 2024-10-16 09-32-01

Screenshot from 2024-10-16 09-32-30

Screenshot from 2024-10-16 09-33-17

Comment on lines 58 to 64
{['/', '/runs', '/create-organization'].includes(location.pathname) ? (
<PageLayout sections={sections}>
<Outlet />
</PageLayout>
) : (
<Outlet />
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done with the file-based routing instead.

Comment on lines 65 to 66
const columns: ColumnDef<OrtRunSummary>[] = [
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old tables use this syntax, but for new tables I'd use the column helper function which provides better type-safety.

Comment on lines 126 to 128
<div>
{new Date(row.original.createdAt).toLocaleString(navigator.language)}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is div needed here?

Comment on lines 137 to 141
<div>
{new Date(row.original.finishedAt).toLocaleString(navigator.language)}
</div>
) : (
<div className='italic'>Not finished yet</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are divs needed?

{new Date(row.original.createdAt).toLocaleString(navigator.language)}
</div>
),
size: 100,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for manually specifying the sizes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default min-width for a column is 150 px so it lowers that, so that some of the columns are a bit narrower and the columns fit on the current width that we have on the layout. I still changed it for a couple of the columns cause I noticed the table was actually still overflowing even though it looked ok.

size: 100,
},
{
accessorKey: 'duration',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably error with the column helpers mentioned, as I believe there is no duration in the returned object. I suggest reading https://tanstack.com/table/latest/docs/guide/column-defs#creating-accessor-columns for how the accessors work.

Comment on lines 323 to 329
await Promise.allSettled([
prefetchUseRunsServiceGetOrtRuns(context.queryClient, {
limit: pageSize || defaultPageSize,
offset: page ? (page - 1) * (pageSize || defaultPageSize) : 0,
status: status?.join(','),
}),
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use allSettled for one promise.

Comment on lines 22 to 24
export const Route = createFileRoute('/_layout/runs')({
component: () => <Outlet />,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required to be added?

@lamppu lamppu force-pushed the 801-add-runs-overview-page-for-admins branch from ba4cfb0 to 27cb98c Compare October 16, 2024 12:23
@lamppu lamppu requested a review from mmurto October 16, 2024 12:27
Only render the separator after a section if some of
the remaining sections are visible to the user.

Signed-off-by: Johanna Lamppu <johanna.lamppu@doubleopen.org>
Add toolbar that can be used with a data table to
show filter and reset buttons, and later on can be
extended to include other possible options to modify
a table with.

Signed-off-by: Johanna Lamppu <johanna.lamppu@doubleopen.org>
Add multivalue filter that can be used in the table
toolbar to allow filtering the data with provided
options.

Signed-off-by: Johanna Lamppu <johanna.lamppu@doubleopen.org>
@lamppu lamppu force-pushed the 801-add-runs-overview-page-for-admins branch from 27cb98c to 796a3aa Compare October 17, 2024 06:13
Comment on lines 148 to 150
<PageLayout sections={rootSections(user.hasRole(['superuser']))}>
<CreateOrganizationPage />
</PageLayout>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this sort of layout sharing should be done by creating a _adminSidebarLayout etc. directory in the current _layout directory, add a route.tsx there with the shared PageLayout with the same sections and move create-organization.tsx and index.tsx there (or handling it with file names like _adminSidebarLayout.route.tsx, _adminSidebarLayout.index.tsx and _adminSidebarLayout.create-organization.tsx directly in _layout directory). That ensures that all shared layouts are handled the same way, so no need to go through and process what rootSections() etc. do.

Here I however wonder whether we could and should just omit the sidebar sections from create-organization page? I think with the current amount of links in the sidebar, it's not really important to be able to select from those in there. As runs/index is also available only for superusers, should it maybe be under the admn route and have a link to it there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I understood it wrong then. Well, the thing is, if you omit it from the create organization page, then there will be this jump in the layout when accessing that page, so that's mainly why I would add it there.

As runs/index is also available only for superusers, should it maybe be under the admin route and have a link to it there?

So to move it to the admin dashboard? I figured this might be something that would be good to be more easily accessible from the front page, but I'm not sure. Or did you mean just change the link?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, I understood it wrong then. Well, the thing is, if you omit it from the create organization page, then there will be this jump in the layout when accessing that page, so that's mainly why I would add it there.

As runs/index is also available only for superusers, should it maybe be under the admin route and have a link to it there?

So to move it to the admin dashboard? I figured this might be something that would be good to be more easily accessible from the front page, but I'm not sure. Or did you mean just change the link?

Yeah exactly, move it to the admin dashboard, probably as a sub-page there. I think as it's a superuser functionality it doesn't really need to be that easily accessible from the front page.

Some layout jumping is totally fine if the pages have different layout. I think it also maybe doesn't make sense to show the sidebar on the front-page, as normal users see only one item there for the page that they're already on, so it provides no value for the regular user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly, move it to the admin dashboard, probably as a sub-page there.

Alright, I guess I'll change this to a draft for a bit and do some refactoring on the admin dashboard layout first to align it with the rest of the ui before adding this there.

@lamppu lamppu marked this pull request as draft October 17, 2024 10:02
Add a runs overview page to allow superusers to get
a quick overview of all runs on the server instance.

Signed-off-by: Johanna Lamppu <johanna.lamppu@doubleopen.org>
@lamppu lamppu force-pushed the 801-add-runs-overview-page-for-admins branch from 796a3aa to 6e8687c Compare October 17, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants