Fixes for package and app links, service type names (likely to change).
This commit is contained in:
parent
ba4de7d1b7
commit
4779ffa804
@ -8,7 +8,7 @@ import Link from '@material-ui/core/Link';
|
|||||||
|
|
||||||
import { getServiceUrl } from '../util/config';
|
import { getServiceUrl } from '../util/config';
|
||||||
|
|
||||||
const getAppUrl = (config, { name, version }) => {
|
const getAppUrl = (config, { wrn }) => {
|
||||||
const base = getServiceUrl(config, 'app.server');
|
const base = getServiceUrl(config, 'app.server');
|
||||||
const pathComponents = [base];
|
const pathComponents = [base];
|
||||||
|
|
||||||
@ -21,11 +21,7 @@ const getAppUrl = (config, { name, version }) => {
|
|||||||
pathComponents.push(prefix.substring(1));
|
pathComponents.push(prefix.substring(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version) {
|
pathComponents.push(encodeURIComponent(wrn));
|
||||||
pathComponents.push(`${name}@${version}`);
|
|
||||||
} else {
|
|
||||||
pathComponents.push(name);
|
|
||||||
}
|
|
||||||
return `${pathComponents.join('/')}/`;
|
return `${pathComponents.join('/')}/`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,11 +30,10 @@ const getAppUrl = (config, { name, version }) => {
|
|||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {string} [text]
|
* @param {string} [text]
|
||||||
* @param {string} [version]
|
|
||||||
*/
|
*/
|
||||||
const AppLink = ({ config, name, version, text }) => {
|
const AppLink = ({ config, wrn, text }) => {
|
||||||
const fullURL = getAppUrl(config, { name, version });
|
const fullURL = getAppUrl(config, { wrn });
|
||||||
return <Link href={fullURL} target={name}>{text || name}</Link>;
|
return <Link href={fullURL} target={wrn}>{text || wrn}</Link>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AppLink;
|
export default AppLink;
|
||||||
|
@ -15,19 +15,18 @@ import { getServiceUrl } from '../util/config';
|
|||||||
* @param {string} [text]
|
* @param {string} [text]
|
||||||
*/
|
*/
|
||||||
const PackageLink = ({ config, type, pkg, text }) => {
|
const PackageLink = ({ config, type, pkg, text }) => {
|
||||||
// TODO(burdon): Pass in expected arg types.
|
|
||||||
if (typeof pkg === 'string') {
|
|
||||||
const ipfsUrl = getServiceUrl(config, 'ipfs.gateway', { path: `${pkg}` });
|
|
||||||
return <Link href={ipfsUrl} key={pkg} target={pkg}>{text || pkg}</Link>;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line default-case
|
// eslint-disable-next-line default-case
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'bot': {
|
case 'wrn://dxos/type/application/web': {
|
||||||
|
const cid = pkg['/'];
|
||||||
|
const ipfsUrl = getServiceUrl(config, 'ipfs.gateway', { path: `${cid}` });
|
||||||
|
return <Link href={ipfsUrl} key={cid} target={cid}>{text || cid}</Link>;
|
||||||
|
}
|
||||||
|
case 'wrn://dxos/type/application/bot': {
|
||||||
const packageLinks = [];
|
const packageLinks = [];
|
||||||
Object.keys(pkg).forEach((platform, i) => {
|
Object.keys(pkg).forEach((platform, i) => {
|
||||||
Object.keys(pkg[platform]).forEach(arch => {
|
Object.keys(pkg[platform]).forEach(arch => {
|
||||||
const cid = pkg[platform][arch];
|
const cid = pkg[platform][arch]['/'];
|
||||||
const ipfsUrl = getServiceUrl(config, 'ipfs.gateway', { path: `${cid}` });
|
const ipfsUrl = getServiceUrl(config, 'ipfs.gateway', { path: `${cid}` });
|
||||||
packageLinks.push(
|
packageLinks.push(
|
||||||
<div>
|
<div>
|
||||||
|
@ -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: 'app' } }
|
variables: { attributes: { type: 'wrn://dxos/type/application/web' } }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// TODO(telackey): Does this also need an interval?
|
// TODO(telackey): Does this also need an interval?
|
||||||
@ -42,7 +42,7 @@ const AppRecords = () => {
|
|||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
|
<TableCell onClick={sortBy('names[0]')}>Registered Names</TableCell>
|
||||||
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
|
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
|
||||||
<TableCell onClick={sortBy('attributes.name')}>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>
|
||||||
@ -54,8 +54,8 @@ const AppRecords = () => {
|
|||||||
return (
|
return (
|
||||||
<TableRow key={id} size='small'>
|
<TableRow key={id} size='small'>
|
||||||
<TableCell monospace>
|
<TableCell monospace>
|
||||||
{names.map(name => <>
|
{names.map(wrn => <>
|
||||||
<AppLink config={config} name={name} />
|
<AppLink config={config} wrn={wrn} />
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -20,8 +20,7 @@ import Table from '../../../components/Table';
|
|||||||
import TableCell from '../../../components/TableCell';
|
import TableCell from '../../../components/TableCell';
|
||||||
import { BooleanIcon } from '../../../components/BooleanIcon';
|
import { BooleanIcon } from '../../../components/BooleanIcon';
|
||||||
|
|
||||||
const RECORD_TYPE = 'wrn:service';
|
const RECORD_TYPE = 'wrn://dxos/type/service/ipfs';
|
||||||
const SERVICE_TYPE = 'ipfs';
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
tableContainer: {
|
tableContainer: {
|
||||||
@ -70,7 +69,7 @@ const IPFSStatus = () => {
|
|||||||
|
|
||||||
const ipfsResponse = useQueryStatusReducer(useQuery(IPFS_STATUS));
|
const ipfsResponse = useQueryStatusReducer(useQuery(IPFS_STATUS));
|
||||||
const wnsResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
|
const wnsResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
|
||||||
variables: { attributes: { type: RECORD_TYPE, service: SERVICE_TYPE } }
|
variables: { attributes: { type: RECORD_TYPE } }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!wnsResponse || !ipfsResponse) {
|
if (!wnsResponse || !ipfsResponse) {
|
||||||
@ -78,10 +77,10 @@ const IPFSStatus = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ipfsData = JSON.parse(ipfsResponse.ipfs_status.json);
|
const ipfsData = JSON.parse(ipfsResponse.ipfs_status.json);
|
||||||
const registeredServers = JSON.parse(wnsResponse.wns_records.json);
|
const registeredServers = JSON.parse(wnsResponse.wns_records.json).filter(record => get(record, 'attributes.active') !== false);
|
||||||
|
|
||||||
const displayServers = registeredServers.map((service) => {
|
const displayServers = registeredServers.map((service) => {
|
||||||
const addresses = get(service, 'attributes.ipfs.addresses');
|
const addresses = get(service, 'attributes.addresses');
|
||||||
let connected = false;
|
let connected = false;
|
||||||
for (const address of addresses) {
|
for (const address of addresses) {
|
||||||
const parts = address.split('/');
|
const parts = address.split('/');
|
||||||
@ -93,10 +92,9 @@ const IPFSStatus = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: get(service, 'name'),
|
...service.attributes,
|
||||||
|
names: get(service, 'names'),
|
||||||
version: get(service, 'version'),
|
version: get(service, 'version'),
|
||||||
description: get(service, 'attributes.description'),
|
|
||||||
ipfs: get(service, 'attributes.ipfs'),
|
|
||||||
connected
|
connected
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -115,19 +113,19 @@ const IPFSStatus = () => {
|
|||||||
<Table stickyHeader size='small' className={classes.table}>
|
<Table stickyHeader size='small' className={classes.table}>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell>Identifier</TableCell>
|
<TableCell>Registered Names</TableCell>
|
||||||
<TableCell size='medium'>Description</TableCell>
|
<TableCell size='medium'>Description</TableCell>
|
||||||
<TableCell>Address</TableCell>
|
<TableCell>Address</TableCell>
|
||||||
<TableCell size='small'>Connected</TableCell>
|
<TableCell size='small'>Connected</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{displayServers.map(({ name, description, ipfs, connected }) => (
|
{displayServers.map(({ names, description, addresses, connected }) => (
|
||||||
<TableRow key={name}>
|
<TableRow key={names}>
|
||||||
<TableCell>{name}</TableCell>
|
<TableCell>{names.map(name => <>{name}<br /></>)}</TableCell>
|
||||||
<TableCell>{description}</TableCell>
|
<TableCell>{description}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{ipfs.addresses}
|
{addresses}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<BooleanIcon yes={connected} />
|
<BooleanIcon yes={connected} />
|
||||||
|
@ -25,13 +25,16 @@ import AppLink from '../../../components/AppLink';
|
|||||||
|
|
||||||
const types = [
|
const types = [
|
||||||
{ key: null, label: 'ALL' },
|
{ key: null, label: 'ALL' },
|
||||||
{ key: 'kube', label: 'Kube' },
|
{ key: 'wrn://dxos/type/application/web', label: 'App' },
|
||||||
{ key: 'resource', label: 'Resource' },
|
{ key: 'wrn://dxos/type/application/bot', label: 'Bot' },
|
||||||
{ key: 'service', label: 'Service' },
|
{ key: 'wrn://dxos/type/device/kube', label: 'Kube' },
|
||||||
{ key: 'app', label: 'App' },
|
{ key: 'wrn://dxos/type/service/bot-factory', label: 'Bot Factory' },
|
||||||
{ key: 'bot', label: 'Bot' },
|
{ key: 'wrn://dxos/type/service/ipfs', label: 'IPFS' },
|
||||||
{ key: 'bot-factory', label: 'Bot Factory' },
|
{ key: 'wrn://dxos/type/service/ipfs-gateway', label: 'IPFS Gateway' },
|
||||||
{ key: 'type', label: 'Type' }
|
{ key: 'wrn://dxos/type/service/signal', label: 'Signal' },
|
||||||
|
{ key: 'wrn://dxos/type/service/stun', label: 'STUN' },
|
||||||
|
{ key: 'wrn://dxos/type/service/turn', label: 'TURN' },
|
||||||
|
{ key: 'type', label: 'Type' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
@ -84,7 +87,7 @@ const WNSRecords = ({ type }) => {
|
|||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell onClick={sortBy('attributes.type')} size='medium'>Type</TableCell>
|
<TableCell onClick={sortBy('attributes.type')} size='medium'>Type</TableCell>
|
||||||
<TableCell onClick={sortBy('names[0]')}>Identifier</TableCell>
|
<TableCell onClick={sortBy('names[0]')}>Registered Names</TableCell>
|
||||||
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
|
<TableCell onClick={sortBy('attributes.version')} size='small'>Version</TableCell>
|
||||||
<TableCell onClick={sortBy('attributes.name')}>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>
|
||||||
@ -104,11 +107,11 @@ const WNSRecords = ({ type }) => {
|
|||||||
pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />);
|
pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'app') {
|
if (type === 'wrn://dxos/type/application/web') {
|
||||||
appLinks = (
|
appLinks = (
|
||||||
<>
|
<>
|
||||||
{names.map(name => <>
|
{names.map(wrn => <>
|
||||||
<AppLink config={config} name={name} />
|
<AppLink config={config} wrn={wrn} />
|
||||||
<br />
|
<br />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"name": "@dxos/console-app",
|
"name": "@dxos/console-app",
|
||||||
"buildDate": "2020-07-21T20:40:54.153Z",
|
"buildDate": "2020-08-18T23:14:12.669Z",
|
||||||
"version": "1.0.0-beta.22"
|
"version": "1.0.0-beta.24"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user