InterfaceList.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. id
  8. interfaceName
  9. workerScript {
  10. path
  11. mtime
  12. updated
  13. }
  14. workerProcess {
  15. pid
  16. killed
  17. signalCode
  18. exitCode
  19. spawnfile
  20. spawnargs
  21. }
  22. ports {
  23. id
  24. interfaceName
  25. host
  26. device
  27. name
  28. description
  29. }
  30. connections {
  31. id
  32. port {
  33. id
  34. interfaceName
  35. host
  36. device
  37. name
  38. description
  39. }
  40. workerProcess {
  41. pid
  42. killed
  43. signalCode
  44. exitCode
  45. spawnfile
  46. spawnargs
  47. }
  48. }
  49. options {
  50. name
  51. type
  52. description
  53. values
  54. }
  55. }
  56. }
  57. `
  58. const INTERFACES = gql`
  59. query INTERFACES {
  60. interfaces {
  61. interfaceName
  62. ports {
  63. id
  64. }
  65. connections {
  66. id
  67. }
  68. }
  69. }
  70. `
  71. const InterfaceList = props => (
  72. <Query query={INTERFACES_FULL}>
  73. {({ data }, loading, error) => {
  74. if (loading) return <p>Loading interfaces...</p>
  75. if (error) return <p>Error loading interfaces: {error.message}</p>
  76. if (!data) return <p>No interfaces found.</p>
  77. const { interfaces } = data
  78. return (
  79. <div>
  80. <h1>Interface List</h1>
  81. {loading ? (
  82. <p>Loading interfaces...</p>
  83. ) : (
  84. interfaces &&
  85. interfaces.map(iface => (
  86. <Interface key={iface.interfaceName} data={iface} />
  87. ))
  88. )}
  89. </div>
  90. )
  91. }}
  92. </Query>
  93. )
  94. export default InterfaceList
  95. export { INTERFACES, INTERFACES_FULL }