diff --git a/client/package.json b/client/package.json index e223dbf..e4cd63d 100644 --- a/client/package.json +++ b/client/package.json @@ -7,6 +7,7 @@ "private": true, "scripts": { "lint": "eslint --ext .js,.vue ./", + "lint:fix": "eslint --ext .js,.vue --fix ./", "test": "echo \"No test specified\" && exit 0", "serve": "npx cross-env NODE_ENV=development quasar dev", "serve:ssr": "quasar dev -m ssr", diff --git a/client/src/App.vue b/client/src/App.vue index 970b520..a2f04b2 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,72 +1,79 @@ diff --git a/client/src/boot/axios.js b/client/src/boot/axios.js index 9dbc942..404f769 100644 --- a/client/src/boot/axios.js +++ b/client/src/boot/axios.js @@ -1,5 +1,5 @@ -import { boot } from 'quasar/wrappers' -import axios from 'axios' +import { boot } from 'quasar/wrappers'; +import axios from 'axios'; // Be careful when using SSR for cross-request state pollution // due to creating a Singleton instance here; @@ -7,18 +7,18 @@ import axios from 'axios' // good idea to move this instance creation inside of the // "export default () => {}" function below (which runs individually // for each client) -const api = axios.create({ baseURL: 'https://api.example.com' }) +const api = axios.create({ baseURL: 'https://api.example.com' }); export default boot(({ app }) => { // for use inside Vue files (Options API) through this.$axios and this.$api - app.config.globalProperties.$axios = axios + app.config.globalProperties.$axios = axios; // ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form) // so you won't necessarily have to import axios in each vue file - app.config.globalProperties.$api = api + app.config.globalProperties.$api = api; // ^ ^ ^ this will allow you to use this.$api (for Vue Options API form) // so you can easily perform requests against your app's API -}) +}); -export { api } +export { api }; diff --git a/client/src/boot/directive.js b/client/src/boot/directive.js index d8d6808..fd758e2 100644 --- a/client/src/boot/directive.js +++ b/client/src/boot/directive.js @@ -1,6 +1,5 @@ -import { boot } from 'quasar/wrappers' +import { boot } from 'quasar/wrappers'; // "async" is optional; // more info on params: https://v2.quasar.dev/quasar-cli/boot-files -export default boot(async ({ app, router }) => { -}) +export default boot(async ({ app, router }) => {}); diff --git a/client/src/boot/main.js b/client/src/boot/main.js index 19c55f8..822cfb2 100644 --- a/client/src/boot/main.js +++ b/client/src/boot/main.js @@ -1,83 +1,81 @@ -import { boot } from 'quasar/wrappers' -import helpers from '@/utils/helpers' -import VueScrollmagic from 'scrollmagic' -import 'vue-final-modal/style.css' -import { VueFinalModal } from 'vue-final-modal' -import {plugin, defaultConfig, createInput} from '@formkit/vue' -import { ru } from '@formkit/i18n' +import { boot } from 'quasar/wrappers'; +import helpers from '@/utils/helpers'; +import VueScrollmagic from 'scrollmagic'; +import 'vue-final-modal/style.css'; +import { VueFinalModal } from 'vue-final-modal'; +import { plugin, defaultConfig, createInput } from '@formkit/vue'; +import { ru } from '@formkit/i18n'; import maskaInput from '@/components/inputs/maska-input'; import toggle from '@/components/inputs/toggle'; -import { vMaska } from 'maska' +import { vMaska } from 'maska'; export default boot(async ({ app, router }) => { - app.config.globalProperties.$router = router - app.use(helpers); - app.scrollMagic = VueScrollmagic; - app.component('VueFinalModal', VueFinalModal); - app.config.globalProperties.$scrollMagic = VueScrollmagic - app.directive('Maska', vMaska); - - const confFormKit = { - locales: { ru }, - locale: 'ru', - config: { - validationVisibility: 'submit', - classes: { - outer: '$reset field', - wrapper: '$reset field__inner', - label: '$reset field__label', - help: '$reset field__help', - inner: '$reset field__input', - input: '$reset input', - messages: '$reset field__comment', - message: '$reset field__comment-item', - legend: '$reset field__legend', - fieldset: '$reset field__fieldset', - options: '$reset field__options', - option: '$reset field__option', - decorator: '$reset field__decorator' - }, - }, - messages: { - ru: { - // validation: { - // date_after({ name, args }) { - // if (args[1] === true) return `${name} должна быть в будущем.`; - // if (Array.isArray(args) && args.length) { - // return `${name} должна быть позже ${new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }).format(typeof args[0] === 'string' ? new Date(Date.parse(args[0])) : args[0]) }`; - // } - // return `${name} должна быть в будущем.`; - // }, - // date_before({ name, args }) { - // if (Array.isArray(args) && args.length) { - // return `${name} должна быть раньше ${new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }).format(typeof args[0] === 'string' ? new Date(Date.parse(args[0])) : args[0]) }`; - // } - // return `${name} должна быть в прошлом.`; - // }, - // }, - } - }, - inputs: { - // datepicker: createInput(datePickerInput, { - // props: ['mode'], - // }), - // select: createInput(multiselectInput, { - // props: ['options', 'placeholder', 'mode', 'searchable'], - // }), - // multiselect: createInput(multiselectInput, { - // props: ['options', 'placeholder', 'mode', 'searchable'], - // }), - maska: createInput(maskaInput, { - props: ['maska', 'placeholder', 'disabled', 'readonly'], - }), - toggle: createInput(toggle, { - props: ['placeholder', 'disabled', 'readonly'], - emits: ['toggle'] - }), - }, - }; - app.use(plugin, defaultConfig(confFormKit)); - -}) + app.config.globalProperties.$router = router; + app.use(helpers); + app.scrollMagic = VueScrollmagic; + app.component('VueFinalModal', VueFinalModal); + app.config.globalProperties.$scrollMagic = VueScrollmagic; + app.directive('Maska', vMaska); + const confFormKit = { + locales: { ru }, + locale: 'ru', + config: { + validationVisibility: 'submit', + classes: { + outer: '$reset field', + wrapper: '$reset field__inner', + label: '$reset field__label', + help: '$reset field__help', + inner: '$reset field__input', + input: '$reset input', + messages: '$reset field__comment', + message: '$reset field__comment-item', + legend: '$reset field__legend', + fieldset: '$reset field__fieldset', + options: '$reset field__options', + option: '$reset field__option', + decorator: '$reset field__decorator', + }, + }, + messages: { + ru: { + // validation: { + // date_after({ name, args }) { + // if (args[1] === true) return `${name} должна быть в будущем.`; + // if (Array.isArray(args) && args.length) { + // return `${name} должна быть позже ${new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }).format(typeof args[0] === 'string' ? new Date(Date.parse(args[0])) : args[0]) }`; + // } + // return `${name} должна быть в будущем.`; + // }, + // date_before({ name, args }) { + // if (Array.isArray(args) && args.length) { + // return `${name} должна быть раньше ${new Intl.DateTimeFormat(undefined, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' }).format(typeof args[0] === 'string' ? new Date(Date.parse(args[0])) : args[0]) }`; + // } + // return `${name} должна быть в прошлом.`; + // }, + // }, + }, + }, + inputs: { + // datepicker: createInput(datePickerInput, { + // props: ['mode'], + // }), + // select: createInput(multiselectInput, { + // props: ['options', 'placeholder', 'mode', 'searchable'], + // }), + // multiselect: createInput(multiselectInput, { + // props: ['options', 'placeholder', 'mode', 'searchable'], + // }), + maska: createInput(maskaInput, { + props: ['maska', 'placeholder', 'disabled', 'readonly'], + }), + toggle: createInput(toggle, { + props: ['placeholder', 'disabled', 'readonly'], + emits: ['toggle'], + }), + }, + }; + app.use(plugin, defaultConfig(confFormKit)); +}); diff --git a/client/src/boot/store.js b/client/src/boot/store.js index fe02e2a..52910c2 100644 --- a/client/src/boot/store.js +++ b/client/src/boot/store.js @@ -1,8 +1,15 @@ -import { boot } from 'quasar/wrappers' +import { boot } from 'quasar/wrappers'; // "async" is optional; // more info on params: https://v2.quasar.dev/quasar-cli/boot-files export default boot(async ({ store }) => { // For Vuex - if (window.__INITIAL_STATE__) store.replaceState(Object.assign(store.state, { metaScheme: window.__INITIAL_STATE__.metaScheme, data: window.__INITIAL_STATE__.data, meta: window.__INITIAL_STATE__.meta })); -}) + if (window.__INITIAL_STATE__) + store.replaceState( + Object.assign(store.state, { + metaScheme: window.__INITIAL_STATE__.metaScheme, + data: window.__INITIAL_STATE__.data, + meta: window.__INITIAL_STATE__.meta, + }), + ); +}); diff --git a/client/src/components/app-footer.vue b/client/src/components/app-footer.vue index 0604e9b..9ba1db3 100644 --- a/client/src/components/app-footer.vue +++ b/client/src/components/app-footer.vue @@ -1,126 +1,118 @@ diff --git a/client/src/components/app-header.vue b/client/src/components/app-header.vue index 2a13094..5506782 100644 --- a/client/src/components/app-header.vue +++ b/client/src/components/app-header.vue @@ -1,147 +1,159 @@ diff --git a/client/src/components/inputs/maska-input.vue b/client/src/components/inputs/maska-input.vue index 781ec45..366a2c6 100644 --- a/client/src/components/inputs/maska-input.vue +++ b/client/src/components/inputs/maska-input.vue @@ -1,25 +1,25 @@ diff --git a/client/src/components/inputs/toggle.vue b/client/src/components/inputs/toggle.vue index 6e2adc7..a3757a3 100644 --- a/client/src/components/inputs/toggle.vue +++ b/client/src/components/inputs/toggle.vue @@ -1,42 +1,39 @@ diff --git a/client/src/components/modal/authentication.vue b/client/src/components/modal/authentication.vue index 51a4907..37811e3 100644 --- a/client/src/components/modal/authentication.vue +++ b/client/src/components/modal/authentication.vue @@ -1,202 +1,203 @@ diff --git a/client/src/components/modal/rubric-modal.vue b/client/src/components/modal/rubric-modal.vue index 9774808..a25f05d 100644 --- a/client/src/components/modal/rubric-modal.vue +++ b/client/src/components/modal/rubric-modal.vue @@ -1,97 +1,100 @@ diff --git a/client/src/components/modal/сhanging-user.vue b/client/src/components/modal/сhanging-user.vue index b1eb36f..26110c6 100644 --- a/client/src/components/modal/сhanging-user.vue +++ b/client/src/components/modal/сhanging-user.vue @@ -1,109 +1,105 @@ diff --git a/client/src/components/pagination.vue b/client/src/components/pagination.vue index 4d2c111..5a8d363 100644 --- a/client/src/components/pagination.vue +++ b/client/src/components/pagination.vue @@ -1,123 +1,142 @@ diff --git a/client/src/components/player.vue b/client/src/components/player.vue index df4d088..1436dbb 100644 --- a/client/src/components/player.vue +++ b/client/src/components/player.vue @@ -1,318 +1,403 @@ diff --git a/client/src/components/playlist-item.vue b/client/src/components/playlist-item.vue index f8e74a7..a357b7d 100644 --- a/client/src/components/playlist-item.vue +++ b/client/src/components/playlist-item.vue @@ -1,27 +1,27 @@ diff --git a/client/src/components/playlist-roster.vue b/client/src/components/playlist-roster.vue index 7044c95..329d198 100644 --- a/client/src/components/playlist-roster.vue +++ b/client/src/components/playlist-roster.vue @@ -1,41 +1,41 @@ diff --git a/client/src/components/rubric-block.vue b/client/src/components/rubric-block.vue index 4844d5f..431740f 100644 --- a/client/src/components/rubric-block.vue +++ b/client/src/components/rubric-block.vue @@ -1,70 +1,93 @@ diff --git a/client/src/components/song-item.vue b/client/src/components/song-item.vue index b882a8e..2eb5646 100644 --- a/client/src/components/song-item.vue +++ b/client/src/components/song-item.vue @@ -1,92 +1,133 @@ diff --git a/client/src/components/song-list.vue b/client/src/components/song-list.vue index fdd4272..d5da98e 100644 --- a/client/src/components/song-list.vue +++ b/client/src/components/song-list.vue @@ -1,72 +1,76 @@ diff --git a/client/src/components/support-block.vue b/client/src/components/support-block.vue index a5fc3d2..69afaaa 100644 --- a/client/src/components/support-block.vue +++ b/client/src/components/support-block.vue @@ -1,25 +1,29 @@ diff --git a/client/src/components/team.vue b/client/src/components/team.vue index 879364d..f6f719a 100644 --- a/client/src/components/team.vue +++ b/client/src/components/team.vue @@ -1,102 +1,108 @@ diff --git a/client/src/router/index.js b/client/src/router/index.js index 4364822..13e852c 100644 --- a/client/src/router/index.js +++ b/client/src/router/index.js @@ -1,7 +1,12 @@ -import { route } from 'quasar/wrappers' -import store from '@/store' -import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router' -import routes from './routes' +import { route } from 'quasar/wrappers'; +import store from '@/store'; +import { + createRouter, + createMemoryHistory, + createWebHistory, + createWebHashHistory, +} from 'vue-router'; +import routes from './routes'; /* * If not building with SSR mode, you can @@ -13,50 +18,57 @@ import routes from './routes' */ export default route(function (/* { store, ssrContext } */) { - const createHistory = process.env.SERVER - ? createMemoryHistory - : (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory) + const createHistory = process.env.SERVER + ? createMemoryHistory + : process.env.VUE_ROUTER_MODE === 'history' + ? createWebHistory + : createWebHashHistory; - const Router = createRouter({ - scrollBehavior(to, from, savedPosition) { - if (savedPosition) { - return savedPosition - } else { - //document.getElementById('app').scrollIntoView({ behavior: 'smooth' }); - //if (to.query.page) return; - return new Promise((resolve) => { - resolve({ left: 0, top: 0 }); - }) - } - }, - routes, - linkActiveClass: 'is-subactive', - linkExactActiveClass: 'is-active', + const Router = createRouter({ + scrollBehavior(to, from, savedPosition) { + if (savedPosition) { + return savedPosition; + } else { + //document.getElementById('app').scrollIntoView({ behavior: 'smooth' }); + //if (to.query.page) return; + return new Promise((resolve) => { + resolve({ left: 0, top: 0 }); + }); + } + }, + routes, + linkActiveClass: 'is-subactive', + linkExactActiveClass: 'is-active', - // Leave this as is and make changes in quasar.conf.js instead! - // quasar.conf.js -> build -> vueRouterMode - // quasar.conf.js -> build -> publicPath - history: createHistory(process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE) - }) + // Leave this as is and make changes in quasar.conf.js instead! + // quasar.conf.js -> build -> vueRouterMode + // quasar.conf.js -> build -> publicPath + history: createHistory( + process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE, + ), + }); - Router.beforeEach((to, from, next) => { - if (to.matched.some(record => record.meta.requiresAuth) && !process.env.SERVER) { - if (store.state.user && store.state.user?.id) { - next(); - } else { - next({ name: 'home' }); - this.$store.dispatch('setShowAuthModal', true); - } - } else { - next(); - } - }); + Router.beforeEach((to, from, next) => { + if ( + to.matched.some((record) => record.meta.requiresAuth) && + !process.env.SERVER + ) { + if (store.state.user && store.state.user?.id) { + next(); + } else { + next({ name: 'home' }); + this.$store.dispatch('setShowAuthModal', true); + } + } else { + next(); + } + }); - Router.afterEach((to, from) => { - if (to.name !== from.name && to.name === 'page404' && from.name) { - if (!process.env.SERVER) window.history.replaceState({}, null, from.path); - } - }); + Router.afterEach((to, from) => { + if (to.name !== from.name && to.name === 'page404' && from.name) { + if (!process.env.SERVER) window.history.replaceState({}, null, from.path); + } + }); - return Router -}) + return Router; +}); diff --git a/client/src/router/routes.js b/client/src/router/routes.js index 959ed7c..6bc4bb8 100644 --- a/client/src/router/routes.js +++ b/client/src/router/routes.js @@ -1,145 +1,145 @@ -import home from "@/views/home.vue"; -import rubric from "@/views/rubric.vue"; -import playlists from "@/views/playlists.vue"; -import support from "@/views/support.vue"; -import contacts from "@/views/contacts.vue"; -import podcasts from "@/views/podcasts.vue"; -import about from "@/views/about.vue"; -import profile from "@/views/profile.vue"; -import playlist from "@/views/playlist.vue"; -import playlistCreate from "@/views/playlist-edit.vue"; - +import home from '@/views/home.vue'; +import rubric from '@/views/rubric.vue'; +import playlists from '@/views/playlists.vue'; +import support from '@/views/support.vue'; +import contacts from '@/views/contacts.vue'; +import podcasts from '@/views/podcasts.vue'; +import about from '@/views/about.vue'; +import profile from '@/views/profile.vue'; +import playlist from '@/views/playlist.vue'; +import playlistCreate from '@/views/playlist-edit.vue'; const routes = [ - { - path: '/', - name: 'home', - component: home, - meta: { - title: 'Главная', - isAuth: false - }, + { + path: '/', + name: 'home', + component: home, + meta: { + title: 'Главная', + isAuth: false, }, - { - path: '/about', - name: 'about', - component: about, - meta: { - title: 'О нас', - isAuth: false - }, + }, + { + path: '/about', + name: 'about', + component: about, + meta: { + title: 'О нас', + isAuth: false, }, - { - path: '/rubric', - name: 'rubric', - component: rubric, - meta: { - title: 'Рубрики', - isAuth: false - }, + }, + { + path: '/rubric', + name: 'rubric', + component: rubric, + meta: { + title: 'Рубрики', + isAuth: false, }, - { - path: '/playlists', - name: 'playlists', - component: playlists, - meta: { - title: 'Плейлисты', - isAuth: false - }, + }, + { + path: '/playlists', + name: 'playlists', + component: playlists, + meta: { + title: 'Плейлисты', + isAuth: false, }, - { - path: '/podcasts', - name: 'podcasts', - component: podcasts, - meta: { - title: 'Подкасты', - isAuth: false - }, + }, + { + path: '/podcasts', + name: 'podcasts', + component: podcasts, + meta: { + title: 'Подкасты', + isAuth: false, }, - { - path: '/support', - name: 'support', - component: support, - meta: { - title: 'Поддержка', - isAuth: false - }, + }, + { + path: '/support', + name: 'support', + component: support, + meta: { + title: 'Поддержка', + isAuth: false, }, - { - path: '/contacts', - name: 'contacts', - component: contacts, - meta: { - title: 'Контакты', - isAuth: false - }, + }, + { + path: '/contacts', + name: 'contacts', + component: contacts, + meta: { + title: 'Контакты', + isAuth: false, }, - { - path: '/profile', - name: 'profile', - component: profile, - meta: { - title: 'Личный кабинет', - isAuth: false - }, - children: [ - { - path: 'playlist/:id', - name: 'playlist', - component: playlist, - meta: { - title: 'Плейлист', - requiresAuth: true - }, - props: true, - }, - { - path: 'playlist-create/:id', - name: 'playlist-create', - component: playlistCreate, - meta: { - title: 'Плейлист', - requiresAuth: true - }, - props: true, - },{ - path: 'playlist-edit/:id', - name: 'playlist-edit', - component: playlistCreate, - meta: { - title: 'Плейлист', - requiresAuth: true - }, - props: true, - }, - ] + }, + { + path: '/profile', + name: 'profile', + component: profile, + meta: { + title: 'Личный кабинет', + isAuth: false, }, - - // { - // path: '/error500', - // name: 'page500', - // component: () => import('@/views/Page500.vue'), - // meta: { - // title: 'Ошибка 500', - // showSidebarAuth: true, - // }, - // }, { - // path: '/error404', - // name: 'error404', - // component: () => import('@/views/Page404.vue'), - // meta: { - // title: 'Ошибка 404', - // showSidebarAuth: true, - // }, - // }, { - // path: '/:catchAll(.*)*', - // name: 'page404', - // component: () => import('@/views/Page404.vue'), - // meta: { - // title: 'Ошибка 404', - // showSidebarAuth: true, - // }, - // }, + children: [ + { + path: 'playlist/:id', + name: 'playlist', + component: playlist, + meta: { + title: 'Плейлист', + requiresAuth: true, + }, + props: true, + }, + { + path: 'playlist-create/:id', + name: 'playlist-create', + component: playlistCreate, + meta: { + title: 'Плейлист', + requiresAuth: true, + }, + props: true, + }, + { + path: 'playlist-edit/:id', + name: 'playlist-edit', + component: playlistCreate, + meta: { + title: 'Плейлист', + requiresAuth: true, + }, + props: true, + }, + ], + }, + + // { + // path: '/error500', + // name: 'page500', + // component: () => import('@/views/Page500.vue'), + // meta: { + // title: 'Ошибка 500', + // showSidebarAuth: true, + // }, + // }, { + // path: '/error404', + // name: 'error404', + // component: () => import('@/views/Page404.vue'), + // meta: { + // title: 'Ошибка 404', + // showSidebarAuth: true, + // }, + // }, { + // path: '/:catchAll(.*)*', + // name: 'page404', + // component: () => import('@/views/Page404.vue'), + // meta: { + // title: 'Ошибка 404', + // showSidebarAuth: true, + // }, + // }, ]; -export default routes +export default routes; diff --git a/client/src/services/app.js b/client/src/services/app.js index 83270c1..dfee8cb 100644 --- a/client/src/services/app.js +++ b/client/src/services/app.js @@ -1,173 +1,216 @@ -import {urlPath as settings} from '@/settings'; -import {REST, RESTError} from './rest'; +import { urlPath as settings } from '@/settings'; +import { REST, RESTError } from './rest'; export default class extends REST { - static get settings() { - return settings; - } - static user(params) { - return this._get(`user`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Не удалось создать пользователя'); - }); - } - static loginUser(params) { - return this._post(`token`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Не удалось создать пользователя'); - }); - } - static createUser(params) { - return this._post(`user/create_user`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Не удалось создать пользователя'); - }); - } - - static updateUser(params) { - return this._post(`user/update_user`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Не удалось создать пользователя'); - }); - } - - static getTeams(station, params) { - return this._get(`radio/teams`, params, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении команды'); - }); - } - - static getCheckFavoriteSong(id){ - return this._get(`radio/song/check_is_favorite/${id}`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при проверке песни'); - }); - } - static getAllSong(){ - return this._get(`radio/song/get_all_song`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получениии всех песен'); - }); - } - static getAudio(id){ - return this._get(`radio/song/get_audio/${id}`, {}, {}, false, true).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получениии песни'); - }); - } - static createFavoriteForUser(params){ - return this._post(`radio/song/add_favorite`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - - static removeFavoriteForUser(params){ - return this._post(`radio/song/delete_song`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - - static getFavoriteList(params){ - return this._get(`radio/song`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - static getRubriks() { - return this._get(`radio/rubriks`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении рубрик'); - }); - } - static getRubrik(id) { - return this._get(`radio/rubriks/${id}`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении рубрик'); - }); - } - - static removeFavorites(params) { - return this._post(`radio/song/delete_song`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении рубрик'); - }); - } - - static getPlaylists() { - return this._get(`radio/playlists`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - static getPlaylist(id) { - return this._get(`radio/playlists/${id}`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - - static addSongToPlaylist(params) { - return this._post(`radio/playlists/add_to_playlist`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - static removeSongToPlaylist(params) { - return this._post(`radio/playlists/delete_song_with_playlist`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при удаления треков из плейлиста'); - }); - } - static updatePlaylist(params) { - return this._post(`radio/playlists/update_playlist`, {}, params).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при удаления треков из плейлиста'); - }); - } - - static createPlaylists() { - return this._post(`radio/playlists/create_playlist`, {}, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - - - static getNews(station, params) { - return this._get(`radio.mp3`, params, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } - static getProfiles(station, params) { - return this._get(`radio.mp3`, params, {}).then((data) => { - return data; - }).catch((error) => { - throw new RESTError(error, 'Ошибка при получении плейлистов'); - }); - } + static get settings() { + return settings; + } + static user(params) { + return this._get(`user`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Не удалось создать пользователя'); + }); + } + static loginUser(params) { + return this._post(`token`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Не удалось создать пользователя'); + }); + } + static createUser(params) { + return this._post(`user/create_user`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Не удалось создать пользователя'); + }); + } + + static updateUser(params) { + return this._post(`user/update_user`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Не удалось создать пользователя'); + }); + } + + static getTeams(station, params) { + return this._get(`radio/teams`, params, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении команды'); + }); + } + + static getCheckFavoriteSong(id) { + return this._get(`radio/song/check_is_favorite/${id}`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при проверке песни'); + }); + } + static getAllSong() { + return this._get(`radio/song/get_all_song`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получениии всех песен'); + }); + } + static getAudio(id) { + return this._get(`radio/song/get_audio/${id}`, {}, {}, false, true) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получениии песни'); + }); + } + static createFavoriteForUser(params) { + return this._post(`radio/song/add_favorite`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + + static removeFavoriteForUser(params) { + return this._post(`radio/song/delete_song`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + + static getFavoriteList(params) { + return this._get(`radio/song`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + static getRubriks() { + return this._get(`radio/rubriks`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении рубрик'); + }); + } + static getRubrik(id) { + return this._get(`radio/rubriks/${id}`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении рубрик'); + }); + } + + static removeFavorites(params) { + return this._post(`radio/song/delete_song`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении рубрик'); + }); + } + + static getPlaylists() { + return this._get(`radio/playlists`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + static getPlaylist(id) { + return this._get(`radio/playlists/${id}`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + + static addSongToPlaylist(params) { + return this._post(`radio/playlists/add_to_playlist`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + static removeSongToPlaylist(params) { + return this._post(`radio/playlists/delete_song_with_playlist`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при удаления треков из плейлиста'); + }); + } + static updatePlaylist(params) { + return this._post(`radio/playlists/update_playlist`, {}, params) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при удаления треков из плейлиста'); + }); + } + + static createPlaylists() { + return this._post(`radio/playlists/create_playlist`, {}, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + + static getNews(station, params) { + return this._get(`radio.mp3`, params, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } + static getProfiles(station, params) { + return this._get(`radio.mp3`, params, {}) + .then((data) => { + return data; + }) + .catch((error) => { + throw new RESTError(error, 'Ошибка при получении плейлистов'); + }); + } } diff --git a/client/src/services/audio.js b/client/src/services/audio.js index 203b23f..3907068 100644 --- a/client/src/services/audio.js +++ b/client/src/services/audio.js @@ -1,6 +1,5 @@ -import { urlPathAudio as settings } from '@/settings'; +import { urlPathAudio as settings, urlPathAudio } from '@/settings'; import { REST, RESTError } from './rest'; -import { urlPathAudio } from '@/settings'; export default class extends REST { static get settings() { diff --git a/client/src/services/rest.js b/client/src/services/rest.js index f0ebcf7..b5edd5f 100644 --- a/client/src/services/rest.js +++ b/client/src/services/rest.js @@ -4,88 +4,115 @@ import store from '@/store'; import cache from '@/utils/cache'; class RESTError extends Error { - constructor(error, message, params={}) { - let detail = error.response && error.response.data && (error.response.data.detail || error.response.data.error && error.response.data.error.detail); - let header = (message || error.message) + (detail ? ': ' + detail : ''); - super(header); + constructor(error, message, params = {}) { + let detail = + error.response && + error.response.data && + (error.response.data.detail || + (error.response.data.error && error.response.data.error.detail)); + let header = (message || error.message) + (detail ? ': ' + detail : ''); + super(header); - this.name = this.constructor.name; - this.parent = error; - this.detail = detail; - this.response = error.response; - for (let k in params) { - this[k] = params[k]; - } - - //if (this.response && (this.response.status === 401 || this.response.status === 403)) { - if (this.response && (this.response.status === 401)) { - store.dispatch('deathUser'); - store.dispatch('setShowAuthModal', true); - } else { - if (typeof Error.captureStackTrace === 'function') { - Error.captureStackTrace(this, this.constructor); - } else { - this.stack = (new Error(header)).stack; - } - } + this.name = this.constructor.name; + this.parent = error; + this.detail = detail; + this.response = error.response; + for (let k in params) { + this[k] = params[k]; } + + //if (this.response && (this.response.status === 401 || this.response.status === 403)) { + if (this.response && this.response.status === 401) { + store.dispatch('deathUser'); + store.dispatch('setShowAuthModal', true); + } else { + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error(header).stack; + } + } + } } class REST { - static get settings() { - throw new Error('settings must be overridden'); - } - static _get(url, params={}, extraParams, use_cache=false, isBlob=false) { - return this._request('get', url, params, {}, {}, extraParams, use_cache, isBlob); - } - static _post(url, params, data) { - return this._request('post', url, params, data); - } - static _put(url, params, data) { - return this._request('put', url, params, data); - } - static _patch(url, params, data) { - return this._request('patch', url, params, data); - } - static _delete(url, params, data) { - return this._request('delete', url, params, data); - } - static _request(method, url, params={}, data={}, extraData={}, extraParams={}, use_cache=false, isBlob=false) { - let cache_key = null; - return ajax.request({ - method, - url: `${this.settings}${url ? '/' : ''}${url}/`, - params, - data, - extraData, - extraParams, - headers: this._getAuthHeaders(), - responseType: this._getResponseType(isBlob), - }).then((response) => { - if (cache_key) { - cache.set(cache_key, response.data); - } - return response.data; - }); - } - static _getResponseType(value){ - if (value) { - return 'arraybuffer' + static get settings() { + throw new Error('settings must be overridden'); + } + static _get( + url, + params = {}, + extraParams, + use_cache = false, + isBlob = false, + ) { + return this._request( + 'get', + url, + params, + {}, + {}, + extraParams, + use_cache, + isBlob, + ); + } + static _post(url, params, data) { + return this._request('post', url, params, data); + } + static _put(url, params, data) { + return this._request('put', url, params, data); + } + static _patch(url, params, data) { + return this._request('patch', url, params, data); + } + static _delete(url, params, data) { + return this._request('delete', url, params, data); + } + static _request( + method, + url, + params = {}, + data = {}, + extraData = {}, + extraParams = {}, + use_cache = false, + isBlob = false, + ) { + let cache_key = null; + return ajax + .request({ + method, + url: `${this.settings}${url ? '/' : ''}${url}/`, + params, + data, + extraData, + extraParams, + headers: this._getAuthHeaders(), + responseType: this._getResponseType(isBlob), + }) + .then((response) => { + if (cache_key) { + cache.set(cache_key, response.data); } + return response.data; + }); + } + static _getResponseType(value) { + if (value) { + return 'arraybuffer'; } - static _getAuthHeaders() { - if (store.state.token) { - return { 'Authorization': `Bearer ${store.state.token}` }; - } - } - static _cancelToken() { - return ajax.cancelToken(); + } + static _getAuthHeaders() { + if (store.state.token) { + return { Authorization: `Bearer ${store.state.token}` }; } + } + static _cancelToken() { + return ajax.cancelToken(); + } } export default REST; -export { - RESTError, - REST -}; +export { RESTError, REST }; diff --git a/client/src/settings/index.js b/client/src/settings/index.js index e0606eb..15eeedb 100644 --- a/client/src/settings/index.js +++ b/client/src/settings/index.js @@ -1,53 +1,45 @@ //throw new Error('Settings module must be replaced depending on mode'); const ajax = { - timeout: process.env.AJAX_TIMEOUT, - responseType: process.env.AJAX_RESPONSE_TYPE, - responseEncoding: process.env.AJAX_ENCODING + timeout: process.env.AJAX_TIMEOUT, + responseType: process.env.AJAX_RESPONSE_TYPE, + responseEncoding: process.env.AJAX_ENCODING, }; const cache = { - storage: process.env.CACHE_STORAGE + storage: process.env.CACHE_STORAGE, }; const serviceUrl = { - selfUrl: process.env.SERVICE_SELF_URL, - url: process.env.SERVICE_URL, - protocol: process.env.SERVICE_PROTOCOL, - port: process.env.SERVICE_PORT, - api: process.env.SERVICE_API, - apiAudio: process.env.SERVICE_URL_AUDIO, - localPath: '//localhost', - onLocal: (process.env.SERVICE_ON_LOCAL === 'true') -} + selfUrl: process.env.SERVICE_SELF_URL, + url: process.env.SERVICE_URL, + protocol: process.env.SERVICE_PROTOCOL, + port: process.env.SERVICE_PORT, + api: process.env.SERVICE_API, + apiAudio: process.env.SERVICE_URL_AUDIO, + localPath: '//localhost', + onLocal: process.env.SERVICE_ON_LOCAL === 'true', +}; let urlPath = `${serviceUrl.protocol}:${serviceUrl.url}${serviceUrl.api}`; let urlPathAudio = `${serviceUrl.protocol}:${serviceUrl.apiAudio}`; if (process.env.CLIENT) { - if (serviceUrl.onLocal || window.location.hostname === 'localhost') { - urlPath = `${serviceUrl.localPath}:${serviceUrl.port}${serviceUrl.api}`; - } + if (serviceUrl.onLocal || window.location.hostname === 'localhost') { + urlPath = `${serviceUrl.localPath}:${serviceUrl.port}${serviceUrl.api}`; + } } -let selfUrl = `${serviceUrl.protocol}:${serviceUrl.url}` +let selfUrl = `${serviceUrl.protocol}:${serviceUrl.url}`; let selfPath = `${serviceUrl.protocol}:${serviceUrl.selfUrl}`; const robotsTxt = { - filePath: '/robots.txt', - host: selfPath, - policy: [ - { - userAgent: process.env.ROBOTS_USER_AGENT, - allow: JSON.parse(process.env.ROBOTS_ALLOW || null), - disallow: JSON.parse(process.env.ROBOTS_DISALLOW || null), - } - ] + filePath: '/robots.txt', + host: selfPath, + policy: [ + { + userAgent: process.env.ROBOTS_USER_AGENT, + allow: JSON.parse(process.env.ROBOTS_ALLOW || null), + disallow: JSON.parse(process.env.ROBOTS_DISALLOW || null), + }, + ], }; -export { - selfUrl, - ajax, - cache, - urlPath, - urlPathAudio, - selfPath, - robotsTxt, -}; +export { selfUrl, ajax, cache, urlPath, urlPathAudio, selfPath, robotsTxt }; diff --git a/client/src/store/index.js b/client/src/store/index.js index 345355c..3d1c56c 100644 --- a/client/src/store/index.js +++ b/client/src/store/index.js @@ -1,144 +1,143 @@ -import {createStore} from 'vuex' +import { createStore } from 'vuex'; import VuexPersist from 'vuex-persist'; const vuexPersist = new VuexPersist({ - key: 'it-radio', - //storage: window.localStorage + key: 'it-radio', + //storage: window.localStorage }); // Vue.use(Vuex); export default createStore({ - state() { - return { - token: null, - refreshToken: null, - user: null, - modal:{ - auth: false, - changingUser: false - }, - showAuthModal: false, - station: { - id: 1 - }, - currentPlay: { - isPlay: false, - isLoader: false, - live: true, - volume: 50, - currentIndex: null, - }, - player: { - target: null, - }, - userFavorite: { - podcast: [], - playlist: [], - songs: [] - } - } + state() { + return { + token: null, + refreshToken: null, + user: null, + modal: { + auth: false, + changingUser: false, + }, + showAuthModal: false, + station: { + id: 1, + }, + currentPlay: { + isPlay: false, + isLoader: false, + live: true, + volume: 50, + currentIndex: null, + }, + player: { + target: null, + }, + userFavorite: { + podcast: [], + playlist: [], + songs: [], + }, + }; + }, + plugins: [vuexPersist.plugin], + mutations: { + user(state, user) { + state.user = user; }, - plugins: [vuexPersist.plugin], - mutations: { - user(state, user) { - state.user = user; - }, - updateToken(state, tokens) { - state.token = tokens.access; - state.refreshToken = tokens.refresh; - }, - removeToken(state) { - state.token = null; - state.refreshToken = null; - }, - setCurrentPlay(state, song) { - state.currentPlay = song; - }, - setModal(state, show) { - state.modal = {...state.modal, ...show} - }, - setPlayer(state, params) { - state.player = {...state.player, ...params} - }, - initPlayer(state) { - state.player.target = document.createElement('audio') - state.player.target.src = ''; - state.player.target.preload = 'auto'; - state.player.target.controls = true; - state.player.target.volume = 0.5; - console.log('initPlayer', state.player.target) - }, - changePlayer(state, params) { - const awaitPlay = () => { - if (state.player.target.readyState >= 4) { - if (state.currentPlay.isPlay){ - state.player.target.play(); - } - state.currentPlay.isLoader = false; - state.player.target.removeEventListener('canplaythrough', awaitPlay); - } else { - awaitPlay(); - } - } - - state.player.target.src = params; - state.player.src = params; - console.log(state.player.target.src) - // state.currentPlay.isLoader = true; - state.player.target.addEventListener('canplaythrough', awaitPlay) - - }, - handlerPlayer(state, params) { - if (params.pause) { - state.currentPlay.isPlay = false; - state.player.target.pause(); - } - if (params.play) { - if (state.player.target.readyState >= 3){ - state.currentPlay.isPlay = true; - state.player.target.play(); - } - } - if (params.volume) { - state.player.target.volume = params.volume; - } - }, - setUserFavorite(state, params) { - state.userFavorite = {...state.userFavorite, ...params} - } + updateToken(state, tokens) { + state.token = tokens.access; + state.refreshToken = tokens.refresh; }, - actions: { - setToken(context, tokens) { - context.commit('updateToken', tokens); - }, - setUser(context, user) { - context.commit('user', user); - }, - deathUser(context) { - context.commit('user', {}); - context.commit('removeToken'); - }, - setCurrentPlay(context, song) { - context.commit('setCurrentPlay', song); - }, - setModal(context, show) { - context.commit('setModal', show); - }, - setPlayer(context, params) { - context.commit('setPlayer', params); - }, - initPlayer(context) { - context.commit('initPlayer'); - }, - handlerPlayer(context, params) { - context.commit('handlerPlayer', params); - }, - changePlayer(context, params) { - context.commit('changePlayer', params); - }, - setUserFavorite(context, params) { - context.commit('setUserFavorite', params); - }, - } + removeToken(state) { + state.token = null; + state.refreshToken = null; + }, + setCurrentPlay(state, song) { + state.currentPlay = song; + }, + setModal(state, show) { + state.modal = { ...state.modal, ...show }; + }, + setPlayer(state, params) { + state.player = { ...state.player, ...params }; + }, + initPlayer(state) { + state.player.target = document.createElement('audio'); + state.player.target.src = ''; + state.player.target.preload = 'auto'; + state.player.target.controls = true; + state.player.target.volume = 0.5; + console.log('initPlayer', state.player.target); + }, + changePlayer(state, params) { + const awaitPlay = () => { + if (state.player.target.readyState >= 4) { + if (state.currentPlay.isPlay) { + state.player.target.play(); + } + state.currentPlay.isLoader = false; + state.player.target.removeEventListener('canplaythrough', awaitPlay); + } else { + awaitPlay(); + } + }; + + state.player.target.src = params; + state.player.src = params; + console.log(state.player.target.src); + // state.currentPlay.isLoader = true; + state.player.target.addEventListener('canplaythrough', awaitPlay); + }, + handlerPlayer(state, params) { + if (params.pause) { + state.currentPlay.isPlay = false; + state.player.target.pause(); + } + if (params.play) { + if (state.player.target.readyState >= 3) { + state.currentPlay.isPlay = true; + state.player.target.play(); + } + } + if (params.volume) { + state.player.target.volume = params.volume; + } + }, + setUserFavorite(state, params) { + state.userFavorite = { ...state.userFavorite, ...params }; + }, + }, + actions: { + setToken(context, tokens) { + context.commit('updateToken', tokens); + }, + setUser(context, user) { + context.commit('user', user); + }, + deathUser(context) { + context.commit('user', {}); + context.commit('removeToken'); + }, + setCurrentPlay(context, song) { + context.commit('setCurrentPlay', song); + }, + setModal(context, show) { + context.commit('setModal', show); + }, + setPlayer(context, params) { + context.commit('setPlayer', params); + }, + initPlayer(context) { + context.commit('initPlayer'); + }, + handlerPlayer(context, params) { + context.commit('handlerPlayer', params); + }, + changePlayer(context, params) { + context.commit('changePlayer', params); + }, + setUserFavorite(context, params) { + context.commit('setUserFavorite', params); + }, + }, }); diff --git a/client/src/store/module-example/actions.js b/client/src/store/module-example/actions.js index cf42235..05658c1 100644 --- a/client/src/store/module-example/actions.js +++ b/client/src/store/module-example/actions.js @@ -1,2 +1 @@ -export function someAction (/* context */) { -} +export function someAction(/* context */) {} diff --git a/client/src/store/module-example/getters.js b/client/src/store/module-example/getters.js index ce8aa1f..9138e2e 100644 --- a/client/src/store/module-example/getters.js +++ b/client/src/store/module-example/getters.js @@ -1,2 +1 @@ -export function someGetter (/* state */) { -} +export function someGetter(/* state */) {} diff --git a/client/src/store/module-example/index.js b/client/src/store/module-example/index.js index babab8e..7588a3c 100644 --- a/client/src/store/module-example/index.js +++ b/client/src/store/module-example/index.js @@ -1,12 +1,12 @@ -import state from './state' -import * as getters from './getters' -import * as mutations from './mutations' -import * as actions from './actions' +import state from './state'; +import * as getters from './getters'; +import * as mutations from './mutations'; +import * as actions from './actions'; export default { namespaced: true, getters, mutations, actions, - state -} + state, +}; diff --git a/client/src/store/module-example/mutations.js b/client/src/store/module-example/mutations.js index ce57bfb..02e5067 100644 --- a/client/src/store/module-example/mutations.js +++ b/client/src/store/module-example/mutations.js @@ -1,2 +1 @@ -export function someMutation (/* state */) { -} +export function someMutation(/* state */) {} diff --git a/client/src/store/module-example/state.js b/client/src/store/module-example/state.js index 6fd747c..80e25b9 100644 --- a/client/src/store/module-example/state.js +++ b/client/src/store/module-example/state.js @@ -1,5 +1,5 @@ export default function () { return { // - } + }; } diff --git a/client/src/utils/ajax.js b/client/src/utils/ajax.js index dbdd3e1..b519095 100644 --- a/client/src/utils/ajax.js +++ b/client/src/utils/ajax.js @@ -3,88 +3,91 @@ import axios from 'axios'; import { ajax as settings } from '@/settings'; export default class { - static get(params) { - return this.request(_defaults({ method: 'get' }, params)); + static get(params) { + return this.request(_defaults({ method: 'get' }, params)); + } + static post(params) { + return this.request(_defaults({ method: 'post' }, params)); + } + static put(params) { + return this.request(_defaults({ method: 'put' }, params)); + } + static patch(params) { + return this.request(_defaults({ method: 'patch' }, params)); + } + static delete(params) { + return this.request(_defaults({ method: 'delete' }, params)); + } + static request(params) { + if (params.extraData) { + params.data = this.__append_extra_data(params.data, params.extraData); + delete params.extraData; } - static post(params) { - return this.request(_defaults({ method: 'post' }, params)); + if (params.extraParams) { + params.params = this.__append_extra_params( + params.params, + params.extraParams, + ); + delete params.extraParams; } - static put(params) { - return this.request(_defaults({ method: 'put' }, params)); - } - static patch(params) { - return this.request(_defaults({ method: 'patch' }, params)); - } - static delete(params) { - return this.request(_defaults({ method: 'delete' }, params)); - } - static request(params) { - if (params.extraData) { - params.data = this.__append_extra_data(params.data, params.extraData); - delete params.extraData; - } - if (params.extraParams) { - params.params = this.__append_extra_params(params.params, params.extraParams); - delete params.extraParams; - } - /* + /* if (params.cancel) { params.cancelToken = this.CancelToken(params.cancel); delete params.cancel; } */ - return axios.request(_defaults({}, params, this.settings)); - } - /* + return axios.request(_defaults({}, params, this.settings)); + } + /* static cancelToken() { return axios.CancelToken.source(); } */ - static getUri(params) { - return axios.getUri(params); - } - static __append_extra_data(data, extra) { - data = data || {}; + static getUri(params) { + return axios.getUri(params); + } + static __append_extra_data(data, extra) { + data = data || {}; - if (process.env.CLIENT && data instanceof FormData) { - for (let k in extra) { - data.append(k, extra[k]); - } - } else if (data instanceof URLSearchParams) { - for (let k in extra) { - data.append(k, extra[k]); - } - } else if (typeof data === 'string') { - for (let k in extra) { - if (data !== '') data += '&'; - data += encodeURIComponent(k) + '=' + encodeURIComponent(data[k]); - } - } else if (typeof data === 'object') { - for (let k in extra) { - data[k] = extra[k]; - } - } else { - throw new Error('Can\'t append extra data to this type of data'); - } - return data; + if (process.env.CLIENT && data instanceof FormData) { + for (let k in extra) { + data.append(k, extra[k]); + } + } else if (data instanceof URLSearchParams) { + for (let k in extra) { + data.append(k, extra[k]); + } + } else if (typeof data === 'string') { + for (let k in extra) { + if (data !== '') data += '&'; + data += encodeURIComponent(k) + '=' + encodeURIComponent(data[k]); + } + } else if (typeof data === 'object') { + for (let k in extra) { + data[k] = extra[k]; + } + } else { + throw new Error("Can't append extra data to this type of data"); } - static __append_extra_params(data, extra) { - data = data || {}; + return data; + } + static __append_extra_params(data, extra) { + data = data || {}; - if (data instanceof URLSearchParams) { - for (let k in extra) { - data.append(k, extra[k]); - } - } else if (typeof data === 'object') { - for (let k in extra) { - data[k] = extra[k]; - } - } else { - throw new Error('Can\'t append extra params to this type of params'); - } - return data; - } - static get settings() { - return settings; + if (data instanceof URLSearchParams) { + for (let k in extra) { + data.append(k, extra[k]); + } + } else if (typeof data === 'object') { + for (let k in extra) { + data[k] = extra[k]; + } + } else { + throw new Error("Can't append extra params to this type of params"); } + return data; + } + static get settings() { + return settings; + } } diff --git a/client/src/utils/cache.js b/client/src/utils/cache.js index a552df4..f1992ee 100644 --- a/client/src/utils/cache.js +++ b/client/src/utils/cache.js @@ -2,74 +2,71 @@ import _keys from 'lodash/keys'; import { cache as settings } from '@/settings'; class Converter { - static encode(value) { - return this.__isComplex(value) ? JSON.stringify(value) : value; - } - static decode(value) { - return this.__isJSON(value) ? JSON.parse(value) : value; - } - static __isComplex(value) { - return (value instanceof Array || typeof value === 'object'); - } - static __isJSON(value) { - return (typeof value === 'string' && /^(\{|\[)/.test(value)); - } + static encode(value) { + return this.__isComplex(value) ? JSON.stringify(value) : value; + } + static decode(value) { + return this.__isJSON(value) ? JSON.parse(value) : value; + } + static __isComplex(value) { + return value instanceof Array || typeof value === 'object'; + } + static __isJSON(value) { + return typeof value === 'string' && /^(\{|\[)/.test(value); + } } - class TempStorage { - constructor() { - this.__data = {}; - } - getItem(key) { - return this.__data[key]; - } - setItem(key, value) { - this.__data[key] = value; - } - removeItem(key) { - delete this.__data[key]; - } - clear() { - this.__data = {}; - } - get length() { - return _keys(this.__data).length; - } + constructor() { + this.__data = {}; + } + getItem(key) { + return this.__data[key]; + } + setItem(key, value) { + this.__data[key] = value; + } + removeItem(key) { + delete this.__data[key]; + } + clear() { + this.__data = {}; + } + get length() { + return _keys(this.__data).length; + } } - class Cache { - constructor(storage) { - if (storage === 'tempStorage') { - this._storage = new TempStorage(); - } else { - if (!(storage in window)) { - throw new Error(`Storage ${storage} is not supported`); - } - this._storage = window[storage]; - } + constructor(storage) { + if (storage === 'tempStorage') { + this._storage = new TempStorage(); + } else { + if (!(storage in window)) { + throw new Error(`Storage ${storage} is not supported`); + } + this._storage = window[storage]; } - get(key) { - return Converter.decode(this._storage.getItem(key)); - } - set(key, value) { - this._storage.setItem(key, Converter.encode(value)); - } - remove(key) { - this._storage.removeItem(key); - } - clear() { - this._storage.clear(); - } - key(ns, type, data) { - let key = ns + ':' + type; - if (data) { - key += ':' + JSON.stringify(data, _keys(data).sort()); - } - return key; + } + get(key) { + return Converter.decode(this._storage.getItem(key)); + } + set(key, value) { + this._storage.setItem(key, Converter.encode(value)); + } + remove(key) { + this._storage.removeItem(key); + } + clear() { + this._storage.clear(); + } + key(ns, type, data) { + let key = ns + ':' + type; + if (data) { + key += ':' + JSON.stringify(data, _keys(data).sort()); } + return key; + } } - export default new Cache(settings.storage); diff --git a/client/src/utils/helpers.js b/client/src/utils/helpers.js index 9767219..30d5425 100644 --- a/client/src/utils/helpers.js +++ b/client/src/utils/helpers.js @@ -1,25 +1,20 @@ - - const helpers = { - range: (start, end, step = 1, toFixed = null) => { - let arr = [] + range: (start, end, step = 1, toFixed = null) => { + let arr = []; - while(start <= end) { - if (toFixed) - start = Number(start.toFixed(toFixed)) - arr.push(start) - start += step - } - return arr - }, -} + while (start <= end) { + if (toFixed) start = Number(start.toFixed(toFixed)); + arr.push(start); + start += step; + } + return arr; + }, +}; export default { - install (app) { - app.helpers = helpers - app.config.globalProperties.$helpers = helpers - } -} -export { - helpers -} + install(app) { + app.helpers = helpers; + app.config.globalProperties.$helpers = helpers; + }, +}; +export { helpers }; diff --git a/client/src/views/Page404.vue b/client/src/views/Page404.vue index ade4c67..b16aee0 100644 --- a/client/src/views/Page404.vue +++ b/client/src/views/Page404.vue @@ -1,61 +1,54 @@ diff --git a/client/src/views/Page500.vue b/client/src/views/Page500.vue index e12be6a..ded5180 100644 --- a/client/src/views/Page500.vue +++ b/client/src/views/Page500.vue @@ -1,60 +1,47 @@ diff --git a/client/src/views/about.vue b/client/src/views/about.vue index 7f85abc..219cb8e 100644 --- a/client/src/views/about.vue +++ b/client/src/views/about.vue @@ -1,103 +1,113 @@ diff --git a/client/src/views/contacts.vue b/client/src/views/contacts.vue index 2a4ee40..7d41275 100644 --- a/client/src/views/contacts.vue +++ b/client/src/views/contacts.vue @@ -1,112 +1,131 @@ diff --git a/client/src/views/home.vue b/client/src/views/home.vue index 6946517..bb6a775 100644 --- a/client/src/views/home.vue +++ b/client/src/views/home.vue @@ -1,133 +1,140 @@ diff --git a/client/src/views/playlist-edit.vue b/client/src/views/playlist-edit.vue index 6f62261..eedeffc 100644 --- a/client/src/views/playlist-edit.vue +++ b/client/src/views/playlist-edit.vue @@ -1,179 +1,203 @@ diff --git a/client/src/views/playlist.vue b/client/src/views/playlist.vue index b672fe1..61edfe1 100644 --- a/client/src/views/playlist.vue +++ b/client/src/views/playlist.vue @@ -1,55 +1,63 @@ diff --git a/client/src/views/playlists.vue b/client/src/views/playlists.vue index 2b16562..6301780 100644 --- a/client/src/views/playlists.vue +++ b/client/src/views/playlists.vue @@ -1,109 +1,109 @@ diff --git a/client/src/views/podcasts.vue b/client/src/views/podcasts.vue index 743e77d..154ca46 100644 --- a/client/src/views/podcasts.vue +++ b/client/src/views/podcasts.vue @@ -1,11 +1,9 @@ diff --git a/client/src/views/profile.vue b/client/src/views/profile.vue index 017e07f..fab2c15 100644 --- a/client/src/views/profile.vue +++ b/client/src/views/profile.vue @@ -1,171 +1,198 @@ diff --git a/client/src/views/rubric.vue b/client/src/views/rubric.vue index c1bcbf1..0739aea 100644 --- a/client/src/views/rubric.vue +++ b/client/src/views/rubric.vue @@ -1,21 +1,21 @@ diff --git a/client/src/views/support.vue b/client/src/views/support.vue index 7550956..63aba05 100644 --- a/client/src/views/support.vue +++ b/client/src/views/support.vue @@ -1,11 +1,9 @@