added lock_device()

This commit is contained in:
iou1name 2019-06-20 11:19:31 -04:00
parent 8f2c127d9c
commit f0f786324d
4 changed files with 24 additions and 8 deletions

Binary file not shown.

View File

@ -46,7 +46,6 @@ nav span:hover {
background-color: whitesmoke; background-color: whitesmoke;
} }
.ip_address { .ip_address {
font-size: 0.8em; font-size: 0.8em;
font-style: italic; font-style: italic;
@ -78,12 +77,12 @@ nav span:hover {
src: url("/static/fontawesome-webfont.woff2"); src: url("/static/fontawesome-webfont.woff2");
} }
.edit, .save { .edit, .save, .lock, .unlock {
font-size: 0.8em; font-size: 0.8em;
color: dimgrey; color: dimgrey;
} }
.edit:hover, .save:hover { .edit:hover, .save:hover, .lock:hover, .unlock:hover {
color: red; color: red;
cursor: pointer; cursor: pointer;
} }

View File

@ -120,3 +120,20 @@ function new_device() {
children[children.length - 1].id = json.device_id; children[children.length - 1].id = json.device_id;
}); });
} }
function lock_device(device) {
let fields = device.querySelectorAll('.editable');
fields.forEach(function(field) {
field.querySelector('.edit').remove();
});
device.querySelector('.id').querySelector('.lock').remove();
let unlock = document.createElement('span');
unlock.innerHTML = '';
unlock.className = 'unlock font-awesome';
unlock.setAttribute('onclick', 'unlock_device(this.parentElement.parentElement)');
device.querySelector('.id').appendChild(unlock);
}
function unlock_device(device) {
console.log(device);
}

View File

@ -18,16 +18,16 @@
<div id="devices"> <div id="devices">
{% for device in network %} {% for device in network %}
<div class="device {{ device.type }}" id="{{ device.id }}"> <div class="device {{ device.type }}" id="{{ device.id }}">
<div class="id">{{ device.id }}</div> <div class="id editable"><span class="field_value">{{ device.id }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span> <span class="lock font-awesome" onclick="lock_device(this.parentElement.parentElement)">&#xe803;</span></div>
<div class="description"><span class="field_value">{{ device.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value">{{ device.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="location"><span class="field_value">{{ device.location }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="location editable"><span class="field_value">{{ device.location }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="ip_address"><span class="field_value"><i>{{ device.ip_address }}</i></span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="ip_address editable"><span class="field_value">{{ device.ip_address }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
<div class="sub_devices"> <div class="sub_devices">
{% for sub_dev in device.sub_devices %} {% for sub_dev in device.sub_devices %}
<div class="sub_device {{ sub_dev.type }}" id="{{ sub_dev.id }}"> <div class="sub_device {{ sub_dev.type }}" id="{{ sub_dev.id }}">
<div class="id">{{ sub_dev.id }}</div> <div class="id">{{ sub_dev.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">{{ sub_dev.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div> <div class="description editable"><span class="field_value">{{ sub_dev.description }}</span> <span class="edit font-awesome" onclick="edit_field(this.parentElement)">&#xe800;</span></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>