Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): show/hide node table columns #407

Merged
merged 6 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions src/components/nodes-table/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-data-table
:headers="headers"
:headers="activeHeaders"
:items="tableNodes"
:mobile-breakpoint="0"
:footer-props="{
Expand Down Expand Up @@ -29,16 +29,50 @@
</v-layout>
<v-layout row ma-2 justify-start>
<v-flex xs12>
<v-btn
color="blue darken-1"
text
@click.native="filterSelected()"
:disabled="selected.length === 0"
>Filter Selected</v-btn
>
<v-btn color="blue darken-1" text @click.native="resetFilters()"
>Reset Filters</v-btn
>
<v-menu v-model="headersMenu" :close-on-content-click="false">
<template v-slot:activator="{ on }">
<v-btn v-on="on">
<v-icon>menu</v-icon>
Columns
</v-btn>
</template>
<v-card>
<v-card-text>
<v-checkbox
v-for="col in selectableHeaders"
:key="col.value"
hide-details
:label="col.text"
v-model="col.active"
></v-checkbox>
</v-card-text>
</v-card>
</v-menu>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn
color="blue darken-1"
text
v-on="on"
@click.native="filterSelected()"
:disabled="selected.length === 0"
>Filter Selected</v-btn
>
</template>
<span>Show only selected nodes</span>
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn
color="blue darken-1"
text
v-on="on"
@click.native="resetFilters()"
>Reset Filters</v-btn
>
</template>
<span>Reset all column filters</span>
</v-tooltip>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<v-btn text color="green" v-on="on" @click="$emit('importNodes')">
Expand All @@ -64,7 +98,7 @@
</v-layout>
</template>
<template
v-for="column in headers"
v-for="column in activeHeaders"
v-slot:[`header.${column.value}`]="{ header }"
>
<span :key="column.value">
Expand Down
100 changes: 88 additions & 12 deletions src/components/nodes-table/nodes-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,93 @@ export default {
filters: {},
sorting: {},
selected: [],
headersMenu: false,
headers: [
{ text: 'ID', type: 'number', value: 'id', groupable: false },
{ text: 'Manufacturer', type: 'string', value: 'manufacturer' },
{ text: 'Product', type: 'string', value: 'productDescription' },
{ text: 'Product code', type: 'string', value: 'productLabel' },
{ text: 'Name', type: 'string', value: 'name' },
{ text: 'Location', type: 'string', value: 'loc' },
{ text: 'Secure', type: 'boolean', value: 'isSecure' },
{ text: 'Beaming', type: 'boolean', value: 'isBeaming' },
{ text: 'Failed', type: 'boolean', value: 'failed' },
{ text: 'Status', type: 'string', value: 'status' },
{ text: 'Interview stage', type: 'string', value: 'interviewStage' },
{
text: 'ID',
type: 'number',
value: 'id',
groupable: false,
selectable: false,
active: true
},
{
text: 'Manufacturer',
type: 'string',
value: 'manufacturer',
selectable: true,
active: true
},
{
text: 'Product',
type: 'string',
value: 'productDescription',
selectable: true,
active: true
},
{
text: 'Product code',
type: 'string',
value: 'productLabel',
selectable: true,
active: false
},
{
text: 'Name',
type: 'string',
value: 'name',
selectable: true,
active: true
},
{
text: 'Location',
type: 'string',
value: 'loc',
selectable: true,
active: true
},
{
text: 'Secure',
type: 'boolean',
value: 'isSecure',
selectable: true,
active: false
},
{
text: 'Beaming',
type: 'boolean',
value: 'isBeaming',
selectable: true,
active: false
},
{
text: 'Failed',
type: 'boolean',
value: 'failed',
selectable: true,
active: false
},
{
text: 'Status',
type: 'string',
value: 'status',
selectable: true,
active: true
},
{
text: 'Interview stage',
type: 'string',
value: 'interviewStage',
selectable: true,
active: true
},
{
text: 'Last Active',
type: 'date',
value: 'lastActive',
groupable: false
groupable: false,
selectable: true,
active: true
}
]
}),
Expand Down Expand Up @@ -115,6 +185,12 @@ export default {
}
},
computed: {
activeHeaders () {
return this.headers.filter(col => col.active)
},
selectableHeaders () {
return this.headers.filter(col => col.selectable)
},
nodeCollection () {
return new NodeCollection(this.nodes)
},
Expand Down