-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
194 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<router-link | ||
class=" | ||
block grid grid-cols-[auto,4rem] grid-rows-3 | ||
rounded border border-gray-300 hover:bg-gray-200 | ||
p-2 | ||
" | ||
:to="`/speed/${result.id}`" | ||
@click="$emit('navigate')" | ||
> | ||
<span class="col-start-2 row-span-3 flex justify-center items-center">{{ result.count }}</span> | ||
|
||
<span class="col-start-1 row-start-1 font-bold"> | ||
{{ result.eventDefinition.name }} | ||
</span> | ||
<span class="col-start-1">{{ formatDateTime(result.createdAt) }}</span> | ||
<span class="col-start-1">{{ result.name }}</span> | ||
</router-link> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { formatDateTime } from '../helpers' | ||
import type { PropType } from 'vue' | ||
import type { SpeedResult } from '../graphql/generated/graphql' | ||
defineProps({ | ||
result: { | ||
type: Object as PropType<Pick<SpeedResult, 'id' | 'name' | 'createdAt' | 'count' | 'eventDefinition'>>, | ||
required: true | ||
} | ||
}) | ||
const a = 1 | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
query Checklist { | ||
me { | ||
id | ||
checklist { | ||
id | ||
trick { | ||
id | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
query Me ($withChecklist: Boolean!) { | ||
query Me { | ||
me { | ||
id | ||
username | ||
name | ||
photo | ||
lang | ||
checklist @include(if: $withChecklist) { | ||
id | ||
trick { | ||
id | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
query SpeedResults ($limit: Int, $startAfter: Timestamp) { | ||
me { | ||
id | ||
speedResults (limit: $limit, startAfter: $startAfter) { | ||
... on SimpleSpeedResult { | ||
id | ||
name | ||
createdAt | ||
count | ||
eventDefinition { | ||
id | ||
name | ||
totalDuration | ||
} | ||
} | ||
... on DetailedSpeedResult { | ||
id | ||
name | ||
createdAt | ||
count | ||
eventDefinition { | ||
id | ||
name | ||
totalDuration | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<!-- position: fixed? --> | ||
<!-- TODO <section class="container mx-auto p-2">filters: eventDefinition, participants</section> --> | ||
|
||
<section class="container mx-auto p-2"> | ||
<div class="min-h-[100vh] grid grid-cols-1 gap-2"> | ||
<speed-box v-for="speedResult of speedResults" :key="speedResult.id" :result="speedResult" /> | ||
</div> | ||
|
||
<button | ||
ref="loadMoreRef" | ||
class="btn full-w mt-2" | ||
:disabled="speedResultsQuery.loading.value" | ||
@click="loadMore()" | ||
> | ||
<span v-if="speedResultsQuery.loading.value"> | ||
<icon-loading class="animate-spin" /> | ||
</span> | ||
<span v-else>Load more</span> | ||
</button> | ||
</section> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { useResult } from '@vue/apollo-composable' | ||
import { useIntersectionObserver, useThrottleFn } from '@vueuse/core' | ||
import { useSpeedResultsQuery } from '../graphql/generated/graphql' | ||
import SpeedBox from '../components/SpeedBox.vue' | ||
import IconLoading from 'virtual:vite-icons/mdi/loading' | ||
const loadMoreRef = ref() | ||
const speedResultsQuery = useSpeedResultsQuery({ | ||
limit: 20, | ||
startAfter: null | ||
}, { fetchPolicy: 'cache-and-network' }) | ||
const speedResults = useResult(speedResultsQuery.result, [], data => data.me?.speedResults) | ||
function loadMore() { | ||
const lastResult = speedResults.value[speedResults.value.length - 1] | ||
if (!lastResult) return false | ||
speedResultsQuery.fetchMore({ | ||
variables: { | ||
limit: 20, | ||
startAfter: lastResult.createdAt | ||
} | ||
}) | ||
} | ||
const throttledLoadMore = useThrottleFn(loadMore, 10000) | ||
useIntersectionObserver(loadMoreRef, () => { | ||
if (speedResultsQuery.loading.value) return | ||
throttledLoadMore() | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters