Skip to content

Commit

Permalink
Merge pull request Katello#380 from jlsherrill/content-browser
Browse files Browse the repository at this point in the history
Content browser updates
  • Loading branch information
jlsherrill committed Jul 27, 2012
2 parents 9e0fe02 + 65799ef commit a93d127
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 40 deletions.
26 changes: 18 additions & 8 deletions src/app/controllers/content_search_controller.rb
Expand Up @@ -11,6 +11,9 @@
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
require 'util/package_util'
class ContentSearchController < ApplicationController

include ContentSearchHelper

before_filter :find_repo, :only => [:repo_packages, :repo_errata]
before_filter :find_repos, :only => [:repo_compare_packages, :repo_compare_errata]

Expand Down Expand Up @@ -158,9 +161,9 @@ def repo_errata
offset = params[:offset] || 0
errata = Glue::Pulp::Errata.search('', offset, current_user.page_size, :repoids => [@repo.pulp_id])
rows = errata.collect do |e|
{:name => e.id, :id => e.id, :cols => {:title => {:display => e[:title]},
{:name => errata_display(e), :id => e.id, :cols => {:title => {:display => e[:title]},
:type => {:display => e[:type]},
:issued => {:display => e[:issued]}
:severity => {:display => e[:severity]}
}
}
end
Expand Down Expand Up @@ -198,9 +201,11 @@ def repo_compare_content is_package, offset
(pack.repoids & repo_map.keys).each do |r|
cols[repo_map[r].id] = {}
end
name = pack.id

if is_package
name = pack.nvrea
else
name = errata_display(pack)
end
{:name => name, :id => pack.id, :cols => cols}
end
Expand Down Expand Up @@ -415,7 +420,7 @@ def spanned_repo_content library_repo, content_type, content_search_obj, offset=
to_ret[repo.environment_id] = {:id=>repo.environment_id, :display=>results.total} if accessible_env_ids.include?(repo.environment_id)
end

{:content_rows=>spanning_content_rows(content, content_type, content_attribute, library_repo, spanning_repos),
{:content_rows=>spanning_content_rows(content, content_type, library_repo, spanning_repos),
:repo_cols=>to_ret, :total=>content.total}
end

Expand All @@ -438,8 +443,8 @@ def multi_repo_content_search( content_class, search_obj, repos, offset, defaul
string search_obj, {:default_field=>default_field}
end
end
fields [:id, :name, :nvrea, :repoids]
sort { by "#{default_field}_sort", 'asc'}
fields [:id, :name, :nvrea, :repoids, :type]
size user.page_size
from offset
if search_obj.is_a? Array
Expand All @@ -460,15 +465,19 @@ def multi_repo_content_search( content_class, search_obj, repos, offset, defaul
#
# content_list list of package or errata items
# id_prefix prefix for the rows (either 'package' or 'errata')
# name_attribute what to display as the name of each item in the row. Will be called on each object
# parent_repo the library repo instance (or the parent row)
# spanned_repos all other instances of repos across all environments
def spanning_content_rows(content_list, id_prefix, name_attribute, parent_repo, spanned_repos)
def spanning_content_rows(content_list, id_prefix, parent_repo, spanned_repos)
env_ids = KTEnvironment.content_readable(current_organization).pluck(:id)
to_ret = []
for item in content_list:
if id_prefix == 'package'
display = item.nvrea
else
display = errata_display(item)
end
row = {:id=>"repo_#{parent_repo.id}_#{id_prefix}_#{item.id}", :parent_id=>"repo_#{parent_repo.id}", :cols=>{},
:name=>item.send(name_attribute)}
:name=>display}
spanned_repos.each do |repo|
if item.repoids.include? repo.pulp_id
row[:cols][repo.environment_id] = {:id=>repo.environment_id} if env_ids.include?(repo.environment_id)
Expand All @@ -478,4 +487,5 @@ def spanning_content_rows(content_list, id_prefix, name_attribute, parent_repo,
end
to_ret
end

end
10 changes: 7 additions & 3 deletions src/app/controllers/errata_controller.rb
Expand Up @@ -23,9 +23,9 @@ def rules
}
{
:show => view,
:packages => view
:packages => view,
:short_details => view
}

end

def show
Expand All @@ -35,7 +35,11 @@ def show
def packages
render :partial=>"packages", :layout => "tupane_layout"
end


def short_details
render :partial=>"short_details"
end

private


Expand Down
8 changes: 8 additions & 0 deletions src/app/helpers/content_search_helper.rb
Expand Up @@ -9,4 +9,12 @@ def content_types
]
end


def errata_display errata
types = {'bugfix'=>'bug_icon_black', 'enhancement'=>'plus_icon_black', 'security'=>'shield_icon_black'}
icon_class = types[errata[:type]] || 'enhancement_icon'
url = short_details_erratum_path(errata.id)
return "<i class=\"errata-icon #{icon_class}\" />" + "<span class=\"tipsify-errata\" data-url=\"#{url}\">#{errata.id}</span>"
end

end
2 changes: 1 addition & 1 deletion src/app/models/glue/pulp/errata.rb
Expand Up @@ -93,7 +93,7 @@ def self.index_mapping
:id => { :type => 'string', :analyzer =>:kt_name_analyzer},
:product_ids => { :type => 'integer', :analyzer =>:kt_name_analyzer},
:severity => { :type => 'string', :analyzer =>:kt_name_analyzer},
:type => { :type => 'string', :analyzer =>:kt_name_analyzer}
:type => { :type => 'string', :analyzer =>:kt_name_analyzer},
}
}
}
Expand Down
36 changes: 33 additions & 3 deletions src/app/stylesheets/sections/content_search.scss
Expand Up @@ -33,15 +33,45 @@ $comparison_grid_column_header-background: #FFF;
.no_border { border: none !important; }

