mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 02:48:21 +00:00
Add API Error Toast
This commit is contained in:
parent
0ddeee2f5c
commit
7d895039bf
4 changed files with 20 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
"vue": "^3.2.45",
|
"vue": "^3.2.45",
|
||||||
"vue-i18n": "9",
|
"vue-i18n": "9",
|
||||||
"vue-router": "4",
|
"vue-router": "4",
|
||||||
|
"vue-toast-notification": "^3.0",
|
||||||
"ws": "^8.13.0"
|
"ws": "^8.13.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
12
client/pnpm-lock.yaml
generated
12
client/pnpm-lock.yaml
generated
|
@ -43,6 +43,9 @@ dependencies:
|
||||||
vue-router:
|
vue-router:
|
||||||
specifier: '4'
|
specifier: '4'
|
||||||
version: 4.1.6(vue@3.2.47)
|
version: 4.1.6(vue@3.2.47)
|
||||||
|
vue-toast-notification:
|
||||||
|
specifier: ^3.0
|
||||||
|
version: 3.1.1(vue@3.2.47)
|
||||||
ws:
|
ws:
|
||||||
specifier: ^8.13.0
|
specifier: ^8.13.0
|
||||||
version: 8.13.0
|
version: 8.13.0
|
||||||
|
@ -3887,6 +3890,15 @@ packages:
|
||||||
he: 1.2.0
|
he: 1.2.0
|
||||||
dev: true
|
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):
|
/vue-tsc@1.2.0(typescript@4.9.5):
|
||||||
resolution: {integrity: sha512-rIlzqdrhyPYyLG9zxsVRa+JEseeS9s8F2BbVVVWRRsTZvJO2BbhLEb2HW3MY+DFma0378tnIqs+vfTzbcQtRFw==}
|
resolution: {integrity: sha512-rIlzqdrhyPYyLG9zxsVRa+JEseeS9s8F2BbVVVWRRsTZvJO2BbhLEb2HW3MY+DFma0378tnIqs+vfTzbcQtRFw==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// import WebSocketServer from 'ws';
|
// import WebSocketServer from 'ws';
|
||||||
import JsonRPC from 'simple-jsonrpc-js';
|
import JsonRPC from 'simple-jsonrpc-js';
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { useToast } from 'vue-toast-notification';
|
||||||
|
|
||||||
|
const $toast = useToast();
|
||||||
|
|
||||||
let jrpc = new JsonRPC.connect_xhr('/api');
|
let jrpc = new JsonRPC.connect_xhr('/api');
|
||||||
// let socket = new WebSocket("ws://"+ window.location.host +"/ws/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) {
|
if (ex.code === 401) {
|
||||||
UnauthorizedCallback();
|
UnauthorizedCallback();
|
||||||
} else {
|
} else {
|
||||||
|
$toast.error(method+ ': ' + ex.message);
|
||||||
console.debug("api call epic fail", ex);
|
console.debug("api call epic fail", ex);
|
||||||
}
|
}
|
||||||
return { Data: null, Error: ex};
|
return { Data: null, Error: ex};
|
||||||
|
|
|
@ -3,11 +3,13 @@ import './global-styles/components.css';
|
||||||
import './global-styles/colors.css';
|
import './global-styles/colors.css';
|
||||||
import './global-styles/mlfe.css';
|
import './global-styles/mlfe.css';
|
||||||
import './global-styles/transitions.css';
|
import './global-styles/transitions.css';
|
||||||
|
import 'vue-toast-notification/dist/theme-default.css';
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
import { createHead } from '@vueuse/head';
|
import { createHead } from '@vueuse/head';
|
||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import routes from '~pages';
|
import routes from '~pages';
|
||||||
|
import ToastPlugin from 'vue-toast-notification';
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
const head = createHead();
|
const head = createHead();
|
||||||
|
@ -18,5 +20,6 @@ const router = createRouter({
|
||||||
|
|
||||||
app.use(router);
|
app.use(router);
|
||||||
app.use(head);
|
app.use(head);
|
||||||
|
app.use(ToastPlugin);
|
||||||
|
|
||||||
app.mount('#app');
|
app.mount('#app');
|
||||||
|
|
Loading…
Add table
Reference in a new issue