diff --git a/schema.sql b/schema.sql index 4bb5f58..43b9be0 100644 --- a/schema.sql +++ b/schema.sql @@ -5,6 +5,7 @@ DROP TABLE IF EXISTS instrument_param; DROP TABLE IF EXISTS instrument_socket; DROP TABLE IF EXISTS patches; DROP TABLE IF EXISTS patch_param; +DROP TABLE IF EXISTS patch_socket; DROP TABLE IF EXISTS snippets; CREATE TABLE instruments ( @@ -25,15 +26,17 @@ CREATE TABLE sockets ( ); CREATE TABLE instrument_param ( - instrument_id INTEGER NOT NULL, + instrument TEXT NOT NULL, param_name TEXT NOT NULL, - PRIMARY KEY (instrument_id, param_name) + FOREIGN KEY (instrument) REFERENCES instruments(slug), + PRIMARY KEY (instrument, param_name) ); CREATE TABLE instrument_socket ( - instrument_id INTEGER NOT NULL, + instrument TEXT NOT NULL, socket_name TEXT NOT NULL, - PRIMARY KEY (instrument_id, socket_name) + FOREIGN KEY (instrument) REFERENCES instruments(slug), + PRIMARY KEY (instrument, socket_name) ); CREATE TABLE patches ( @@ -54,6 +57,13 @@ CREATE TABLE patch_param ( PRIMARY KEY (patch_id, param_name) ); +CREATE TABLE patch_socket ( + patch_id INTEGER NOT NULL, + socket_name TEXT NOT NULL, + value TEXT NOT NULL, + PRIMARY KEY (patch_id, socket_name) +); + CREATE TABLE snippets ( filename TEXT NOT NULL, instrument TEXT NOT NULL, diff --git a/static/css/add.css b/static/css/add.css index f065b9f..4a8c2c9 100644 --- a/static/css/add.css +++ b/static/css/add.css @@ -1,4 +1,4 @@ -main { +.grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; @@ -17,7 +17,7 @@ textarea { font-family: sans-serif; } -form > * + * { +.meta > * + * { margin-top: 16px; } @@ -37,6 +37,10 @@ input[type="submit"]:hover { border: 1px solid currentColor; } +.meta { + grid-column: 1 / span 1; +} + .preview { position: absolute; top: 8px; diff --git a/static/css/patch.css b/static/css/patch.css index 7be2e8f..91b9fcd 100644 --- a/static/css/patch.css +++ b/static/css/patch.css @@ -82,7 +82,7 @@ main { .meta { display: inline-block; - border: 2px solid currentColor; + border: 1px solid currentColor; padding: 16px; margin: 32px 0; max-width: 40ch; @@ -91,4 +91,14 @@ main { .meta .date { margin-top: 8px; opacity: 0.5; -} \ No newline at end of file +} + +.patch-text { + padding: 8px; + display: inline-block; + white-space: pre-wrap; + line-height: 1; + font-size: 18px; + background-color: rgba(200, 200, 200, 0.5); + max-width: 60ch; +} diff --git a/static/js/panel.js b/static/js/panel.js index c36d18a..2623659 100644 --- a/static/js/panel.js +++ b/static/js/panel.js @@ -287,6 +287,14 @@ class Panel { if (socket && socket.classList.contains("socket")) { this.cable.end = socket.getAttribute("name"); + let startSocket = document.querySelector(`.socket[name="${this.cable.start}"]`); + + let values = (startSocket.getAttribute("value") || "") + .split(",") + .map((entry) => entry.trim()); + values.push(this.cable.end); + startSocket.setAttribute("value", values.filter((value) => value != "").join()); + // TODO: log cable } else { this.cable.path.remove(); diff --git a/templates/add_instrument.html b/templates/add_instrument.html index 7012527..1df10b0 100644 --- a/templates/add_instrument.html +++ b/templates/add_instrument.html @@ -27,8 +27,8 @@ /