Update app/bot pages, fix sorting.

This commit is contained in:
Ashwin Phatak 2020-07-28 15:51:35 +05:30
parent c760a55ae6
commit a3df29c729
4 changed files with 24 additions and 20 deletions

View File

@ -11,7 +11,7 @@ import { getServiceUrl } from '../util/config';
const QUERY = ` const QUERY = `
query { query {
getRecordsByIds([ "%ID%" ]) { getRecordsByIds(ids: [ "%ID%" ]) {
id id
names names
bondId bondId

View File

@ -25,7 +25,7 @@ const AppRecords = () => {
const [sorter, sortBy] = useSorter('createTime', false); const [sorter, sortBy] = useSorter('createTime', false);
const appResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, { const appResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
pollInterval: config.api.intervalQuery, pollInterval: config.api.intervalQuery,
variables: { attributes: { type: 'wrn:app' } } variables: { attributes: { type: 'app' } }
})); }));
// TODO(telackey): Does this also need an interval? // TODO(telackey): Does this also need an interval?
@ -42,22 +42,26 @@ const AppRecords = () => {
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell onClick={sortBy('name')}>Identifier</TableCell> <TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell> <TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell> <TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell> <TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell size='icon' /> <TableCell size='icon' />
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{appData.sort(sorter).map(({ id, name, version, createTime, attributes: { displayName, package: hash } }) => { {appData.sort(sorter).map(({ id, names, createTime, attributes: { name: displayName, version, package: hash } }) => {
return ( return (
<TableRow key={id} size='small'> <TableRow key={id} size='small'>
<TableCell monospace> <TableCell monospace>
{names.map(name => <>
<AppLink config={config} name={name} /> <AppLink config={config} name={name} />
<br />
</>
)}
</TableCell> </TableCell>
<TableCell monospace> <TableCell monospace>
<AppLink config={config} name={name} version={version} text={version} /> {version}
</TableCell> </TableCell>
<TableCell> <TableCell>
{displayName} {displayName}

View File

@ -22,7 +22,7 @@ const BotRecords = () => {
const [sorter, sortBy] = useSorter('createTime', false); const [sorter, sortBy] = useSorter('createTime', false);
const data = useQueryStatusReducer(useQuery(WNS_RECORDS, { const data = useQueryStatusReducer(useQuery(WNS_RECORDS, {
pollInterval: config.api.intervalQuery, pollInterval: config.api.intervalQuery,
variables: { attributes: { type: 'wrn:bot' } } variables: { attributes: { type: 'bot' } }
})); }));
if (!data) { if (!data) {
@ -35,18 +35,18 @@ const BotRecords = () => {
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell onClick={sortBy('name')}>Identifier</TableCell> <TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell> <TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell> <TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell> <TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell size='icon' /> <TableCell size='icon' />
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{records.sort(sorter).map(({ id, name, version, createTime, attributes: { displayName } }) => { {records.sort(sorter).map(({ id, names, createTime, attributes: { name: displayName, version } }) => {
return ( return (
<TableRow key={id} size='small'> <TableRow key={id} size='small'>
<TableCell monospace>{name}</TableCell> <TableCell monospace>{names}</TableCell>
<TableCell monospace>{version}</TableCell> <TableCell monospace>{version}</TableCell>
<TableCell>{displayName}</TableCell> <TableCell>{displayName}</TableCell>
<TableCell>{moment.utc(createTime).fromNow()}</TableCell> <TableCell>{moment.utc(createTime).fromNow()}</TableCell>

View File

@ -83,12 +83,12 @@ const WNSRecords = ({ type }) => {
<Table> <Table>
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell onClick={sortBy('type')} size='medium'>Type</TableCell> <TableCell onClick={sortBy('attributes.type')} size='medium'>Type</TableCell>
<TableCell onClick={sortBy('name')}>Identifier</TableCell> <TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
<TableCell onClick={sortBy('version')} size='small'>Version</TableCell> <TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
<TableCell onClick={sortBy('attributes.displayName')}>Name</TableCell> <TableCell onClick={sortBy('attributes.name')}>Name</TableCell>
<TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell> <TableCell onClick={sortBy('createTime')} size='small'>Created</TableCell>
<TableCell onClick={sortBy('package')}>Package</TableCell> <TableCell onClick={sortBy('attributes.package')}>Package</TableCell>
<TableCell size='icon' /> <TableCell size='icon' />
</TableRow> </TableRow>
</TableHead> </TableHead>
@ -135,7 +135,7 @@ const WNSRecords = ({ type }) => {
{pkgLink} {pkgLink}
</TableCell> </TableCell>
<TableCell> <TableCell>
<QueryLink config={config} name={name} icon /> <QueryLink config={config} id={id} icon />
</TableCell> </TableCell>
</TableRow> </TableRow>
); );