diff --git a/.gitignore b/.gitignore index ad46b30..b886261 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +public +data/raw/real +data/json/real # Logs logs *.log diff --git a/copyAssets.sh b/copyAssets.sh new file mode 100644 index 0000000..912ed74 --- /dev/null +++ b/copyAssets.sh @@ -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 diff --git a/mkData.js b/mkData.js new file mode 100644 index 0000000..004a2b3 --- /dev/null +++ b/mkData.js @@ -0,0 +1,5 @@ +let dataFromDate = require('./mkDataFromDate.js'); +let dataFromDiskspace = require('./mkDataFromDiskspace.js'); + +dataFromDate(); +dataFromDiskspace(); diff --git a/mkDataFromDate.js b/mkDataFromDate.js new file mode 100644 index 0000000..3aba07d --- /dev/null +++ b/mkDataFromDate.js @@ -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; + }); + }); +} + diff --git a/mkDataFromDiskspace.js b/mkDataFromDiskspace.js new file mode 100644 index 0000000..b24c75e --- /dev/null +++ b/mkDataFromDiskspace.js @@ -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; + }); + }); +} + diff --git a/mkRaw.sh b/mkRaw.sh new file mode 100644 index 0000000..9d5a0bf --- /dev/null +++ b/mkRaw.sh @@ -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 diff --git a/package-lock.json b/package-lock.json index 92e672f..b7b2b99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,12 @@ "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": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", diff --git a/package.json b/package.json index 2cd55ec..9b35c02 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,9 @@ "main": "index.js", "scripts": { "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" }, "repository": { @@ -18,6 +21,7 @@ }, "homepage": "https://github.com/sharpshark28/basking-dashboard#readme", "devDependencies": { - "node-static": "^0.7.11" + "node-static": "^0.7.11", + "purecss": "^1.0.0" } } diff --git a/public/index.html b/public/index.html index 0264274..361b09a 100644 --- a/public/index.html +++ b/public/index.html @@ -1,12 +1,24 @@