Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/galaxyproject/galaxy into Re…
Browse files Browse the repository at this point in the history
…ports_newpage

Conflicts:
	lib/galaxy/webapps/reports/controllers/jobs.py
	templates/webapps/reports/jobs_specified_month_all.mako
  • Loading branch information
Airistotal committed Jul 20, 2015
2 parents 6f4eeb2 + 6d9ac63 commit 48931a6
Show file tree
Hide file tree
Showing 5 changed files with 339 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/eggs/dist.py
Expand Up @@ -63,14 +63,14 @@ def parse( self ):

def get_platforms( self, wanted ):
# find all the members of a group and process them
if self.groups in wanted:
if wanted in self.groups:
platforms = []
for name in self.groups[wanted].split():
for platform in self.get_platforms( name ):
if platform not in platforms:
platforms.append( platform )
return platforms
elif self.hosts in wanted:
elif wanted in self.hosts:
return [ wanted ]
else:
raise Exception( "unknown platform: %s" % wanted )
Expand Down
34 changes: 22 additions & 12 deletions lib/galaxy/webapps/reports/controllers/jobs.py
Expand Up @@ -12,10 +12,8 @@
from galaxy import model, util
from galaxy.web.base.controller import BaseUIController, web
from galaxy.web.framework.helpers import grids
from math import floor
import pkg_resources
pkg_resources.require( "SQLAlchemy >= 0.4" )
import re
from math import ceil, floor
from galaxy.webapps.reports.controllers.query import ReportQueryBuilder

