From 8c9db67b95b3d1f99c19e353b4a8d804d7ecdf25 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 25 May 2021 16:13:15 +0200 Subject: [PATCH] [core] Seperated all plugins from the main source tree --- .../utils => api/components}/IsoDateInput.vue | 2 +- .../components}/PasswordInput.vue | 0 api/components/index.ts | 4 + api/index.ts | 7 + api/package.json | 40 ++ api/shims-vue.d.ts | 6 + api/src/internal.ts | 6 + api/src/stores/index.ts | 3 + src/stores/index.ts => api/src/stores/main.ts | 16 +- api/src/stores/session.ts | 69 +++ .../user/store.ts => api/src/stores/user.ts | 71 +-- {src => api/src}/utils/datetime.ts | 0 {src => api/src}/utils/loading.ts | 0 {src => api/src}/utils/permission.ts | 2 +- {src => api/src}/utils/validators.ts | 0 api/tsconfig.json | 16 + package.json | 11 +- plugin.config.js | 6 + quasar.conf.js | 33 +- src/boot/axios.ts | 10 +- src/boot/login.ts | 3 +- src/boot/plugins.ts | 226 ++++---- src/boot/store.ts | 9 +- src/components/Notification.vue | 4 +- .../navigation/EssentialExpansionLink.vue | 4 +- src/components/navigation/EssentialLink.vue | 4 +- src/components/navigation/ShortcutLink.vue | 4 +- src/layouts/MainLayout.vue | 16 +- src/layouts/OutLayout.vue | 2 +- src/pages/Dashboard.vue | 4 +- src/pages/Login.vue | 17 +- src/pages/Offline.vue | 4 +- src/pages/Reset.vue | 2 +- src/pages/about/About.vue | 2 +- src/plugins/balance/components/BalanceAdd.vue | 115 ---- .../balance/components/BalanceHeader.vue | 66 --- .../balance/components/BalanceTransfer.vue | 75 --- .../balance/components/Transaction.vue | 107 ---- src/plugins/balance/components/Widget.vue | 29 - src/plugins/balance/pages/Admin.vue | 59 -- src/plugins/balance/pages/MainPage.vue | 135 ----- src/plugins/balance/pages/Overview.vue | 166 ------ src/plugins/balance/permissions.ts | 21 - src/plugins/balance/plugin.ts | 21 - src/plugins/balance/routes/index.ts | 50 -- src/plugins/balance/store.ts | 166 ------ .../BuildManual/BuildManualVolume.vue | 62 --- .../BuildManual/BuildManualVolumePart.vue | 65 --- .../pricelist/components/CalculationTable.vue | 512 ------------------ .../CalculationTable/BuildManual.vue | 60 -- .../CalculationTable/DrinkPriceVolumes.vue | 340 ------------ .../CalculationTable/Ingredients.vue | 271 --------- .../components/CalculationTable/NewPrice.vue | 59 -- .../pricelist/components/DrinkModify.vue | 354 ------------ .../pricelist/components/DrinkTypes.vue | 113 ---- .../pricelist/components/ExtraIngredients.vue | 154 ------ .../pricelist/components/MinPriceSetting.vue | 55 -- .../pricelist/components/Pricelist.vue | 327 ----------- .../pricelist/components/SearchInput.vue | 89 --- src/plugins/pricelist/components/Tags.vue | 181 ------- .../pricelist/pages/CocktailBuilder.vue | 65 --- .../pricelist/pages/InnerPricelist.vue | 38 -- .../pricelist/pages/OuterPricelist.vue | 36 -- src/plugins/pricelist/pages/Receipts.vue | 175 ------ src/plugins/pricelist/pages/Settings.vue | 136 ----- src/plugins/pricelist/permissions.ts | 33 -- src/plugins/pricelist/plugin.ts | 14 - src/plugins/pricelist/routes/index.ts | 73 --- src/plugins/pricelist/store.ts | 313 ----------- src/plugins/pricelist/utils/filter.ts | 39 -- src/plugins/pricelist/utils/sort.ts | 7 - src/plugins/pricelist/utils/utils.ts | 84 --- src/plugins/schedule/components/Widget.vue | 25 - .../components/management/EditEvent.vue | 245 --------- .../components/management/EventTypes.vue | 126 ----- .../schedule/components/management/Job.vue | 113 ---- .../components/management/JobTypes.vue | 125 ----- .../components/management/RecurrenceRule.vue | 96 ---- .../components/overview/AgendaView.vue | 241 --------- .../components/overview/slots/EventSlot.vue | 99 ---- .../components/overview/slots/JobSlot.vue | 142 ----- src/plugins/schedule/events.d.ts | 9 - src/plugins/schedule/pages/Event.vue | 29 - src/plugins/schedule/pages/Management.vue | 95 ---- src/plugins/schedule/pages/Overview.vue | 87 --- src/plugins/schedule/pages/Requests.vue | 8 - src/plugins/schedule/permissions.ts | 16 - src/plugins/schedule/plugin.ts | 22 - src/plugins/schedule/routes/index.ts | 56 -- src/plugins/schedule/store.ts | 165 ------ src/plugins/user/components/NewUser.vue | 39 -- src/plugins/user/components/UpdateUser.vue | 40 -- src/plugins/user/components/UserSelector.vue | 43 -- src/plugins/user/components/Widget.vue | 72 --- .../components/settings/MainUserSettings.vue | 218 -------- .../user/components/settings/RoleSettings.vue | 160 ------ .../user/components/settings/Session.vue | 168 ------ src/plugins/user/models.ts | 14 - src/plugins/user/pages/AdminSettings.vue | 93 ---- src/plugins/user/pages/Settings.vue | 57 -- src/plugins/user/permissions.ts | 12 - src/plugins/user/plugin.ts | 21 - src/plugins/user/routes/index.ts | 39 -- src/router/index.ts | 19 +- src/stores/store-flag.d.ts | 9 - src/vendor-plugin.config.js | 1 + tsconfig.json | 2 +- 107 files changed, 348 insertions(+), 7626 deletions(-) rename {src/components/utils => api/components}/IsoDateInput.vue (99%) rename {src/components/utils => api/components}/PasswordInput.vue (100%) create mode 100644 api/components/index.ts create mode 100644 api/index.ts create mode 100644 api/package.json create mode 100644 api/shims-vue.d.ts create mode 100644 api/src/internal.ts create mode 100644 api/src/stores/index.ts rename src/stores/index.ts => api/src/stores/main.ts (92%) create mode 100644 api/src/stores/session.ts rename src/plugins/user/store.ts => api/src/stores/user.ts (63%) rename {src => api/src}/utils/datetime.ts (100%) rename {src => api/src}/utils/loading.ts (100%) rename {src => api/src}/utils/permission.ts (91%) rename {src => api/src}/utils/validators.ts (100%) create mode 100644 api/tsconfig.json create mode 100644 plugin.config.js delete mode 100644 src/plugins/balance/components/BalanceAdd.vue delete mode 100644 src/plugins/balance/components/BalanceHeader.vue delete mode 100644 src/plugins/balance/components/BalanceTransfer.vue delete mode 100644 src/plugins/balance/components/Transaction.vue delete mode 100644 src/plugins/balance/components/Widget.vue delete mode 100644 src/plugins/balance/pages/Admin.vue delete mode 100644 src/plugins/balance/pages/MainPage.vue delete mode 100644 src/plugins/balance/pages/Overview.vue delete mode 100644 src/plugins/balance/permissions.ts delete mode 100644 src/plugins/balance/plugin.ts delete mode 100644 src/plugins/balance/routes/index.ts delete mode 100644 src/plugins/balance/store.ts delete mode 100644 src/plugins/pricelist/components/BuildManual/BuildManualVolume.vue delete mode 100644 src/plugins/pricelist/components/BuildManual/BuildManualVolumePart.vue delete mode 100644 src/plugins/pricelist/components/CalculationTable.vue delete mode 100644 src/plugins/pricelist/components/CalculationTable/BuildManual.vue delete mode 100644 src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue delete mode 100644 src/plugins/pricelist/components/CalculationTable/Ingredients.vue delete mode 100644 src/plugins/pricelist/components/CalculationTable/NewPrice.vue delete mode 100644 src/plugins/pricelist/components/DrinkModify.vue delete mode 100644 src/plugins/pricelist/components/DrinkTypes.vue delete mode 100644 src/plugins/pricelist/components/ExtraIngredients.vue delete mode 100644 src/plugins/pricelist/components/MinPriceSetting.vue delete mode 100644 src/plugins/pricelist/components/Pricelist.vue delete mode 100644 src/plugins/pricelist/components/SearchInput.vue delete mode 100644 src/plugins/pricelist/components/Tags.vue delete mode 100644 src/plugins/pricelist/pages/CocktailBuilder.vue delete mode 100644 src/plugins/pricelist/pages/InnerPricelist.vue delete mode 100644 src/plugins/pricelist/pages/OuterPricelist.vue delete mode 100644 src/plugins/pricelist/pages/Receipts.vue delete mode 100644 src/plugins/pricelist/pages/Settings.vue delete mode 100644 src/plugins/pricelist/permissions.ts delete mode 100644 src/plugins/pricelist/plugin.ts delete mode 100644 src/plugins/pricelist/routes/index.ts delete mode 100644 src/plugins/pricelist/store.ts delete mode 100644 src/plugins/pricelist/utils/filter.ts delete mode 100644 src/plugins/pricelist/utils/sort.ts delete mode 100644 src/plugins/pricelist/utils/utils.ts delete mode 100644 src/plugins/schedule/components/Widget.vue delete mode 100644 src/plugins/schedule/components/management/EditEvent.vue delete mode 100644 src/plugins/schedule/components/management/EventTypes.vue delete mode 100644 src/plugins/schedule/components/management/Job.vue delete mode 100644 src/plugins/schedule/components/management/JobTypes.vue delete mode 100644 src/plugins/schedule/components/management/RecurrenceRule.vue delete mode 100644 src/plugins/schedule/components/overview/AgendaView.vue delete mode 100644 src/plugins/schedule/components/overview/slots/EventSlot.vue delete mode 100644 src/plugins/schedule/components/overview/slots/JobSlot.vue delete mode 100644 src/plugins/schedule/events.d.ts delete mode 100644 src/plugins/schedule/pages/Event.vue delete mode 100644 src/plugins/schedule/pages/Management.vue delete mode 100644 src/plugins/schedule/pages/Overview.vue delete mode 100644 src/plugins/schedule/pages/Requests.vue delete mode 100644 src/plugins/schedule/permissions.ts delete mode 100644 src/plugins/schedule/plugin.ts delete mode 100644 src/plugins/schedule/routes/index.ts delete mode 100644 src/plugins/schedule/store.ts delete mode 100644 src/plugins/user/components/NewUser.vue delete mode 100644 src/plugins/user/components/UpdateUser.vue delete mode 100644 src/plugins/user/components/UserSelector.vue delete mode 100644 src/plugins/user/components/Widget.vue delete mode 100644 src/plugins/user/components/settings/MainUserSettings.vue delete mode 100644 src/plugins/user/components/settings/RoleSettings.vue delete mode 100644 src/plugins/user/components/settings/Session.vue delete mode 100644 src/plugins/user/models.ts delete mode 100644 src/plugins/user/pages/AdminSettings.vue delete mode 100644 src/plugins/user/pages/Settings.vue delete mode 100644 src/plugins/user/permissions.ts delete mode 100644 src/plugins/user/plugin.ts delete mode 100644 src/plugins/user/routes/index.ts delete mode 100644 src/stores/store-flag.d.ts create mode 100644 src/vendor-plugin.config.js diff --git a/src/components/utils/IsoDateInput.vue b/api/components/IsoDateInput.vue similarity index 99% rename from src/components/utils/IsoDateInput.vue rename to api/components/IsoDateInput.vue index 6d7460b..48ed355 100644 --- a/src/components/utils/IsoDateInput.vue +++ b/api/components/IsoDateInput.vue @@ -40,7 +40,7 @@ diff --git a/src/plugins/balance/components/BalanceHeader.vue b/src/plugins/balance/components/BalanceHeader.vue deleted file mode 100644 index 61a3171..0000000 --- a/src/plugins/balance/components/BalanceHeader.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - diff --git a/src/plugins/balance/components/BalanceTransfer.vue b/src/plugins/balance/components/BalanceTransfer.vue deleted file mode 100644 index fdfe0f5..0000000 --- a/src/plugins/balance/components/BalanceTransfer.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/src/plugins/balance/components/Transaction.vue b/src/plugins/balance/components/Transaction.vue deleted file mode 100644 index 167db0d..0000000 --- a/src/plugins/balance/components/Transaction.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - diff --git a/src/plugins/balance/components/Widget.vue b/src/plugins/balance/components/Widget.vue deleted file mode 100644 index bbbcdf4..0000000 --- a/src/plugins/balance/components/Widget.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - diff --git a/src/plugins/balance/pages/Admin.vue b/src/plugins/balance/pages/Admin.vue deleted file mode 100644 index eeab423..0000000 --- a/src/plugins/balance/pages/Admin.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - diff --git a/src/plugins/balance/pages/MainPage.vue b/src/plugins/balance/pages/MainPage.vue deleted file mode 100644 index 105930e..0000000 --- a/src/plugins/balance/pages/MainPage.vue +++ /dev/null @@ -1,135 +0,0 @@ - - - diff --git a/src/plugins/balance/pages/Overview.vue b/src/plugins/balance/pages/Overview.vue deleted file mode 100644 index d4e4678..0000000 --- a/src/plugins/balance/pages/Overview.vue +++ /dev/null @@ -1,166 +0,0 @@ - - - diff --git a/src/plugins/balance/permissions.ts b/src/plugins/balance/permissions.ts deleted file mode 100644 index 536f0f5..0000000 --- a/src/plugins/balance/permissions.ts +++ /dev/null @@ -1,21 +0,0 @@ -const PERMISSIONS = { - // Show own and others balance - SHOW: 'balance_show', - SHOW_OTHER: 'balance_show_others', - // Credit balance (give) - CREDIT: 'balance_credit', - // Debit balance (take) - DEBIT: 'balance_debit', - // Debit own balance only - DEBIT_OWN: 'balance_debit_own', - // Send from to other - SEND: 'balance_send', - // Send from other to another - SEND_OTHER: 'balance_send_others', - // Can set limit for users - SET_LIMIT: 'balance_set_limit', - //Allow sending / sub while exceeding the set limit - EXCEED_LIMIT: 'balance_exceed_limit', -}; - -export default PERMISSIONS; diff --git a/src/plugins/balance/plugin.ts b/src/plugins/balance/plugin.ts deleted file mode 100644 index 412ee2d..0000000 --- a/src/plugins/balance/plugin.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; -import { defineAsyncComponent } from 'vue'; -import routes from './routes'; - -const plugin: FG_Plugin.Plugin = { - name: 'Balance', - innerRoutes: routes, - requiredModules: ['User'], - requiredBackendModules: ['balance'], - version: '0.0.2', - widgets: [ - { - priority: 0, - name: 'current', - permissions: ['balance_show'], - widget: defineAsyncComponent(() => import('./components/Widget.vue')), - }, - ], -}; - -export default plugin; diff --git a/src/plugins/balance/routes/index.ts b/src/plugins/balance/routes/index.ts deleted file mode 100644 index 711b918..0000000 --- a/src/plugins/balance/routes/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; -import permissions from '../permissions'; - -const mainRoutes: FG_Plugin.MenuRoute[] = [ - { - title: 'Gerücht', - icon: 'mdi-cash-100', - permissions: ['user'], - route: { - path: 'balance', - name: 'balance', - redirect: { name: 'balance-view' }, - }, - children: [ - { - title: 'Übersicht', - icon: 'mdi-cash-check', - permissions: [permissions.SHOW], - route: { - path: 'overview', - name: 'balance-view', - component: () => import('../pages/Overview.vue'), - }, - }, - { - title: 'Buchen', - icon: 'mdi-cash-plus', - shortcut: true, - permissions: [permissions.DEBIT_OWN, permissions.SHOW], - route: { - path: 'change', - name: 'balance-change', - component: () => import('../pages/MainPage.vue'), - }, - }, - { - title: 'Verwaltung', - icon: 'mdi-account-cash', - permissions: [permissions.SET_LIMIT, permissions.SHOW_OTHER], - route: { - path: 'admin', - name: 'balance-admin', - component: () => import('../pages/Admin.vue'), - }, - }, - ], - }, -]; - -export default mainRoutes; diff --git a/src/plugins/balance/store.ts b/src/plugins/balance/store.ts deleted file mode 100644 index f961482..0000000 --- a/src/plugins/balance/store.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { api } from 'src/boot/axios'; - -interface BalanceResponse { - balance: number; - credit: number; - debit: number; - limit?: number; -} - -export interface BalancesResponse extends BalanceResponse { - userid: string; -} - -export interface TransactionsResponse { - transactions: Array; - count?: number; -} - -import { defineStore } from 'pinia'; -import { useMainStore } from 'src/stores'; -import { AxiosResponse } from 'axios'; -import { Notify } from 'quasar'; - -function fixTransaction(t: FG.Transaction) { - t.time = new Date(t.time); -} - -export const useBalanceStore = defineStore({ - id: 'balance', - - state: () => ({ - balances: [] as BalancesResponse[], - shortcuts: [] as number[], - transactions: [] as FG.Transaction[], - _balances_dirty: 0, - }), - - getters: { - balance(): BalancesResponse | undefined { - const mainStore = useMainStore(); - return this.balances.find((v) => v.userid === mainStore.user?.userid); - }, - }, - - actions: { - async createShortcut(shortcut: number) { - const mainStore = useMainStore(); - this.shortcuts.push(shortcut); - this.shortcuts.sort((a, b) => a - b); - await api.put(`/users/${mainStore.currentUser.userid}/balance/shortcuts`, this.shortcuts); - }, - - async removeShortcut(shortcut: number) { - const mainStore = useMainStore(); - this.shortcuts = this.shortcuts.filter((value: number) => value !== shortcut); - this.shortcuts.sort((a, b) => a - b); - await api.put(`/users/${mainStore.currentUser.userid}/balance/shortcuts`, this.shortcuts); - }, - - async getShortcuts(force = false) { - if (force || this.shortcuts.length == 0) { - const mainStore = useMainStore(); - const { data } = await api.get( - `/users/${mainStore.currentUser.userid}/balance/shortcuts` - ); - this.shortcuts = data; - } - }, - - async getBalance(user: FG.User) { - const { data } = await api.get(`/users/${user.userid}/balance`); - const idx = this.balances.findIndex((x) => x.userid === user.userid); - if (idx == -1) this.balances.push(Object.assign(data, { userid: user.userid })); - else this.balances[idx] = Object.assign(data, { userid: user.userid }); - return data; - }, - - async getBalances(force = false) { - if ( - force || - this.balances.length == 0 || - new Date().getTime() - this._balances_dirty > 60000 - ) { - const { data } = await api.get('/balance'); - this.balances = data; - } - return this.balances; - }, - - async changeBalance(amount: number, user: FG.User, sender: FG.User | undefined = undefined) { - const mainStore = useMainStore(); - try { - const { data } = await api.put(`/users/${user.userid}/balance`, { - amount, - user: user.userid, - sender: sender?.userid, - }); - fixTransaction(data); - if ( - user.userid === mainStore.currentUser.userid || - sender?.userid === mainStore.currentUser.userid - ) - this.transactions.push(data); - const f = this.balances.find((x) => x.userid === user.userid); - if (f) f.balance += amount; - if (sender) { - const f = this.balances.find((x) => x.userid === sender.userid); - if (f) f.balance += -1 * amount; - } - this._balances_dirty = 0; - return data; - } catch ({ response }) { - // Maybe Balance changed - if (response && (response).status == 409) { - Notify.create({ - type: 'negative', - group: false, - message: 'Das Limit wurde überschritten!', - timeout: 10000, - progress: true, - actions: [{ icon: 'mdi-close', color: 'white' }], - }); - //void this.getTransactions(true); - void this.getBalance(sender ? sender : user); - } - } - }, - - async getTransactions( - user: FG.User, - filter: - | { - limit?: number; - offset?: number; - from?: Date; - to?: Date; - showReversals?: boolean; - showCancelled?: boolean; - } - | undefined = undefined - ) { - if (!filter) filter = { limit: 10 }; - const { data } = await api.get( - `/users/${user.userid}/balance/transactions`, - { params: filter } - ); - data.transactions.forEach((t) => fixTransaction(t)); - if (data.transactions) this.transactions.push(...data.transactions); - return data; - }, - - async revert(transaction: FG.Transaction) { - try { - const { data } = await api.delete(`/balance/${transaction.id}`); - fixTransaction(data); - const f = this.transactions.find((x) => x.id === transaction.id); - if (f) f.reversal_id = data.id; - this.transactions.push(data); - console.log(data); - } catch (error) { - // ... - } - this._balances_dirty = 0; - }, - }, -}); diff --git a/src/plugins/pricelist/components/BuildManual/BuildManualVolume.vue b/src/plugins/pricelist/components/BuildManual/BuildManualVolume.vue deleted file mode 100644 index 66b1fcd..0000000 --- a/src/plugins/pricelist/components/BuildManual/BuildManualVolume.vue +++ /dev/null @@ -1,62 +0,0 @@ - - diff --git a/src/plugins/pricelist/components/BuildManual/BuildManualVolumePart.vue b/src/plugins/pricelist/components/BuildManual/BuildManualVolumePart.vue deleted file mode 100644 index 27e21ea..0000000 --- a/src/plugins/pricelist/components/BuildManual/BuildManualVolumePart.vue +++ /dev/null @@ -1,65 +0,0 @@ - - diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue deleted file mode 100644 index 80e92cd..0000000 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ /dev/null @@ -1,512 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/CalculationTable/BuildManual.vue b/src/plugins/pricelist/components/CalculationTable/BuildManual.vue deleted file mode 100644 index b3e746a..0000000 --- a/src/plugins/pricelist/components/CalculationTable/BuildManual.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue deleted file mode 100644 index d7dca5f..0000000 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue +++ /dev/null @@ -1,340 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/CalculationTable/Ingredients.vue b/src/plugins/pricelist/components/CalculationTable/Ingredients.vue deleted file mode 100644 index 7090199..0000000 --- a/src/plugins/pricelist/components/CalculationTable/Ingredients.vue +++ /dev/null @@ -1,271 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/CalculationTable/NewPrice.vue b/src/plugins/pricelist/components/CalculationTable/NewPrice.vue deleted file mode 100644 index 978736b..0000000 --- a/src/plugins/pricelist/components/CalculationTable/NewPrice.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/DrinkModify.vue b/src/plugins/pricelist/components/DrinkModify.vue deleted file mode 100644 index d5c1bc2..0000000 --- a/src/plugins/pricelist/components/DrinkModify.vue +++ /dev/null @@ -1,354 +0,0 @@ - - diff --git a/src/plugins/pricelist/components/DrinkTypes.vue b/src/plugins/pricelist/components/DrinkTypes.vue deleted file mode 100644 index 517e4c6..0000000 --- a/src/plugins/pricelist/components/DrinkTypes.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/ExtraIngredients.vue b/src/plugins/pricelist/components/ExtraIngredients.vue deleted file mode 100644 index 171d801..0000000 --- a/src/plugins/pricelist/components/ExtraIngredients.vue +++ /dev/null @@ -1,154 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/MinPriceSetting.vue b/src/plugins/pricelist/components/MinPriceSetting.vue deleted file mode 100644 index c697da7..0000000 --- a/src/plugins/pricelist/components/MinPriceSetting.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/Pricelist.vue b/src/plugins/pricelist/components/Pricelist.vue deleted file mode 100644 index d1c26bd..0000000 --- a/src/plugins/pricelist/components/Pricelist.vue +++ /dev/null @@ -1,327 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/components/SearchInput.vue b/src/plugins/pricelist/components/SearchInput.vue deleted file mode 100644 index de407e3..0000000 --- a/src/plugins/pricelist/components/SearchInput.vue +++ /dev/null @@ -1,89 +0,0 @@ - - -a diff --git a/src/plugins/pricelist/components/Tags.vue b/src/plugins/pricelist/components/Tags.vue deleted file mode 100644 index 1cb3be8..0000000 --- a/src/plugins/pricelist/components/Tags.vue +++ /dev/null @@ -1,181 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/pages/CocktailBuilder.vue b/src/plugins/pricelist/pages/CocktailBuilder.vue deleted file mode 100644 index 3193fd6..0000000 --- a/src/plugins/pricelist/pages/CocktailBuilder.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/pages/InnerPricelist.vue b/src/plugins/pricelist/pages/InnerPricelist.vue deleted file mode 100644 index 626bbb3..0000000 --- a/src/plugins/pricelist/pages/InnerPricelist.vue +++ /dev/null @@ -1,38 +0,0 @@ - - diff --git a/src/plugins/pricelist/pages/OuterPricelist.vue b/src/plugins/pricelist/pages/OuterPricelist.vue deleted file mode 100644 index 05011d5..0000000 --- a/src/plugins/pricelist/pages/OuterPricelist.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/pages/Receipts.vue b/src/plugins/pricelist/pages/Receipts.vue deleted file mode 100644 index bb7232c..0000000 --- a/src/plugins/pricelist/pages/Receipts.vue +++ /dev/null @@ -1,175 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/pages/Settings.vue b/src/plugins/pricelist/pages/Settings.vue deleted file mode 100644 index 8b9f744..0000000 --- a/src/plugins/pricelist/pages/Settings.vue +++ /dev/null @@ -1,136 +0,0 @@ - - - - - diff --git a/src/plugins/pricelist/permissions.ts b/src/plugins/pricelist/permissions.ts deleted file mode 100644 index a378a74..0000000 --- a/src/plugins/pricelist/permissions.ts +++ /dev/null @@ -1,33 +0,0 @@ -export const PERMISSIONS = { - CREATE: 'drink_create', - - EDIT: 'drink_edit', - - DELETE: 'drink_delete', - - CREATE_TAG: 'drink_tag_create', - - EDIT_PRICE: 'edit_price', - DELETE_PRICE: 'delete_price', - - EDIT_VOLUME: 'edit_volume', - DELETE_VOLUME: 'delete_volume', - - EDIT_INGREDIENTS_DRINK: 'edit_ingredients_drink', - DELETE_INGREDIENTS_DRINK: 'delete_ingredients_drink', - - EDIT_INGREDIENTS: 'edit_ingredients', - DELETE_INGREDIENTS: 'delete_ingredients', - - EDIT_TAG: 'drink_tag_edit', - - DELETE_TAG: 'drink_tag_delete', - - CREATE_TYPE: 'drink_type_create', - - EDIT_TYPE: 'drink_type_edit', - - DELETE_TYPE: 'drink_type_delete', - - EDIT_MIN_PRICES: 'edit_min_prices', -}; diff --git a/src/plugins/pricelist/plugin.ts b/src/plugins/pricelist/plugin.ts deleted file mode 100644 index 4e5a938..0000000 --- a/src/plugins/pricelist/plugin.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { innerRoutes, outerRoutes } from './routes'; -import { FG_Plugin } from '@flaschengeist/typings'; - -const plugin: FG_Plugin.Plugin = { - name: 'Pricelist', - innerRoutes, - outerRoutes, - requiredModules: [], - requiredBackendModules: ['pricelist'], - version: '0.0.1', - widgets: [], -}; - -export default plugin; diff --git a/src/plugins/pricelist/routes/index.ts b/src/plugins/pricelist/routes/index.ts deleted file mode 100644 index 341cc66..0000000 --- a/src/plugins/pricelist/routes/index.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; - -export const innerRoutes: FG_Plugin.MenuRoute[] = [ - { - title: 'Getränke', - icon: 'mdi-glass-mug-variant', - route: { - path: 'drinks', - name: 'drinks', - redirect: { name: 'drinks-pricelist' }, - }, - permissions: ['user'], - children: [ - { - title: 'Preisliste', - icon: 'mdi-cash-100', - shortcut: true, - permissions: ['user'], - route: { - path: 'pricelist', - name: 'drinks-pricelist', - component: () => import('../pages/InnerPricelist.vue'), - }, - }, - { - title: 'Rezepte', - shortcut: false, - icon: 'mdi-receipt', - permissions: ['user'], - route: { - path: 'reciepts', - name: 'reciepts', - component: () => import('../pages/Receipts.vue'), - }, - }, - { - title: 'Cocktailbuilder', - shortcut: false, - icon: 'mdi-glass-cocktail', - permissions: ['user'], - route: { - path: 'cocktail-builder', - name: 'cocktail-builder', - component: () => import('../pages/CocktailBuilder.vue'), - }, - }, - { - title: 'Einstellungen', - icon: 'mdi-coffee-to-go', - shortcut: false, - permissions: ['drink_edit', 'drink_tag_edit'], - route: { - path: 'settings', - name: 'drinks-settings', - component: () => import('../pages/Settings.vue'), - }, - }, - ], - }, -]; - -export const outerRoutes: FG_Plugin.MenuRoute[] = [ - { - title: 'Preisliste', - icon: 'mdi-glass-mug-variant', - shortcut: true, - route: { - path: 'pricelist', - name: 'outter-pricelist', - component: () => import('../pages/OuterPricelist.vue'), - }, - }, -]; diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts deleted file mode 100644 index a0da12a..0000000 --- a/src/plugins/pricelist/store.ts +++ /dev/null @@ -1,313 +0,0 @@ -import { api } from 'src/boot/axios'; -import { defineStore } from 'pinia'; -import { - calc_volume, - calc_cost_per_volume, - calc_all_min_prices, -} from 'src/plugins/pricelist/utils/utils'; - -interface DrinkPriceVolume extends Omit { - _volume: number; - volume?: number; -} - -interface Drink extends Omit, 'volumes'> { - volumes: DrinkPriceVolume[]; - cost_per_volume?: number; - _cost_per_volume?: number; -} - -interface Pricelist { - name: string; - type: FG.DrinkType; - tags: Array; - volume: number; - price: number; - public: boolean; - description: string; -} - -class DrinkPriceVolume implements DrinkPriceVolume { - constructor({ id, volume, prices, ingredients }: FG.DrinkPriceVolume) { - this.id = id; - this._volume = volume; - this.prices = prices; - this.ingredients = ingredients; - this.min_prices = []; - this.volume = calc_volume(this); - } -} - -class Drink { - constructor({ - id, - article_id, - package_size, - name, - volume, - cost_per_volume, - cost_per_package, - tags, - type, - uuid, - receipt, - }: FG.Drink) { - this.id = id; - this.article_id = article_id; - this.package_size = package_size; - this.name = name; - this.volume = volume; - this.cost_per_package = cost_per_package; - this._cost_per_volume = cost_per_volume; - this.cost_per_volume = calc_cost_per_volume(this); - this.tags = tags; - this.type = type; - this.volumes = []; - this.uuid = uuid; - this.receipt = receipt || []; - } -} - -interface Order { - label: string; - name: string; -} - -export const usePricelistStore = defineStore({ - id: 'pricelist', - - state: () => ({ - drinkTypes: [] as Array, - drinks: [] as Array, - extraIngredients: [] as Array, - min_prices: [] as Array, - tags: [] as Array, - pricecalc_columns: [] as Array, - pricelist_view: false as boolean, - pricelist_columns_order: [] as Array, - }), - - actions: { - async getDrinkTypes(force = false) { - if (force || this.drinks.length == 0) { - const { data } = await api.get>('/pricelist/drink-types'); - this.drinkTypes = data; - } - return this.drinkTypes; - }, - async addDrinkType(name: string) { - const { data } = await api.post('/pricelist/drink-types', { name: name }); - this.drinkTypes.push(data); - }, - async removeDrinkType(id: number) { - await api.delete(`/pricelist/drink-types/${id}`); - const idx = this.drinkTypes.findIndex((val) => val.id == id); - if (idx >= 0) this.drinkTypes.splice(idx, 1); - }, - async changeDrinkTypeName(drinkType: FG.DrinkType) { - await api.put(`/pricelist/drink-types/${drinkType.id}`, drinkType); - const itm = this.drinkTypes.filter((val) => val.id == drinkType.id); - if (itm.length > 0) itm[0].name = drinkType.name; - }, - async getExtraIngredients() { - const { data } = await api.get>( - 'pricelist/ingredients/extraIngredients' - ); - this.extraIngredients = data; - }, - async setExtraIngredient(ingredient: FG.ExtraIngredient) { - const { data } = await api.post( - 'pricelist/ingredients/extraIngredients', - ingredient - ); - this.extraIngredients.push(data); - }, - async updateExtraIngredient(ingredient: FG.ExtraIngredient) { - const { data } = await api.put( - `pricelist/ingredients/extraIngredients/${ingredient.id}`, - ingredient - ); - const index = this.extraIngredients.findIndex((a) => a.id === ingredient.id); - if (index > -1) { - this.extraIngredients[index] = data; - } else { - this.extraIngredients.push(data); - } - }, - async deleteExtraIngredient(ingredient: FG.ExtraIngredient) { - await api.delete(`pricelist/ingredients/extraIngredients/${ingredient.id}`); - const index = this.extraIngredients.findIndex((a) => a.id === ingredient.id); - if (index > -1) { - this.extraIngredients.splice(index, 1); - } - }, - async getDrinks() { - const { data } = await api.get>('pricelist/drinks'); - this.drinks = []; - data.forEach((drink) => { - const _drink = new Drink(drink); - drink.volumes.forEach((volume) => { - const _volume = new DrinkPriceVolume(volume); - _drink.volumes.push(_volume); - }); - this.drinks.push(_drink); - }); - calc_all_min_prices(this.drinks, this.min_prices); - }, - sortPrices(volume: DrinkPriceVolume) { - volume.prices.sort((a, b) => { - if (a.price > b.price) return 1; - if (b.price > a.price) return -1; - return 0; - }); - }, - async deletePrice(price: FG.DrinkPrice) { - await api.delete(`pricelist/prices/${price.id}`); - }, - async deleteVolume(volume: DrinkPriceVolume, drink: Drink) { - await api.delete(`pricelist/volumes/${volume.id}`); - const index = drink.volumes.findIndex((a) => a.id === volume.id); - if (index > -1) { - drink.volumes.splice(index, 1); - } - }, - async deleteIngredient(ingredient: FG.Ingredient) { - await api.delete(`pricelist/ingredients/${ingredient.id}`); - }, - async setDrink(drink: Drink) { - const { data } = await api.post('pricelist/drinks', { - ...drink, - }); - const _drink = new Drink(data); - data.volumes.forEach((volume) => { - const _volume = new DrinkPriceVolume(volume); - _drink.volumes.push(_volume); - }); - this.drinks.push(_drink); - calc_all_min_prices(this.drinks, this.min_prices); - return _drink; - }, - async updateDrink(drink: Drink) { - const { data } = await api.put(`pricelist/drinks/${drink.id}`, { - ...drink, - }); - const index = this.drinks.findIndex((a) => a.id === data.id); - if (index > -1) { - const _drink = new Drink(data); - data.volumes.forEach((volume) => { - const _volume = new DrinkPriceVolume(volume); - _drink.volumes.push(_volume); - }); - this.drinks[index] = _drink; - } - calc_all_min_prices(this.drinks, this.min_prices); - }, - deleteDrink(drink: Drink) { - api - .delete(`pricelist/drinks/${drink.id}`) - .then(() => { - const index = this.drinks.findIndex((a) => a.id === drink.id); - if (index > -1) { - this.drinks.splice(index, 1); - } - }) - .catch((err) => console.warn(err)); - }, - async get_min_prices() { - const { data } = await api.get>('pricelist/settings/min_prices'); - this.min_prices = data; - }, - async set_min_prices() { - await api.post>('pricelist/settings/min_prices', this.min_prices); - calc_all_min_prices(this.drinks, this.min_prices); - }, - async upload_drink_picture(drink: Drink, file: File) { - const formData = new FormData(); - formData.append('file', file); - const { data } = await api.post(`pricelist/drinks/${drink.id}/picture`, formData, { - headers: { - 'Content-Type': 'multipart/form-data', - }, - }); - const _drink = this.drinks.find((a) => a.id === drink.id); - if (_drink) { - _drink.uuid = data.uuid; - } - }, - async delete_drink_picture(drink: Drink) { - await api.delete(`pricelist/drinks/${drink.id}/picture`); - drink.uuid = ''; - }, - async getTags() { - const { data } = await api.get>('/pricelist/tags'); - this.tags = data; - }, - async setTag(tag: FG.Tag) { - const { data } = await api.post('/pricelist/tags', tag); - this.tags.push(data); - }, - async updateTag(tag: FG.Tag) { - const { data } = await api.put(`/pricelist/tags/${tag.id}`, tag); - const index = this.tags.findIndex((a) => a.id === data.id); - if (index > -1) { - this.tags[index] = data; - } - }, - async deleteTag(tag: FG.Tag) { - await api.delete(`/pricelist/tags/${tag.id}`); - const index = this.tags.findIndex((a) => a.id === tag.id); - if (index > -1) { - this.tags.splice(index, 1); - } - }, - async getPriceCalcColumn(userid: string) { - const { data } = await api.get>(`pricelist/users/${userid}/pricecalc_columns`); - this.pricecalc_columns = data; - }, - async updatePriceCalcColumn(userid: string, data: Array) { - await api.put>(`pricelist/users/${userid}/pricecalc_columns`, data); - this.pricecalc_columns = data; - }, - async getPriceListView(userid: string) { - const { data } = await api.get<{ value: boolean }>(`pricelist/users/${userid}/pricelist`); - this.pricelist_view = data.value; - }, - async updatePriceListView(userid: string, data: boolean) { - await api.put>(`pricelist/users/${userid}/pricelist`, { value: data }); - this.pricelist_view = data; - }, - async getPriceListColumnOrder(userid: string) { - const { data } = await api.get>( - `pricelist/users/${userid}/pricecalc_columns_order` - ); - this.pricelist_columns_order = data; - }, - async updatePriceListColumnOrder(userid: string, data: Array) { - await api.put>(`pricelist/users/${userid}/pricecalc_columns_order`, data); - this.pricelist_columns_order = data; - }, - }, - getters: { - pricelist() { - const retVal: Array = []; - this.drinks.forEach((drink) => { - drink.volumes.forEach((volume) => { - volume.prices.forEach((price) => { - retVal.push({ - name: drink.name, - type: drink.type, - tags: >drink.tags, - volume: volume.volume, - price: price.price, - public: price.public, - description: price.description, - }); - }); - }); - }); - return retVal; - }, - }, -}); - -export { DrinkPriceVolume, Drink, Order }; diff --git a/src/plugins/pricelist/utils/filter.ts b/src/plugins/pricelist/utils/filter.ts deleted file mode 100644 index cb8c5ba..0000000 --- a/src/plugins/pricelist/utils/filter.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Drink } from '../store'; - -function filter( - rows: Array, - terms: Search, - cols: Array, - cellValue: { (col: Col, row: Drink): string } -) { - if (terms.value) { - return rows.filter((row) => { - if (!terms.key || terms.key === '') { - return cols.some((col) => { - const val = cellValue(col, row) + ''; - const haystack = val === 'undefined' || val === 'null' ? '' : val.toLowerCase(); - return haystack.indexOf(terms.value) !== -1; - }); - } - const index = cols.findIndex((col) => col.name === terms.key); - const val = cellValue(cols[index], row) + ''; - const haystack = val === 'undefined' || val === 'null' ? '' : val.toLowerCase(); - return haystack.indexOf(terms.value) !== -1; - }); - } - return rows; -} - -interface Search { - value: string; - label: string | undefined; - key: string | undefined; -} - -interface Col { - name: string; - label: string; - field: string; -} - -export { filter, Search, Col }; diff --git a/src/plugins/pricelist/utils/sort.ts b/src/plugins/pricelist/utils/sort.ts deleted file mode 100644 index cfd6f2a..0000000 --- a/src/plugins/pricelist/utils/sort.ts +++ /dev/null @@ -1,7 +0,0 @@ -function sort(a: string | number, b: string | number) { - if (a > b) return 1; - if (b > a) return -1; - return 0; -} - -export { sort }; diff --git a/src/plugins/pricelist/utils/utils.ts b/src/plugins/pricelist/utils/utils.ts deleted file mode 100644 index 1bc4de6..0000000 --- a/src/plugins/pricelist/utils/utils.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { Drink, DrinkPriceVolume, usePricelistStore } from 'src/plugins/pricelist/store'; - -function calc_volume(volume: DrinkPriceVolume) { - if (volume.ingredients.some((ingredient) => !!ingredient.drink_ingredient)) { - let retVal = 0; - volume.ingredients.forEach((ingredient) => { - if (ingredient.drink_ingredient?.volume) { - retVal += ingredient.drink_ingredient.volume; - } - }); - return retVal; - } else { - return volume._volume; - } -} - -function calc_cost_per_volume(drink: Drink) { - let retVal = drink._cost_per_volume; - if (!!drink.volume && !!drink.package_size && !!drink.cost_per_package) { - retVal = - ((drink.cost_per_package || 0) / ((drink.volume || 0) * (drink.package_size || 0))) * 1.19; - } - - return retVal ? Math.round(retVal * 1000) / 1000 : retVal; -} - -function calc_all_min_prices(drinks: Array, min_prices: Array) { - drinks.forEach((drink) => { - drink.volumes.forEach((volume) => { - volume.min_prices = calc_min_prices(volume, drink.cost_per_volume, min_prices); - }); - }); -} - -function helper(volume: DrinkPriceVolume, min_price: number) { - let retVal = 0; - let extraIngredientPrice = 0; - volume.ingredients.forEach((ingredient) => { - if (ingredient.drink_ingredient) { - const _drink = usePricelistStore().drinks.find( - (a) => a.id === ingredient.drink_ingredient?.ingredient_id - ); - retVal += ingredient.drink_ingredient.volume * (_drink?.cost_per_volume); - } - if (ingredient.extra_ingredient) { - extraIngredientPrice += ingredient.extra_ingredient.price; - } - }); - return (retVal * min_price) / 100 + extraIngredientPrice; -} - -function calc_min_prices( - volume: DrinkPriceVolume, - cost_per_volume: number | undefined, - min_prices: Array -) { - const retVal: Array = []; - volume.min_prices = []; - if (min_prices) { - min_prices.forEach((min_price) => { - let computedMinPrice: number; - if (cost_per_volume) { - computedMinPrice = (cost_per_volume * volume.volume * min_price) / 100; - } else { - computedMinPrice = helper(volume, min_price); - } - retVal.push({ percentage: min_price, price: computedMinPrice }); - }); - } - return retVal; -} - -function clone(o: T): T { - return JSON.parse(JSON.stringify(o)); -} - -interface DeleteObjects { - prices: Array; - volumes: Array; - ingredients: Array; -} -export { DeleteObjects }; - -export { calc_volume, calc_cost_per_volume, calc_all_min_prices, calc_min_prices, clone }; diff --git a/src/plugins/schedule/components/Widget.vue b/src/plugins/schedule/components/Widget.vue deleted file mode 100644 index 84650c3..0000000 --- a/src/plugins/schedule/components/Widget.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/src/plugins/schedule/components/management/EditEvent.vue b/src/plugins/schedule/components/management/EditEvent.vue deleted file mode 100644 index 77ae50d..0000000 --- a/src/plugins/schedule/components/management/EditEvent.vue +++ /dev/null @@ -1,245 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/management/EventTypes.vue b/src/plugins/schedule/components/management/EventTypes.vue deleted file mode 100644 index a9dbf80..0000000 --- a/src/plugins/schedule/components/management/EventTypes.vue +++ /dev/null @@ -1,126 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/management/Job.vue b/src/plugins/schedule/components/management/Job.vue deleted file mode 100644 index 95f05ca..0000000 --- a/src/plugins/schedule/components/management/Job.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/management/JobTypes.vue b/src/plugins/schedule/components/management/JobTypes.vue deleted file mode 100644 index c3fc3f8..0000000 --- a/src/plugins/schedule/components/management/JobTypes.vue +++ /dev/null @@ -1,125 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/management/RecurrenceRule.vue b/src/plugins/schedule/components/management/RecurrenceRule.vue deleted file mode 100644 index c5aa054..0000000 --- a/src/plugins/schedule/components/management/RecurrenceRule.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/overview/AgendaView.vue b/src/plugins/schedule/components/overview/AgendaView.vue deleted file mode 100644 index 3f4e081..0000000 --- a/src/plugins/schedule/components/overview/AgendaView.vue +++ /dev/null @@ -1,241 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/overview/slots/EventSlot.vue b/src/plugins/schedule/components/overview/slots/EventSlot.vue deleted file mode 100644 index 1524001..0000000 --- a/src/plugins/schedule/components/overview/slots/EventSlot.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/components/overview/slots/JobSlot.vue b/src/plugins/schedule/components/overview/slots/JobSlot.vue deleted file mode 100644 index 9a65835..0000000 --- a/src/plugins/schedule/components/overview/slots/JobSlot.vue +++ /dev/null @@ -1,142 +0,0 @@ - - - - - diff --git a/src/plugins/schedule/events.d.ts b/src/plugins/schedule/events.d.ts deleted file mode 100644 index ec9d101..0000000 --- a/src/plugins/schedule/events.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare namespace FG { - export interface RecurrenceRule { - frequency: string; - interval: number; - count?: number; - until?: Date; - weekdays?: Array; - } -} diff --git a/src/plugins/schedule/pages/Event.vue b/src/plugins/schedule/pages/Event.vue deleted file mode 100644 index 0e99801..0000000 --- a/src/plugins/schedule/pages/Event.vue +++ /dev/null @@ -1,29 +0,0 @@ - - - diff --git a/src/plugins/schedule/pages/Management.vue b/src/plugins/schedule/pages/Management.vue deleted file mode 100644 index 200b038..0000000 --- a/src/plugins/schedule/pages/Management.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - diff --git a/src/plugins/schedule/pages/Overview.vue b/src/plugins/schedule/pages/Overview.vue deleted file mode 100644 index 2a0f627..0000000 --- a/src/plugins/schedule/pages/Overview.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - diff --git a/src/plugins/schedule/pages/Requests.vue b/src/plugins/schedule/pages/Requests.vue deleted file mode 100644 index b64ab3f..0000000 --- a/src/plugins/schedule/pages/Requests.vue +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/src/plugins/schedule/permissions.ts b/src/plugins/schedule/permissions.ts deleted file mode 100644 index c1bc584..0000000 --- a/src/plugins/schedule/permissions.ts +++ /dev/null @@ -1,16 +0,0 @@ -export const PERMISSIONS = { - // Can create events - CREATE: 'events_create', - // Can edit events - EDIT: 'events_edit', - // Can delete events - DELETE: 'events_delete', - // Can create and edit EventTypes - EVENT_TYPE: 'events_event_type', - // Can create and edit JobTypes - JOB_TYPE: 'events_job_type', - // Can self assign to jobs - ASSIGN: 'events_assign', - // Can assign other users to jobs - ASSIGN_OTHER: 'events_assign_other', -}; diff --git a/src/plugins/schedule/plugin.ts b/src/plugins/schedule/plugin.ts deleted file mode 100644 index 11e7bda..0000000 --- a/src/plugins/schedule/plugin.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { innerRoutes, privateRoutes } from './routes'; -import { FG_Plugin } from '@flaschengeist/typings'; -import { defineAsyncComponent } from 'vue'; - -const plugin: FG_Plugin.Plugin = { - name: 'Schedule', - innerRoutes, - internalRoutes: privateRoutes, - requiredModules: ['User'], - requiredBackendModules: ['events'], - version: '0.0.1', - widgets: [ - { - priority: 0, - name: 'stats', - permissions: [], - widget: defineAsyncComponent(() => import('./components/Widget.vue')), - }, - ], -}; - -export default plugin; diff --git a/src/plugins/schedule/routes/index.ts b/src/plugins/schedule/routes/index.ts deleted file mode 100644 index 994dfba..0000000 --- a/src/plugins/schedule/routes/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; -import { PERMISSIONS } from '../permissions'; - -export const innerRoutes: FG_Plugin.MenuRoute[] = [ - { - title: 'Dienste', - icon: 'mdi-briefcase', - permissions: ['user'], - route: { - path: 'schedule', - name: 'schedule', - redirect: { name: 'schedule-overview' }, - }, - children: [ - { - title: 'Dienstübersicht', - icon: 'mdi-account-group', - shortcut: true, - route: { - path: 'schedule-overview', - name: 'schedule-overview', - component: () => import('../pages/Overview.vue'), - }, - }, - { - title: 'Dienstverwaltung', - icon: 'mdi-account-details', - shortcut: false, - permissions: [PERMISSIONS.CREATE], - route: { - path: 'schedule-management', - name: 'schedule-management', - component: () => import('../pages/Management.vue'), - }, - }, - { - title: 'Dienstanfragen', - icon: 'mdi-account-switch', - shortcut: false, - route: { - path: 'schedule-requests', - name: 'schedule-requests', - component: () => import('../pages/Requests.vue'), - }, - }, - ], - }, -]; - -export const privateRoutes: FG_Plugin.NamedRouteRecordRaw[] = [ - { - name: 'events-edit', - path: 'schedule/:id/edit', - component: () => import('../pages/Event.vue'), - }, -]; diff --git a/src/plugins/schedule/store.ts b/src/plugins/schedule/store.ts deleted file mode 100644 index 113fd8f..0000000 --- a/src/plugins/schedule/store.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { api } from 'src/boot/axios'; -import { AxiosError } from 'axios'; -import { defineStore } from 'pinia'; - -interface UserService { - user: FG.Service; -} - -function fixJob(job: FG.Job) { - job.start = new Date(job.start); - if (job.end) job.end = new Date(job.end); -} - -function fixEvent(event: FG.Event) { - event.start = new Date(event.start); - if (event.end) event.end = new Date(event.end); - - event.jobs.forEach((job) => fixJob(job)); -} - -export const useScheduleStore = defineStore({ - id: 'schedule', - - state: () => ({ - jobTypes: [] as FG.JobType[], - eventTypes: [] as FG.EventType[], - templates: [] as FG.Event[], - }), - - getters: {}, - - actions: { - async getJobTypes(force = false) { - if (force || this.jobTypes.length == 0) - try { - const { data } = await api.get('/events/job-types'); - this.jobTypes = data; - } catch (error) { - throw error; - } - return this.jobTypes; - }, - - async addJobType(name: string) { - await api.post('/events/job-types', { name: name }); - //TODO: HAndle new JT - }, - - async removeJobType(id: number) { - await api.delete(`/events/job-types/${id}`); - //Todo Handle delete JT - }, - - async renameJobType(id: number, newName: string) { - await api.put(`/events/job-types/${id}`, { name: newName }); - // TODO handle rename - }, - - async getEventTypes(force = false) { - if (force || this.eventTypes.length == 0) - try { - const { data } = await api.get('/events/event-types'); - this.eventTypes = data; - } catch (error) { - throw error; - } - return this.eventTypes; - }, - - /** Add new EventType - * - * @param name Name of new EventType - * @returns EventType object or null if name already exists - * @throws Exception if requests fails because of an other reason - */ - async addEventType(name: string) { - try { - const { data } = await api.post('/events/event-types', { name: name }); - return data; - } catch (error) { - if ('response' in error) { - const ae = error; - if (ae.response && ae.response.status == 409 /* CONFLICT */) return null; - } - throw error; - } - }, - async removeEvent(id: number) { - try { - await api.delete(`/events/${id}`); - const idx = this.templates.findIndex((v) => v.id === id); - if (idx !== -1) this.templates.splice(idx, 1); - } catch (e) { - const error = e; - if (error.response && error.response.status === 404) return false; - throw e; - } - return true; - }, - - async removeEventType(id: number) { - await api.delete(`/events/event-types/${id}`); - // TODO handle delete - }, - - async renameEventType(id: number, newName: string) { - try { - await api.put(`/events/event-types/${id}`, { name: newName }); - // TODO handle rename - return true; - } catch (error) { - if ('response' in error) { - const ae = error; - if (ae.response && ae.response.status == 409 /* CONFLICT */) return false; - } - throw error; - } - }, - - async getTemplates(force = false) { - if (force || this.templates.length == 0) { - const { data } = await api.get('/events/templates'); - data.forEach((element) => fixEvent(element)); - this.templates = data; - } - return this.templates; - }, - - async getEvents(filter: { from?: Date; to?: Date } | undefined = undefined) { - try { - const { data } = await api.get('/events', { params: filter }); - data.forEach((element) => fixEvent(element)); - return data; - } catch (error) { - throw error; - } - }, - - async getEvent(id: number) { - try { - const { data } = await api.get(`/events/${id}`); - fixEvent(data); - return data; - } catch (error) { - throw error; - } - }, - - async updateJob(eventId: number, jobId: number, service: FG.Service | UserService) { - try { - const { data } = await api.put(`/events/${eventId}/jobs/${jobId}`, service); - fixJob(data); - return data; - } catch (error) { - throw error; - } - }, - - async addEvent(event: FG.Event) { - const { data } = await api.post('/events', event); - if (data.is_template) this.templates.push(data); - return data; - }, - }, -}); diff --git a/src/plugins/user/components/NewUser.vue b/src/plugins/user/components/NewUser.vue deleted file mode 100644 index d59b746..0000000 --- a/src/plugins/user/components/NewUser.vue +++ /dev/null @@ -1,39 +0,0 @@ - - - - - diff --git a/src/plugins/user/components/UpdateUser.vue b/src/plugins/user/components/UpdateUser.vue deleted file mode 100644 index 820d0f6..0000000 --- a/src/plugins/user/components/UpdateUser.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - - - diff --git a/src/plugins/user/components/UserSelector.vue b/src/plugins/user/components/UserSelector.vue deleted file mode 100644 index 96cb109..0000000 --- a/src/plugins/user/components/UserSelector.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/src/plugins/user/components/Widget.vue b/src/plugins/user/components/Widget.vue deleted file mode 100644 index 26aeae0..0000000 --- a/src/plugins/user/components/Widget.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - diff --git a/src/plugins/user/components/settings/MainUserSettings.vue b/src/plugins/user/components/settings/MainUserSettings.vue deleted file mode 100644 index 20e5123..0000000 --- a/src/plugins/user/components/settings/MainUserSettings.vue +++ /dev/null @@ -1,218 +0,0 @@ - - - diff --git a/src/plugins/user/components/settings/RoleSettings.vue b/src/plugins/user/components/settings/RoleSettings.vue deleted file mode 100644 index 0b4c2d3..0000000 --- a/src/plugins/user/components/settings/RoleSettings.vue +++ /dev/null @@ -1,160 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/plugins/user/components/settings/Session.vue b/src/plugins/user/components/settings/Session.vue deleted file mode 100644 index 3b69bdf..0000000 --- a/src/plugins/user/components/settings/Session.vue +++ /dev/null @@ -1,168 +0,0 @@ - - - diff --git a/src/plugins/user/models.ts b/src/plugins/user/models.ts deleted file mode 100644 index b0d9a69..0000000 --- a/src/plugins/user/models.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface LoginData { - userid: string; - password: string; -} - -export interface LoginResponse { - user: FG.User; - session: FG.Session; - permissions: FG.Permission[]; -} - -export interface CurrentUserResponse extends FG.User { - permissions: FG.Permission[]; -} diff --git a/src/plugins/user/pages/AdminSettings.vue b/src/plugins/user/pages/AdminSettings.vue deleted file mode 100644 index 5dbf96f..0000000 --- a/src/plugins/user/pages/AdminSettings.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - diff --git a/src/plugins/user/pages/Settings.vue b/src/plugins/user/pages/Settings.vue deleted file mode 100644 index 116932f..0000000 --- a/src/plugins/user/pages/Settings.vue +++ /dev/null @@ -1,57 +0,0 @@ - - - diff --git a/src/plugins/user/permissions.ts b/src/plugins/user/permissions.ts deleted file mode 100644 index 2ba1b10..0000000 --- a/src/plugins/user/permissions.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const PERMISSIONS = { - // Kann andere Nutzer bearbeiten - EDIT_OTHER: 'users_edit_other', - // Kann Rollen von Nutzern setzen - SET_ROLES: 'users_set_roles', - // Kann Nutzer löschen - DELETE: 'users_delete_other', - // Kann neue Nutzer hinzufügen - REGISTER: 'users_register', - // Kann Rollen löschen oder bearbeiten, z.b. Rechte hinzufügen etc - ROLES_EDIT: 'roles_edit', -}; diff --git a/src/plugins/user/plugin.ts b/src/plugins/user/plugin.ts deleted file mode 100644 index 7a1245a..0000000 --- a/src/plugins/user/plugin.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; -import { defineAsyncComponent } from 'vue'; -import routes from './routes'; - -const plugin: FG_Plugin.Plugin = { - name: 'User', - innerRoutes: routes, - requiredModules: [], - requiredBackendModules: ['auth', 'users', 'roles'], - version: '0.0.1', - widgets: [ - { - priority: 1, - name: 'greeting', - permissions: [], - widget: defineAsyncComponent(() => import('./components/Widget.vue')), - }, - ], -}; - -export default plugin; diff --git a/src/plugins/user/routes/index.ts b/src/plugins/user/routes/index.ts deleted file mode 100644 index 0fb2d5d..0000000 --- a/src/plugins/user/routes/index.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { FG_Plugin } from '@flaschengeist/typings'; -import { useMainStore } from 'src/stores'; - -const mainRoutes: FG_Plugin.MenuRoute[] = [ - { - get title() { - return () => useMainStore().currentUser.display_name; - }, - icon: 'mdi-account', - permissions: ['user'], - route: { path: 'user', name: 'user', redirect: { name: 'user-settings' } }, - children: [ - { - title: 'Einstellungen', - icon: 'mdi-account-edit', - shortcut: true, - permissions: ['user'], - route: { - path: 'settings', - name: 'user-settings', - component: () => import('../pages/Settings.vue'), - }, - }, - { - title: 'Admin', - icon: 'mdi-cog', - shortcut: false, - permissions: ['users_edit_other'], - route: { - path: 'admin', - name: 'admin-settings', - component: () => import('../pages/AdminSettings.vue'), - }, - }, - ], - }, -]; - -export default mainRoutes; diff --git a/src/router/index.ts b/src/router/index.ts index 8cb857b..cbcc285 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -16,13 +16,12 @@ import routes from './routes'; * with the Router instance. */ -function router(/* { store, ssrContext } */) { - const createHistory = - process.env.MODE === 'ssr' - ? createMemoryHistory - : process.env.VUE_ROUTER_MODE === 'history' - ? createWebHistory - : createWebHashHistory; +export default route(function (/* { store, ssrContext } */) { + const createHistory = process.env.SERVER + ? createMemoryHistory + : process.env.VUE_ROUTER_MODE === 'history' + ? createWebHistory + : createWebHashHistory; const Router = createRouter({ scrollBehavior: () => ({ left: 0, top: 0 }), @@ -35,8 +34,4 @@ function router(/* { store, ssrContext } */) { }); return Router; -} - -export default route(router); - -export const Router = router(); +}); diff --git a/src/stores/store-flag.d.ts b/src/stores/store-flag.d.ts deleted file mode 100644 index af80dbe..0000000 --- a/src/stores/store-flag.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// THIS FEATURE-FLAG FILE IS AUTOGENERATED, -// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING -import 'quasar/dist/types/feature-flag'; - -declare module 'quasar/dist/types/feature-flag' { - interface QuasarFeatureFlags { - store: true; - } -} diff --git a/src/vendor-plugin.config.js b/src/vendor-plugin.config.js new file mode 100644 index 0000000..8ea3fcc --- /dev/null +++ b/src/vendor-plugin.config.js @@ -0,0 +1 @@ +module.exports = [] \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c3aff81..be94438 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ "dom" ], "types": [ - "@flaschengeist/typings", + "@flaschengeist/types", "@quasar/app", "node", "webpack-env"