fix pinia error

This commit is contained in:
jb-alvarado 2023-05-15 14:08:40 +02:00
parent 5c37a260df
commit 3c48ce09e0
4 changed files with 1481 additions and 6 deletions

1463
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,6 @@ const { timeToSeconds } = stringFormatter()
import { useAuth } from '~/stores/auth'
import { useIndex } from '~/stores/index'
const authStore = useAuth()
const indexStore = useIndex()
interface GuiConfig {
id: number
@ -81,6 +79,8 @@ export const useConfig = defineStore('config', {
},
async nuxtClientInit() {
const authStore = useAuth()
authStore.inspectToken()
if (authStore.isLogin) {
@ -91,6 +91,9 @@ export const useConfig = defineStore('config', {
},
async getGuiConfig() {
const authStore = useAuth()
const indexStore = useIndex()
let statusCode = 0
await fetch('/api/channels', {
method: 'GET',
@ -136,6 +139,7 @@ export const useConfig = defineStore('config', {
},
async setGuiConfig(obj: GuiConfig): Promise<any> {
const authStore = useAuth()
const stringObj = _.cloneDeep(obj)
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
let response
@ -175,6 +179,8 @@ export const useConfig = defineStore('config', {
},
async getPlayoutConfig() {
const authStore = useAuth()
const indexStore = useIndex()
const channel = this.configGui[this.configID].id
await fetch(`/api/playout/config/${channel}`, {
@ -203,6 +209,7 @@ export const useConfig = defineStore('config', {
},
async setPlayoutConfig(obj: any) {
const authStore = useAuth()
const channel = this.configGui[this.configID].id
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
@ -216,6 +223,8 @@ export const useConfig = defineStore('config', {
},
async getUserConfig() {
const authStore = useAuth()
await fetch('/api/user', {
method: 'GET',
headers: authStore.authHeader,
@ -228,6 +237,7 @@ export const useConfig = defineStore('config', {
},
async setUserConfig(obj: any) {
const authStore = useAuth()
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
const update = await fetch(`/api/user/${obj.id}`, {

View File

@ -2,8 +2,6 @@ import { defineStore } from 'pinia'
import { useAuth } from '~/stores/auth'
import { useConfig } from '~/stores/config'
const authStore = useAuth()
const configStore = useConfig()
export const useMedia = defineStore('media', {
state: () => ({
@ -17,6 +15,8 @@ export const useMedia = defineStore('media', {
getters: {},
actions: {
async getTree(path: string, foldersOnly: boolean = false) {
const authStore = useAuth()
const configStore = useConfig()
const contentType = { 'content-type': 'application/json;charset=UTF-8' }
const channel = configStore.configGui[configStore.configID].id
const crumbs: Crumb[] = []

View File

@ -10,8 +10,6 @@ dayjs.extend(timezone)
import { useAuth } from '~/stores/auth'
import { useConfig } from '~/stores/config'
const authStore = useAuth()
const configStore = useConfig()
const { timeToSeconds } = stringFormatter()
const { processPlaylist } = playlistOperations()
@ -37,6 +35,8 @@ export const usePlaylist = defineStore('playlist', {
},
async getPlaylist(date: string) {
const authStore = useAuth()
const configStore = useConfig()
const timeInSec = timeToSeconds(dayjs().utcOffset(configStore.utcOffset).format('HH:mm:ss'))
const channel = configStore.configGui[configStore.configID].id
let dateToday = dayjs().utcOffset(configStore.utcOffset).format('YYYY-MM-DD')
@ -63,6 +63,8 @@ export const usePlaylist = defineStore('playlist', {
},
async playoutStat() {
const authStore = useAuth()
const configStore = useConfig()
const channel = configStore.configGui[configStore.configID].id
await fetch(`/api/control/${channel}/media/current`, {