1
0
Fork 0

WIP Data retrieval, purecss

This commit is contained in:
Joe Wroten 2019-05-15 18:01:19 -05:00
parent e67918ca8f
commit a233b0aa62
11 changed files with 121 additions and 6 deletions

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
public
data/raw/real
data/json/real
# Logs # Logs
logs logs
*.log *.log

5
copyAssets.sh Normal file
View file

@ -0,0 +1,5 @@
mkdir -p public
cp src/index.html public
cp -R src/assets public
cp node_modules/purecss/build/base-min.css public/assets
cp node_modules/purecss/build/pure-min.css public/assets

5
mkData.js Normal file
View file

@ -0,0 +1,5 @@
let dataFromDate = require('./mkDataFromDate.js');
let dataFromDiskspace = require('./mkDataFromDiskspace.js');
dataFromDate();
dataFromDiskspace();

21
mkDataFromDate.js Normal file
View file

@ -0,0 +1,21 @@
const fs = require('fs');
const path = require('path');
module.exports = async function() {
fs.readFile(path.join(__dirname, 'data/raw/real', 'date.raw'), 'utf8', (err, date) => {
if (err || !date.length) {
console.error(err);
process.exit(1);
}
date = new Date(date.slice(0, date.length - 1));
let jsonString = JSON.stringify({
raw: date,
pretty: date.toDateString(),
});
fs.writeFile(path.join(__dirname, 'data/json/real', 'date.json'), jsonString, err => {
if (err) throw err;
});
});
}

27
mkDataFromDiskspace.js Normal file
View file

@ -0,0 +1,27 @@
const fs = require('fs');
const path = require('path');
module.exports = async function() {
fs.readFile(path.join(__dirname, 'data/raw/real', 'diskspace.raw'), 'utf8', (err, diskspace) => {
if (err || !diskspace.length) {
console.error(err);
process.exit(1);
}
let diskspaceData = diskspace.split(' ').filter(str => str.length);
let [ partitionName, size, used, avail, capacity ] = diskspaceData;
let jsonString = JSON.stringify({
partitionName,
size,
used,
avail,
capacity,
});
fs.writeFile(path.join(__dirname, 'data/json/real', 'diskspace.json'), jsonString, err => {
if (err) throw err;
});
});
}

8
mkRaw.sh Normal file
View file

@ -0,0 +1,8 @@
mkdir -p data/raw/real
mkdir -p data/json/real
touch data/raw/real/date.raw
date > data/raw/real/date.raw
touch data/raw/real/diskspace.raw
df -H | grep /dev/disk1s1 > data/raw/real/diskspace.raw

6
package-lock.json generated
View file

@ -43,6 +43,12 @@
"wordwrap": "~0.0.2" "wordwrap": "~0.0.2"
} }
}, },
"purecss": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/purecss/-/purecss-1.0.0.tgz",
"integrity": "sha512-gfC78WCOWNnfkzulx9aoWwcl+0JflhwKeJ+k9s/ZyIawfYNA4bqBmt0DtfgtQK9iuYMtGfbdE8R2AQMjSWR2VQ==",
"dev": true
},
"wordwrap": { "wordwrap": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz",

View file

@ -5,6 +5,9 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",
"copy:assets": "bash ./copyAssets.sh",
"mk:raw": "bash ./mkRaw.sh",
"mk:data": "node mkData.js",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
@ -18,6 +21,7 @@
}, },
"homepage": "https://github.com/sharpshark28/basking-dashboard#readme", "homepage": "https://github.com/sharpshark28/basking-dashboard#readme",
"devDependencies": { "devDependencies": {
"node-static": "^0.7.11" "node-static": "^0.7.11",
"purecss": "^1.0.0"
} }
} }

View file

@ -1,12 +1,24 @@
<html> <html>
<head> <head>
<title>Basking</title> <title>Basking</title>
<link rel="stylesheet" type="text/css" href="./assets/base-min.css" />
<link rel="stylesheet" type="text/css" href="./assets/pure-min.css" />
<link rel="stylesheet" type="text/css" href="./assets/styles.css" />
</head> </head>
<body> <body>
<h1>Basking</h1> <main class="pure-g">
<ul> <section class="pure-u-1-3">
<li><a href="/emby">Emby</a> Yo
<li><a href="/portainer">Portainer</a> </section>
</ul> <section class="pure-u-1-3">
Yo
</section>
<section class="pure-u-1-3">
Yo
</section>
</main>
<a href="/emby">Emby</a>
<a href="/portainer">Portainer</a>
</body> </body>
</html> </html>

0
src/assets/styles.css Normal file
View file

24
src/index.html Normal file
View file

@ -0,0 +1,24 @@
<html>
<head>
<title>Basking</title>
<link rel="stylesheet" type="text/css" href="./assets/base-min.css" />
<link rel="stylesheet" type="text/css" href="./assets/pure-min.css" />
<link rel="stylesheet" type="text/css" href="./assets/styles.css" />
</head>
<body>
<main class="pure-g">
<section class="pure-u-1-3">
Yo
</section>
<section class="pure-u-1-3">
Yo
</section>
<section class="pure-u-1-3">
Yo
</section>
</main>
<a href="/emby">Emby</a>
<a href="/portainer">Portainer</a>
</body>
</html>