Skip to content

Commit

Permalink
[webui] Separate tables for requests on the user home page
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Oct 16, 2013
1 parent 2c52710 commit d2ac9f5
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 104 deletions.
17 changes: 10 additions & 7 deletions src/webui/app/assets/javascripts/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ function renderProjectsTable(length)
});
}

function renderPackagesProjectsTable(packages, length)
function renderPackagesProjectsTable(options)
{
length = (typeof length === "undefined") ? 25 : length;
var packageurl = $("#packages_projects_table_wrapper").data("url");
$("#packages_projects_table_wrapper").html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="packages_projects_table"></table>' );
$("#packages_projects_table").dataTable(
var length = options.length || 25
var name = options.name || "packages_projects_wrapper"
console.log ("Rendering PackagesProjectTable for name: %s", name);

var packageurl = $("#" + name).data("url");
$("#" + name).html("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" class=\"display\" id=\"" + name + '_table' + "\"></table>" );
$("#" + name + "_table").dataTable(
{
"aaData": packages,
"bPaginate": packages.length > 12,
"aaData": options.packages,
"bPaginate": options.packages.length > 12,
"aoColumns": [
{
"sTitle": "Package",
Expand Down
41 changes: 34 additions & 7 deletions src/webui/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def index
end
@ipackages = @displayed_user.involved_packages.each.map {|x| [x.name, x.project]}
begin
@owned = ReverseOwner.find_cached(:user => @displayed_user.login).each.map {|x| [x.rootproject, x.package, x.project]}
@owned = ReverseOwner.find_cached(:user => @displayed_user.login).each.map {|x| [x.package, x.project]}
# :limit => "#{@owner_limit}", :devel => "#{@owner_devel}"
rescue ActiveXML::Transport::Error
# OBSRootOwner isn't set...
Expand Down Expand Up @@ -65,22 +65,49 @@ def icon

def requests
requests = @displayed_user.requests_that_need_work
@declined_requests = BsRequest.ids(requests['declined'])

# Reviews
@open_reviews = BsRequest.ids(requests['reviews'])
@new_requests = BsRequest.ids(requests['new'])
@reviews_in = []
@reviews_out = []
@open_reviews.each do |review|
if review["creator"] == @displayed_user.login
@reviews_out << review
else
@reviews_in << review
end
end

# Other requests
@declined_requests = BsRequest.ids(requests['declined'])

@open_requests = BsRequest.ids(requests['new'])
@requests_in = []
@requests_out = []
@open_requests.each do |request|
if request["creator"] == @displayed_user.login
@requests_out << request
else
@requests_in << request
end
end


@open_patchinfos = @displayed_user.running_patchinfos
session[:requests] = (requests['declined'] + requests['reviews'] + requests['new'])
@requests = BsRequest.ids(session[:requests])

session[:requests] = (requests['declined'] + requests['reviews'] + requests['new'])

@requests = @declined_requests + @open_reviews + @open_requests
@default_request_type = params[:type] if params[:type]
@default_request_state = params[:state] if params[:state]

respond_to do |format|
format.html
format.json do
rawdata = Hash.new
rawdata["declined"] = @declined_requests
rawdata["review"] = @open_reviews
rawdata["new"] = @new_requests
rawdata["new"] = @open_requests
rawdata["declined"] = @declined_requests
rawdata["patchinfos"] = @open_patchinfos
render :text => JSON.pretty_generate(rawdata)
end
Expand Down
214 changes: 124 additions & 90 deletions src/webui/app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,24 @@
</div>

<div class="grid_12 omega box box-shadow">
<div id="tabs1">
<div id="involved">
<div class="box-header header-tabs">
<ul>
<li><a href="#ipackages" title="Packages that you are involved with">Involved Packages</a></li>
<li><a href="#iprojects" title="Projects that you are involved with">Involved Projects</a></li>
<li><a href="#owned" title="Projects/Packages where you are responsible for the maintenance">Owned Project/Packages</a></li>
<!-- <li><a href="#activity">Public Activity</a></li> -->
<li><a href="#iowned" title="Projects/Packages where you are responsible for the maintenance">Owned Project/Packages</a></li>
</ul>
</div>
<div id="ipackages" class="tab">
<% if @ipackages.length > 0 %>
<div id="packages_projects_table_wrapper" data-url="<%= url_for(:controller => 'package',
<div id="ipackages_wrapper" data-url="<%= url_for(:controller => 'package',
:action => 'show',
:project => 'REPLACEPRJ',
:package => 'REPLACEPKG') %> ">
<% content_for :ready_function do %>
var packages = [ <%= @ipackages.map {|p|
var ipackages = [ <%= @ipackages.map {|p|
"['#{p[0]}','#{escape_javascript(p[1])}']" }.join(",\n").html_safe %> ];
renderPackagesProjectsTable(packages, length=15 );
renderPackagesProjectsTable({packages: ipackages, length: '15', name: 'ipackages_wrapper'});
<% end %>
</div>
<% else %>
Expand All @@ -101,38 +100,23 @@
<% end %>
</div>

<div id="owned" class="tab">
<% if @owned.length > 0 %>
<table id='owned-table'>
<thead>
<tr>
<!-- <th>Product</th> -->
<th>Project/Package</th>
</tr>
</thead>
<tbody>
<% @owned.each do |i| -%>
<tr>
<!--
<td>
<%= i[0] %>
</td>
-->
<td>
<% if i[1] %>
<%= render :partial => 'shared/project_or_package_link', :locals => {:project => i[2], :package => i[1],:short => true} %>
<% else %>
<%= render :partial => 'shared/project_or_package_link', :locals => {:project => i[2], :short => true} %>
<%end %>
</td>
</tr>
<% end -%>
</tbody>
</table>
<% else -%>
<p><%= @displayed_user.login %> doesn't own packages/projects.</p>
<div id="iowned" class="tab">
<% if @owned.blank? %>
<p><i><%= @displayed_user.login %> is not involved in any projects</i></p>
<% else %>
<div id="iowned_wrapper" data-url="<%= url_for(:controller => 'package',
:action => 'show',
:project => 'REPLACEPRJ',
:package => 'REPLACEPKG') %> ">
<% content_for :ready_function do %>
var iowned = [ <%= @owned.map {|p|
"['#{p[0]}','#{escape_javascript(p[1])}']" }.join(",\n").html_safe %> ];
renderPackagesProjectsTable({packages: iowned, length: '15', name: 'iowned_wrapper'});
<% end %>
</div>
<% end %>
</div>
</div>

<!--
<div id="activity" class="tab">
<p>Activity</p>
Expand All @@ -143,70 +127,120 @@

<div class="clear"></div>

<% if @requests %>
<% if @requests and @reviews_in.count + @reviews_out.count > 0 %>
<div class="grid_16 alpha omega box box-shadow">
<div id="tabs2">
<div id="reviews">
<div class="box-header header-tabs">
<ul>
<li><a href="#irequests" title="Requests that require your action">Involved Requests (<%= @new_requests.count + @open_reviews.count + @declined_requests.count %>)</a></li>
<li><a href="#ipatches" title="Open Patchinfos">Involved Patchinfos (<%=@open_patchinfos.length %>)</a></li>
<li></li>
<% if @reviews_in.count > 0 %>
<li><a href="#reviews_in" title="Requests that <%= @displayed_user.login %> has to review">Incoming Reviews</a></li>
<% end %>
<% if @reviews_out.count > 0 %>
<li><a href="#reviews_out" title="Requests <%= @displayed_user.login %> has sent">Outgoing Reviews</a></li>
<% end %>
</ul>
</div>
<div id="irequests" class="tab">
<% if @requests.count > 0 %>
<%= render(:partial => 'shared/requests', :locals => { :requests => @requests, :request_table_id => 'new_reviews_table', :hide_state => true }) %>
<p>
<%= link_to('See requests in any state.', :action => 'requests', :user => @displayed_user.to_s) %>
</p>
<% else %>
<p>
There is currently no action required from you on any request.
<%= link_to('See requests in any state.', :action => 'requests', :user => @displayed_user.to_s) %>
</p>
<% if @reviews_in.count > 0 %>
<div id="reviews_in" class="tab">
<%= render(:partial => 'shared/requests', :locals => { :requests => @reviews_in, :request_table_id => 'reviews_in_table', :hide_state => true }) %>
</div>
<% end %>
<% if @reviews_out.count > 0 %>
<div id="reviews_out" class="tab">
<%= render(:partial => 'shared/requests', :locals => { :requests => @reviews_out, :request_table_id => 'reviews_out_table', :hide_state => true }) %>
</div>
<% end -%>
</div>
</div>
<% end %>
<% if @requests and @requests_in.count + @requests_out.count > 0 %>
<div class="grid_16 alpha omega box box-shadow">
<div id="requests">
<div class="box-header header-tabs">
<ul>
<% if @requests_in.count > 0 %>
<li><a href="#requests_in" title="Requests that <%= @displayed_user.login %> has to merge">Incoming Requests</a></li>
<% end -%>
<% if @requests_out.count > 0 %>
<li><a href="#requests_out" title="Requests that <%= @displayed_user.login %> has sent">Outgoing Requests</a></li>
<% end -%>
<% if @declined_requests.count > 0 %>
<li><a href="#requests_declined" title="Requests from <%= @displayed_user.login %> that are declined">Declined Requests</a></li>
<% end -%>
</ul>
</div>
<% if @requests_in.count > 0 %>
<div id="requests_in" class="tab">
<%= render(:partial => 'shared/requests', :locals => { :requests => @requests_in, :request_table_id => 'requests_in_table', :hide_state => true }) %>
</div>
<% end -%>
<% if @requests_out.count > 0 %>
<div id="requests_out" class="tab">
<%= render(:partial => 'shared/requests', :locals => { :requests => @requests_out, :request_table_id => 'requests_out_table', :hide_state => true }) %>
</div>
<% end -%>
<% if @declined_requests.count > 0 %>
<div id="requests_declined" class="tab">
<%= render(:partial => 'shared/requests', :locals => { :requests => @declined_requests, :request_table_id => 'requests_declined_table', :hide_state => true }) %>
</div>
<% end -%>
</div>
</div>
<% end %>
<div id="ipatches" class="tab">
<% if @open_patchinfos.length > 0 %>
<h3 title="Maintenance updates where you are assigned as bugowner">Running Maintenance Updates</h3>
<table id='open_patchinfos-table' class='grid' title="Running Maintenance Updates">
<tr>
<th>Project</th>
<th>Package</th>
<th>Issues</th>
<th style="width: 1%">Actions</th>
</tr>
<% @open_patchinfos.each do |pi| -%>
<% if @open_patchinfos and @open_patchinfos.count > 0 %>
<div class="grid_16 alpha omega box box-shadow">
<div id="patchinfos">
<div class="box-header header-tabs">
<ul>
<li><a href="#patchinfos_in" title="Requests that <%= @displayed_user.login %> has to merge">Maintenance Requests</a></li>
</ul>
</div>
<div id="patchinfos_in" class="tab">
<table id='open_patchinfos-table' title="Running Maintenance Updates">
<thead>
<tr>
<% shortened_prj, shortened_pkg = elide_two(pi[:package][:project], pi[:package][:name], 60) %>
<td><%= link_to shortened_prj, :controller => :project, :action => :show, :project => pi[:package][:project] %></td>
<td><%= link_to shortened_pkg, :controller => :package, :action => :show, :project => pi[:package][:project], :package => pi[:package][:name]%></td>
<td>
<% pi[:issues].each do |i| -%>
<%= link_to i[:label], i[:url], :title => i[:summary]%>,
<% end -%>
</td>
<td><%= link_to image_tag('monitor.png', :size => '16x16', :alt => 'Monitor', :title => 'Monitor'), :action => :monitor, :project => pi[:package][:project], :pkgname => pi[:package][:name], :controller => :project %></td>
<th>Project</th>
<th>Package</th>
<th>Issues</th>
<th style="width: 1%">Actions</th>
</tr>
<% end -%>
</table>
<% else -%>
<p><%= @displayed_user.login %> is not involved in any patchinfos</p>
<% end %>
</div>
</div>
</thead>
<tbody>
<% @open_patchinfos.each do |pi| -%>
<tr>
<% shortened_prj, shortened_pkg = elide_two(pi[:package][:project], pi[:package][:name], 60) %>
<td><%= link_to shortened_prj, :controller => :project, :action => :show, :project => pi[:package][:project] %></td>
<td><%= link_to shortened_pkg, :controller => :package, :action => :show, :project => pi[:package][:project], :package => pi[:package][:name]%></td>
<td>
<% pi[:issues].each do |i| -%>
<%= link_to i[:label], i[:url], :title => i[:summary]%>,
<% end -%>
</td>
<td><%= link_to image_tag('monitor.png', :size => '16x16', :alt => 'Monitor', :title => 'Monitor'), :action => :monitor, :project => pi[:package][:project], :pkgname => pi[:package][:name], :controller => :project %></td>
</tr>
<% end -%>
</tbody>
</table>
</div>
</div>
</div>
<% end %>
<%= javascript_tag do %>
$(document).ready(function() {
$('#open_patchinfos-table').dataTable();
});
<% end %>
<% end %>
<% content_for :ready_function do %>
$( "#tabs1" ).tabs();
$( "#tabs2" ).tabs();
<% if @owned.length > 0 %>
$('#owned-table').dataTable({
"bLengthChange": false,
"bStateSave": true,
"iDisplayLength": 15,
});
<% end %>
$( "#involved" ).tabs();
<% if @requests %>
$( "#reviews" ).tabs();
$( "#requests" ).tabs();
<% end -%>
<% if @open_patchinfos %>
$( "#patchinfos" ).tabs();
<% end -%>
<% end %>

0 comments on commit d2ac9f5

Please sign in to comment.