.content-tipsy {
ul {
list-style-type: disc;
}
.example {
margin-left: 6px;
margin-bottom: 6px;
}
}


.tipsify-errata {
&:hover {
color: $kselected_color;
}
}
.tipsify-errata.tipsy-hover {
color: $kselected_color;
background-color: transparent;
}
.tipsify-errata.tipsy-nohover {
background-color: transparent;
}

.tipsy-inner{
.spinner {
//margin:10px;
margin-top: 40px;
margin-bottom: 40px;
margin-left: 70px;
margin-right: 70px;
}
}

.errata-icon {
@extend .errata_icon;
float: left;
padding: 0px;
margin-left: 0px;
margin-right: 4px;
}


#browse_box {
width: $browse_box-width;
min-height: $browse_box-height;
Expand Down
43 changes: 43 additions & 0 deletions src/app/views/errata/_short_details.html.haml
@@ -0,0 +1,43 @@
.details_container
.item-container
%label.fl.ra
= _("Id")
%p
= @errata.id
.item-container
%label.fl.ra
= _("Title: ")
%p
= @errata.title

.item-container
%label.fl.ra
=_("Issued: ")
%p
= @errata.issued

.item-container
%label.fl.ra
=_("References:")
%p
= @errata.references[0] ? @errata.references[0][:href] : ''

.item-container
%label.fl.ra
= _("Description:")
- @errata.description.split("\n\n").each do |p|
%p
= p
%p
&nbsp;

.item-container
%label.fl.ra
= _("Packages:")
%p
&nbsp;
- if @errata.pkglist[0]
- @errata.pkglist[0][:packages].each do |p|
%p
= p[:filename]

1 change: 1 addition & 0 deletions src/config/routes.rb
Expand Up @@ -202,6 +202,7 @@
resources :errata, :only => [:show] do
member do
get :packages
get :short_details
end
end

