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