Skip to content
Snippets Groups Projects
Verified Commit 6f578364 authored by BARBIER Marc's avatar BARBIER Marc
Browse files

Fixed toasts and added warning when the backend is not ready.

The patches for the toasts have been submited to upstream
https://github.com/InCuca/vue3-toaster/pull/5
parent b1175c6f
No related branches found
No related tags found
No related merge requests found
diff --git a/node_modules/@incuca/vue3-toaster/package.json b/node_modules/@incuca/vue3-toaster/package.json
index ca7aad8..ae27c43 100644
--- a/node_modules/@incuca/vue3-toaster/package.json
+++ b/node_modules/@incuca/vue3-toaster/package.json
@@ -12,6 +12,8 @@
"url": "https://github.com/InCuca/vue3-toaster/issues"
},
"main": "src/index.js",
+ "types": "src/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
diff --git a/node_modules/@incuca/vue3-toaster/src/index.d.ts b/node_modules/@incuca/vue3-toaster/src/index.d.ts
new file mode 100644
index 0000000..b8eeaa7
--- /dev/null
+++ b/node_modules/@incuca/vue3-toaster/src/index.d.ts
@@ -0,0 +1,29 @@
+interface ToastOptions {
+ message?: string
+ type?: 'success' | 'info' | 'warning' | 'error' | 'default'
+ position?: 'top' | ' bottom' | ' top-right' | ' bottom-right' | 'top-left' | 'bottom-left',
+ duration?: number
+ dismissible?: boolean
+ onClick?: () => void
+ onClose?: () => void
+ queue?: boolean
+ maxToasts?: number
+ pauseOnHover?: boolean
+ useDefaultCss?: boolean
+}
+
+export type { ToastOptions }
+export default {} as Plugin_2
+
+declare module 'vue' {
+ interface ComponentCustomProperties {
+ $toast: {
+ clear: () => void
+ show: (message: string, ToastOptions: ToastOptions) => void
+ success: (message: string) => void
+ error: (message: string) => void
+ warning: (message: string) => void
+ info: (message: string) => void
+ }
+ }
+}
diff --git a/node_modules/@incuca/vue3-toaster/src/index.js b/node_modules/@incuca/vue3-toaster/src/index.js
index 01510cc..5a097f7 100644
--- a/node_modules/@incuca/vue3-toaster/src/index.js
+++ b/node_modules/@incuca/vue3-toaster/src/index.js
@@ -1,7 +1,7 @@
import "./styles.css";
import Event from "./composables/event-bus";
import useComponent from "./composables/component";
-import Toaster, { POSITIONS, definePosition } from "./Toaster";
+import Toaster, { POSITIONS, definePosition } from "./Toaster.vue";
Toaster.install = (app, options = {}) => {
const globalOptions = options;
......@@ -28,6 +28,12 @@ export default defineComponent({
else {
this.projects = await response.json()
}
}).catch(() => {
//if nothing was loaded keep trying since it means the server isn't on
//longer duration than timeout to avoir animations
this.$toast.clear()
this.$toast.show('Could not contact the server make sure it is running on port 8080', { maxToasts: 1, type: 'error' })
setTimeout(this.loadProjects, 1000)
})
},
......
interface ToastOptions {
message: string
type: string
position: string,
duration: number
dismissible: boolean
onClick: () => void
onClose: () => void
queue: boolean
maxToasts: number
pauseOnHover: boolean
useDefaultCss: boolean
}
export { }
declare module 'vue' {
interface ComponentCustomProperties {
$toast: {
show: (message, ToastOptions?) => void
success: (message, ToastOptions?) => void
error: (message, ToastOptions?) => void
warning: (message, ToastOptions?) => void
info: (message, ToastOptions?) => void
}
}
}
declare module '@incuca/vue3-toaster' {
export default {} as Plugin_2
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment