From a5183bc511adc16b208a6e71b8d781d5fa23567b Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sat, 10 Sep 2022 20:05:47 +0200 Subject: [PATCH] Add start live survey button on responses page --- ui/src/components/BuildState.svelte | 2 +- ui/src/components/StartStopLiveSurvey.svelte | 31 +++++++++++++++++++ ui/src/routes/surveys/[sid]/admin.svelte | 27 +++++----------- .../surveys/[sid]/responses/index.svelte | 8 +++++ 4 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 ui/src/components/StartStopLiveSurvey.svelte diff --git a/ui/src/components/BuildState.svelte b/ui/src/components/BuildState.svelte index 70c729b..b651435 100644 --- a/ui/src/components/BuildState.svelte +++ b/ui/src/components/BuildState.svelte @@ -13,7 +13,7 @@
diff --git a/ui/src/components/StartStopLiveSurvey.svelte b/ui/src/components/StartStopLiveSurvey.svelte new file mode 100644 index 0000000..7c0fed9 --- /dev/null +++ b/ui/src/components/StartStopLiveSurvey.svelte @@ -0,0 +1,31 @@ + + +{#if survey.direct !== null} + + +{:else} + +{/if} diff --git a/ui/src/routes/surveys/[sid]/admin.svelte b/ui/src/routes/surveys/[sid]/admin.svelte index dbd3bd3..1fae957 100644 --- a/ui/src/routes/surveys/[sid]/admin.svelte +++ b/ui/src/routes/surveys/[sid]/admin.svelte @@ -14,6 +14,7 @@ import CorrectionPieChart from '../../../components/CorrectionPieChart.svelte'; import ListInputResponses from '../../../components/ListInputResponses.svelte'; import QuestionForm from '../../../components/QuestionForm.svelte'; + import StartStopLiveSurvey from '../../../components/StartStopLiveSurvey.svelte'; import SurveyAdmin from '../../../components/SurveyAdmin.svelte'; import SurveyBadge from '../../../components/SurveyBadge.svelte'; import { getSurvey } from '../../../lib/surveys'; @@ -234,26 +235,12 @@ {#await surveyP then survey} {#if $user && $user.is_admin} - {#if survey.direct !== null} - - - {:else} - - {/if} + updateSurvey()} + on:end={() => { if (confirm("Sûr ?")) ws.send('{"action":"end"}') }} + /> {/if}
diff --git a/ui/src/routes/surveys/[sid]/responses/index.svelte b/ui/src/routes/surveys/[sid]/responses/index.svelte index 2b4a1b4..f90105f 100644 --- a/ui/src/routes/surveys/[sid]/responses/index.svelte +++ b/ui/src/routes/surveys/[sid]/responses/index.svelte @@ -11,6 +11,9 @@ {#await surveyP then survey} + goto(`surveys/${survey.id}/admin`)} + />

<