Commit 5558b6df authored by Vladislav Rykov's avatar Vladislav Rykov
Browse files

recent actity in json packet possibility added

parent 168f75d4
......@@ -144,7 +144,7 @@
</div>
<div class="table-responsive">
<!-- Projects table -->
<table class="table align-items-center table-flush">
<table class="table align-items-center table-flush" id="ra_id">
<thead class="thead-light">
<tr>
<th scope="col">App name</th>
......@@ -270,5 +270,44 @@
$("#recent_activity_body").html(cdata);
});
/* recent activity in JSON
$.get("./recent-activity-json", function(cdata) {
var data = eval(cdata);
console.log(data);
var table = document.getElementById("ra_id");
for (var dct in data) {
var tr = document.createElement("tr");
tr.appendChild(create_ra_entry("appname", "app", data[dct]));
tr.appendChild(create_ra_entry("devname", "dev", data[dct]));
tr.appendChild(create_ra_entry("timedate", "", data[dct]));
tr.appendChild(create_ra_entry("data", "", data[dct]));
table.appendChild(tr);
}
});
function create_ra_entry(entry_name, link, data) {
var td = document.createElement("td");
if (link === "app") {
var a = document.createElement("a");
a.setAttribute("href", "/application/"+data["appkey"]);
a.innerHTML = data[entry_name];
td.appendChild(a);
} else if (link === "dev") {
var a = document.createElement("a");
a.setAttribute("href", "/application/"+data["appkey"]+"/"+data["devid"]);
a.innerHTML = data[entry_name];
td.appendChild(a);
} else {
if (typeof data[entry_name] == 'object') {
td.innerHTML = JSON.stringify(data[entry_name]);
} else {
td.innerHTML = data[entry_name];
}
}
return td;
}
*/
</script>
{% endblock %}
......@@ -365,9 +365,22 @@ def recent_activity():
hrefapp = '<th scope="row"><a href="application/{}">{}</a></th>'.format(r[5], r[1])
hrefdev = '<th><a href="application/{}/device/{}">{}</a></th>'.format(r[5], r[6], r[2])
ra += '<tr>'+hrefapp+hrefdev+'<th>'+r[0]+'</th><th>'+str(ddm.read_data(r[3].tobytes(), dev[3]))+'</th></tr>'
return ra, 200
#@app.route('/recent-activity-json')
#@decorators.restricted('interface')
#def recent_activity_json():
# raj = md.get_recent_activity_json(session['name'])[1]
# rajl = []
#
# for i in range(len(raj)):
# dev = dd.get(raj[i][0]['appkey'], raj[i][0]['devid'])[1]
# raj[i][0]['data'] = ddm.read_data(binascii.unhexlify(raj[i][0]["data"][2:]), dev[3])
# rajl.append(raj[i][0])
#
# return str(rajl), 200
@app.route('/application/<appkey>/device/<devid>/remove-configuration')
@decorators.restricted('user')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment