Skip to content

Commit

Permalink
Remove client filter from Project monitor
Browse files Browse the repository at this point in the history
and do it on the server again.
The client search is not sufficient in its current implementation
because to add a filter you first need to remove all filters
which takes a lot of time for big projects like Factory.

We will think about a hibrid solution to enable client and server
side filter but for now the easiest solution is to always search on
the server.
  • Loading branch information
ChrisBr committed Dec 10, 2018
1 parent c1d1ae0 commit b1a3812
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 209 deletions.
87 changes: 0 additions & 87 deletions src/api/app/assets/javascripts/webui2/project_monitor.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,3 @@
function hideRepositoryColumns() {
var table = $('#project-monitor-table').DataTable();

var repositories = [];
$('#project-monitor-repositories-dropdown input:checked').each(function () {
repositories.push($(this).val().trim());
});

if (repositories.length === 0) {
return;
}

var toShowColumns = [];
var offSet = 0;
$('#project-monitor-table thead tr:eq(0) th').each(function () {
var column = $(this);
var colSpan = column.prop('colspan');
if (repositories.includes(column.text().trim())) {
var range = [];
for (var i = offSet; i < offSet + colSpan; i++) {
range.push(i);
}
toShowColumns = toShowColumns.concat(range);
}
offSet += colSpan;
});

table.columns().every(function () {
var index = this.index();
if (index === 0) return;
this.visible(toShowColumns.includes(index));
});
}

function hideArchitectureColumns() {
var table = $('#project-monitor-table').DataTable();

var architectures = [];
$('#project-monitor-architectures-dropdown input:checked').each(function () {
architectures.push($(this).val());
});

if (architectures.length === 0) {
return;
}

table.columns().every(function () {
if (this.index() === 0) return;
if (!this.visible()) return;

var title = $(this.header()).text().trim();
this.visible(architectures.includes(title));
});
}

function updateStatusSearch() {
var table = $('#project-monitor-table').DataTable();
var searchInput = $('#project-monitor_filter input');

var terms = [];
$('#project-monitor-status-dropdown input:checked').each(function () {
terms.push($(this).val());
});

var searchTerm = terms.join("|");
searchInput.val(searchTerm);
table.search(searchTerm).draw();
}

function updateMonitorFilters() {
updateStatusSearch();
var table = $('#project-monitor-table').DataTable();
table.columns().visible(true);
hideRepositoryColumns();
hideArchitectureColumns();
}

function setupProjectMonitor() { // jshint ignore:line
initializeDataTable('#project-monitor-table', { // jshint ignore:line
scrollX: true,
Expand All @@ -90,17 +13,7 @@ function setupProjectMonitor() { // jshint ignore:line

$('[data-toggle="popover"]').popover({ trigger: 'hover click' });

$('#project-monitor-status-dropdown input:checkbox').on('change', function () {
updateStatusSearch();
});

$('.monitor-no-filter-link').on('click', function () {
$(this).siblings().children('input:checked').prop('checked', false);
updateMonitorFilters();

});

$('#project-monitor-architectures-dropdown input:checkbox, #project-monitor-repositories-dropdown input:checkbox').on('change', function () {
updateMonitorFilters();
});
}
6 changes: 0 additions & 6 deletions src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ def move_path
end

def monitor
if params.keys.length < 4
@activate_client_search = true
else
flash[:notice] = "Limited search results, click #{view_context.link_to('here', project_monitor_path(@project))} to remove the filter."
end

@legend = Buildresult::STATUS_DESCRIPTION

@name_filter = params[:pkgname]
Expand Down
31 changes: 16 additions & 15 deletions src/api/app/views/webui2/webui/project/_monitor_control.html.haml
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
.row
.col-md-12
- if activate_client_search
= form_tag(project_monitor_path, method: :get) do
= hidden_field_tag :project, project
= hidden_field_tag :defaults, 0
%span.dropdown#project-monitor-status-dropdown
%button.btn.btn-outline-secondary.dropdown-toggle{ data: { toggle: :dropdown }, type: :button }
%span.caret
Status
.dropdown-menu
%button.btn.btn-link.monitor-no-filter-link No filter
%button.btn.btn-link.monitor-no-filter-link{ type: :button } No filter
- status.each do |status|
.custom-control.custom-checkbox.dropdown-item.ml-2
%input.custom-control-input{ type: :checkbox, id: "#{status}-checkbox".parameterize, checked: status_filter.include?(status), value: status }
%label.custom-control-label{ for: "#{status}-checkbox".parameterize }
= check_box_tag valid_xml_id(status), 1, status_filter.include?(status), class: 'custom-control-input'
%label.custom-control-label{ for: valid_xml_id(status) }
= status
%span.dropdown#project-monitor-architectures-dropdown
%button.btn.btn-outline-secondary.dropdown-toggle{ data: { toggle: :dropdown }, type: :button }
%span.caret
Architecture
.dropdown-menu
%button.btn.btn-link.monitor-no-filter-link No filter
%button.btn.btn-link.monitor-no-filter-link{ type: :button } No filter
- architectures.each do |architecture|
.custom-control.custom-checkbox.dropdown-item.ml-2
%input.custom-control-input{ type: :checkbox, id: "#{architecture}-checkbox".parameterize, checked: architecture_filter.include?(architecture), value: architecture }
%label.custom-control-label{ for: "#{architecture}-checkbox".parameterize }
= check_box_tag valid_xml_id('arch_' + architecture), 1, architecture_filter.include?(architecture), class: 'custom-control-input'
%label.custom-control-label{ for: valid_xml_id('arch_' + architecture) }
= architecture
%span.dropdown#project-monitor-repositories-dropdown
%button.btn.btn-outline-secondary.dropdown-toggle{ data: { toggle: :dropdown }, type: :button }
%span.caret
Repository
.dropdown-menu
%button.btn.btn-link.monitor-no-filter-link No filter
%button.btn.btn-link.monitor-no-filter-link{ type: :button } No filter
- repositories.each do |repository|
.custom-control.custom-checkbox.dropdown-item.ml-2
%input.custom-control-input{ type: :checkbox, id: "#{repository}-checkbox".parameterize, checked: repository_filter.include?(repository), value: repository }
%label.custom-control-label{ for: "#{repository}-checkbox".parameterize }
= check_box_tag valid_xml_id('repo_' + repository), 1, repository_filter.include?(repository), class: 'custom-control-input'
%label.custom-control-label{ for: valid_xml_id('repo_' + repository) }
= repository
%button.btn.btn-outline-secondary{ data: { toggle: 'modal', target: '#build-monitor-legend' }, title: 'Build status legend' }
%button.btn.btn-outline-primary{ type: :submit }
Filter
%button.btn.btn-outline-secondary.float-right{ type: :button,
data: { toggle: 'modal', target: '#build-monitor-legend' }, title: 'Build status legend' }
Legend
- unless activate_client_search
.float-right
%a.btn.btn-outline-primary{ href: project_monitor_path(project) }
Remove filter

.modal.fade#build-monitor-legend{ tabindex: -1, role: 'dialog', aria: { labelledby: 'confirm-modal-label', hidden: true } }
.modal-dialog.modal-dialog-centered.modal-lg{ role: 'document' }
Expand Down
101 changes: 0 additions & 101 deletions src/api/spec/bootstrap/features/webui/projects/monitor_spec.rb

This file was deleted.

0 comments on commit b1a3812

Please sign in to comment.