mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
Fixed bug in terms-management-interface (only display one paste) + removed get_language of all pastes due to the huge overhead.
This commit is contained in:
parent
d3c0fc5f94
commit
e144e8e1c6
2 changed files with 22 additions and 29 deletions
|
@ -626,8 +626,6 @@ def terms_management_query_paste():
|
||||||
|
|
||||||
set_paste_name = "tracked_" + term
|
set_paste_name = "tracked_" + term
|
||||||
track_list_path = r_serv_term.smembers(set_paste_name)
|
track_list_path = r_serv_term.smembers(set_paste_name)
|
||||||
print set_paste_name
|
|
||||||
print track_list_path
|
|
||||||
|
|
||||||
for path in track_list_path:
|
for path in track_list_path:
|
||||||
paste = Paste.Paste(path)
|
paste = Paste.Paste(path)
|
||||||
|
@ -635,14 +633,13 @@ def terms_management_query_paste():
|
||||||
p_date = p_date[6:]+'/'+p_date[4:6]+'/'+p_date[0:4]
|
p_date = p_date[6:]+'/'+p_date[4:6]+'/'+p_date[0:4]
|
||||||
p_source = paste.p_source
|
p_source = paste.p_source
|
||||||
p_encoding = paste._get_p_encoding()
|
p_encoding = paste._get_p_encoding()
|
||||||
p_language = paste._get_p_language()
|
|
||||||
p_size = paste.p_size
|
p_size = paste.p_size
|
||||||
p_mime = paste.p_mime
|
p_mime = paste.p_mime
|
||||||
p_lineinfo = paste.get_lines_info()
|
p_lineinfo = paste.get_lines_info()
|
||||||
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
||||||
if p_content != 0:
|
if p_content != 0:
|
||||||
p_content = p_content[0:400]
|
p_content = p_content[0:400]
|
||||||
paste_info.append({"path": path, "date": p_date, "source": p_source, "encoding": p_encoding, "language": p_language, "size": p_size, "mime": p_mime, "lineinfo": p_lineinfo, "content": p_content})
|
paste_info.append({"path": path, "date": p_date, "source": p_source, "encoding": p_encoding, "size": p_size, "mime": p_mime, "lineinfo": p_lineinfo, "content": p_content})
|
||||||
|
|
||||||
return jsonify(paste_info)
|
return jsonify(paste_info)
|
||||||
|
|
||||||
|
|
|
@ -220,48 +220,44 @@
|
||||||
|
|
||||||
// On click, get html content from url and update the corresponding modal
|
// On click, get html content from url and update the corresponding modal
|
||||||
$("[data-toggle='modal']").on("click.openmodal", function (event) {
|
$("[data-toggle='modal']").on("click.openmodal", function (event) {
|
||||||
|
//console.log(data);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var the_modal=$(this);
|
var the_modal=$(this);
|
||||||
var url = "{{ url_for('terms_management_query_paste') }}?term=" + $(this).attr('data-term');
|
var url = "{{ url_for('terms_management_query_paste') }}?term=" + $(this).attr('data-term');
|
||||||
$.getJSON(url, function (data) {
|
$.getJSON(url, function (data) {
|
||||||
//console.log(data);
|
|
||||||
if (data.length != 0) {
|
if (data.length != 0) {
|
||||||
for (i=0; i<data.length; i++) {
|
|
||||||
curr_data = data[i];
|
|
||||||
var html_to_add = "";
|
var html_to_add = "";
|
||||||
html_to_add += "<table class=\"table table-condensed\">";
|
html_to_add += "<table class=\"table table-striped\">";
|
||||||
html_to_add += "<thead>";
|
html_to_add += "<thead>";
|
||||||
html_to_add += "<tr>";
|
html_to_add += "<tr>";
|
||||||
html_to_add += "<th>Source</th>";
|
html_to_add += "<th>Source</th>";
|
||||||
html_to_add += "<th>Date</th>";
|
html_to_add += "<th>Date</th>";
|
||||||
html_to_add += "<th>Encoding</th>";
|
html_to_add += "<th>Encoding</th>";
|
||||||
html_to_add += "<th>Language</th>";
|
|
||||||
html_to_add += "<th>Size (Kb)</th>";
|
html_to_add += "<th>Size (Kb)</th>";
|
||||||
html_to_add += "<th>Mime</th>";
|
html_to_add += "<th>Mime</th>";
|
||||||
html_to_add += "<th>Number of lines</th>";
|
html_to_add += "<th>(# lines, Max line length)</th>";
|
||||||
html_to_add += "<th>Max line length</th>";
|
|
||||||
html_to_add += "<th>Preview</th>";
|
html_to_add += "<th>Preview</th>";
|
||||||
html_to_add += "</tr>";
|
html_to_add += "</tr>";
|
||||||
html_to_add += "</thead>";
|
html_to_add += "</thead>";
|
||||||
html_to_add += "<tbody>";
|
html_to_add += "<tbody>";
|
||||||
|
for (i=0; i<data.length; i++) {
|
||||||
|
curr_data = data[i];
|
||||||
html_to_add += "<tr>";
|
html_to_add += "<tr>";
|
||||||
html_to_add += "<td>"+curr_data.source+"</td>";
|
html_to_add += "<td>"+curr_data.source+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.date+"</td>";
|
html_to_add += "<td>"+curr_data.date+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.encoding+"</td>";
|
html_to_add += "<td>"+curr_data.encoding+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.language+"</td>";
|
|
||||||
html_to_add += "<td>"+curr_data.size+"</td>";
|
html_to_add += "<td>"+curr_data.size+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.mime+"</td>";
|
html_to_add += "<td>"+curr_data.mime+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.lineinfo[0]+"</td>";
|
html_to_add += "<td>("+curr_data.lineinfo[0]+", "+curr_data.lineinfo[1]+")</td>";
|
||||||
html_to_add += "<td>"+curr_data.lineinfo[1]+"</td>";
|
|
||||||
html_to_add += "<td><div class=\"row\"><button class=\"btn btn-xs btn-default\" data-toggle=\"popover\" data-placement=\"left\" data-content=\""+curr_data.content+"\">Preview content</button><a target=\"_blank\" href=\"{{ url_for('showsavedpaste') }}?paste="+curr_data.path+"&num=0\"> <button type=\"button\" class=\"btn btn-xs btn-info\">Show Paste</button></a></div></td>";
|
html_to_add += "<td><div class=\"row\"><button class=\"btn btn-xs btn-default\" data-toggle=\"popover\" data-placement=\"left\" data-content=\""+curr_data.content+"\">Preview content</button><a target=\"_blank\" href=\"{{ url_for('showsavedpaste') }}?paste="+curr_data.path+"&num=0\"> <button type=\"button\" class=\"btn btn-xs btn-info\">Show Paste</button></a></div></td>";
|
||||||
|
|
||||||
html_to_add += "</tr>";
|
html_to_add += "</tr>";
|
||||||
|
}
|
||||||
html_to_add += "</tbody>";
|
html_to_add += "</tbody>";
|
||||||
html_to_add += "</table>";
|
html_to_add += "</table>";
|
||||||
$("#mymodalbody").html(html_to_add);
|
$("#mymodalbody").html(html_to_add);
|
||||||
$("[data-toggle=popover]").popover();
|
$("[data-toggle=popover]").popover();
|
||||||
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$("#mymodalbody").html("No paste containing this term has been received yet.");
|
$("#mymodalbody").html("No paste containing this term has been received yet.");
|
||||||
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
||||||
|
|
Loading…
Reference in a new issue