From 166d7f1d6fbc7701c340c36b1382ccdcb8a28115 Mon Sep 17 00:00:00 2001 From: iou1name Date: Thu, 20 Jun 2019 08:38:56 -0400 Subject: [PATCH] new_device() frontend --- static/juice.js | 7 ++++++- templates/index.html | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/static/juice.js b/static/juice.js index c07fc32..eb79ffa 100644 --- a/static/juice.js +++ b/static/juice.js @@ -112,6 +112,11 @@ function new_device() { return response.json(); }) .then(function(json) { - console.log(json); + let template = document.querySelector('#RelayDevice_template'); + let node = document.importNode(template.content, true); + node.querySelector('.id').textContent = json.device_id; + document.querySelector('#devices').appendChild(node); + let children = document.querySelector('#devices').children; + children[children.length - 1].id = json.device_id; }); } diff --git a/templates/index.html b/templates/index.html index 03eabf5..1d66e55 100644 --- a/templates/index.html +++ b/templates/index.html @@ -35,22 +35,22 @@ {% endfor %} -