Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/views/dashboard/charts/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ Template.chartsLayout.created = function () {
var overviewChart = dc.barChart("#overview-chart");
var moveChart = dc.barChart("#move-chart");


overviewChart
.height(80)
.dimension(timeStampDimension)
Expand Down
8 changes: 4 additions & 4 deletions client/views/dashboard/charts/filter/filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 class="box-title">{{_ "filterData_Title"}}</h3>
<div class="box-body">
<form id="filteringForm">
{{_ "filterData_Month"}}
<select name="month" >
<select id="month" name="month" >
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps prefix these IDs with filter-, to be a bit more specific. E.g.

  • filter-month
  • filter-year
  • filter-limit
  • filter-reset

The reason for this is the dashboard HTML may be pretty dense, and may include other elements that could aptly be assigned the month, year, limit, and/or reset IDs.

<option value="00">-</option>
<option value="01">{{_ "filterData_January"}}</option>
<option value="02">{{_ "filterData_February"}}</option>
Expand All @@ -23,18 +23,18 @@ <h3 class="box-title">{{_ "filterData_Title"}}</h3>
<option value="12">{{_ "filterData_December"}}</option>
</select>
{{_ "filterData_Year"}}
<select name="year">
<select id="year" name="year">
<option value="0000">-</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
</select>
{{_ "filterData_Limit"}}
<input name="limit" type="text" value="10000" />
<input id="limit" name="limit" type="text" value="10000" />

<span class="dc-data-count dc-chart" id="row-selection" style="margin:0">
<span class="filter-count">_</span> {{_ "filterData_SelectedOf"}} <span class="total-count">_</span> {{_ "filterData_Records"}}
<span>
<a href='javascript:dc.filterAll();dc.redrawAll();'>{{_ "filterData_Reset"}}</a>
<a id="reset" href="#">{{_ "filterData_Reset"}}</a>
</span>
</span>
<span id="loadingState">
Expand Down
36 changes: 36 additions & 0 deletions client/views/dashboard/charts/filter/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,41 @@ Template.chartsLayout.events({

instance.getDashboardData(input)

},
"click #reset": function(event, template){
// appending loading state
$('#loadingState').html("Loading...");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup whitespace.



// gets current month and year -> providing them for initial query
var currentYearAndMonth = moment().format("YYYY-MM");

// sets default items amount to be returned
var initialLimit = 10000;

// Initialize filter values
$('#month option[value="00"]').prop('selected', true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is difficult to read, and may be overly complicated.

Try something simpler here. E.g.

// Explicitly reset the select box by setting value to undefined
$('#month-select').val(undefined);

$('#year option[value="0000"]').prop('selected', true);
$('#limit').val( initialLimit.toString() );

// sets query for elastic search
var input = {
index : "api-umbrella-logs-v1-"+currentYearAndMonth,
type : "log",
limit : initialLimit,
fields: [
'request_at',
'request_ip_country',
'request_ip',
'response_time',
'request_path',
'request_ip_location.lon',
'request_ip_location.lat'
]
};

// get data
template.getDashboardData(input);
}
});