InterfaceList.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import gql from 'graphql-tag'
  2. import { Query } from 'react-apollo'
  3. import Interface from './Interface'
  4. const INTERFACE_LIST = gql`
  5. query INTERFACE_LIST {
  6. interfaces {
  7. interfaceName
  8. workerScript
  9. ports {
  10. id
  11. device
  12. interfaceName
  13. name
  14. description
  15. }
  16. connections {
  17. id
  18. device
  19. interfaceName
  20. }
  21. options {
  22. name
  23. type
  24. description
  25. values
  26. }
  27. }
  28. }
  29. `
  30. const InterfaceList = props => (
  31. <Query query={INTERFACE_LIST}>
  32. {({ data }, loading, error) => {
  33. if (!data) return <p>No interfaces found.</p>
  34. const { interfaces } = data
  35. return (
  36. <div>
  37. <h1>Interface List</h1>
  38. {loading ? (
  39. <p>Loading interfaces...</p>
  40. ) : (
  41. interfaces && interfaces.map(iface => <Interface key={iface.interfaceName} data={iface} />)
  42. )}
  43. </div>
  44. )
  45. }}
  46. </Query>
  47. )
  48. export default InterfaceList
  49. export { INTERFACE_LIST }