forked from cerc-io/laconic-console
Merge pull request #42 from dxos/ashwinp-wrn-naming-changes
WRN & Naming changes
This commit is contained in:
commit
ba4de7d1b7
@ -23,7 +23,7 @@ const PackageLink = ({ config, type, pkg, text }) => {
|
|||||||
|
|
||||||
// eslint-disable-next-line default-case
|
// eslint-disable-next-line default-case
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'wrn:bot': {
|
case '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 => {
|
||||||
|
@ -11,10 +11,9 @@ import { getServiceUrl } from '../util/config';
|
|||||||
|
|
||||||
const QUERY = `
|
const QUERY = `
|
||||||
query {
|
query {
|
||||||
queryRecords(attributes: [{ key: "name", value: { string: "%NAME%" } }]) {
|
getRecordsByIds(ids: [ "%ID%" ]) {
|
||||||
id
|
id
|
||||||
type
|
names
|
||||||
name
|
|
||||||
bondId
|
bondId
|
||||||
createTime
|
createTime
|
||||||
expiryTime
|
expiryTime
|
||||||
@ -33,13 +32,13 @@ const QUERY = `
|
|||||||
/**
|
/**
|
||||||
* Render link to record in WNS.
|
* Render link to record in WNS.
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {string} name
|
* @param {string} id
|
||||||
* @param {string} [text]
|
* @param {string} [text]
|
||||||
* @param {boolean} icon
|
* @param {boolean} icon
|
||||||
*/
|
*/
|
||||||
const QueryLink = ({ config, name, text, icon = false }) => {
|
const QueryLink = ({ config, id, text, icon = false }) => {
|
||||||
const baseURL = getServiceUrl(config, 'wns.webui');
|
const baseURL = getServiceUrl(config, 'wns.webui');
|
||||||
const query = QUERY.replace('%NAME%', name);
|
const query = QUERY.replace('%ID%', id);
|
||||||
|
|
||||||
// NOTE: Playground bug opens two tabs.
|
// NOTE: Playground bug opens two tabs.
|
||||||
const fullURL = encodeURI(`${baseURL}?query=${query}`);
|
const fullURL = encodeURI(`${baseURL}?query=${query}`);
|
||||||
@ -50,7 +49,7 @@ const QueryLink = ({ config, name, text, icon = false }) => {
|
|||||||
<LinkIcon />
|
<LinkIcon />
|
||||||
)}
|
)}
|
||||||
{!icon && (
|
{!icon && (
|
||||||
text || name
|
text || id
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
@ -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>
|
||||||
<AppLink config={config} name={name} />
|
{names.map(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}
|
||||||
|
@ -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>
|
||||||
|
@ -25,13 +25,13 @@ import AppLink from '../../../components/AppLink';
|
|||||||
|
|
||||||
const types = [
|
const types = [
|
||||||
{ key: null, label: 'ALL' },
|
{ key: null, label: 'ALL' },
|
||||||
{ key: 'wrn:kube', label: 'Kube' },
|
{ key: 'kube', label: 'Kube' },
|
||||||
{ key: 'wrn:resource', label: 'Resource' },
|
{ key: 'resource', label: 'Resource' },
|
||||||
{ key: 'wrn:service', label: 'Service' },
|
{ key: 'service', label: 'Service' },
|
||||||
{ key: 'wrn:app', label: 'App' },
|
{ key: 'app', label: 'App' },
|
||||||
{ key: 'wrn:bot', label: 'Bot' },
|
{ key: 'bot', label: 'Bot' },
|
||||||
{ key: 'wrn:bot-factory', label: 'Bot Factory' },
|
{ key: 'bot-factory', label: 'Bot Factory' },
|
||||||
{ key: 'wrn:type', label: 'Type' }
|
{ key: 'type', label: 'Type' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
@ -83,41 +83,47 @@ 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>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{records.sort(sorter)
|
{records.sort(sorter)
|
||||||
.map((record) => {
|
.map((record) => {
|
||||||
const { id, type, name, version, createTime, attributes: { displayName, description, service, package: pkg } } = record;
|
const { id, names, createTime, attributes: { type, name: displayName, version, description, service, package: pkg } } = record;
|
||||||
|
|
||||||
let pkgLink;
|
let pkgLink;
|
||||||
let appLink;
|
let appLinks;
|
||||||
let verLink;
|
|
||||||
|
|
||||||
if (pkg) {
|
if (pkg) {
|
||||||
pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />);
|
pkgLink = (<PackageLink config={config} type={type} pkg={pkg} />);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'wrn:app') {
|
if (type === 'app') {
|
||||||
appLink = (<AppLink config={config} name={name} />);
|
appLinks = (
|
||||||
verLink = (<AppLink config={config} name={name} version={version} text={version} />);
|
<>
|
||||||
|
{names.map(name => <>
|
||||||
|
<AppLink config={config} name={name} />
|
||||||
|
<br />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={id} size='small'>
|
<TableRow key={id} size='small'>
|
||||||
<TableCell monospace>{type}</TableCell>
|
<TableCell monospace>{type}</TableCell>
|
||||||
<TableCell monospace>
|
<TableCell monospace>
|
||||||
{appLink || name}
|
{appLinks || names}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell monospace>
|
<TableCell monospace>
|
||||||
{verLink || version}
|
{version}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{displayName || service || description}
|
{displayName || service || description}
|
||||||
@ -129,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>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user