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 @@ ...@@ -144,7 +144,7 @@
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<!-- Projects table --> <!-- 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"> <thead class="thead-light">
<tr> <tr>
<th scope="col">App name</th> <th scope="col">App name</th>
...@@ -270,5 +270,44 @@ ...@@ -270,5 +270,44 @@
$("#recent_activity_body").html(cdata); $("#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> </script>
{% endblock %} {% endblock %}
...@@ -368,6 +368,19 @@ def recent_activity(): ...@@ -368,6 +368,19 @@ def recent_activity():
return ra, 200 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') @app.route('/application/<appkey>/device/<devid>/remove-configuration')
@decorators.restricted('user') @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