Merge pull request #1 from redref/mterzo_data_table_format
datatable and list behaviors
This commit is contained in:
@@ -1,21 +1,28 @@
|
|||||||
$ = jQuery
|
$ = jQuery
|
||||||
$ ->
|
filter_list = (val) ->
|
||||||
$('input.filter-list').parent('div').removeClass('hide')
|
rex = new RegExp(val, "i")
|
||||||
$("input.filter-list").on "keyup", (e) ->
|
|
||||||
rex = new RegExp($(this).val(), "i")
|
|
||||||
|
|
||||||
$(".searchable li").hide()
|
$(".searchable li").hide()
|
||||||
$(".searchable li").parent().parent().hide()
|
$(".searchable li").parent().parent('.list_hide_segment').hide()
|
||||||
$(".searchable li").filter( ->
|
$(".searchable li").filter( ->
|
||||||
rex.test $(this).text()
|
rex.test $(this).text()
|
||||||
).show()
|
).show()
|
||||||
$(".searchable li").filter( ->
|
$(".searchable li").filter( ->
|
||||||
rex.test $(this).text()
|
rex.test $(this).text()
|
||||||
).parent().parent().show()
|
).parent().parent().show()
|
||||||
|
$("input.filter-list").on "keyup", (e) ->
|
||||||
|
# If key is escape, reset value
|
||||||
if e.keyCode is 27
|
if e.keyCode is 27
|
||||||
$(e.currentTarget).val ""
|
$(e.currentTarget).val ""
|
||||||
ev = $.Event("keyup")
|
ev = $.Event("keyup")
|
||||||
ev.keyCode = 13
|
ev.keyCode = 13
|
||||||
$(e.currentTarget).trigger(ev)
|
$(e.currentTarget).trigger(ev)
|
||||||
e.currentTarget.blur()
|
e.currentTarget.blur()
|
||||||
|
else
|
||||||
|
filter_list($(this).val())
|
||||||
|
$("input.filter-list").ready ->
|
||||||
|
elem = $("input.filter-list")
|
||||||
|
elem.focus()
|
||||||
|
val = elem.val()
|
||||||
|
filter_list(val)
|
||||||
|
# Force cursor at the end
|
||||||
|
elem.val('').val(val)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ h1.ui.header.no-margin-bottom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.ui.grid.padding-bottom {
|
.ui.grid.padding-bottom {
|
||||||
padding-bottom: 40px !important;
|
padding-bottom: 4em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
|
|||||||
@@ -1,31 +1,42 @@
|
|||||||
// Generated by CoffeeScript 1.9.3
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var $;
|
var $, filter_list;
|
||||||
|
|
||||||
$ = jQuery;
|
$ = jQuery;
|
||||||
|
|
||||||
$(function() {});
|
filter_list = function(val) {
|
||||||
|
var rex;
|
||||||
$('input.filter-list').parent('div').removeClass('hide');
|
rex = new RegExp(val, "i");
|
||||||
|
|
||||||
$("input.filter-list").on("keyup", function(e) {
|
|
||||||
var ev, rex;
|
|
||||||
rex = new RegExp($(this).val(), "i");
|
|
||||||
$(".searchable li").hide();
|
$(".searchable li").hide();
|
||||||
$(".searchable li").parent().parent().hide();
|
$(".searchable li").parent().parent('.list_hide_segment').hide();
|
||||||
$(".searchable li").filter(function() {
|
$(".searchable li").filter(function() {
|
||||||
return rex.test($(this).text());
|
return rex.test($(this).text());
|
||||||
}).show();
|
}).show();
|
||||||
$(".searchable li").filter(function() {
|
return $(".searchable li").filter(function() {
|
||||||
return rex.test($(this).text());
|
return rex.test($(this).text());
|
||||||
}).parent().parent().show();
|
}).parent().parent().show();
|
||||||
|
};
|
||||||
|
|
||||||
|
$("input.filter-list").on("keyup", function(e) {
|
||||||
|
var ev;
|
||||||
if (e.keyCode === 27) {
|
if (e.keyCode === 27) {
|
||||||
$(e.currentTarget).val("");
|
$(e.currentTarget).val("");
|
||||||
ev = $.Event("keyup");
|
ev = $.Event("keyup");
|
||||||
ev.keyCode = 13;
|
ev.keyCode = 13;
|
||||||
$(e.currentTarget).trigger(ev);
|
$(e.currentTarget).trigger(ev);
|
||||||
return e.currentTarget.blur();
|
return e.currentTarget.blur();
|
||||||
|
} else {
|
||||||
|
return filter_list($(this).val());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("input.filter-list").ready(function() {
|
||||||
|
var elem, val;
|
||||||
|
elem = $("input.filter-list");
|
||||||
|
elem.focus();
|
||||||
|
val = elem.val();
|
||||||
|
filter_list(val);
|
||||||
|
return elem.val('').val(val);
|
||||||
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None, columns) -%}
|
{% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None) -%}
|
||||||
// Init datatable
|
// Init datatable
|
||||||
$.fn.dataTable.ext.errMode = 'throw';
|
$.fn.dataTable.ext.errMode = 'throw';
|
||||||
var table = $('#{{ table_html_id }}').DataTable({
|
var table = $('#{{ table_html_id }}').DataTable({
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% import '_macros.html' as macros %}
|
{% import '_macros.html' as macros %}
|
||||||
|
|
||||||
{% if render_graph %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
|
{% if render_graph %}
|
||||||
var chart = null;
|
var chart = null;
|
||||||
var data = [
|
var data = [
|
||||||
{% for fact in facts|groupby('value') %}
|
{% for fact in facts|groupby('value') %}
|
||||||
@@ -22,19 +21,21 @@ var otherdata = fact_values.slice(15);
|
|||||||
if (otherdata.length > 0) {
|
if (otherdata.length > 0) {
|
||||||
realdata.push(["other", otherdata.reduce(function(a,b){return a + b[1];},0)]);
|
realdata.push(["other", otherdata.reduce(function(a,b){return a + b[1];},0)]);
|
||||||
}
|
}
|
||||||
|
{% endif %}
|
||||||
{% endblock javascript %}
|
{% endblock javascript %}
|
||||||
|
|
||||||
{% block onload_script %}
|
{% block onload_script %}
|
||||||
$('table').tablesort();
|
$('table').tablesort();
|
||||||
|
{% if render_graph %}
|
||||||
chart = c3.generate({
|
chart = c3.generate({
|
||||||
bindto: '#factChart',
|
bindto: '#factChart',
|
||||||
data: {
|
data: {
|
||||||
columns: realdata,
|
columns: realdata,
|
||||||
type : '{{config.GRAPH_TYPE|default('pie')}}',
|
type : '{{config.GRAPH_TYPE|default('pie')}}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
{% endif %}
|
||||||
{% endblock onload_script %}
|
{% endblock onload_script %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="factChart" width="300" height="300"></div>
|
<div id="factChart" width="300" height="300"></div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="ui fluid icon input hide" style="margin-bottom:20px">
|
<div class="ui fluid icon input" style="margin-bottom:20px">
|
||||||
<input autofocus="autofocus" class="filter-list" placeholder="Type here to filter...">
|
<input autofocus="autofocus" class="filter-list" placeholder="Type here to filter...">
|
||||||
</div>
|
</div>
|
||||||
<div class="ui searchable stackable doubling four column grid factlist">
|
<div class="ui searchable stackable doubling four column grid factlist">
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
{%- set facts_count = 0 -%}
|
{%- set facts_count = 0 -%}
|
||||||
{%- set break = facts_len//4 + 1 -%}
|
{%- set break = facts_len//4 + 1 -%}
|
||||||
{%- for key,facts_list in facts_dict %}
|
{%- for key,facts_list in facts_dict %}
|
||||||
<div class="ui segment">
|
<div class="ui list_hide_segment segment">
|
||||||
<a class="ui darkblue ribbon label">{{key}}</a>
|
<a class="ui darkblue ribbon label">{{key}}</a>
|
||||||
<ul>
|
<ul>
|
||||||
{%- for fact in facts_list %}
|
{%- for fact in facts_list %}
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Metrics</h1>
|
<h1>Metrics</h1>
|
||||||
<div class="ui fluid icon input hide" style="margin-bottom:20px">
|
<div class="ui fluid icon input" style="margin-bottom:20px">
|
||||||
<input autofocus="autofocus" class="filter-table" placeholder="Type here to filter...">
|
<input autofocus="autofocus" class="filter-list" placeholder="Type here to filter...">
|
||||||
</div>
|
</div>
|
||||||
<table class='ui very compact very basic sortable table'>
|
<ul class="ui list searchable">
|
||||||
<thead>
|
|
||||||
<tr>Metric</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="searchable">
|
|
||||||
{% for metric in metrics %}
|
{% for metric in metrics %}
|
||||||
<tr>
|
<li>
|
||||||
<td><a href="{{url_for('metric', env=current_env, metric=metric)}}">{{metric}}</a></td>
|
<a href="{{url_for('metric', env=current_env, metric=metric)}}">{{metric}}</a>
|
||||||
</tr>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</ul>
|
||||||
</table>
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
'pagingType': 'simple',
|
'pagingType': 'simple',
|
||||||
"bFilter": false,
|
"bFilter": false,
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node.name), default_length=config.LITTLE_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, columns=columns, extra_options=extra_options) }}
|
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node.name), default_length=config.LITTLE_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, extra_options=extra_options) }}
|
||||||
{% endblock onload_script %}
|
{% endblock onload_script %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
// No initial loading
|
// No initial loading
|
||||||
"deferLoading": true,
|
"deferLoading": true,
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node_name), default_length=config.NORMAL_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, extra_options=extra_options, columns=columns) }}
|
{{ macros.datatable_init(table_html_id="reports_table", ajax_url=url_for('reports_ajax', env=current_env, node_name=node_name), default_length=config.NORMAL_TABLE_COUNT, length_selector=config.TABLE_COUNT_SELECTOR, extra_options=extra_options) }}
|
||||||
|
|
||||||
// Event listener for status filters
|
// Event listener for status filters
|
||||||
function status_filter_change(){
|
function status_filter_change(){
|
||||||
|
|||||||
Reference in New Issue
Block a user