Skip to content

Commit

Permalink
feat: Executions sorting (#885)
Browse files Browse the repository at this point in the history
* feat: Executions sorting

* Restore the necessary code to sort executions datagrid.
* Only sort by some fields

* Update assets
  • Loading branch information
Victor Castell committed Jan 7, 2021
1 parent 50db5aa commit 31df1ae
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 82 deletions.
130 changes: 65 additions & 65 deletions dkron/assets_ui/assets_vfsdata.go

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions ui/src/dataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { fetchUtils } from 'ra-core';
import jsonServerProvider from 'ra-data-json-server';
import { stringify } from 'query-string';

export const apiUrl = window.DKRON_API_URL || 'http://localhost:8080/v1'
const dataProvider = jsonServerProvider(apiUrl);

const myDataProvider = {
...dataProvider,
getManyReference: (resource: any, params: any) => {
// Commented because executions query do not accept any query options yet

// const { page, perPage } = params.pagination;
// const { field, order } = params.sort;
const { page, perPage } = params.pagination;
const { field, order } = params.sort;

// const query = {
// ...fetchUtils.flattenObject(params.filter),
// [params.target]: params.id,
// _sort: field,
// _order: order,
// _start: (page - 1) * perPage,
// _end: page * perPage,
// };
const url = `${apiUrl}/${params.target}/${params.id}/${resource}`;
const query = {
...fetchUtils.flattenObject(params.filter),
[params.target]: params.id,
_sort: field,
_order: order,
_start: (page - 1) * perPage,
_end: page * perPage,
};
const url = `${apiUrl}/${params.target}/${params.id}/${resource}?${stringify(query)}`;

return fetchUtils.fetchJson(url).then(({ headers, json }) => {
if (!headers.has('x-total-count')) {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/jobs/JobShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ const JobShow = (props: any) => (
<ReferenceManyField reference="executions" target="jobs" label="Executions">
<Datagrid rowClick="expand" isRowSelectable={ record => false } expand={<OutputPanel {...props} />}>
<TextField source="id" />
<TextField source="group" />
<TextField source="job_name" />
<TextField source="group" sortable={false} />
<TextField source="job_name" sortable={false} />
<DateField source="started_at" showTime />
<DateField source="finished_at" showTime />
<TextField source="node_name" />
<BooleanField source="success" />
<TextField source="node_name" sortable={false} />
<BooleanField source="success" sortable={false} />
<NumberField source="attempt" />
</Datagrid>
</ReferenceManyField>
Expand Down

0 comments on commit 31df1ae

Please sign in to comment.