diff --git a/src/store/index.ts b/src/store/index.ts index 94ca1ec3..96a36f8b 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -76,27 +76,39 @@ const { async fetchWorkspaces(context) { const { commit } = rootActionContext(context); const workspaces = await api.workspaces(); - commit.setWorkspaces(workspaces); + commit.setWorkspaces(workspaces.results.map((w) => w.name)); }, async fetchWorkspace(context, workspace: string) { const { commit } = rootActionContext(context); commit.unsetCurrentWorkspace(); - const nodeTables = await api.tables(workspace, { type: 'node' }); - const edgeTables = await api.tables(workspace, { type: 'edge' }); const graphs = await api.graphs(workspace); + const tables = (await api.tables(workspace)).results; + const nodeTables = tables.filter((table) => table.edge === false); + const edgeTables = tables.filter((table) => table.edge === true); commit.setCurrentWorkspace({ - name: workspace, nodeTables, edgeTables, graphs, + name: workspace, + nodeTables: nodeTables.map((table) => table.name), + edgeTables: edgeTables.map((table) => table.name), + graphs: graphs.results.map((graph) => graph.name), }); }, async fetchUserInfo(context) { const { commit } = rootActionContext(context); - const info = await api.userInfo(); - commit.setUserInfo(info); + try { + const info = await api.userInfo(); + commit.setUserInfo(info); + } catch (error) { + if (error.response.status === 401) { + commit.setUserInfo(null); + } else { + throw new Error(error); + } + } }, async logout(context) { diff --git a/src/views/TableDetail.vue b/src/views/TableDetail.vue index af5e21ad..1d997383 100644 --- a/src/views/TableDetail.vue +++ b/src/views/TableDetail.vue @@ -242,7 +242,7 @@ export default Vue.extend({ }); const { - rows, + results: rows, count, } = result; @@ -272,9 +272,9 @@ export default Vue.extend({ this.headers = headers; // Roni to convert these lines to computed function - this.tables = await api.tables(this.workspace, { + this.tables = (await api.tables(this.workspace, { type: 'all', - }); + })).results.map((table) => table.name); this.loading = false; },