Beautify link status.

editsong
Sander Vocke 5 years ago
parent e257c135be
commit 8d204a34e6
  1. 55
      client/src/components/windows/manage_links/LinksStatusWidget.tsx

@ -1,10 +1,10 @@
import { Box, Typography } from '@material-ui/core'; import { Box, LinearProgress, Typography } from '@material-ui/core';
import React, { useCallback, useEffect, useReducer, useState } from 'react'; import React, { useCallback, useEffect, useReducer, useState } from 'react';
import { $enum } from 'ts-enum-util'; import { $enum } from 'ts-enum-util';
import { ItemType, QueryElemProperty, QueryResponseType } from '../../../api'; import { ItemType, QueryElemProperty, QueryResponseType } from '../../../api';
import { queryItems } from '../../../lib/backend/queries'; import { queryItems } from '../../../lib/backend/queries';
import { QueryElem, QueryLeafBy, QueryLeafOp } from '../../../lib/query/Query'; import { QueryElem, QueryLeafBy, QueryLeafOp } from '../../../lib/query/Query';
import { ExternalStore, StoreURLIdentifiers } from '../../common/StoreLinkIcon'; import StoreLinkIcon, { ExternalStore, StoreURLIdentifiers } from '../../common/StoreLinkIcon';
var _ = require('lodash'); var _ = require('lodash');
@ -93,19 +93,46 @@ export default function LinksStatusWidget(props: {
return s in linkedCounts; return s in linkedCounts;
} }
return <> return <Box display="flex" flexDirection="column" alignItems="left">
<table>
{$enum(ExternalStore).getValues().map((s: ExternalStore) => { {$enum(ExternalStore).getValues().map((s: ExternalStore) => {
return <Box> if (!totalCounts) { return <></>; }
{totalCounts && storeReady(s) && <Box> if (!storeReady(s)) { return <></>; }
<Typography> let tot = totalCounts;
{s}:<br /> let lin = linkedCounts[s];
{linkedCounts[s].songs} / {totalCounts.songs} songs linked<br /> let perc = {
{linkedCounts[s].artists} / {totalCounts.artists} artists linked<br /> songs: Math.round((lin.songs || 0) / (tot.songs || 1) * 100),
{linkedCounts[s].albums} / {totalCounts.albums} albums linked<br /> artists: Math.round((lin.artists || 0) / (tot.artists || 1) * 100),
<br /> albums: Math.round((lin.albums || 0) / (tot.albums || 1) * 100),
</Typography> }
</Box>} return <>
{totalCounts && storeReady(s) && <>
<tr>
<td rowSpan={3}>
<Box display="flex" flexDirection="column" alignItems="center">
<StoreLinkIcon whichStore={s} />
<Typography>{s}</Typography>
</Box> </Box>
})} </td>
<td><Typography>Linked artists:</Typography></td>
<td><Box minWidth="200px"><LinearProgress variant="determinate" color="secondary" value={perc.artists} /></Box></td>
<td><Typography>{lin.artists} / {tot.artists}</Typography></td>
</tr>
<tr>
<td><Typography>Linked albums:</Typography></td>
<td><Box minWidth="200px"><LinearProgress variant="determinate" color="secondary" value={perc.albums} /></Box></td>
<td><Typography>{lin.albums} / {tot.albums}</Typography></td>
</tr>
<tr>
<td><Typography>Linked songs:</Typography></td>
<td><Box minWidth="200px"><LinearProgress variant="determinate" color="secondary" value={perc.songs} /></Box></td>
<td><Typography>{lin.songs} / {tot.songs}</Typography></td>
</tr>
<tr><td colSpan={4}>&nbsp;</td></tr>
</> </>
}
</>;
})}
</table>
</Box >
} }
Loading…
Cancel
Save