log = logging.getLogger( __name__ )
Expand Down Expand Up @@ -275,6 +273,7 @@ def specified_month_all( self, trans, **kwd ):
Queries the DB for all jobs in given month, defaults to current month.
"""
message = ''
PageSpec = namedtuple('PageSpec', ['entries', 'offset', 'page', 'pages_found'])

params = util.Params( kwd )
monitor_email = params.get( 'monitor_email', 'monitor@bx.psu.edu' )
Expand All @@ -286,6 +285,22 @@ def specified_month_all( self, trans, **kwd ):
arrow = specs.arrow
_order = specs.exc_order

if "entries" in kwd:
entries = int(kwd.get( 'entries' ))
else:
entries = 50
limit = entries * 4

if "offset" in kwd:
offset = int(kwd.get( 'offset' ))
else:
offset = 0

if "page" in kwd:
page = int(kwd.get( 'page' ))
else:
page = 1

# In case we don't know which is the monitor user we will query for all jobs
monitor_user_id = get_monitor_id( trans, monitor_email )

Expand Down Expand Up @@ -339,13 +354,17 @@ def specified_month_all( self, trans, **kwd ):
row.date
) )

pages_found = ceil(len(jobs) / float(entries))
page_specs = PageSpec(entries, offset, page, pages_found)

return trans.fill_template( '/webapps/reports/jobs_specified_month_all.mako',
order=order,
arrow=arrow,
sort_id=sort_id,
month_label=month_label,
year_label=year_label,
month=month,
page_specs=page_specs,
jobs=jobs,
trends=trends,
is_user_jobs_only=monitor_user_id,
Expand Down Expand Up @@ -898,15 +917,6 @@ def job_info( self, trans, **kwd ):
job=job,
message=message )

@web.expose
def test( self, trans, **kwd ):
message = ''
order = "asc"

return trans.fill_template( '/webapps/reports/test.mako',
order=order,
message=message )

# ---- Utility methods -------------------------------------------------------


Expand Down
280 changes: 280 additions & 0 deletions templates/page_base.mako
@@ -0,0 +1,280 @@
<%doc>
This file defines methods for displaying information about pagination
</%doc>

<%def name="get_page_url( sort_id, order, *args, **kwargs )">
<a href="${h.url_for( controller=args[0], action=args[1], sort_id=sort_id, order=order, **kwargs )}">${kwargs.get("page")}</a>
</%def>

<%!
def get_raw_url(sort_id, order, *args, **kwargs):
return h.url_for( controller=args[0], action=args[1], sort_id=sort_id, order=order, **kwargs )
%>

<%def name="get_pages( sort_id, order, page_specs, *args, **kwargs )">
## Creates the page buttons
${get_page_script()}
${get_page_css()}
<div id="page_selector">
<div id="back_button">&#x219e;</div>
%for x in range(-2,3):
<%
page = int(page_specs.page) + x
pages_found = int(page_specs.pages_found)
%>
%if page > 0:
%if x == 0:
<div id="curr_button">${page}</div>
%elif page < page_specs.page + pages_found:
<%
entries = page_specs.entries
offset = page_specs.entries * (page - 1)
%>
%if x == -2 and page > 1:
<div class="miss_pages">...</div>
%endif
<div class="page_button">${get_page_url( sort_id, order, *args, page=page, offset=offset, entries=entries )}</div>
%if x == 2 and pages_found == 4:
<div class="miss_pages">...</div>
%endif
%endif
%endif
%endfor
<div id="next_button">&#x21a0;</div>
</div>
</%def>

<%def name="get_entry_selector(controller, action, entries, sort_id, order)">
<div id="entry_form" >
<form method="post" controller=${controller} action=${action}>
<input type="hidden" value=${sort_id} name="sort_id">
<input type="hidden" value=${order} name="order">
Max items:
<input id="entries_edit"
type="text"
name="entries"
value="${entries}">
</input>
<button id="entry_submit">Go</button>
</form>
</div>
</%def>

<%def name="get_page_css()">
<%doc>
Page Styling
</%doc>
<style>
#back_button, #next_button, #curr_button, .miss_pages, .page_button {
position: relative;
float: left;
height: 24px;
width: 23px;
margin: 0 -1px 0 0;
padding-top: 2.5px;
border: 1px solid #bfbfbf;
z-index: 0;
}
#curr_button {
background: #ebd9b2;
border: 1px solid #5f6990;
z-index: 1;
}
#back_button {
cursor: pointer;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
#next_button {
cursor: pointer;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
#page_selector {
cursor: default;
position: relative;
text-align: center;
}
.page_button > a {
text-decoration: none;
padding: 8px;
margin: -8px;
height: 100%;
width: 100%;
}
#formHeader > tbody > tr {
vertical-align: middle;
}
</style>
<%doc>
Entry Styling
</%doc>
<style>
#entries_edit {
position: relative;
padding: 0;
width: 36px;
height: 20px;
text-align: center;
border: 1px solid black;
border-radius: 3px;
z-index: 6;
}
#entry_submit {
cursor: default;
position: relative;
display: inline-block;
border: 1px solid black;
padding: 0;
width: 22px;
height: 22px;
border-radius: 11px;
background-color: #ebd9b2;
text-align: center;
opacity: 0.0;
z-index: 0;
}
</style>
</%def>

<%def name="get_page_script()">
<script>
$(document).ready( function(e) {
var drop_down = false;
//Close the dropdown in the event of focusout() from entries edit
$("#entries_edit").focusout( function(e) {
var speed = 50;
$("#entry_submit").css("cursor", "default");
$("#entry_submit").fadeTo(speed, 0.0);
$(".st4").animate({top: "-=18px"}, {duration: speed, queue: false, complete: function() {
$(".st3").animate({top: "-=18px"}, {duration: speed, queue: false, complete: function() {
$(".st2").animate({top: "-=18px"}, {duration: speed, queue: false, complete: function() {
$(".st1").animate({top: "-=18px"}, {duration: speed, queue: false, complete: function() {
$(".st1").remove()
}});
}});
}});
}});
drop_down = false;
});
//Make sure the elements stay correctly positioned
$("#formHeader").css("margin-left", $(".colored").css("margin-left"));
$("#formHeader").css("width", $(".colored").css("width"));
$(window).resize( function(e) {
$("#formHeader").css("margin-left", $(".colored").css("margin-left"));
$("#formHeader").css("width", $(".colored").css("width"));
//Remove drop down for entry amount selection
$(".st1").remove();
$("#entry_submit").css("cursor", "default");
$("#entry_submit").css("opacity", "0.0");
$("#entry_submit").blur();
drop_down = false;
});
//If there are pages to go back to, go back
if( $("#curr_button").html() == 1) {
$("#back_button").css( "cursor", "default" );
$("#back_button").css( "color", "grey" );
}
$("#back_button").click( function(e) {
if( $("#curr_button").html() != 1) {
window.open( $(".page_button:first").children().attr("href"), "_self" );
}
});
//If there is a next page, go to the next page
if( ${int(page_specs.pages_found)} == 1 ) {
$("#next_button").css( "cursor", "default" );
$("#next_button").css( "color", "grey" );
}
$("#next_button").click( function(e) {
if( ${int(page_specs.pages_found)} > 1 ) {
window.open( $(".page_button:last").children().attr("href"), "_self" );
}
});
//Select amount of entries per page
$("#entry_form").on( "mousedown", ".st1", function(e) {
e.preventDefault();
$("#entries_edit").val( $(this).html() );
});
$("#entry_form").on("mouseenter", ".st1", function(e) {
$(this).css({
"border-color": "black",
"background-color": "#ebd9b2",
})
});
$("#entry_form").on("mouseleave", ".st1", function(e) {
$(this).css({
"border-color": "grey",
"background-color": "white",
})
});
$("#entries_edit").click( function(e) {
if(!drop_down) {
//Initialize items
$("#entries_edit").parent().append("<div class=\"st1\"\">10</div>");
$("#entries_edit").parent().append("<div class=\"st1 st2\">25</div>");
$("#entries_edit").parent().append("<div class=\"st1 st2 st3\">50</div>");
$("#entries_edit").parent().append("<div class=\"st1 st2 st3 st4\">100</div>");
$("#entry_submit").css("cursor", "pointer");
var top_pos = $("#entries_edit").offset().top;
var left_pos = $("#entries_edit").offset().left;
$(".st1").css({
"cursor": "pointer",
"position": "absolute",
"text-align": "center",
"border": "1px solid grey",
"background-color": "white",
"margin-left": "3px",
"top": top_pos,
"left": left_pos,
"width": "30px",
"z-index": "4",
});
$(".st1").css({
"top": $("#entries_edit").offset().top,
});
$(".st2").css({"z-index": "3"})
$(".st3").css({"z-index": "2"})
$(".st4").css({
"z-index": "1",
"border-bottom-left-radius": "3px",
"border-bottom-right-radius": "3px",
});
//Anitmate items
var speed = 50;
$("#entry_submit").fadeTo(speed, 1.0);
$(".st1").animate({top: "+=18px"}, speed);
$(".st2").animate({top: "+=18px"}, speed);
$(".st3").animate({top: "+=18px"}, speed);
$(".st4").animate({top: "+=18px"}, speed);
}
drop_down = true;
});
});
</script>
</%def>
4 changes: 3 additions & 1 deletion templates/sorting_base.mako
Expand Up @@ -3,8 +3,10 @@
if sort_id == test_id:
if order == "asc":
tool_order = "desc"
else:
elif order == "desc":
tool_order = "asc"
else:
tool_order = "default"
else:
tool_order = "default"
%>
Expand Down

0 comments on commit 48931a6

Please sign in to comment.