You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.1KB

  1. <template>
  2. <v-container
  3. fluid
  4. tag="section"
  5. >
  6. <h1>{{ name }}</h1>
  7. <v-data-table
  8. :headers="ergebnis.headers"
  9. :items="ergebnisse"
  10. sort-by="time"
  11. :items-per-page="-1"
  12. >
  13. <template #item.time="{item}">
  14. {{ item.time | float2_0 }}s
  15. </template>
  16. </v-data-table>
  17. </v-container>
  18. </template>
  19. <script>
  20. import gql from 'graphql-tag'
  21. const timeslotquery = '_id time duration team { _id name } result { bonus runtime calctime results { _id teile bonus wechsel bonusteil fehler } }'
  22. const query = `_id name date _organizer organizer { name } apparatus { _apparatus apparatus { name logo } elements bonus malus } timeslots { ${timeslotquery} }`
  23. export default {
  24. name: 'Public',
  25. props: {
  26. id: {
  27. type: String,
  28. required: true
  29. }
  30. },
  31. data: () => ({
  32. Event: null,
  33. ApparatusFind: [],
  34. ergebnis: {
  35. headers: [
  36. {
  37. text: 'Platz',
  38. value: 'platz',
  39. sortable: false
  40. },
  41. {
  42. text: 'Mannschaft',
  43. value: 'team',
  44. sortable: false
  45. },
  46. {
  47. text: 'Zeit',
  48. value: 'time',
  49. sortable: false
  50. }
  51. ]
  52. }
  53. }),
  54. computed: {
  55. name () {
  56. return this.Event?.name
  57. },
  58. ergebnisse () {
  59. return this.Event?.timeslots?.reduce((acc, curr) => {
  60. if (curr.team && curr.result) {
  61. acc.push({ team: curr.team.name, time: curr.result.calctime })
  62. }
  63. return acc
  64. }, []).sort((a, b) => a.time < b.time ? -1 : 1).map((m, i) => ({ ...m, platz: i + 1 }))
  65. }
  66. },
  67. apollo: {
  68. Event: {
  69. query: gql`query($event: UUID!) { Event(id: $event) { ${query} } }`,
  70. variables () {
  71. return {
  72. event: this.id
  73. }
  74. },
  75. subscribeToMore: {
  76. document: gql`subscription($id: UUID!) { EventUpdated(id: $id) { ${query} } }`,
  77. variables () {
  78. return {
  79. id: this.id
  80. }
  81. }
  82. }
  83. },
  84. ApparatusFind: {
  85. query: gql`query { ApparatusFind { _id name }}`
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. </style>