polishing chart, build info in top left
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
d5dc2f933a
commit
36d12a784a
@ -2,6 +2,11 @@ kind: pipeline
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: version
|
||||||
|
image: alpine
|
||||||
|
commands:
|
||||||
|
- echo "module.exports = '$(date)';" > version.js
|
||||||
|
|
||||||
- name: docker build
|
- name: docker build
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
|
5
index.js
5
index.js
@ -5,6 +5,7 @@
|
|||||||
* Created by Timo Hocker <timo@scode.ovh>, August 2020
|
* Created by Timo Hocker <timo@scode.ovh>, August 2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable no-console */
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -15,9 +16,12 @@ const api = require ('./lib/api');
|
|||||||
const http_proxy = require ('express-http-proxy');
|
const http_proxy = require ('express-http-proxy');
|
||||||
const history_fallback = require ('connect-history-api-fallback');
|
const history_fallback = require ('connect-history-api-fallback');
|
||||||
const { argv } = require ('yargs');
|
const { argv } = require ('yargs');
|
||||||
|
const version = require ('./version');
|
||||||
|
|
||||||
const is_dev = argv.dev;
|
const is_dev = argv.dev;
|
||||||
|
|
||||||
|
console.log (`starting appreports build ${version}`);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await db.init (is_dev);
|
await db.init (is_dev);
|
||||||
|
|
||||||
@ -32,7 +36,6 @@ const is_dev = argv.dev;
|
|||||||
app.use (express.static ('dist'));
|
app.use (express.static ('dist'));
|
||||||
|
|
||||||
app.listen (3000, () => {
|
app.listen (3000, () => {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log ('listening on 3000');
|
console.log ('listening on 3000');
|
||||||
});
|
});
|
||||||
}) ();
|
}) ();
|
||||||
|
@ -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 */
|
/* eslint-disable no-console */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
"express-http-proxy": "^1.6.2",
|
"express-http-proxy": "^1.6.2",
|
||||||
"faker": "^4.1.0",
|
"faker": "^4.1.0",
|
||||||
"knex": "^0.21.2",
|
"knex": "^0.21.2",
|
||||||
"simplex-noise": "^2.4.0",
|
|
||||||
"sqlite3": "^5.0.0",
|
"sqlite3": "^5.0.0",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-chartjs": "^3.5.0",
|
"vue-chartjs": "^3.5.0",
|
||||||
@ -47,4 +46,4 @@
|
|||||||
"name": "Timo Hocker",
|
"name": "Timo Hocker",
|
||||||
"email": "timo@scode.ovh"
|
"email": "timo@scode.ovh"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const faker = require ('faker');
|
const faker = require ('faker');
|
||||||
const sn = require ('simplex-noise');
|
|
||||||
|
|
||||||
const apps = [];
|
const apps = [];
|
||||||
|
|
||||||
@ -20,17 +19,23 @@ async function create_app (knex) {
|
|||||||
apps.push (id);
|
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 = {
|
const data = {
|
||||||
light: faker.random.number (),
|
light: faker.random.number (10),
|
||||||
temperature: simplex.noise2D (index * 0.1, 0),
|
temperature: last_t,
|
||||||
humidity: simplex.noise2D (index * 0.1, 1000)
|
humidity: last_h
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
app_id: faker.random.arrayElement (apps),
|
app_id: faker.random.arrayElement (apps),
|
||||||
message: faker.random.words (),
|
message: faker.random.words (),
|
||||||
data: JSON.stringify (data),
|
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
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await create_app (knex);
|
await create_app (knex);
|
||||||
|
|
||||||
const simplex = (new sn);
|
const log = (Array (1000))
|
||||||
const log = (Array (20))
|
|
||||||
.fill (() => null)
|
.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);
|
await knex.batchInsert ('log', log, 10);
|
||||||
}
|
}
|
||||||
|
26
src/App.vue
26
src/App.vue
@ -1,11 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
<p
|
||||||
|
id="build-info"
|
||||||
|
v-text="version"
|
||||||
|
/>
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {};
|
import version from '../version';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return { version: `build: ${version}` };
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@ -17,16 +27,8 @@ export default {};
|
|||||||
color: #2c3e50;
|
color: #2c3e50;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav {
|
#build-info {
|
||||||
padding: 30px;
|
font-size: 10pt;
|
||||||
}
|
text-align: left;
|
||||||
|
|
||||||
#nav a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: #2c3e50;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav a.router-link-exact-active {
|
|
||||||
color: #42b983;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -38,9 +38,19 @@ export default {
|
|||||||
},
|
},
|
||||||
chart_options () {
|
chart_options () {
|
||||||
return {
|
return {
|
||||||
scales: {
|
animation: { duration: 0 },
|
||||||
yAxes: this.yaxis.map (
|
responsiveAnimationDuration: 0,
|
||||||
(y, index) => ({ id: index })
|
scales: {
|
||||||
|
yAxes: this.yaxis.map (
|
||||||
|
(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 };
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -116,7 +116,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return { temp: this.value };
|
let val = this.value;
|
||||||
|
if (typeof val === 'undefined')
|
||||||
|
val = this.create_default (this.template);
|
||||||
|
|
||||||
|
return { temp: val };
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
config: {
|
config: {
|
||||||
@ -124,8 +128,14 @@ export default {
|
|||||||
return this.temp;
|
return this.temp;
|
||||||
},
|
},
|
||||||
set (val) {
|
set (val) {
|
||||||
this.$emit ('input', val);
|
let mapped = val;
|
||||||
this.temp = val;
|
if (this.template.type === 'number') {
|
||||||
|
mapped = parseFloat (val);
|
||||||
|
if (isNaN (mapped))
|
||||||
|
mapped = 0;
|
||||||
|
}
|
||||||
|
this.$emit ('input', mapped);
|
||||||
|
this.temp = mapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -25,16 +25,20 @@ export default {
|
|||||||
x: 'timestamp',
|
x: 'timestamp',
|
||||||
y: [
|
y: [
|
||||||
{
|
{
|
||||||
label: 'temperature',
|
label: 'temperature',
|
||||||
field: 'data/temperature',
|
field: 'data/temperature',
|
||||||
color: '#ff0000',
|
color: '#ff0000',
|
||||||
fill: '#0000'
|
fill: '#0000',
|
||||||
|
min_value: 10,
|
||||||
|
max_value: 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'humidity',
|
label: 'humidity',
|
||||||
field: 'data/humidity',
|
field: 'data/humidity',
|
||||||
color: '#0000ff',
|
color: '#0000ff',
|
||||||
fill: '#0000'
|
fill: '#0000',
|
||||||
|
min_value: 100,
|
||||||
|
max_value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'light',
|
label: 'light',
|
||||||
|
@ -68,7 +68,9 @@ export default {
|
|||||||
{ type: 'string', name: 'label' },
|
{ type: 'string', name: 'label' },
|
||||||
{ type: 'string', name: 'field' },
|
{ type: 'string', name: 'field' },
|
||||||
{ type: 'string', name: 'color' },
|
{ 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
10
version.js
Normal 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';
|
@ -7940,11 +7940,6 @@ simple-swizzle@^0.2.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-arrayish "^0.3.1"
|
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:
|
slash@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user