diff --git a/package.json b/package.json index e62ceb7..1bb9a6a 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,10 @@ "dependencies": { "@fortawesome/fontawesome-free": "^5.13.0", "bulma": "^0.8.2", - "compression": "^1.7.4", "core-js": "^3.6.4", - "dotenv": "^8.2.0", - "express": "^4.17.1", "js-yaml": "^3.14.0", "lodash.merge": "^4.6.2", - "passport": "^0.4.1", - "passport-local": "^1.0.0", - "ping": "^0.3.0", - "register-service-worker": "^1.7.1", - "rpio": "^2.2.0", - "vue": "^2.6.11" + "register-service-worker": "^1.7.1" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.4.1", diff --git a/public/.env b/public/.env deleted file mode 100644 index 1630b79..0000000 --- a/public/.env +++ /dev/null @@ -1,3 +0,0 @@ -NODE_PORT=3000 -NODE_ENV=production -NODE_IP=127.0.0.80 \ No newline at end of file diff --git a/public/config.yml b/public/config.yml index 298f93b..7a79cd3 100644 --- a/public/config.yml +++ b/public/config.yml @@ -112,6 +112,11 @@ services: subtitle: "192.168.10.6" url: "http://192.168.10.6" target: "_blank" + - name: " Turn on PC" + icon: "fas fa-ethernet" + subtitle: "192.168.10.15" + url: "/api/powerOnPc" + target: "_blank" external: - name: "System" icon: "fas fa-heartbeat" @@ -119,35 +124,35 @@ external: - name: "System Status" icon: "fas fa-joint" subtitle: "" - url: "/sysStatus" + url: "/api/sysStatus" - name: "Icanhazip" icon: "fas fa-joint" subtitle: "" - url: "/internetCheck" + url: "/api/internetCheck" - name: "VPN" icon: "fas fa-joint" subtitle: "" - url: "/vpnCheck" + url: "/api/vpnCheck" - name: "VPN" icon: "fas fa-joint" subtitle: "" - url: "/lancianoCheck" + url: "/api/lancianoCheck" - name: "TV Status" icon: "fas fa-heartbeat" items: - name: "Tv Hat Frequency" icon: "fas fa-broadcast-tower" subtitle: "" - url: "/dvbStatus?t=1" + url: "/api/dvbStatus?t=1" - name: "Tv Hat Channel" icon: "fas fa-tv" subtitle: "" - url: "/dvbChannel?t=1" + url: "/api/dvbChannel?t=1" - name: "USB tuner Frequency" icon: "fas fa-broadcast-tower" subtitle: "" - url: "/dvbStatus?t=0" + url: "/api/dvbStatus?t=0" - name: "USB Tv Channel" icon: "fas fa-tv" subtitle: "" - url: "/dvbChannel?t=0" \ No newline at end of file + url: "/api/dvbChannel?t=0" \ No newline at end of file diff --git a/public/node.js b/public/node.js deleted file mode 100644 index 6f1cb56..0000000 --- a/public/node.js +++ /dev/null @@ -1,169 +0,0 @@ -const express = require('express'); -const compression = require('compression'); -const util = require('util'); -const fs = require('fs'); -const path = require('path'); -const os = require('os'); -const http = require("http"); -const ping = require('ping'); - -const exec = util.promisify(require('child_process').exec); -const readFileAsync = util.promisify(fs.readFile); - -const app = express(); // app is an instance of express - -app.use(compression()); // enables gzip compression - -app.options('*', (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Methods': 'GET, OPTIONS', - 'Access-Control-Allow-Headers': 'Content-Type', - 'Access-Control-Max-Age': 600 - }) - res.status(200).end(); -}) - -app.get('/dvbStatus', async (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - let tuner = 0; - tuner = req.query.t; - const { stdout, stderr } = await exec(`DTV2 -t ${tuner}`); - const i = parseInt(stdout) * 1e-6; // i is in Hz; divide by 1M to have MHz - res.send({ - "id": "dvb-t-status", - "data": `Frontend Frequency: ${i} Mhz`, - "stderr": stderr - }); - -}); - -app.get('/dvbChannel', async (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - let tuner = 0; - tuner = req.query.t; - const { stdout, stderr } = await exec(`DTV2 -t ${tuner}`); - const i = parseInt(stdout) * 1e-6; // i is in Hz; divide by 1M to have MHz - readFileAsync(path.join(__dirname,"frequencies.json")) - .then(res2 => { - const db = JSON.parse(res2); - res.send({ - "id": `dvb-t-channel`, - "name": db[i]["name"].toString(), - "data": db[i]["channels"].toString(), - "stderr": stderr - }); - }) - .catch(err => console.error(err)) - - -}); - -app.get('/internetCheck', async (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - http.get('http://icanhazip.com', (httpRes) => { - httpRes.setEncoding('utf8'); - httpRes.on('data', (body) => { - res.send( - { - "id": "internet-check", - "data": body, - "stderr": "" - } - ) - }); - }); - -}); -app.get('/vpnCheck', async (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - let ifaces = os.networkInterfaces() - if(ifaces.hasOwnProperty('tun0')){ - res.send( - { - "id": "vpn-check", - "data": ifaces["tun0"][0]["cidr"], - "stderr": "" - }) - } else { - res.send( - { - "id": "vpn-check", - "data": "Not connected", - "stderr": "VPN not connected" - }) - - } - -}); - -app.get('/sysStatus', (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - readFileAsync('/sys/class/thermal/thermal_zone0/temp') - .then(res2=> - { - res.send({ - "id": "sys-stats", - "data": `${(parseFloat(res2)*1e-3).toFixed(2)} °C Load: ${os.loadavg().map(x=>x.toFixed(2)).toString()}`, - "stderr": "" - }) - }) - .catch(err=> { - console.error(err) - res.send({ - "id": "sys-stats", - "data": `Load Avg: ${os.loadavg().map(x=>x.toFixed(2)).toString()}`, - "stderr": err - }) - }) - -}); - -app.get('/lancianoCheck', async (req, res) => { - res.set({ - 'Access-Control-Allow-Origin': '*' - }); - let hostRes=''; - let hosts = ["10.8.0.45","10.8.0.46"]; - let promArr=[]; - for(let host of hosts) { - promArr.push(ping.promise.probe(host)); - } - Promise.all(promArr) - .then(function (res) { - for (let item of res) { - if(item.alive) { - hostRes+=item.host+' alive '; - } - else{ - hostRes+=item.host+' dead '; - } - } - }) - .finally(()=>{ - res.send({ - "id": "lanciano-check", - "data": hostRes.toString(), - "stderr": "" - }) - }) -}) - -app.use(express.static('/var/www/forbidden-fruit-dashboard')); // serve static build site - -// app.get('*', (req, res) => { -// res.sendFile(__dirname + '/public/index.html'); -// }); - -//app.listen(8000,"192.168.10.14", () => console.log('listen on 8000')); -app.listen(process.env.NODE_PORT,process.env.NODE_IP, () => console.log(`Bind on ${process.env.NODE_IP}:${process.env.NODE_PORT}`)); \ No newline at end of file diff --git a/public/package.json b/public/package.json deleted file mode 100644 index 2a0d0f1..0000000 --- a/public/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "forbidden-fruit-dashboard", - "version": "3.0.0", - "license": "Apache-2.0", - - "dependencies": { - "compression": "^1.7.4", - "dotenv": "^8.2.0", - "express": "^4.17.1", - "ping": "^0.3.0", - "rpio": "^2.2.0", - "passport": "^0.4.1", - "passport-local": "^1.0.0" - } -} \ No newline at end of file diff --git a/src/components/External.vue b/src/components/External.vue index a604d48..eafb9dd 100644 --- a/src/components/External.vue +++ b/src/components/External.vue @@ -3,18 +3,19 @@
-
- +
+
-
-

{{ item.name }}

-

{{ response.data }}

+
+

{{ item.name }}

+

{{ response.data }}

+
-
+
@@ -28,21 +29,23 @@ export default { }, data: function () { return { - response: null + response: null, }; - }, -mounted: async function () { - let response = await fetch(this.item.url,{headers: { - 'Content-Type': 'application/json' - }}); - if (!response.ok) { - throw Error(response.statusText); - } - this.response = await response.json(); - if(this.response.stderr !== "") { - console.error(this.response.stderr); - } - } + }, + mounted: async function () { + let response = await fetch(this.item.url, { + headers: { + "Content-Type": "application/json", + }, + }); + if (!response.ok) { + throw Error(response.statusText); + } + this.response = await response.json(); + if (this.response.stderr !== "") { + console.error(this.response.stderr); + } + }, };