new_device() frontend

This commit is contained in:
iou1name 2019-06-20 08:38:56 -04:00
parent ded3593a2f
commit 166d7f1d6f
2 changed files with 11 additions and 6 deletions

View File

@ -112,6 +112,11 @@ function new_device() {
return response.json(); return response.json();
}) })
.then(function(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;
}); });
} }

View File

@ -35,22 +35,22 @@
{% endfor %} {% endfor %}
</div> </div>
</main> </main>
<template id="RelayDevice"> <template id="RelayDevice_template">
<div class="device RelayDevice" id=""> <div class="device RelayDevice" id="">
<div class="id"></div> <div class="id"></div>
<div class="description"><span class="field_value"></span> <span class="edit" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location"><span class="field_value"></span> <span class="edit" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="location"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address"><i></i></div> <div class="ip_address"><i></i></div>
<div class="sub_devices"> <div class="sub_devices">
<div class="sub_device RelayOutlet" id=""> <div class="sub_device RelayOutlet" id="">
<div class="id"></div> <div class="id"></div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" data="/static/outlet.svg"></object>
<div class="description"><span class="field_value"></span> <span class="edit" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
<div class="sub_device RelayOutlet" id=""> <div class="sub_device RelayOutlet" id="">
<div class="id"></div> <div class="id"></div>
<object class="outlet_image" data="/static/outlet.svg"></object> <object class="outlet_image" data="/static/outlet.svg"></object>
<div class="description"><span class="field_value"></span> <span class="edit" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description"><span class="field_value"></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
</div> </div>
</div> </div>