dynamic config
This commit is contained in:
parent
9ec6440dc7
commit
63978a522c
@ -23,6 +23,7 @@
|
|||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-http-proxy": "^1.6.2",
|
"express-http-proxy": "^1.6.2",
|
||||||
"faker": "^4.1.0",
|
"faker": "^4.1.0",
|
||||||
|
"hjson": "^3.2.1",
|
||||||
"knex": "^0.21.2",
|
"knex": "^0.21.2",
|
||||||
"simplex-noise": "^2.4.0",
|
"simplex-noise": "^2.4.0",
|
||||||
"sqlite3": "^5.0.0",
|
"sqlite3": "^5.0.0",
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { Line, mixins } from 'vue-chartjs';
|
import { Line, mixins } from 'vue-chartjs';
|
||||||
|
import { resolve_data } from '../helper';
|
||||||
function resolve_data (set, index) {
|
|
||||||
const keys = typeof index === 'string' ? index.split ('/') : index;
|
|
||||||
const data = set[keys[0]];
|
|
||||||
if (keys.length === 1)
|
|
||||||
return data;
|
|
||||||
return resolve_data (data, keys.slice (1));
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: Line,
|
extends: Line,
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<td
|
<td
|
||||||
v-for="(col,c_key) of columns"
|
v-for="(col,c_key) of columns"
|
||||||
:key="c_key"
|
:key="c_key"
|
||||||
v-text="item[col]"
|
v-text="resolve_data(item,col)"
|
||||||
/>
|
/>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -19,6 +19,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { resolve_data } from '../helper';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
items: {
|
items: {
|
||||||
@ -29,7 +31,8 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
methods: { resolve_data }
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
36
src/components/ViewComponent.vue
Normal file
36
src/components/ViewComponent.vue
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<ChartView
|
||||||
|
v-if="config.type === 'chart'"
|
||||||
|
:data="data"
|
||||||
|
:xaxis="config.x"
|
||||||
|
:yaxis="config.y"
|
||||||
|
/>
|
||||||
|
<TableView
|
||||||
|
v-else
|
||||||
|
:items="data"
|
||||||
|
:columns="config.columns"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ChartView from './ChartView.vue';
|
||||||
|
import TableView from './TableView.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: { ChartView, TableView },
|
||||||
|
props: {
|
||||||
|
config: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
50
src/default.js
Normal file
50
src/default.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
export default [
|
||||||
|
{
|
||||||
|
type: 'table',
|
||||||
|
columns: [
|
||||||
|
'id',
|
||||||
|
'app',
|
||||||
|
'timestamp'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'table',
|
||||||
|
columns: [ 'data' ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'chart',
|
||||||
|
x: 'timestamp',
|
||||||
|
y: [
|
||||||
|
{
|
||||||
|
label: 'foo',
|
||||||
|
field: 'data/num2',
|
||||||
|
color: '#ff000055',
|
||||||
|
fill: '#0000'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'bar',
|
||||||
|
field: 'data/num3',
|
||||||
|
color: '#00ff00',
|
||||||
|
fill: '#0000'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'table',
|
||||||
|
columns: [
|
||||||
|
'id',
|
||||||
|
'app',
|
||||||
|
'message'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'table',
|
||||||
|
columns: [
|
||||||
|
'id',
|
||||||
|
'app',
|
||||||
|
'message',
|
||||||
|
'data',
|
||||||
|
'timestamp'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
7
src/helper.js
Normal file
7
src/helper.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export function resolve_data (set, index) {
|
||||||
|
const keys = typeof index === 'string' ? index.split ('/') : index;
|
||||||
|
const data = set[keys[0]];
|
||||||
|
if (keys.length === 1)
|
||||||
|
return data;
|
||||||
|
return resolve_data (data, keys.slice (1));
|
||||||
|
}
|
@ -2,45 +2,36 @@
|
|||||||
<div
|
<div
|
||||||
class="grid"
|
class="grid"
|
||||||
>
|
>
|
||||||
<TableView
|
<textarea v-model="config" />
|
||||||
:items="log"
|
<ViewComponent
|
||||||
:columns="['id', 'app','timestamp']"
|
v-for="(item,key) of parsed_config"
|
||||||
/>
|
:key="key"
|
||||||
<TableView
|
:config="item"
|
||||||
:items="log"
|
|
||||||
:columns="['data']"
|
|
||||||
/>
|
|
||||||
<ChartView
|
|
||||||
:data="parsed_log"
|
:data="parsed_log"
|
||||||
xaxis="timestamp"
|
|
||||||
:yaxis="datasets"
|
|
||||||
/>
|
|
||||||
<TableView
|
|
||||||
v-if="log.length > 0"
|
|
||||||
:items="log"
|
|
||||||
:columns="Object.keys(log[0]).slice(0,3)"
|
|
||||||
/>
|
|
||||||
<TableView
|
|
||||||
v-if="log.length > 0"
|
|
||||||
:items="log"
|
|
||||||
:columns="Object.keys(log[0])"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
import TableView from '../components/TableView.vue';
|
import hjson from 'hjson';
|
||||||
import ChartView from '../components/ChartView.vue';
|
import ViewComponent from '../components/ViewComponent.vue';
|
||||||
|
import default_config from '../default';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { TableView, ChartView },
|
components: { ViewComponent },
|
||||||
|
data () {
|
||||||
|
return { config: hjson.stringify (default_config) };
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
datasets () {
|
parsed_config () {
|
||||||
return [
|
try {
|
||||||
{ label: 'foo', field: 'data/num2', color: '#ff000055', fill: '#0000' },
|
return hjson.parse (this.config);
|
||||||
{ label: 'bar', field: 'data/num3', color: '#00ff00', fill: '#0000' }
|
}
|
||||||
];
|
catch {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
return [];
|
||||||
},
|
},
|
||||||
parsed_log () {
|
parsed_log () {
|
||||||
return this.log.map ((l) => {
|
return this.log.map ((l) => {
|
||||||
|
@ -4445,6 +4445,11 @@ highlight.js@^9.6.0:
|
|||||||
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634"
|
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634"
|
||||||
integrity sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==
|
integrity sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ==
|
||||||
|
|
||||||
|
hjson@^3.2.1:
|
||||||
|
version "3.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/hjson/-/hjson-3.2.1.tgz#20de41dc87fc9a10d1557d0230b0e02afb1b09ac"
|
||||||
|
integrity sha512-OhhrFMeC7dVuA1xvxuXGTv/yTdhTvbe8hz+3LgVNsfi9+vgz0sF/RrkuX8eegpKaMc9cwYwydImBH6iePoJtdQ==
|
||||||
|
|
||||||
hmac-drbg@^1.0.0:
|
hmac-drbg@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
|
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user