diff --git a/data/raw/test/diskspace.raw b/data/raw/test/diskspace.raw index fe66081..f013de1 100644 --- a/data/raw/test/diskspace.raw +++ b/data/raw/test/diskspace.raw @@ -1 +1 @@ -/dev/disk1 1000G 100G 900G 10% 0000001 9999999999999999999 0% / +/dev/disk1 1000000 100000 900000 10% 0000001 9999999999999999999 0% / diff --git a/index.js b/index.js index b4fa08d..ea90cb9 100644 --- a/index.js +++ b/index.js @@ -29,3 +29,10 @@ app.route(apiPrefix + '/builddate').get((req, res) => { }); }); +app.route(apiPrefix + '/diskspace').get((req, res) => { + fs.readFile(path.join(__dirname, 'data/json', 'diskspace.json'), 'utf8', (err, json) => { + if (err) { throw new Error(err); } + res.json(JSON.parse(json)); + }); +}); + diff --git a/mkRaw.sh b/mkRaw.sh index 7ad1223..18e8734 100644 --- a/mkRaw.sh +++ b/mkRaw.sh @@ -5,4 +5,4 @@ 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 +df | grep /dev/disk1s1 > data/raw/real/diskspace.raw diff --git a/public/index.html b/public/index.html index 84b3d1c..0c99f81 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,16 @@
- +
+ +
+
+

Used: {{diskCapacity}} +

+
+ +
+
diff --git a/src/assets/app.js b/src/assets/app.js index 38eab63..1efd834 100644 --- a/src/assets/app.js +++ b/src/assets/app.js @@ -1,11 +1,17 @@ new Vue({ el: '#app', data: { - lastBuildDate: '', fetchingLastBuildDate: true, + lastBuildDate: '', + + fetchingDiskSpace: '', + diskSize: '', + diskUsed: '', + diskCapacity: '', }, created() { this.fetchLastBuildDate(); + this.fetchDiskSpace(); }, methods: { async fetchLastBuildDate() { @@ -16,5 +22,15 @@ new Vue({ this.fetchingLastBuildDate = false; } catch (err) { throw new Error(err); } }, + async fetchDiskSpace() { + this.fetchingDiskSpace = true; + try { + let { data } = await axios.get('/api/diskspace'); + this.diskSize = data.size; + this.diskUsed = data.used; + this.diskCapacity = data.capacity; + this.fetchingDiskSpace = false; + } catch (err) { throw new Error(err); } + }, }, }); diff --git a/src/assets/emby.png b/src/assets/emby.png deleted file mode 100644 index 2eef3dc..0000000 Binary files a/src/assets/emby.png and /dev/null differ diff --git a/src/assets/styles.css b/src/assets/styles.css index 6b5f8a0..b93b4b7 100644 --- a/src/assets/styles.css +++ b/src/assets/styles.css @@ -1,3 +1,7 @@ +meter { + width: 100%; +} + .fadein { animation: fadein 1s; } diff --git a/src/index.html b/src/index.html index 84b3d1c..0c99f81 100644 --- a/src/index.html +++ b/src/index.html @@ -16,7 +16,16 @@
- +
+ +
+
+

Used: {{diskCapacity}} +

+
+ +
+