From e089856edb58234d4efc1396d17dd3ebf9b9bdf3 Mon Sep 17 00:00:00 2001 From: velvettear Date: Sat, 12 Feb 2022 03:54:17 +0100 Subject: [PATCH] initial commit --- .gitignore | 4 ++ .vscode/launch.json | 21 +++++++ .vscode/tasks.json | 45 +++++++++++++++ README.md | 20 +++++++ package.json | 27 +++++++++ public/favicon.ico | Bin 0 -> 4286 bytes public/index.html | 27 +++++++++ src/App.vue | 57 ++++++++++++++++++ src/components/Control.vue | 39 +++++++++++++ src/components/HostInfo.vue | 111 ++++++++++++++++++++++++++++++++++++ src/components/Menu.vue | 98 +++++++++++++++++++++++++++++++ src/components/Pedal.vue | 59 +++++++++++++++++++ src/config.json | 45 +++++++++++++++ src/libs/requests.js | 20 +++++++ src/libs/util.js | 76 ++++++++++++++++++++++++ src/main.js | 13 +++++ src/pedals.json | 72 +++++++++++++++++++++++ src/router/router.js | 19 ++++++ vue.config.js | 14 +++++ 19 files changed, 767 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 README.md create mode 100644 package.json create mode 100644 public/favicon.ico create mode 100644 public/index.html create mode 100644 src/App.vue create mode 100644 src/components/Control.vue create mode 100644 src/components/HostInfo.vue create mode 100644 src/components/Menu.vue create mode 100644 src/components/Pedal.vue create mode 100644 src/config.json create mode 100644 src/libs/requests.js create mode 100644 src/libs/util.js create mode 100644 src/main.js create mode 100644 src/pedals.json create mode 100644 src/router/router.js create mode 100644 vue.config.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6d7877 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +dist +yarn-error.log +yarn.lock \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4a0e314 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "chromium: tabber", + "url": "http://localhost:9000", + "webRoot": "${workspaceFolder}/src", + "breakOnLoad": true, + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + }, + "runtimeArgs": [ + "--auto-open-devtools-for-tabs" + ], + "preLaunchTask": "serve", + "postDebugTask": "terminate all tasks" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..8b5186a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,45 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "run backend", + "type": "shell", + "command": "node", + "args": [ + "../pbc/pbc.js" + ] + }, + { + "label": "build", + "type": "shell", + "command": "yarn", + "args": [ + "build" + ] + }, + { + "label": "serve", + "type": "shell", + "command": "yarn", + "args": [ + "run", + "serve" + ], + "isBackground": true + }, + { + "label": "terminate all tasks", + "command": "echo ${input:terminate}", + "type": "shell", + "problemMatcher": [] + } + ], + "inputs": [ + { + "id": "terminate", + "type": "command", + "command": "workbench.action.tasks.terminate", + "args": "terminateAll" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3923658 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# pbc + +pedal board control + +## yarn + +### setup +``` +yarn install +``` + +### compile and serve with hot-reloads for development +``` +yarn run serve +``` + +### compile, minify and build for production +``` +yarn run build +``` diff --git a/package.json b/package.json new file mode 100644 index 0000000..36d15ad --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "pbc", + "author": "Daniel Sommer ", + "description": "pedal board control", + "license": "MIT", + "version": "0.0.1", + "private": true, + "repository": { + "type": "git", + "url": "https://git.velvettear.de/velvettear/pbc.git" + }, + "scripts": { + "serve": "vue-cli-service serve --host 0.0.0.0 --port 9000", + "build": "vue-cli-service build" + }, + "dependencies": { + "purecss": "^2.0.6", + "remixicon": "^2.5.0", + "vue": "^2.6.14", + "vue-resource": "^1.5.3", + "vue-router": "^3.5.3" + }, + "devDependencies": { + "@vue/cli-service": "^3.12.1", + "vue-template-compiler": "^2.6.11" + } +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..60c20e6 --- /dev/null +++ b/public/index.html @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + + + +
+ + + \ No newline at end of file diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..83fbee1 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/components/Control.vue b/src/components/Control.vue new file mode 100644 index 0000000..a45572b --- /dev/null +++ b/src/components/Control.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/src/components/HostInfo.vue b/src/components/HostInfo.vue new file mode 100644 index 0000000..2d00ad4 --- /dev/null +++ b/src/components/HostInfo.vue @@ -0,0 +1,111 @@ + + + + + \ No newline at end of file diff --git a/src/components/Menu.vue b/src/components/Menu.vue new file mode 100644 index 0000000..0ffa5f8 --- /dev/null +++ b/src/components/Menu.vue @@ -0,0 +1,98 @@ + + + + + \ No newline at end of file diff --git a/src/components/Pedal.vue b/src/components/Pedal.vue new file mode 100644 index 0000000..d34138a --- /dev/null +++ b/src/components/Pedal.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/src/config.json b/src/config.json new file mode 100644 index 0000000..a933728 --- /dev/null +++ b/src/config.json @@ -0,0 +1,45 @@ +{ + "api": { + "protocol": "http", + "host": "localhost", + "port": 3000 + }, + "hostinfo": { + "enabled": true, + "refresh": 3000, + "hostname": { + "title": "host:", + "enabled": true + }, + "os": { + "title": "os:", + "enabled": true + }, + "kernel": { + "title": "kernel:", + "enabled": false + }, + "uptime": { + "title": "uptime:", + "enabled": true, + "format": "[h] hours [m] minutes" + }, + "cpu": { + "title": "cpu:", + "enabled": true, + "format": "[count]x [model] @ [speed]mhz" + }, + "load": { + "title": "load:", + "enabled": true + }, + "memory": { + "title": "memory:", + "enabled": true + }, + "temperature": { + "title": "temperature:", + "enabled": true + } + } +} \ No newline at end of file diff --git a/src/libs/requests.js b/src/libs/requests.js new file mode 100644 index 0000000..b46d951 --- /dev/null +++ b/src/libs/requests.js @@ -0,0 +1,20 @@ +const config = require('../config.json'); + +const BASE_URL = config.api.protocol + '://' + config.api.host + ':' + config.api.port; + +function get(url) { + return new Promise(function (resolve, reject) { + if (url == undefined) { + return reject('error: no url defined'); + } + url = BASE_URL + url; + fetch(url) + .then(response => response.json()) + .then(result => resolve(result)) + .catch(reject); + }); +} + +module.exports = { + get +} \ No newline at end of file diff --git a/src/libs/util.js b/src/libs/util.js new file mode 100644 index 0000000..1310452 --- /dev/null +++ b/src/libs/util.js @@ -0,0 +1,76 @@ +const uptimeFormat = require('@/config.json').hostinfo.uptime.format; +const cpuFormat = require('@/config.json').hostinfo.cpu.format; + +const formatBytes = (bytes, decimals = 2) => { + if (bytes === 0) { + return '0 Bytes'; + } + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['byte', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb', 'zb', 'yb']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; +} + +const formatSeconds = (seconds) => { + var secs = seconds % 60; + seconds = (seconds - secs) / 60; + var mins = seconds % 60; + var hrs = (seconds - mins) / 60; + return uptimeFormat.replace('\[h\]', fill(hrs, 2)).replace('\[m\]', fill(mins, 2)).replace('\[s\]', fill(Math.round(secs), 2)); +} + +const fill = (value, count, fill, front) => { + if (value == undefined || count == undefined) { + return; + } + if (fill == undefined) { + fill = '0'; + } + if (front == undefined) { + front = true; + } + while (value.toString().length < count) { + if (front) { + value = fill + value; + } else { + value += fill; + } + } + return value; +} + +const formatCpu = (data) => { + var model = data[0].model; + var cut = model.toLowerCase().indexOf('cpu'); + if (cut != -1) { + model = model.substring(0, cut); + } + cut = model.indexOf('@'); + if (cut != -1) { + model = model.substring(0, cut); + } + model = model.trim(); + var speed = 0; + for (var index = 0; index < data.length; index++) { + speed += data[index].speed; + } + if (speed < 0) { + speed = 0; + } + return cpuFormat.replace('[count]', data.length).replace('[model]', model).replace('[speed]', Math.round(speed / data.length)); +} + +const formatInfo = (info) => { + info.memory.total = formatBytes(info.memory.total); + info.memory.used = formatBytes(info.memory.used); + info.memory.free = formatBytes(info.memory.free); + info.uptime = formatSeconds(info.uptime); + info.load = info.load[0] + ' ' + info.load[1] + ' ' + info.load[2]; + info.cpu = formatCpu(info.cpu); + return info; +} + +module.exports = { + formatInfo +} \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..ca346a1 --- /dev/null +++ b/src/main.js @@ -0,0 +1,13 @@ +import Vue from 'vue' +import App from './App.vue' +import router from './router/router.js' +import '../node_modules/purecss/build/base-min.css' +import '../node_modules/purecss/build/grids-min.css' +import '../node_modules/purecss/build/grids-responsive-min.css' + +Vue.config.productionTip = false + +const app = new Vue({ + router, + render: h => h(App), +}).$mount('#app') \ No newline at end of file diff --git a/src/pedals.json b/src/pedals.json new file mode 100644 index 0000000..c10dae0 --- /dev/null +++ b/src/pedals.json @@ -0,0 +1,72 @@ +[ + { + "id": 0, + "name": "tubewarmth", + "color": "#880088", + "controls": [ + { + "name": "on/off", + "midi": { + "channel": 0, + "controller": 0, + "value": 0 + } + }, + { + "name": "drive", + "midi": { + "channel": 0, + "controller": 1, + "value": 5 + } + }, + { + "name": "tape/tube", + "midi": { + "channel": 0, + "controller": 2, + "value": 10 + } + } + ] + }, + { + "id": 1, + "name": "big muff", + "color": "#339900", + "controls": [ + { + "name": "on/off", + "midi": { + "channel": 0, + "controller": 4, + "value": 0 + } + }, + { + "name": "tone", + "midi": { + "channel": 0, + "controller": 5, + "value": 0.5 + } + }, + { + "name": "level", + "midi": { + "channel": 0, + "controller": 6, + "value": 0.5 + } + }, + { + "name": "sustain", + "midi": { + "channel": 0, + "controller": 7, + "value": 0.5 + } + } + ] + } +] \ No newline at end of file diff --git a/src/router/router.js b/src/router/router.js new file mode 100644 index 0000000..4190e06 --- /dev/null +++ b/src/router/router.js @@ -0,0 +1,19 @@ +import Vue from 'vue'; +import VueRouter from 'vue-router'; +// import List from '@/components/List.vue' +// import Tab from '@/components/Tab.vue' + +Vue.use(VueRouter); + +const routes = [ + // { path: '/', name: 'List', component: List }, + // { path: '/:id', name: 'Tab', component: Tab } +]; + +const router = new VueRouter({ + mode: 'history', + base: process.env.BASE_URL, + routes +}) + +export default router; \ No newline at end of file diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..01c53c8 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,14 @@ +module.exports = { + runtimeCompiler: true, + chainWebpack: (config) => { + config + .plugin('html') + .tap((args) => { + args[0].title = "tabber"; + return args; + }); + }, + configureWebpack: { + devtool: 'source-map' + } +}