|
235 | 235 | > |
236 | 236 | <v-toolbar-title> |
237 | 237 | Nodes |
| 238 | + <small>(explore tables in node types)</small> |
238 | 239 | </v-toolbar-title> |
239 | | - <v-spacer /> |
240 | | - <div class="pagination"> |
241 | | - <v-btn |
242 | | - class="mx-1" |
243 | | - icon |
244 | | - small |
245 | | - :disabled="!prev" |
246 | | - @click="firstPage()" |
247 | | - > |
248 | | - <v-icon>skip_previous</v-icon> |
249 | | - </v-btn> |
250 | | - <v-btn |
251 | | - class="mx-1" |
252 | | - icon |
253 | | - small |
254 | | - :disabled="!prev" |
255 | | - @click="turnPage(false)" |
256 | | - > |
257 | | - <v-icon>chevron_left</v-icon> |
258 | | - </v-btn> |
259 | | - <v-btn |
260 | | - class="mx-1" |
261 | | - icon |
262 | | - small |
263 | | - :disabled="!next" |
264 | | - @click="turnPage(true)" |
265 | | - > |
266 | | - <v-icon>chevron_right</v-icon> |
267 | | - </v-btn> |
268 | | - <v-btn |
269 | | - class="mx-1" |
270 | | - icon |
271 | | - small |
272 | | - :disabled="!next" |
273 | | - @click="lastPage()" |
274 | | - > |
275 | | - <v-icon>skip_next</v-icon> |
276 | | - </v-btn> |
277 | | - </div> |
278 | 240 | </v-toolbar> |
279 | 241 | <v-card-text class="pa-0"> |
280 | 242 | <v-list |
|
324 | 286 |
|
325 | 287 | <script lang="ts"> |
326 | 288 | import Vue, { PropType } from 'vue'; |
327 | | -import { EdgesSpec, TableRow } from 'multinet'; |
328 | 289 | import WorkspaceOptionMenu from '@/components/WorkspaceOptionMenu.vue'; |
329 | 290 |
|
330 | 291 | import api from '@/api'; |
@@ -421,35 +382,31 @@ export default Vue.extend({ |
421 | 382 | this.panelOpen = !this.panelOpen; |
422 | 383 | }, |
423 | 384 | async update() { |
424 | | - function tableName(tableRow: TableRow | EdgesSpec) { |
425 | | - // eslint-disable-next-line no-underscore-dangle |
426 | | - return tableRow._id.split('/')[0]; |
427 | | - } |
428 | 385 | this.loading = true; |
429 | 386 | const network = await api.network(this.workspace, this.network); |
430 | | - const nodes = await api.nodes(this.workspace, this.network, { |
431 | | - offset: this.offset, |
432 | | - limit: this.limit, |
433 | | - }); |
434 | | - const edges = await api.edges(this.workspace, this.network, { |
435 | | - offset: this.offset, |
436 | | - limit: this.limit, |
437 | | - }); |
438 | 387 | this.totalNodes = network.node_count; |
439 | 388 | this.totalEdges = network.edge_count; |
440 | 389 |
|
441 | | - const prelimNodes = nodes.results.map((node) => tableName(node)); |
442 | | - prelimNodes.forEach((nodeType) => { |
443 | | - if (!this.nodeTypes.includes(nodeType)) { |
444 | | - this.nodeTypes.push(nodeType); |
445 | | - } |
446 | | - }); |
447 | | - this.edgeTypes = edges.results.length > 0 ? [tableName(edges.results[0])] : []; |
448 | | - this.nodeTypes = this.nodeTypes.sort(); |
449 | | - this.edgeTypes = this.edgeTypes.sort(); |
| 390 | + const workspaceTables = await api.networkTables(this.workspace, this.network); |
| 391 | + this.nodeTypes = workspaceTables |
| 392 | + .filter((table) => !table.edge) |
| 393 | + .map((table) => table.name) |
| 394 | + .sort(); |
| 395 | + this.edgeTypes = workspaceTables |
| 396 | + .filter((table) => table.edge) |
| 397 | + .map((table) => table.name) |
| 398 | + .sort(); |
450 | 399 |
|
451 | 400 | // eslint-disable-next-line no-underscore-dangle |
452 | | - this.nodes = nodes.results.map((node) => node._id); |
| 401 | + if (this.totalNodes < 1000) { |
| 402 | + const nodes = await api.nodes(this.workspace, this.network); |
| 403 | + // eslint-disable-next-line no-underscore-dangle |
| 404 | + this.nodes = nodes.results.map((node) => node._id); |
| 405 | + } else { |
| 406 | + const nodes = await api.table(this.workspace, this.nodeTypes[0], { limit: 10 }); |
| 407 | + // eslint-disable-next-line no-underscore-dangle |
| 408 | + this.nodes = nodes.results.map((node) => node._id); |
| 409 | + } |
453 | 410 | this.loading = false; |
454 | 411 | }, |
455 | 412 | turnPage(forward: number) { |
|
0 commit comments