InterfaceList.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import gql from 'graphql-tag'
  2. import { Query } from 'react-apollo'
  3. import Interface from './Interface'
  4. const INTERFACES_FULL = gql`
  5. query INTERFACES_FULL {
  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 INTERFACES = gql`
  31. query INTERFACES {
  32. interfaces {
  33. interfaceName
  34. ports {
  35. id
  36. }
  37. connections {
  38. id
  39. }
  40. }
  41. }
  42. `
  43. const InterfaceList = props => (
  44. <Query query={INTERFACES_FULL}>
  45. {({ data }, loading, error) => {
  46. if (!data) return <p>No interfaces found.</p>
  47. const { interfaces } = data
  48. return (
  49. <div>
  50. <h1>Interface List</h1>
  51. {loading ? (
  52. <p>Loading interfaces...</p>
  53. ) : (
  54. interfaces && interfaces.map(iface => <Interface key={iface.interfaceName} data={iface} />)
  55. )}
  56. </div>
  57. )
  58. }}
  59. </Query>
  60. )
  61. export default InterfaceList
  62. export { INTERFACES, INTERFACES_FULL }