Skip to content

Commit 30498a8

Browse files
committed
✨ add disconnected indicator
1 parent 0161979 commit 30498a8

File tree

7 files changed

+32
-5
lines changed

7 files changed

+32
-5
lines changed

frontend/src/components/data/TraceList.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default class TraceList extends Vue {
154154
public show: boolean = true;
155155
public interval?: number;
156156
// this is so dumb need a better way to do dynamic v-model defualts
157-
public burnIn = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10];
157+
public burnIn = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10];
158158
159159
get traces() {
160160
const traces = readTraces(this.$store);

frontend/src/store/main/actions.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ActionContext } from 'vuex';
66
import { State } from '../state';
77
import {
88
commitAddNotification,
9+
commitDisconnected,
910
commitRemoveNotification,
1011
commitSetLoggedIn,
1112
commitSetLogInError,
@@ -66,14 +67,21 @@ export const actions = {
6667
}
6768
},
6869
async actionCheckApiError(context: MainContext, payload: AxiosError) {
70+
// check for general errors e.g. CORS or network issues
71+
if (!payload.response) {
72+
console.log('Network error');
73+
return commitDisconnected(context, true);
74+
}
75+
console.log('API error', payload.response);
76+
commitDisconnected(context, false);
6977
if (payload.response!.status === 401) {
70-
await dispatchLogOut(context);
78+
return await dispatchLogOut(context);
7179
}
7280
if (payload.response!.status === 404) {
73-
commitAddNotification(context, { content: payload.response!.data.detail, color: 'error', notFound: true});
81+
return commitAddNotification(context, { content: payload.response!.data.detail, color: 'error', notFound: true});
7482
}
7583
if (payload.response!.status === 500) {
76-
commitAddNotification(context, { content: payload.response!.data.detail, color: 'error', notFound: true});
84+
return commitAddNotification(context, { content: payload.response!.data.detail, color: 'error', notFound: true});
7785
}
7886
},
7987
actionRouteLoggedIn(context: MainContext) {

frontend/src/store/main/getters.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { MainState } from './state';
44

55
export const getters = {
66
loginError: (state: MainState) => state.logInError,
7+
disconnected: (state: MainState) => state.disconnected,
78
dashboardShowDrawer: (state: MainState) => state.dashboardShowDrawer,
89
dashboardMiniDrawer: (state: MainState) => state.dashboardMiniDrawer,
910
token: (state: MainState) => state.token,
@@ -19,3 +20,4 @@ export const readIsLoggedIn = read(getters.isLoggedIn);
1920
export const readLoginError = read(getters.loginError);
2021
export const readToken = read(getters.token);
2122
export const readFirstNotification = read(getters.firstNotification);
23+
export const readDisconnected = read(getters.disconnected);

frontend/src/store/main/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const defaultState: MainState = {
77
isLoggedIn: null,
88
token: '',
99
logInError: false,
10+
disconnected: false,
1011
dashboardMiniDrawer: false,
1112
dashboardShowDrawer: false,
1213
notifications: [],

frontend/src/store/main/mutations.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export const mutations = {
1313
setLogInError(state: MainState, payload: boolean) {
1414
state.logInError = payload;
1515
},
16+
setDisconnected(state: MainState, payload: boolean) {
17+
state.disconnected = payload;
18+
},
1619
setDashboardMiniDrawer(state: MainState, payload: boolean) {
1720
state.dashboardMiniDrawer = payload;
1821
},
@@ -36,3 +39,4 @@ export const commitSetLogInError = commit(mutations.setLogInError);
3639
export const commitSetToken = commit(mutations.setToken);
3740
export const commitAddNotification = commit(mutations.addNotification);
3841
export const commitRemoveNotification = commit(mutations.removeNotification);
42+
export const commitDisconnected = commit(mutations.setDisconnected);

frontend/src/store/main/state.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface MainState {
99
token: string;
1010
isLoggedIn: boolean | null;
1111
logInError: boolean;
12+
disconnected: boolean;
1213
dashboardMiniDrawer: boolean;
1314
dashboardShowDrawer: boolean;
1415
notifications: AppNotification[];

frontend/src/views/main/Dashboard.vue

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
class="rounded-lg"
88
flat >
99
<v-toolbar-title class="text-h5">
10-
Traces
10+
Traces
11+
<v-tooltip v-if="isDisconnected" color="black" top>
12+
<template #activator="{ on }">
13+
<v-icon v-on="on" color="red darken-2">mdi-link-variant-off</v-icon>
14+
</template>
15+
<span>Disconnected from server!</span>
16+
</v-tooltip>
1117
</v-toolbar-title>
1218

1319
<v-spacer></v-spacer>
@@ -161,6 +167,7 @@ import StatsTable from '@/components/data/StatsTable.vue';
161167
import TraceList from '@/components/data/TraceList.vue';
162168
163169
import { readActiveTraceIDs, readTraces } from '@/store/data/getters';
170+
import { readDisconnected } from '@/store/main/getters';
164171
import { Plotly } from 'vue-plotly';
165172
import { Component, Vue } from 'vue-property-decorator';
166173
import VueResizable from 'vue-resizable';
@@ -194,6 +201,10 @@ export default class Dashboard extends Vue {
194201
}
195202
}
196203
204+
get isDisconnected() {
205+
return readDisconnected(this.$store);
206+
}
207+
197208
get activeTraceIDs() {
198209
const IDs = readActiveTraceIDs(this.$store);
199210
return IDs;

0 commit comments

Comments
 (0)