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
3 changes: 3 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
<template #button-content>
<em>{{ CURRENT_USER.username }}</em>
</template>
<b-dropdown-item to="/me">
Settings
</b-dropdown-item>
<b-dropdown-item-button @click.stop.prevent="USER_LOGOUT">
Sign Out
</b-dropdown-item-button>
Expand All @@ -99,7 +102,7 @@
</b-navbar-nav>
</b-collapse>
</b-navbar>
<template>

Check warning on line 105 in client/src/App.vue

View workflow job for this annotation

GitHub Actions / build

`<template>` require directive
<div
v-if="!loaded"
class="text-center center-spinner"
Expand Down Expand Up @@ -234,7 +237,7 @@
}
},
},
computed: {

Check warning on line 240 in client/src/App.vue

View workflow job for this annotation

GitHub Actions / build

The "computed" property should be above the "methods" property on line 158
isAdminUser() {
return this.CURRENT_USER != null && this.CURRENT_USER.is_admin;
},
Expand Down Expand Up @@ -263,7 +266,7 @@
...mapGetters(['WEBSOCKET_HEALTHY', 'CURRENT_SHOW_SESSION', 'SETTINGS', 'CURRENT_USER',
'RBAC_ROLES', 'CURRENT_USER_RBAC', 'INTERNAL_UUID']),
},
async created() {

Check warning on line 269 in client/src/App.vue

View workflow job for this annotation

GitHub Actions / build

The "created" property should be above the "methods" property on line 158
this.$router.beforeEach(async (to, from, next) => {
if (!this.SETTINGS.has_admin_user) {
this.$toast.error('Please create an admin user before continuing');
Expand Down
7 changes: 6 additions & 1 deletion client/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ const routes = [
{
path: '/login',
name: 'login',
component: () => import('../views/LoginView.vue'),
component: () => import('../views/user/LoginView.vue'),
},
{
path: '/me',
name: 'user_settings',
component: () => import('../views/user/Settings.vue'),
},
{
path: '*',
Expand Down
84 changes: 84 additions & 0 deletions client/src/store/modules/user/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import Vue from 'vue';
import log from 'loglevel';

import { makeURL } from '@/js/utils';

export default {
state: {
stageDirectionStyleOverrides: [],
},
mutations: {
SET_STAGE_DIRECTION_STYLE_OVERRIDES(state, overrides) {
state.stageDirectionStyleOverrides = overrides;
},
},
actions: {
async GET_STAGE_DIRECTION_STYLE_OVERRIDES(context) {
const response = await fetch(`${makeURL('/api/v1/user/settings/stage_direction_overrides')}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
if (response.ok) {
const respJson = await response.json();
context.commit('SET_STAGE_DIRECTION_STYLE_OVERRIDES', respJson.overrides);
} else {
log.error('Unable to load stage direction style overrides');
}
},
async ADD_STAGE_DIRECTION_STYLE_OVERRIDE(context, style) {
const response = await fetch(`${makeURL('/api/v1/user/settings/stage_direction_overrides')}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(style),
});
if (response.ok) {
context.dispatch('GET_STAGE_DIRECTION_STYLE_OVERRIDES');
Vue.$toast.success('Added new stage direction style override!');
} else {
log.error('Unable to add new stage direction style override');
Vue.$toast.error('Unable to add new stage direction style override');
}
},
async DELETE_STAGE_DIRECTION_STYLE_OVERRIDE(context, styleId) {
const response = await fetch(`${makeURL('/api/v1/user/settings/stage_direction_overrides')}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: styleId }),
});
if (response.ok) {
context.dispatch('GET_STAGE_DIRECTION_STYLE_OVERRIDES');
Vue.$toast.success('Deleted stage direction style override!');
} else {
log.error('Unable to delete stage direction style override');
Vue.$toast.error('Unable to delete stage direction style override');
}
},
async UPDATE_STAGE_DIRECTION_STYLE_OVERRIDE(context, style) {
const response = await fetch(`${makeURL('/api/v1/user/settings/stage_direction_overrides')}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(style),
});
if (response.ok) {
context.dispatch('GET_STAGE_DIRECTION_STYLE_OVERRIDES');
Vue.$toast.success('Updated stage direction style override!');
} else {
log.error('Unable to edit stage direction style override');
Vue.$toast.error('Unable to edit stage direction style override');
}
},
},
getters: {
STAGE_DIRECTION_STYLE_OVERRIDES(state) {
return state.stageDirectionStyleOverrides;
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from 'loglevel';

import { makeURL } from '@/js/utils';
import router from '@/router';
import settings from './settings';

export default {
state: {
Expand Down Expand Up @@ -129,4 +130,7 @@ export default {
return state.currentRbac;
},
},
modules: {
settings,
},
};
2 changes: 1 addition & 1 deletion client/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import createPersistedState from 'vuex-persistedstate';
import log from 'loglevel';

import { makeURL } from '@/js/utils';
import user from '@/store/modules/user';
import user from '@/store/modules/user/user';
import websocket from './modules/websocket';
import system from './modules/system';
import show from './modules/show';
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions client/src/views/user/Settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<b-container
fluid
class="mx-0"
>
<h1>User Settings</h1>
<b-tabs
pills
vertical
>
<b-tab
active
title="About"
>
<about-user />
</b-tab>
<b-tab
title="Stage Direction Styles"
>
<stage-direction-styles />
</b-tab>
</b-tabs>
</b-container>
</template>

<script>
import StageDirectionStyles from '@/vue_components/user/settings/StageDirectionStyles.vue';
import AboutUserUser from '@/vue_components/user/settings/AboutUser.vue';

export default {
name: 'UserSettings',
components: { AboutUser: AboutUserUser, StageDirectionStyles },
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export default {
event.preventDefault();
} else {
await this.ADD_STAGE_DIRECTION_STYLE(this.createPayload);
this.resetNewCueTypeForm();
this.resetNewFormState();
}
},
async onSubmitEditStyle(event) {
Expand Down
40 changes: 40 additions & 0 deletions client/src/vue_components/user/settings/AboutUser.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<b-table-simple>
<b-tr
v-for="key in orderedKeys"
:key="key"
>
<b-th>{{ key }}</b-th>
<b-td>{{ tableData[key] != null ? tableData[key] : 'N/A' }}</b-td>
</b-tr>
</b-table-simple>
</template>

<script>
import { mapActions, mapGetters } from 'vuex';
import { titleCase } from '@/js/utils';

export default {
name: 'AboutUser',
computed: {
tableData() {
const data = {};
Object.keys(this.CURRENT_USER).forEach(function (key) {
data[this.titleCase(key, '_')] = this.CURRENT_USER[key];
}, this);
return data;
},
orderedKeys() {
return Object.keys(this.tableData).sort();
},
...mapGetters(['CURRENT_USER']),
},
async beforeMount() {
await this.GET_CURRENT_USER();
},
methods: {
titleCase,
...mapActions(['GET_CURRENT_USER']),
},
};
</script>
Loading
Loading