Skip to content

Commit 30dead1

Browse files
authored
Merge pull request #709 from dreamteamprod/dev
Add jumping to page in live show view (#708)
2 parents eecb72b + 9bbe67c commit 30dead1

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

client/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "client",
3-
"version": "0.17.7",
3+
"version": "0.17.8",
44
"private": true,
55
"scripts": {
66
"build": "vite build",

client/src/App.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
>
4848
Reload Clients
4949
</b-dropdown-item-btn>
50+
<b-dropdown-item
51+
v-b-modal.go-to-page
52+
:disabled="CURRENT_SHOW_SESSION == null || !WEBSOCKET_HEALTHY || stoppingSession || startingSession"
53+
>
54+
Jump To Page
55+
</b-dropdown-item>
5056
</b-nav-item-dropdown>
5157
</template>
5258
<b-nav-item
@@ -134,6 +140,40 @@
134140
</b-container>
135141
</template>
136142
<router-view v-else />
143+
<b-modal
144+
id="go-to-page"
145+
ref="go-to-page"
146+
title="Go to Page"
147+
size="sm"
148+
:hide-header-close="changingPage"
149+
:hide-footer="changingPage"
150+
:no-close-on-backdrop="changingPage"
151+
:no-close-on-esc="changingPage"
152+
@ok="goToLivePage"
153+
>
154+
<b-form @submit.stop.prevent="">
155+
<b-form-group
156+
id="page-input-group"
157+
label="Page"
158+
label-for="page-input"
159+
label-cols="auto"
160+
>
161+
<b-form-input
162+
id="page-input"
163+
v-model="$v.pageInputFormState.pageNo.$model"
164+
name="page-input"
165+
type="number"
166+
:state="validatePageState('pageNo')"
167+
aria-describedby="page-feedback"
168+
/>
169+
<b-form-invalid-feedback
170+
id="page-feedback"
171+
>
172+
This is a required field, and must be greater than 0.
173+
</b-form-invalid-feedback>
174+
</b-form-group>
175+
</b-form>
176+
</b-modal>
137177
</div>
138178
</template>
139179

@@ -142,6 +182,8 @@ import { mapGetters, mapActions } from 'vuex';
142182
import log from 'loglevel';
143183
import CreateUser from '@/vue_components/user/CreateUser.vue';
144184
import { makeURL } from '@/js/utils';
185+
import { notNull, notNullAndGreaterThanZero } from '@/js/customValidators';
186+
import { required, minValue } from 'vuelidate/lib/validators';
145187
146188
export default {
147189
components: { CreateUser },
@@ -152,8 +194,22 @@ export default {
152194
stoppingSession: false,
153195
startingSession: false,
154196
wsStateCheckInterval: null,
197+
changingPage: false,
198+
pageInputFormState: {
199+
pageNo: 1,
200+
},
155201
};
156202
},
203+
validations: {
204+
pageInputFormState: {
205+
pageNo: {
206+
required,
207+
notNull,
208+
notNullAndGreaterThanZero,
209+
minValue: minValue(1),
210+
},
211+
},
212+
},
157213
computed: {
158214
isAllowedScriptConfig() {
159215
return (this.IS_ADMIN_USER
@@ -313,6 +369,18 @@ export default {
313369
});
314370
}
315371
},
372+
validatePageState(name) {
373+
const { $dirty, $error } = this.$v.pageInputFormState[name];
374+
return $dirty ? !$error : null;
375+
},
376+
async goToLivePage() {
377+
this.$socket.sendObj({
378+
OP: 'LIVE_SHOW_JUMP_TO_PAGE',
379+
DATA: {
380+
page: this.pageInputFormState.pageNo,
381+
},
382+
});
383+
},
316384
},
317385
};
318386
</script>

server/controllers/ws_controller.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,19 @@ async def on_message(
384384
await self.application.ws_send_to_all(
385385
"RELOAD_CLIENT", "NOOP", {}
386386
)
387+
elif ws_op == "LIVE_SHOW_JUMP_TO_PAGE":
388+
if show and show.current_session_id:
389+
show_session = session.query(ShowSession).get(
390+
show.current_session_id
391+
)
392+
if show_session:
393+
show_session.latest_line_ref = (
394+
f"page_{message['DATA']['page']}_line_0"
395+
)
396+
session.commit()
397+
await self.application.ws_send_to_all(
398+
"RELOAD_CLIENT", "NOOP", {}
399+
)
387400
else:
388401
get_logger().warning(
389402
f"Unknown OP {ws_op} received from "

0 commit comments

Comments
 (0)