parent
2b7a7d9221
commit
bff7fe704e
@ -6,8 +6,7 @@
|
||||
"main": "src/schema/index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint . --fix --ext .js --ext .graphql",
|
||||
"fmt":
|
||||
"prettier --write --single-quote src/**/*.js src/*.js src/**/*.graphql",
|
||||
"fmt": "prettier --write --single-quote src/**/*.js src/*.js src/**/*.graphql",
|
||||
"test": "echo 0",
|
||||
"test-ci": "echo 0",
|
||||
"start": "PORT=4000 node src/server.js",
|
||||
@ -36,19 +35,22 @@
|
||||
"hapi": "^16.6.2",
|
||||
"hasha": "^3.0.0",
|
||||
"inert": "^4.2.1",
|
||||
"lodash.get": "^4.4.2",
|
||||
"node-fetch": "^1.7.3",
|
||||
"smartdc-auth": "^2.5.6",
|
||||
"triton": "^5.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"graphql-faker": "^1.4.0",
|
||||
"eslint": "^4.8.0",
|
||||
"eslint-config-joyent-portal": "3.1.0",
|
||||
"eslint-plugin-graphql": "^1.4.0-1",
|
||||
"graphql-faker": "^1.4.0",
|
||||
"nodemon": "^1.12.1",
|
||||
"prettier": "^1.7.4"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": ["doc/*"]
|
||||
"ignore": [
|
||||
"doc/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
const { toKeyValue, fromKeyValue } = require('../api/key-value');
|
||||
const api = require('../api');
|
||||
const forceArray = require('force-array');
|
||||
const get = require('lodash.get');
|
||||
|
||||
const resolvers = {
|
||||
Query: {
|
||||
@ -57,16 +59,34 @@ const resolvers = {
|
||||
|
||||
package: (root, { id, name }) => api.packages.get({ id, name }),
|
||||
|
||||
machines: (root, { id, brand, state, tags, ...rest }) =>
|
||||
id
|
||||
? api.machines.get({ id }).then(machine => [machine])
|
||||
machines: (root, { id, brand, state, tags, ...rest }, _, ctx) =>
|
||||
id ? api.machines.get({ id }).then(machine => [machine])
|
||||
: api.machines.list(
|
||||
Object.assign(rest, {
|
||||
brand: brand ? brand.toLowerCase() : brand,
|
||||
state: state ? state.toLowerCase() : state,
|
||||
tags: fromKeyValue(tags)
|
||||
})
|
||||
),
|
||||
)
|
||||
.then(machines => {
|
||||
const field = forceArray(ctx.fieldNodes)
|
||||
.filter(({ name }) => name.value === 'machines')
|
||||
.shift();
|
||||
|
||||
if (!field) {
|
||||
return machines;
|
||||
}
|
||||
|
||||
const prop = get(field, 'selectionSet.selections', [])
|
||||
.filter(({ name }) => name.value === 'dns_names')
|
||||
.shift();
|
||||
|
||||
if (!prop) {
|
||||
return machines;
|
||||
}
|
||||
|
||||
return machines.map(({ id }) => api.machines.get({ id }));
|
||||
}),
|
||||
|
||||
machine: (root, { id }) => api.machines.get({ id }),
|
||||
|
||||
|
@ -199,6 +199,8 @@ type Machine {
|
||||
compute_node: ID
|
||||
# The id or name of the package used to create this instance
|
||||
package: Package
|
||||
# DNS names of the instance (if the instance is using CNS)
|
||||
dns_names: [String]
|
||||
# The snapshots based on this instance
|
||||
snapshots(
|
||||
# Snapshot name
|
||||
|
@ -6,8 +6,7 @@
|
||||
"repository": "github:yldio/joyent-portal",
|
||||
"main": "build/",
|
||||
"scripts": {
|
||||
"dev":
|
||||
"REACT_APP_GQL_PORT=4000 PORT=3069 REACT_APP_GQL_PROTOCOL=http joyent-react-scripts start",
|
||||
"dev": "REACT_APP_GQL_PORT=4000 PORT=3069 REACT_APP_GQL_PROTOCOL=http joyent-react-scripts start",
|
||||
"start": "PORT=3069 joyent-react-scripts start",
|
||||
"build": "NODE_ENV=production joyent-react-scripts build",
|
||||
"lint:css": "stylelint './src/**/*.js'",
|
||||
@ -20,6 +19,7 @@
|
||||
"dependencies": {
|
||||
"@manaflair/redux-batch": "^0.1.0",
|
||||
"apollo": "^0.2.2",
|
||||
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
||||
"joyent-ui-toolkit": "^2.0.0",
|
||||
"lodash.find": "^4.6.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
|
63
packages/my-joy-beta/src/containers/instances/dns.js
Normal file
63
packages/my-joy-beta/src/containers/instances/dns.js
Normal file
@ -0,0 +1,63 @@
|
||||
import React from 'react';
|
||||
import ReactJson from 'react-json-view';
|
||||
import PropTypes from 'prop-types';
|
||||
import { compose, graphql } from 'react-apollo';
|
||||
import find from 'lodash.find';
|
||||
import get from 'lodash.get';
|
||||
|
||||
import {
|
||||
ViewContainer,
|
||||
Title,
|
||||
StatusLoader,
|
||||
Message,
|
||||
MessageDescription,
|
||||
MessageTitle
|
||||
} from 'joyent-ui-toolkit';
|
||||
|
||||
import ListDNS from '@graphql/list-dns.gql';
|
||||
|
||||
const DNS = ({ instance, loading, error }) => {
|
||||
const { name, dns_names } = instance || {};
|
||||
const _title = <Title>DNS</Title>;
|
||||
const _loading = loading && !name && !dns_names && <StatusLoader />;
|
||||
const _summary = !_loading && instance && <ReactJson src={dns_names} />;
|
||||
|
||||
const _error = error &&
|
||||
!_loading &&
|
||||
!instance && (
|
||||
<Message error>
|
||||
<MessageTitle>Ooops!</MessageTitle>
|
||||
<MessageDescription>
|
||||
An error occurred while loading your instance DNS
|
||||
</MessageDescription>
|
||||
</Message>
|
||||
);
|
||||
|
||||
return (
|
||||
<ViewContainer center={Boolean(_loading)} main>
|
||||
{_title}
|
||||
{_loading}
|
||||
{_error}
|
||||
{_summary}
|
||||
</ViewContainer>
|
||||
);
|
||||
};
|
||||
|
||||
DNS.propTypes = {
|
||||
loading: PropTypes.bool
|
||||
};
|
||||
|
||||
export default compose(
|
||||
graphql(ListDNS, {
|
||||
options: ({ match }) => ({
|
||||
variables: {
|
||||
name: get(match, 'params.instance')
|
||||
}
|
||||
}),
|
||||
props: ({ data: { loading, error, variables, ...rest } }) => ({
|
||||
instance: find(get(rest, 'machines', []), ['name', variables.name]),
|
||||
loading,
|
||||
error
|
||||
})
|
||||
})
|
||||
)(DNS);
|
@ -4,6 +4,7 @@ export { default as Tags } from './tags';
|
||||
export { default as Metadata } from './metadata';
|
||||
export { default as Networks } from './networks';
|
||||
export { default as Firewall } from './firewall';
|
||||
export { default as Dns } from './dns';
|
||||
export { default as Snapshots } from './snapshots';
|
||||
export { default as Resize } from './resize';
|
||||
export { default as CreateSnapshot } from './create-snapshot';
|
||||
|
@ -1,15 +1,6 @@
|
||||
query instance($name: String) {
|
||||
machines(name: $name) {
|
||||
id
|
||||
name
|
||||
state
|
||||
memory
|
||||
disk
|
||||
created
|
||||
updated
|
||||
firewall_enabled
|
||||
package {
|
||||
name
|
||||
}
|
||||
id,
|
||||
dns_names
|
||||
}
|
||||
}
|
||||
|
7
packages/my-joy-beta/src/graphql/list-dns.gql
Normal file
7
packages/my-joy-beta/src/graphql/list-dns.gql
Normal file
@ -0,0 +1,7 @@
|
||||
query instance($name: String!) {
|
||||
machines(name: $name) {
|
||||
id,
|
||||
name,
|
||||
dns_names
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import {
|
||||
Metadata as InstanceMetadata,
|
||||
Networks as InstanceNetworks,
|
||||
Firewall as InstanceFirewall,
|
||||
Dns as InstanceDns,
|
||||
Snapshots as InstanceSnapshots,
|
||||
Resize as InstanceResize,
|
||||
CreateSnapshot as InstanceCreateSnapshot
|
||||
@ -78,6 +79,7 @@ export default () => (
|
||||
exact
|
||||
component={InstanceFirewall}
|
||||
/>
|
||||
<Route path="/instances/:instance/dns" exact component={InstanceDns} />
|
||||
<Route
|
||||
path="/instances/:instance/snapshots"
|
||||
exact
|
||||
|
@ -8,6 +8,7 @@ export default {
|
||||
'metadata',
|
||||
'networks',
|
||||
'firewall',
|
||||
'dns',
|
||||
'snapshots'
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user