polishing chart, build info in top left
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Timo Hocker 2020-08-24 21:20:58 +02:00
parent d5dc2f933a
commit 36d12a784a
12 changed files with 97 additions and 44 deletions

View File

@ -2,6 +2,11 @@ kind: pipeline
name: default
steps:
- name: version
image: alpine
commands:
- echo "module.exports = '$(date)';" > version.js
- name: docker build
image: plugins/docker
settings:

View File

@ -5,6 +5,7 @@
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
/* eslint-disable no-console */
// @ts-nocheck
'use strict';
@ -15,9 +16,12 @@ const api = require ('./lib/api');
const http_proxy = require ('express-http-proxy');
const history_fallback = require ('connect-history-api-fallback');
const { argv } = require ('yargs');
const version = require ('./version');
const is_dev = argv.dev;
console.log (`starting appreports build ${version}`);
(async () => {
await db.init (is_dev);
@ -32,7 +36,6 @@ const is_dev = argv.dev;
app.use (express.static ('dist'));
app.listen (3000, () => {
// eslint-disable-next-line no-console
console.log ('listening on 3000');
});
}) ();

View File

@ -1,3 +1,10 @@
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of appreports which is released under GPL-3.0-or-later.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
/* eslint-disable no-console */
'use strict';

View File

@ -20,7 +20,6 @@
"express-http-proxy": "^1.6.2",
"faker": "^4.1.0",
"knex": "^0.21.2",
"simplex-noise": "^2.4.0",
"sqlite3": "^5.0.0",
"vue": "^2.6.11",
"vue-chartjs": "^3.5.0",

View File

@ -8,7 +8,6 @@
'use strict';
const faker = require ('faker');
const sn = require ('simplex-noise');
const apps = [];
@ -20,17 +19,23 @@ async function create_app (knex) {
apps.push (id);
}
function create_log (index, simplex) {
let last_t = 0;
let last_h = 0;
function create_log (timestamp) {
last_t += faker.random.number (3) - 1;
last_h += faker.random.number (2) - 1;
const data = {
light: faker.random.number (),
temperature: simplex.noise2D (index * 0.1, 0),
humidity: simplex.noise2D (index * 0.1, 1000)
light: faker.random.number (10),
temperature: last_t,
humidity: last_h
};
return {
app_id: faker.random.arrayElement (apps),
message: faker.random.words (),
data: JSON.stringify (data),
timestamp: faker.date.recent ()
timestamp
};
}
@ -41,10 +46,11 @@ async function seed (knex) {
// eslint-disable-next-line no-await-in-loop
await create_app (knex);
const simplex = (new sn);
const log = (Array (20))
const log = (Array (1000))
.fill (() => null)
.map ((a, index) => create_log (index, simplex));
.map (() => faker.date.recent (30))
.sort ()
.map ((t) => create_log (t));
await knex.batchInsert ('log', log, 10);
}

View File

@ -1,11 +1,21 @@
<template>
<div id="app">
<p
id="build-info"
v-text="version"
/>
<router-view />
</div>
</template>
<script>
export default {};
import version from '../version';
export default {
data () {
return { version: `build: ${version}` };
}
};
</script>
<style>
@ -17,16 +27,8 @@ export default {};
color: #2c3e50;
}
#nav {
padding: 30px;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
#build-info {
font-size: 10pt;
text-align: left;
}
</style>

View File

@ -38,9 +38,19 @@ export default {
},
chart_options () {
return {
animation: { duration: 0 },
responsiveAnimationDuration: 0,
scales: {
yAxes: this.yaxis.map (
(y, index) => ({ id: index })
(y, index) => {
const range = {};
if (typeof y.min_value === 'number')
range.suggestedMin = y.min_value;
if (typeof y.max_value === 'number')
range.suggestedMax = y.max_value;
return { id: index, ticks: range };
}
)
}
};

View File

@ -116,7 +116,11 @@ export default {
}
},
data () {
return { temp: this.value };
let val = this.value;
if (typeof val === 'undefined')
val = this.create_default (this.template);
return { temp: val };
},
computed: {
config: {
@ -124,8 +128,14 @@ export default {
return this.temp;
},
set (val) {
this.$emit ('input', val);
this.temp = val;
let mapped = val;
if (this.template.type === 'number') {
mapped = parseFloat (val);
if (isNaN (mapped))
mapped = 0;
}
this.$emit ('input', mapped);
this.temp = mapped;
}
}
},

View File

@ -28,13 +28,17 @@ export default {
label: 'temperature',
field: 'data/temperature',
color: '#ff0000',
fill: '#0000'
fill: '#0000',
min_value: 10,
max_value: 40
},
{
label: 'humidity',
field: 'data/humidity',
color: '#0000ff',
fill: '#0000'
fill: '#0000',
min_value: 100,
max_value: 0
},
{
label: 'light',

View File

@ -68,7 +68,9 @@ export default {
{ type: 'string', name: 'label' },
{ type: 'string', name: 'field' },
{ type: 'string', name: 'color' },
{ type: 'string', name: 'fill' }
{ type: 'string', name: 'fill' },
{ type: 'number', name: 'min_value' },
{ type: 'number', name: 'max_value' }
]
}
}

10
version.js Normal file
View File

@ -0,0 +1,10 @@
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of appreports which is released under GPL-3.0-or-later.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
'use strict';
module.exports = 'development';

View File

@ -7940,11 +7940,6 @@ simple-swizzle@^0.2.2:
dependencies:
is-arrayish "^0.3.1"
simplex-noise@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/simplex-noise/-/simplex-noise-2.4.0.tgz#81b3458fb22dccc3bc8dd9a977c73797f86f523a"
integrity sha512-OjyDWm/QZjVbMrPxDVi9b2as+SeNn9EBXlrWVRlFW+TSyWMSXouDryXkQN0vf5YP+QZKobrmkvx1eQYPLtuqfw==
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"