Add API Error Toast

This commit is contained in:
Samuel Lorch 2023-04-02 13:06:29 +02:00
parent 0ddeee2f5c
commit 7d895039bf
4 changed files with 20 additions and 0 deletions

View file

@ -25,6 +25,7 @@
"vue": "^3.2.45",
"vue-i18n": "9",
"vue-router": "4",
"vue-toast-notification": "^3.0",
"ws": "^8.13.0"
},
"devDependencies": {

12
client/pnpm-lock.yaml generated
View file

@ -43,6 +43,9 @@ dependencies:
vue-router:
specifier: '4'
version: 4.1.6(vue@3.2.47)
vue-toast-notification:
specifier: ^3.0
version: 3.1.1(vue@3.2.47)
ws:
specifier: ^8.13.0
version: 8.13.0
@ -3887,6 +3890,15 @@ packages:
he: 1.2.0
dev: true
/vue-toast-notification@3.1.1(vue@3.2.47):
resolution: {integrity: sha512-DXEE38NxXFCNinKI+MyZBMWsaqE9Lwxg9GkMVkzKXY1ACCeNztBXuUiSvKMe36dnnYd1qnlP+cWNSvHlkt5xNA==}
engines: {node: '>=12.15.0'}
peerDependencies:
vue: ^3.0
dependencies:
vue: 3.2.47
dev: false
/vue-tsc@1.2.0(typescript@4.9.5):
resolution: {integrity: sha512-rIlzqdrhyPYyLG9zxsVRa+JEseeS9s8F2BbVVVWRRsTZvJO2BbhLEb2HW3MY+DFma0378tnIqs+vfTzbcQtRFw==}
hasBin: true

View file

@ -1,6 +1,9 @@
// import WebSocketServer from 'ws';
import JsonRPC from 'simple-jsonrpc-js';
import axios from "axios";
import { useToast } from 'vue-toast-notification';
const $toast = useToast();
let jrpc = new JsonRPC.connect_xhr('/api');
// let socket = new WebSocket("ws://"+ window.location.host +"/ws/api");
@ -21,6 +24,7 @@ export async function apiCall(method: string, params: Record<string, any>): Prom
if (ex.code === 401) {
UnauthorizedCallback();
} else {
$toast.error(method+ ': ' + ex.message);
console.debug("api call epic fail", ex);
}
return { Data: null, Error: ex};

View file

@ -3,11 +3,13 @@ import './global-styles/components.css';
import './global-styles/colors.css';
import './global-styles/mlfe.css';
import './global-styles/transitions.css';
import 'vue-toast-notification/dist/theme-default.css';
import App from './App.vue';
import { createHead } from '@vueuse/head';
import { createRouter, createWebHistory } from 'vue-router';
import routes from '~pages';
import ToastPlugin from 'vue-toast-notification';
const app = createApp(App);
const head = createHead();
@ -18,5 +20,6 @@ const router = createRouter({
app.use(router);
app.use(head);
app.use(ToastPlugin);
app.mount('#app');