diff --git a/Dockerfile b/Dockerfile index 26016b362..055360585 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,6 +65,8 @@ RUN mkdir -p app/db && \ RUN cp .env.example .env +RUN php please ziggy:generate --types + # Laravel storage items such as logs, caches, rendered views, etc. VOLUME /var/munkireport/storage diff --git a/compatibility/Unserializer.php b/compatibility/Unserializer.php index c68fd5fc1..1c0bd8a1a 100644 --- a/compatibility/Unserializer.php +++ b/compatibility/Unserializer.php @@ -9,6 +9,7 @@ * Based on the python unserializer * Does not convert objects * + * @todo Replace with eg. xkerman/restricted-unserialize */ class Unserializer { diff --git a/composer.json b/composer.json index 13f9b848a..2b45968ea 100644 --- a/composer.json +++ b/composer.json @@ -109,7 +109,7 @@ "rodneyrehm/plist": "^2.0", "socialiteproviders/microsoft-azure": "^5.1.0", "symfony/yaml": "^5.4", - "tightenco/ziggy": "^1.0", + "tightenco/ziggy": "^1.8", "wikimedia/composer-merge-plugin": "^2.0", "xkerman/restricted-unserialize": "^1.1", "zircote/swagger-php": "^4.7" diff --git a/package-lock.json b/package-lock.json index 47b55f970..9d4109ae8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,14 +45,16 @@ "vue": "^3.3.4", "vue-codemirror6": "^1.1.27", "whatwg-fetch": "^3.6.2", - "ziggy-js": "^1.5.0" + "ziggy-js": "^1.8.1" }, "devDependencies": { "@graphql-codegen/cli": "^4.0.1", "@graphql-codegen/client-preset": "^4.1.0", "@tailwindcss/forms": "^0.5.2", "@tailwindcss/typography": "^0.5.2", - "@types/ziggy-js": "^1.3.3", + "@types/bootstrap": "^5.2.10", + "@types/jquery": "^3.5.29", + "@types/lodash": "^4.14.202", "@vitejs/plugin-basic-ssl": "^1.0.0", "@vitejs/plugin-vue": "^4.0.0", "@vue/tsconfig": "^0.4.0", @@ -3185,6 +3187,16 @@ "node": ">=10.12.0" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@repeaterjs/repeater": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/@repeaterjs/repeater/-/repeater-3.0.4.tgz", @@ -3218,11 +3230,23 @@ "tailwindcss": ">=3.0.0 || insiders" } }, - "node_modules/@types/history": { - "version": "4.7.11", - "resolved": "https://registry.npmjs.org/@types/history/-/history-4.7.11.tgz", - "integrity": "sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==", - "dev": true + "node_modules/@types/bootstrap": { + "version": "5.2.10", + "resolved": "https://registry.npmjs.org/@types/bootstrap/-/bootstrap-5.2.10.tgz", + "integrity": "sha512-F2X+cd6551tep0MvVZ6nM8v7XgGN/twpdNDjqS1TUM7YFNEtQYWk+dKAnH+T1gr6QgCoGMPl487xw/9hXooa2g==", + "dev": true, + "dependencies": { + "@popperjs/core": "^2.9.2" + } + }, + "node_modules/@types/jquery": { + "version": "3.5.29", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.29.tgz", + "integrity": "sha512-oXQQC9X9MOPRrMhPHHOsXqeQDnWeCDT3PelUIg/Oy8FAbzSZtFHRjc7IpbfFVmpLtJ+UOoywpRsuO5Jxjybyeg==", + "dev": true, + "dependencies": { + "@types/sizzle": "*" + } }, "node_modules/@types/js-yaml": { "version": "4.0.6", @@ -3236,12 +3260,24 @@ "integrity": "sha512-s2cfwagOQAS8o06TcwKfr9Wx11dNGbH2E9vJz1cqV+a/LOyhWNLUNd6JSRYNzvB4d29UuJX2M0Dj9vE1T8fRXw==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.202", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.202.tgz", + "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==", + "dev": true + }, "node_modules/@types/node": { "version": "20.8.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.0.tgz", "integrity": "sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==", "dev": true }, + "node_modules/@types/sizzle": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz", + "integrity": "sha512-0vWLNK2D5MT9dg0iOo8GlKguPAU02QjmZitPEsXRuJXU/OGIOt9vT9Fc26wtYuavLxtO45v9PGleoL9Z0k1LHg==", + "dev": true + }, "node_modules/@types/ws": { "version": "8.5.6", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.6.tgz", @@ -3251,15 +3287,6 @@ "@types/node": "*" } }, - "node_modules/@types/ziggy-js": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@types/ziggy-js/-/ziggy-js-1.3.3.tgz", - "integrity": "sha512-vBsSiMYhpG6zMiFUFmGoeo/0Ff882m7GLmy2dutsnx9NI+bces+ap4e5tKrzy4TzAAFHlvU1Io6SN8IeUp689w==", - "dev": true, - "dependencies": { - "@types/history": "^4.7.11" - } - }, "node_modules/@urql/core": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/@urql/core/-/core-4.1.3.tgz", @@ -8142,9 +8169,9 @@ } }, "node_modules/ziggy-js": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/ziggy-js/-/ziggy-js-1.6.2.tgz", - "integrity": "sha512-abUqQ1hatBLZnxqfgytxB+Rd3uey+ivPxU5alKxB8GS1xbc0mtntxHX/+tZ9q9UjFGxAUHd4IGGkhg5TboxulQ==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/ziggy-js/-/ziggy-js-1.8.1.tgz", + "integrity": "sha512-fnf30uG0yvUQBPL4T8YPgmkBHUdjYaOFgUb1K1gj0+rclnLTNr9/K/cxC3xkCZyYCZz8oTnXkdf3oJXRPSzavw==", "dependencies": { "qs": "~6.9.7" } diff --git a/package.json b/package.json index f974f080b..03f3a72a5 100644 --- a/package.json +++ b/package.json @@ -48,14 +48,16 @@ "vue": "^3.3.4", "vue-codemirror6": "^1.1.27", "whatwg-fetch": "^3.6.2", - "ziggy-js": "^1.5.0" + "ziggy-js": "^1.8.1" }, "devDependencies": { "@graphql-codegen/cli": "^4.0.1", "@graphql-codegen/client-preset": "^4.1.0", "@tailwindcss/forms": "^0.5.2", "@tailwindcss/typography": "^0.5.2", - "@types/ziggy-js": "^1.3.3", + "@types/bootstrap": "^5.2.10", + "@types/jquery": "^3.5.29", + "@types/lodash": "^4.14.202", "@vitejs/plugin-basic-ssl": "^1.0.0", "@vitejs/plugin-vue": "^4.0.0", "@vue/tsconfig": "^0.4.0", diff --git a/resources/js/app.ts b/resources/js/app.ts index a7195591f..63dd33b5d 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -1,12 +1,20 @@ import {createApp, h} from 'vue' +import type {DefineComponent} from 'vue' import { createInertiaApp } from '@inertiajs/vue3' -import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m' -import { Ziggy } from './ziggy' +import routeFn from 'ziggy-js' +//import { ZiggyVue } from 'ziggy-js/dist/vue.m.js' +//import { Ziggy } from './ziggy.js' import i18next from 'i18next' import I18NextVue from 'i18next-vue' import Fetch from 'i18next-fetch-backend'; import urql, { cacheExchange, fetchExchange } from '@urql/vue'; + + +declare global { + var route: typeof routeFn; +} + i18next .use(Fetch) .init({ @@ -25,25 +33,33 @@ i18next }) createInertiaApp({ - resolve: name => { + resolve: (name: string): DefineComponent | Promise | { default: DefineComponent; } => { const pages = import.meta.glob('./Pages/**/*.vue', { eager: true }) + // @ts-ignore return pages[`./Pages/${name}.vue`] }, setup({ el, App, props, plugin }) { createApp({ render: () => h(App, props) }) .use(plugin) - .use(ZiggyVue, Ziggy) +// .use(ZiggyVue, Ziggy) .use(I18NextVue, {i18next}) .use(urql, { url: '/graphql', exchanges: [cacheExchange, fetchExchange], fetchOptions: () => { - const csrfToken = document.querySelector('meta[name="csrf-token"]').content - return { - headers: { - 'X-CSRF-TOKEN': csrfToken + const csrfTokenMeta = document.querySelector('meta[name="csrf-token"]') + if (!csrfTokenMeta) { + console.log('No CSRF token was found on the current view, this should be an error'); + return {} + } else { + const csrfToken = (csrfTokenMeta).content + return { + headers: { + 'X-CSRF-TOKEN': csrfToken + } } } + } }) .mount(el) diff --git a/resources/js/bootstrap.d.ts b/resources/js/bootstrap.d.ts new file mode 100644 index 000000000..788642fe8 --- /dev/null +++ b/resources/js/bootstrap.d.ts @@ -0,0 +1,12 @@ +import type jquery from "jquery" +import type axios from "axios" +import type popper from "popper.js" + +declare global { + interface Window { + $: jquery; + jQuery: jquery; + axios: axios; + Popper: popper; + } +} diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index ab0f2e5a8..cf2210953 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -11,6 +11,7 @@ import jquery from 'jquery'; //try { + // @ts-ignore window.Popper = popper; window.$ = window.jQuery = jquery; import bootstrap from 'bootstrap'; diff --git a/resources/views/partials/head.php b/resources/views/partials/head.php index 2efb34bd1..a495fa4f5 100644 --- a/resources/views/partials/head.php +++ b/resources/views/partials/head.php @@ -217,8 +217,8 @@