Skip to content

Commit

Permalink
[webui] First step of more useful user home / start page
Browse files Browse the repository at this point in the history
  • Loading branch information
saschpe committed Jun 20, 2012
1 parent 5d1791e commit d0b45ff
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 47 deletions.
15 changes: 14 additions & 1 deletion src/webui/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ class HomeController < ApplicationController
before_filter :overwrite_user, :only => [:index, :my_work, :requests, :list_my]

def index
#@requests_in = BsRequest.list({})
# [
# BsRequest.list({:states => 'review', :reviewstates => 'new', :roles => "reviewer", :user => login}),
# BsRequest.list({:states => 'new', :roles => "maintainer", :user => login})]
#@requests_out = BsRequest.list({:states => 'new,review', :user => login, :roles => 'creator'})
@roles = Role.local_roles
@projects = @displayed_user.involved_projects.each.map {|x| x.name}.uniq.sort
@packages = {}
pkglist = @displayed_user.involved_packages.each.reject {|x| @projects.include?(x.project)}
pkglist.sort(&@displayed_user.method('packagesorter')).each do |pack|
@packages[pack.project] ||= []
@packages[pack.project] << pack.name if !@packages[pack.project].include? pack.name
end
end

def icon
Expand Down Expand Up @@ -42,7 +55,7 @@ def icon

def my_work
unless @displayed_user
require_login
require_login
return
end
@declined_requests, @open_reviews, @new_requests = @displayed_user.requests_that_need_work(:cache => false)
Expand Down
246 changes: 200 additions & 46 deletions src/webui/app/views/home/index.rhtml
Original file line number Diff line number Diff line change
@@ -1,49 +1,203 @@
<% @pagetitle = "Home of #{@displayed_user}" %>
<% @crumb_list = [@pagetitle] %>

<h3><%= @pagetitle %></h3>

<h4>User Info</h4>

<p><strong>Profile picture:</strong></p>
<table>
<tr>
<td><a href="http://gravatar.com/emails"><%= user_icon(@displayed_user.login, 60) if @displayed_user.email %></a></td>
<td>Profile pictures are provided by <a href="http://gravatar.com/">Gravatar</a>,<br/> and are based on your email address
<a href="http://gravatar.com/emails" class="block avatar"><span>Update your picture...</span></a>
</td>
</tr>
</table>

<p>
<strong>Real name:</strong>
<% if @displayed_user.realname && !@displayed_user.realname.to_s.empty? %>
<%= h(@displayed_user.realname) %>
<% else %>
<em>No real name set.</em>
<% end %>
</p>
<p><strong>Email address:</strong> <%= mail_to(@displayed_user.email) %></p>

<% if @displayed_user.to_s == session[:login] %>
<p><%= image_tag('icons/user_edit.png') %> <%= link_to("Edit user data", :controller => "user", :action => "edit") %></p>
<% if defined?( CHANGE_PASSWD ) && CHANGE_PASSWD == 'on' %>
<p><%= image_tag('icons/key.png') %> <%= link_to("Change password", :controller => "user", :action => "change_my_password") %></p>
<% end %>
<% end %>
<% @pagetitle = 'Home' %>
<% @layouttype = 'custom' %>
<% @crumb_list = ['User', @displayed_user] %>
<% if not @displayed_user.groups.empty? %>
<h4>Groups Memberships</h4>
<ul>
<% @displayed_user.groups.each do |group| %>
<li><%= group %> </li>
<% end %>
</ul>
<% content_for :content_for_head do %>
<%= stylesheet_link_tag 'jquery.dataTables' %>
<% end %>
<%= javascript_include_tag 'jquery.dataTables.min' %>

<div class="grid_6 box box-shadow alpha">
<table class="user-detail">
<tbody>
<tr>
<td rowspan="3">
<a href="http://gravatar.com/emails"><%= user_icon(@displayed_user.login, 56) if @displayed_user.email %></a>
</td>
<td class="textright"><b>Name:</b></td>
<td>
<%= h(@displayed_user.realname) %>
<%= link_to(image_tag('icons/user_edit.png'), :controller => "user", :action => "edit") %>
<% if @displayed_user.to_s == session[:login] %>
<% if defined?( CHANGE_PASSWD ) && CHANGE_PASSWD == 'on' %>
<%= link_to(image_tag('icons/key.png'), :controller => "user", :action => "change_my_password") %>
<% end %>
<% end %>
</td>
</tr>
<tr>
<td class="textright"><b>Mail:</b></td>
<td><%= mail_to(@displayed_user.email) %></td>
</tr>
<tr>
<td class="textright"><b>Project:</b></td>
<td><%= link_to("home:#{@displayed_user.value('login')}", :controller => 'project', :action => 'show', :project => "home:#{@displayed_user.value('login')}") %></td>
</tr>
</tbody>
</table>
</div>
<div class="grid_10 box box-shadow omega">
</div>
<%= render :partial => 'main/news' %>

