PageRenderTime 29ms CodeModel.GetById 19ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/history/display_structured.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 131 lines | 112 code | 19 blank | 0 comment | 8 complexity | e89bc0172fd0f898af2d1213c81d1427 MD5 | raw file
  1<%inherit file="/base.mako"/>
  2<%namespace file="/root/history_common.mako" import="render_dataset" />
  3
  4<%def name="stylesheets()">
  5    ${parent.stylesheets()}
  6    ${h.css( "history" )}
  7    <style type="text/css">
  8        body {
  9            background: white;
 10            padding: 5px;
 11        }
 12        
 13        .clickable {
 14            cursor: pointer;
 15        }
 16        
 17        .workflow {
 18            border: solid gray 1px;
 19            margin: 5px 0;
 20            border-left-width: 5px;
 21        }
 22        
 23        .workflow > .header {
 24            background: lightgray;
 25            padding: 5px 10px;
 26            
 27            font-weight: bold;
 28        }
 29        
 30        .workflow > .body {
 31            border-top: solid gray 1px;
 32            padding: 5px;
 33        }
 34        
 35        div.toolForm {
 36            margin: 5px 0;
 37            border-left-width: 5px;
 38        }
 39        div.toolFormBody {
 40            padding: 5px 5px;
 41        }
 42    </style>
 43</%def>
 44
 45<%def name="javascripts()">
 46    ${parent.javascripts()}
 47    <script type="text/javascript">
 48        $(function(){
 49            
 50            $(".workflow, .tool").each( function() {
 51                var body = $(this).children( ".body" );
 52                $(this).children( ".header" ).click( function() {
 53                    body.toggle();
 54                }).addClass( "clickable" );
 55                // body.hide();
 56            });
 57            
 58            $(".historyItem").each( function() {
 59                var id = this.id;
 60                var body = $(this).children( "div.historyItemBody" );
 61                var peek = body.find( "pre.peek" )
 62                $(this).children( ".historyItemTitleBar" ).find( ".historyItemTitle" ).wrap( "<a href='#'></a>" ).click( function() {
 63                    if ( body.is(":visible") ) {
 64                        // Hiding stuff here
 65                        if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ) }
 66                        body.slideUp( "fast" );
 67                    } else {
 68                        // Showing stuff here
 69                        body.slideDown( "fast", function() { 
 70                            if ( $.browser.mozilla ) { peek.css( "overflow", "auto" ); } 
 71                        });
 72                    }
 73                    return false;
 74                });
 75                body.hide();
 76            });
 77        });    
 78    </script>
 79</%def>
 80
 81<%def name="render_item( entity, children )">
 82<%
 83entity_name = entity.__class__.__name__
 84if entity_name == "HistoryDatasetAssociation":
 85    render_item_hda( entity, children )
 86elif entity_name == "Job":
 87    render_item_job( entity, children )
 88elif entity_name == "WorkflowInvocation":
 89    render_item_wf( entity, children )
 90%>
 91</%def>
 92
 93<%def name="render_item_hda( hda, children  )">
 94    ${render_dataset( hda, hda.hid, display_structured=True )}
 95</%def>
 96
 97<%def name="render_item_job( job, children  )">
 98
 99    <div class="tool toolForm">
100        <%
101            if job.tool_id in trans.app.toolbox.tools_by_id:
102                tool_name = trans.app.toolbox.tools_by_id[job.tool_id].name
103            else:
104                tool_name = "Unknown tool with id '%s'" % job.tool_id       
105        %>
106        <div class="header toolFormTitle">Tool: ${tool_name}</div>
107        <div class="body toolFormBody">
108        %for e, c in reversed( children ):
109            ${render_item( e, c )}
110        %endfor
111        </div>
112    </div>
113
114</%def>
115
116<%def name="render_item_wf( wf, children )">
117
118    <div class="workflow">
119        <div class="header">Workflow: ${wf.workflow.name}</div>
120        <div class="body">
121        %for e, c in reversed( children ):
122            ${render_item( e, c )}
123        %endfor
124        </div>
125    </div>
126
127</%def>
128
129%for entity, children in items:
130    ${render_item( entity, children )}
131%endfor