Expand Down
5 changes: 3 additions & 2 deletions src/public/javascripts/comparison_grid.js
Expand Up @@ -350,13 +350,13 @@ KT.comparison_grid.models = function() {

self.export_data = function(type) {
if( type === "columns" ){
return { columns : self.columns };
return { columns :$.extend(true, [], self.columns) };
} else if( type === "rows" ){
return { rows : $.extend(true, {}, self.rows.get()) };
} else if( type === "mode" ){
return { mode : self.mode };
} else {
return { columns : self.columns,
return { columns : $.extend(true, [], self.columns),
rows : $.extend(true, {}, self.rows.get()),
mode : self.mode };
}
Expand Down Expand Up @@ -585,6 +585,7 @@ KT.comparison_grid.controls = function(grid) {

selector.append(html);
selector.chosen();
selector.trigger("liszt:updated");
},
show = function(){
container.show();
Expand Down
43 changes: 26 additions & 17 deletions src/public/javascripts/content_search.js
Expand Up @@ -48,8 +48,7 @@ KT.content_search = function(paths_in){
cols:{
title : {id:'title', name:i18n.title, span: "2"},
type : {id:'type', name:i18n.type},
severity : {id:'severity', name:i18n.severity},
issued : {id:'issued', name:i18n.issued}
severity : {id:'severity', name:i18n.severity}
},
selector:['repo_packages', 'repo_errata']
},
Expand Down Expand Up @@ -188,6 +187,7 @@ KT.content_search = function(paths_in){
data: data_out,
success: function(data){
$(document).trigger('show_more.comparison_grid', [data.rows]);
close_tipsy();
}
})
});
Expand Down Expand Up @@ -218,32 +218,35 @@ KT.content_search = function(paths_in){
}
},
main_search = function(search_params){
if (search_params.mode === undefined){
search_params.mode = search_modes[0].id;
}

search_params.environments = []
utils.each(get_initial_environments(), function(item){
search_params.environments.push(item.id);
});

var options = {};
close_tipsy();

options.show_compare_btn = search_pages[search_params.content_type].comparable;
if (cache.get_state(search_params)){
comparison_grid.import_data(cache.get_state(search_params));
comparison_grid.set_mode("results", options);
}
else {

if (search_params.mode === undefined){
search_params.mode = search_modes[0].id;
}

search_params.environments = [];
utils.each(get_initial_environments(), function(item){
search_params.environments.push(item.id);
});

$(document).trigger('loading.comparison_grid');
$.ajax({
type: 'POST',
contentType:"application/json",
url: search_pages[search_params.content_type].url,
data: JSON.stringify(search_params),
success: function(data){
var options = {};
options.show_compare_btn = search_pages[search_params.content_type].comparable;
if (search_pages[search_params.content_type].modes){
options.right_selector = true;
comparison_grid.set_right_select(search_modes, search_params.mode);
comparison_grid.set_right_select(search_modes, search_params.mode || search_modes.first.id);
}

comparison_grid.set_columns(env_select.get_paths());
Expand All @@ -259,7 +262,7 @@ KT.content_search = function(paths_in){
subgrid_search = function(search_params){
var type = search_params.subgrid.type,
subgrid = subgrids[search_params.subgrid.type];

close_tipsy();
comparison_grid.controls.comparison.hide();
$(document).trigger('loading.comparison_grid');
$.ajax({
Expand All @@ -285,6 +288,9 @@ KT.content_search = function(paths_in){
}
});
},
close_tipsy = function(){
$(document).trigger("close.tipsy");
},
draw_grid = function(data){
comparison_grid.set_rows(data, true);
},
Expand Down Expand Up @@ -321,7 +327,8 @@ KT.content_search = function(paths_in){
if (envs_changed && search && search.mode && search.mode !== 'all'){
search_initiated(undefined, search);
envs_changed = false;
}
}
cache.save_state(comparison_grid, search);
});
//select event
$(document).bind(env_select.get_select_event(), function(event){
Expand Down Expand Up @@ -372,6 +379,8 @@ KT.content_search = function(paths_in){
return $(this).find('.hidden-text').html();
}
});
KT.tipsy.custom.url_tooltip($('.tipsify-errata'), 'w');

},
subgrid_selector_items = function(type) {
var to_ret = [],
Expand Down Expand Up @@ -400,7 +409,7 @@ KT.content_search_cache = (function(){
saved_data = undefined;

var save_state = function(grid, search){
saved_search = search;
saved_search = $.extend(true, {}, search);
saved_data = grid.export_data();
},
get_state = function(search){
Expand Down

0 comments on commit a93d127

Please sign in to comment.