Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions client/src/store/modules/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default {
micAllocations: [],
noLeaderToast: null,
scriptModes: [],
sessionTags: [],
},
mutations: {
SET_CAST_LIST(state, castList) {
Expand All @@ -45,6 +46,7 @@ export default {
state.characterList = [];
state.actList = [];
state.sceneList = [];
state.sessionTags = [];
},
SET_SESSIONS_LIST(state, sessions) {
state.sessions = sessions;
Expand All @@ -70,6 +72,9 @@ export default {
UPDATE_SCRIPT_MODES(state, modes) {
state.scriptModes = modes;
},
SET_SESSION_TAGS(state, tags) {
state.sessionTags = tags;
},
},
actions: {
async GET_CAST_LIST(context) {
Expand Down Expand Up @@ -572,6 +577,83 @@ export default {
log.error('Unable to fetch script modes');
}
},
async GET_SESSION_TAGS(context) {
const response = await fetch(`${makeURL('/api/v1/show/session/tags')}`);
if (response.ok) {
const data = await response.json();
context.commit('SET_SESSION_TAGS', data.tags);
} else {
log.error('Unable to get session tags');
}
},
async ADD_SESSION_TAG(context, tag) {
const response = await fetch(`${makeURL('/api/v1/show/session/tags')}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(tag),
});
if (response.ok) {
context.dispatch('GET_SESSION_TAGS');
Vue.$toast.success('Added new session tag!');
} else {
log.error('Unable to add session tag');
Vue.$toast.error('Unable to add session tag');
}
},
async UPDATE_SESSION_TAG(context, tag) {
const response = await fetch(`${makeURL('/api/v1/show/session/tags')}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(tag),
});
if (response.ok) {
context.dispatch('GET_SESSION_TAGS');
Vue.$toast.success('Updated session tag!');
} else {
log.error('Unable to edit session tag');
Vue.$toast.error('Unable to edit session tag');
}
},
async DELETE_SESSION_TAG(context, tagId) {
const response = await fetch(`${makeURL('/api/v1/show/session/tags')}?id=${tagId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
});
if (response.ok) {
context.dispatch('GET_SESSION_TAGS');
Vue.$toast.success('Deleted session tag!');
} else {
log.error('Unable to delete session tag');
Vue.$toast.error('Unable to delete session tag');
}
},
async UPDATE_SESSION_TAGS(context, { sessionId, tagIds }) {
const response = await fetch(`${makeURL('/api/v1/show/sessions/assign-tags')}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
session_id: sessionId,
tag_ids: tagIds,
}),
});
if (response.ok) {
await context.dispatch('GET_SHOW_SESSION_DATA');
Vue.$toast.success('Updated session tags!');
} else {
const errorData = await response.json().catch(() => ({}));
log.error('Unable to update session tags:', errorData);
Vue.$toast.error(errorData.message || 'Unable to update session tags');
throw new Error('Failed to update session tags');
}
},
},
getters: {
CAST_LIST(state) {
Expand Down Expand Up @@ -755,5 +837,21 @@ export default {
SCRIPT_MODES(state) {
return state.scriptModes;
},
SESSION_TAGS(state) {
return state.sessionTags;
},
SESSION_TAGS_DICT(state) {
return Object.fromEntries(state.sessionTags.map((tag) => [tag.id, tag]));
},
SESSION_TAG_BY_ID: (state, getters) => (tagId) => {
if (tagId == null) {
return null;
}
const tagStr = tagId.toString();
if (Object.keys(getters.SESSION_TAGS_DICT).includes(tagStr)) {
return getters.SESSION_TAGS_DICT[tagStr];
}
return null;
},
},
};
116 changes: 29 additions & 87 deletions client/src/views/show/config/ConfigSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,111 +4,53 @@
fluid
>
<b-row>
<b-col>
<h5>Sessions List</h5>
<b-table
id="acts-table"
:items="SHOW_SESSIONS_LIST"
:fields="sessionFields"
show-empty
>
<template #cell(run_time)="data">
<p v-if="data.item.end_date_time">
{{ runTimeCalc(data.item.start_date_time, data.item.end_date_time) }}
</p>
</template>
</b-table>
</b-col>
</b-row>
<b-row>
<b-col>
<b-button-group v-if="IS_SHOW_EXECUTOR">
<b-button
variant="success"
:disabled="CURRENT_SHOW_SESSION !== null || startingSession"
@click.stop="startSession"
>
Start Session
</b-button>
<b-button
variant="danger"
:disabled="CURRENT_SHOW_SESSION === null || stoppingSession"
@click.stop="stopSession"
<b-col v-if="loaded">
<b-tabs content-class="mt-3">
<b-tab
title="Sessions"
active
>
Stop Session
</b-button>
</b-button-group>
<session-list />
</b-tab>
<b-tab title="Tags">
<session-tag-list />
</b-tab>
</b-tabs>
</b-col>
<b-col v-else>
<div
class="text-center center-spinner"
>
<b-spinner
style="width: 10rem; height: 10rem;"
variant="info"
/>
</div>
</b-col>
</b-row>
</b-container>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';
import log from 'loglevel';

import { makeURL, msToTimerString } from '@/js/utils';
import { mapActions } from 'vuex';
import SessionList from '@/vue_components/show/config/sessions/SessionList.vue';
import SessionTagList from '@/vue_components/show/config/sessions/SessionTagList.vue';

export default {
name: 'ConfigSessions',
components: { SessionTagList, SessionList },
data() {
return {
sessionFields: [
{ key: 'start_date_time', label: 'Start Date' },
{ key: 'end_date_time', label: 'End Date' },
{ key: 'run_time', label: 'Runtime' },
],
startingSession: false,
stoppingSession: false,
loaded: false,
};
},
computed: {
...mapGetters(['SHOW_SESSIONS_LIST', 'CURRENT_SHOW_SESSION', 'INTERNAL_UUID', 'IS_SHOW_EXECUTOR']),
},
async mounted() {
await this.GET_SHOW_SESSION_DATA();
await this.GET_SESSION_TAGS();
this.loaded = true;
},
methods: {
async startSession() {
if (this.INTERNAL_UUID == null) {
this.$toast.error('Unable to start new show session');
return;
}
this.startingSession = true;
const response = await fetch(`${makeURL('/api/v1/show/sessions/start')}`, {
method: 'POST',
body: JSON.stringify({
session_id: this.INTERNAL_UUID,
}),
});
if (response.ok) {
this.$toast.success('Started new show session');
} else {
log.error('Unable to start new show session');
this.$toast.error('Unable to start new show session');
}
this.startingSession = false;
},
async stopSession() {
this.stoppingSession = true;
const response = await fetch(`${makeURL('/api/v1/show/sessions/stop')}`, {
method: 'POST',
});
if (response.ok) {
this.$toast.success('Stopped show session');
} else {
log.error('Unable to stop show session');
this.$toast.error('Unable to stop show session');
}
this.stoppingSession = false;
},
runTimeCalc(start, end) {
const startDate = Date.parse(start);
const endDate = Date.parse(end);
const diff = endDate - startDate;
return msToTimerString(diff);
},
...mapActions(['GET_SHOW_SESSION_DATA']),
...mapActions(['GET_SHOW_SESSION_DATA', 'GET_SESSION_TAGS']),
},
};
</script>
Loading
Loading