Commit e9adf11fc7364922e1d482fca81ff05ad4170bfa
1 parent
959ec49d
Exists in
master
and in
2 other branches
built log table html
Showing
2 changed files
with
27 additions
and
3 deletions
Show diff stats
dashboards/static/dashboards/js/logbehavior.js
@@ -22,14 +22,34 @@ var log = { | @@ -22,14 +22,34 @@ var log = { | ||
22 | 22 | ||
23 | refresh_log_data: function(init_date, end_date){ | 23 | refresh_log_data: function(init_date, end_date){ |
24 | $.get("/dashboards/get_log_data", {init_date: init_date.format("YYYY-MM-DD HH:mm"), end_date: end_date.format("YYYY-MM-DD HH:mm")}).done(function(data){ | 24 | $.get("/dashboards/get_log_data", {init_date: init_date.format("YYYY-MM-DD HH:mm"), end_date: end_date.format("YYYY-MM-DD HH:mm")}).done(function(data){ |
25 | - log.render_table("log_body", data); | 25 | + log.render_table("log-body", data); |
26 | }) | 26 | }) |
27 | }, | 27 | }, |
28 | render_table: function(target_id, data){ | 28 | render_table: function(target_id, data){ |
29 | table_body = $('#' + target_id); | 29 | table_body = $('#' + target_id); |
30 | 30 | ||
31 | + content = "<table id='log-table'>"; | ||
32 | + | ||
33 | + //load row names at the top | ||
34 | + | ||
35 | + //build row html data | ||
31 | data.forEach(function(datum){ | 36 | data.forEach(function(datum){ |
32 | - console.log(datum); | 37 | + content += "<tr>" + html_helper.row_builder(datum) + "</tr>"; |
33 | }); | 38 | }); |
39 | + | ||
40 | + content += "</table>"; | ||
41 | + | ||
42 | + $(table_body).append(content); | ||
34 | }, | 43 | }, |
35 | } | 44 | } |
45 | + | ||
46 | + | ||
47 | +var html_helper = { | ||
48 | + row_builder: function(datum){ | ||
49 | + result = ""; | ||
50 | + result = "<td>" + datum.datetime + "</td>" + "<td>" + datum.user + "</td>" + "<td>" + datum.component + "</td>" | ||
51 | + + "<td>" + datum.resource + "</td>" + "<td>" + datum.action + "</td>" + "<td>" + datum.context.category_name + "</td>" | ||
52 | + + "<td>" + datum.context.subject_name + "</td>" + "<td>"+ datum.context + "</td>"; | ||
53 | + return result; | ||
54 | + } | ||
55 | +} | ||
36 | \ No newline at end of file | 56 | \ No newline at end of file |
dashboards/views.py
@@ -135,6 +135,10 @@ def parse_log_queryset_to_JSON(logs): | @@ -135,6 +135,10 @@ def parse_log_queryset_to_JSON(logs): | ||
135 | for log in logs: | 135 | for log in logs: |
136 | datum = {} | 136 | datum = {} |
137 | datum['user'] = log.user | 137 | datum['user'] = log.user |
138 | - | 138 | + datum['resource'] = log.resource |
139 | + datum['datetime'] = log.datetime | ||
140 | + datum['action'] = log.action | ||
141 | + datum['context'] = log.context | ||
142 | + datum['component'] = log.component | ||
139 | data.append(datum) | 143 | data.append(datum) |
140 | return data | 144 | return data |
141 | \ No newline at end of file | 145 | \ No newline at end of file |