<div class="grid_16 box box-shadow alpha omega">
<div class="box-header header-tabs">
<ul id="user_select">
<li class="selected">
<a class="user_select_link" id="user_select_link_0" href="#">
Request Inbox <span id="request_in_count"></span>
</a>
</li>
<li>
<a class="user_select_link" id="user_select_link_1" href="#">
Request Outbox <span id="request_out_count"></span>
</a>
</li>
<li>
<a class="user_select_link" id="user_select_link_2" href="#">
Projects <% if not @projects.empty? %>(<%= @projects.length %>)<% end %>
</a>
</li>
<li>
<a class="user_select_link" id="user_select_link_3" href="#">
Packages <% if not @packages.empty? %>(<%= @packages.length %>)<% end %>
</a>
</li>
<li>
<a class="user_select_link" id="user_select_link_4" href="#">
Groups <% if not @displayed_user.groups.empty? %>(<%= @displayed_user.groups.length %>)<% end %>
</a>
</li>
</ul>
</div>

<div class="user_display" id="user_display_0">
<h4>Incomming</h4>
</div>
<div class="user_display" style="display:none" id="user_display_1">
<h4>Outgoing</h4>
</div>

<div class="user_display" style="display: none" id="user_display_2">
<% if not @projects.empty? %>
<table id="user_projects_table">
<thead>
<tr>
<th>Project</th>
<% @roles.each do |role| %>
<th><%= role.capitalize %></th>
<% end %>
<th>Watched</th>
</tr>
</thead>
<tbody>
<% @projects.each do |project| %>
<tr>
<td><%= link_to(project, :controller => 'project', :action => 'show', :project => project) %></td>
<% @roles.each do |role| %>
<td>TODO</td>
<% end %>
<td>TODO</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>No roles in any project yet!</p>
<% end %>
</div>
<div class="user_display" style="display: none" id="user_display_3">
<% if not @packages.empty? %>
<table id="user_packages_table">
<thead>
<tr>
<th>Project</th>
<th>Package</th>
<% @roles.each do |role| %>
<th><%= role.capitalize %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @packages.each do |project, pkgs| %>
<% pkgs.each do |package| %>
<tr>
<td><%= link_to(project, :controller => 'project', :action => 'show', :project => project) %></td>
<td><%= link_to(package, :controller => 'package', :action => 'show', :project => project, :package => package) %></td>
<% @roles.each do |role| %>
<td>TODO</td>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% else %>
<p>No roles in any package yet!</p>
<% end %>
</div>
<div class="user_display" style="display: none" id="user_display_4">
<% if not @displayed_user.groups.empty? %>
<table id="user_groups_table">
<thead>
<tr>
<th>Group</th>
</tr>
</thead>
<tbody>
<% @displayed_user.groups.each do |group| %>
<tr>
<td><%= group %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>No membership in any group yet!</p>
<% end %>
</div>
</div>

<h4>Related Links</h4>
<ul>
<li><%= link_to('Home project', :controller => 'project', :action => 'show', :project => "home:#{@displayed_user.to_s}") %></li>
<li><%= link_to('Involved projects', :action => 'list_my', :user => @displayed_user.to_s) %></li>
<li><%= link_to('Involved requests', :action => 'requests', :user => @displayed_user.to_s) %></li>
</ul>
<% javascript_tag do %>
$('.user_select_link').click(function (event) {
$('#user_select li.selected').attr('class', '');
$(event.target).parent().attr('class', 'selected')
$('.user_display').hide();
index = event.target.id.split('user_select_link_')[1]
$('#user_display_' + index).show();
});

$(document).ready(function() {
$.extend($.fn.dataTable.defaults, {
'iDisplayLength': 25,
});

<% if not @projects.empty? %>
$('#user_projects_table').dataTable({
'aoColumns': [
null,
<% @roles.length.times do %>
{'bSortable': false},
<% end %>
null,
]
});
<% end %>
<% if not @packages.empty? %>
$('#user_packages_table').dataTable({
'aoColumns': [
null,
null,
<% @roles.length.times do %>
{'bSortable': false},
<% end %>
]
});
<% end %>
<% if not @displayed_user.groups.empty? %>
$('#user_groups_table').dataTable();
<% end %>
});
<% end %>
4 changes: 4 additions & 0 deletions src/webui/public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ td pre.plain {
background-color: #F6F6F6;
}

table.user-detail > tbody > tr > td {
border: 0px;
}

.error {
color: red;
}
Expand Down

0 comments on commit d0b45ff

Please sign in to comment.