table headings
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2020-09-02 12:05:48 +02:00
parent 4174e26496
commit 6e9d634f74
4 changed files with 46 additions and 16 deletions

View File

@ -4,6 +4,13 @@
class="table_view" class="table_view"
> >
<table> <table>
<tr v-if="headings.length > 0">
<th
v-for="(heading,key) of headings"
:key="key"
v-text="heading"
/>
</tr>
<tr <tr
v-for="(item,key) of items" v-for="(item,key) of items"
:key="key" :key="key"
@ -30,6 +37,10 @@ export default {
columns: { columns: {
type: Array, type: Array,
required: true required: true
},
headings: {
type: Array,
default: () => []
} }
}, },
methods: { resolve_data } methods: { resolve_data }
@ -38,7 +49,7 @@ export default {
<style> <style>
.table_view { .table_view {
overflow: auto; overflow-y: scoll;
width: max-content; width: max-content;
max-width: 100%; max-width: 100%;
max-height: 100vh; max-height: 100vh;
@ -54,7 +65,7 @@ tr:nth-child(odd) {
color: var(--color-accent); color: var(--color-accent);
} }
td { td, th {
border: var(--sub-container-border); border: var(--sub-container-border);
padding: 3px; padding: 3px;
} }

View File

@ -10,6 +10,7 @@
v-else v-else
:items="data" :items="data"
:columns="config.columns" :columns="config.columns"
:headings="config.headings"
/> />
</template> </template>

View File

@ -6,17 +6,10 @@
*/ */
export default { export default {
sources: [ sources: [
{ { name: 'default', limit: 140, offset: 0 },
name: 'default', { name: 'secondary', limit: 10, offset: 0 },
limit: 140, { name: 'version', limit: 1, offset: 0 }
offset: 0
},
{
name: 'secondary',
limit: 10,
offset: 0
}
], ],
displays: [ displays: [
{ {
@ -50,12 +43,31 @@ export default {
] ]
}, },
{ {
source: 'secondary', source: 'secondary',
type: 'table', type: 'table',
headings: [
'timestamp',
'temperature',
'humidity',
'light',
'fan'
],
columns: [ columns: [
'timestamp', 'timestamp',
'data' 'data/temperature',
'data/humidity',
'data/light',
'data/latch'
] ]
},
{
source: 'version',
type: 'table',
headings: [ 'hardware version' ],
columns: [ 'message' ],
x: '',
y: [],
remove_duplicates: false
} }
] ]
}; };

View File

@ -47,6 +47,12 @@ export default {
'chart' 'chart'
] ]
}, },
{
name: 'headings',
type: 'array',
child: { type: 'string' },
if: { prop: 'type', op: '=', val: 'table' }
},
{ {
name: 'columns', name: 'columns',
type: 'array', type: 'array',