commit e089856edb58234d4efc1396d17dd3ebf9b9bdf3 Author: velvettear Date: Sat Feb 12 03:54:17 2022 +0100 initial commit 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 0000000..df36fcf Binary files /dev/null and b/public/favicon.ico differ 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' + } +}