/templates/root/history_common.mako

https://bitbucket.org/cistrome/cistrome-harvard/ · Mako · 305 lines · 274 code · 19 blank · 12 comment · 2 complexity · c962b9a0b36366e97114953ea25b38c7 MD5 · raw file

  1. <% _=n_ %>
  2. <%def name="render_download_links( data, dataset_id )">
  3. <%
  4. from galaxy.datatypes.metadata import FileParameter
  5. %>
  6. %if not data.purged:
  7. ## Check for downloadable metadata files
  8. <% meta_files = [ k for k in data.metadata.spec.keys() if isinstance( data.metadata.spec[k].param, FileParameter ) ] %>
  9. %if meta_files:
  10. <div popupmenu="dataset-${dataset_id}-popup">
  11. <a class="action-button" href="${h.url_for( controller='dataset', action='display', dataset_id=dataset_id, \
  12. to_ext=data.ext )}">Download Dataset</a>
  13. <a>Additional Files</a>
  14. %for file_type in meta_files:
  15. <a class="action-button" href="${h.url_for( controller='dataset', action='get_metadata_file', \
  16. hda_id=dataset_id, metadata_name=file_type )}">Download ${file_type}</a>
  17. %endfor
  18. </div>
  19. <div style="float:left;" class="menubutton split popup" id="dataset-${dataset_id}-popup">
  20. %endif
  21. <a href="${h.url_for( controller='dataset', action='display', dataset_id=dataset_id, to_ext=data.ext )}" title="Download" class="icon-button disk tooltip"></a>
  22. %if meta_files:
  23. </div>
  24. %endif
  25. %endif
  26. </%def>
  27. ## Render the dataset `data` as history item, using `hid` as the displayed id
  28. <%def name="render_dataset( data, hid, show_deleted_on_refresh = False, for_editing = True, display_structured = False )">
  29. <%
  30. dataset_id = trans.security.encode_id( data.id )
  31. if data.state in ['no state','',None]:
  32. data_state = "queued"
  33. else:
  34. data_state = data.state
  35. current_user_roles = trans.get_current_user_roles()
  36. can_edit = not ( data.deleted or data.purged )
  37. %>
  38. %if not trans.user_is_admin() and not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ):
  39. <div class="historyItemWrapper historyItem historyItem-${data_state} historyItem-noPermission" id="historyItem-${dataset_id}">
  40. %else:
  41. <div class="historyItemWrapper historyItem historyItem-${data_state}" id="historyItem-${dataset_id}">
  42. %endif
  43. %if data.deleted or data.purged or data.dataset.purged:
  44. <div class="warningmessagesmall"><strong>
  45. %if data.dataset.purged or data.purged:
  46. This dataset has been deleted and removed from disk.
  47. %else:
  48. This dataset has been deleted.
  49. %if for_editing:
  50. Click <a href="${h.url_for( controller='dataset', action='undelete', dataset_id=dataset_id )}" class="historyItemUndelete" id="historyItemUndeleter-${dataset_id}" target="galaxy_history">here</a> to undelete
  51. %if trans.app.config.allow_user_dataset_purge:
  52. or <a href="${h.url_for( controller='dataset', action='purge', dataset_id=dataset_id )}" class="historyItemPurge" id="historyItemPurger-${dataset_id}" target="galaxy_history">here</a> to immediately remove it from disk.
  53. %else:
  54. it.
  55. %endif
  56. %endif
  57. %endif
  58. </strong></div>
  59. %endif
  60. %if data.visible is False:
  61. <div class="warningmessagesmall">
  62. <strong>This dataset has been hidden. Click <a href="${h.url_for( controller='dataset', action='unhide', dataset_id=dataset_id )}" class="historyItemUnhide" id="historyItemUnhider-${dataset_id}" target="galaxy_history">here</a> to unhide.</strong>
  63. </div>
  64. %endif
  65. ## Header row for history items (name, state, action buttons)
  66. <div style="overflow: hidden;" class="historyItemTitleBar">
  67. <div class="historyItemButtons">
  68. %if data_state == "upload":
  69. ## TODO: Make these CSS, just adding a "disabled" class to the normal
  70. ## links should be enough. However the number of datasets being uploaded
  71. ## at a time is usually small so the impact of these images is also small.
  72. <span title='Display Data' class='icon-button display_disabled tooltip'></span>
  73. %if for_editing:
  74. <span title='Edit Attributes' class='icon-button edit_disabled tooltip'></span>
  75. %endif
  76. %else:
  77. <%
  78. if for_editing:
  79. display_url = h.url_for( controller='dataset', action='display', dataset_id=dataset_id, preview=True, filename='' )
  80. else:
  81. # Get URL for display only.
  82. if data.history.user and data.history.user.username:
  83. display_url = h.url_for( controller='dataset', action='display_by_username_and_slug',
  84. username=data.history.user.username, slug=dataset_id )
  85. else:
  86. # HACK: revert to for_editing display URL when there is no user/username. This should only happen when
  87. # there's no user/username because dataset is being displayed by history/view after error reported.
  88. # There are no security concerns here because both dataset/display and dataset/display_by_username_and_slug
  89. # check user permissions (to the same degree) before displaying.
  90. display_url = h.url_for( controller='dataset', action='display', dataset_id=dataset_id, preview=True, filename='' )
  91. %>
  92. %if data.purged:
  93. <span class="icon-button display_disabled tooltip" title="Cannoy display datasets removed from disk"></span>
  94. %else:
  95. <a class="icon-button display tooltip" title="Display data in browser" href="${display_url}"
  96. %if for_editing:
  97. target="galaxy_main"
  98. %endif
  99. ></a>
  100. %endif
  101. %if for_editing:
  102. %if data.deleted and not data.purged:
  103. <span title="Undelete dataset to edit attributes" class="icon-button edit_disabled tooltip"></span>
  104. %elif data.purged:
  105. <span title="Cannot edit attributes of datasets removed from disk" class="icon-button edit_disabled tooltip"></span>
  106. %else:
  107. <a class="icon-button edit tooltip" title="Edit attributes" href="${h.url_for( controller='dataset', action='edit', dataset_id=dataset_id )}" target="galaxy_main"></a>
  108. %endif
  109. %endif
  110. %endif
  111. %if for_editing:
  112. %if can_edit:
  113. <a class="icon-button delete tooltip" title="Delete" href="${h.url_for( controller='dataset', action='delete', dataset_id=dataset_id, show_deleted_on_refresh=show_deleted_on_refresh )}" id="historyItemDeleter-${dataset_id}"></a>
  114. %else:
  115. <span title="Dataset is already deleted" class="icon-button delete_disabled tooltip"></span>
  116. %endif
  117. %endif
  118. </div>
  119. <span class="state-icon"></span>
  120. <span class="historyItemTitle">${hid}: ${data.display_name()}</span>
  121. </div>
  122. ## Body for history items, extra info and actions, data "peek"
  123. <div id="info${data.id}" class="historyItemBody">
  124. %if not trans.user_is_admin() and not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ):
  125. <div>You do not have permission to view this dataset.</div>
  126. %elif data_state == "upload":
  127. <div>Dataset is uploading</div>
  128. %elif data_state == "queued":
  129. <div>${_('Job is waiting to run')}</div>
  130. <div>
  131. <a href="${h.url_for( controller='dataset', action='show_params', dataset_id=dataset_id )}" target="galaxy_main" title="View Details" class="icon-button information tooltip"></a>
  132. %if for_editing:
  133. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  134. %endif
  135. </div>
  136. %elif data_state == "running":
  137. <div>${_('Job is currently running')}</div>
  138. <div>
  139. <a href="${h.url_for( controller='dataset', action='show_params', dataset_id=dataset_id )}" target="galaxy_main" title="View Details" class="icon-button information tooltip"></a>
  140. %if for_editing:
  141. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  142. %endif
  143. </div>
  144. %elif data_state == "error":
  145. <div>
  146. An error occurred running this job: <i>${data.display_info().strip()}</i>
  147. </div>
  148. <div>
  149. %if for_editing:
  150. <a href="${h.url_for( controller='dataset', action='errors', id=data.id )}" target="galaxy_main" title="View or report this error" class="icon-button bug tooltip"></a>
  151. %endif
  152. %if data.has_data():
  153. ${render_download_links( data, dataset_id )}
  154. %endif
  155. <a href="${h.url_for( controller='dataset', action='show_params', dataset_id=dataset_id )}" target="galaxy_main" title="View Details" class="icon-button information tooltip"></a>
  156. %if for_editing:
  157. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  158. %endif
  159. </div>
  160. %elif data_state == "discarded":
  161. <div>
  162. The job creating this dataset was cancelled before completion.
  163. </div>
  164. %elif data_state == 'setting_metadata':
  165. <div>${_('Metadata is being Auto-Detected.')}</div>
  166. %elif data_state == "empty":
  167. <div>${_('No data: ')}<i>${data.display_info()}</i></div>
  168. <div>
  169. <a href="${h.url_for( controller='dataset', action='show_params', dataset_id=dataset_id )}" target="galaxy_main" title="View Details" class="icon-button information tooltip"></a>
  170. %if for_editing:
  171. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  172. %endif
  173. </div>
  174. %elif data_state in [ "ok", "failed_metadata" ]:
  175. %if data_state == "failed_metadata":
  176. <div class="warningmessagesmall" style="margin: 4px 0 4px 0">
  177. An error occurred setting the metadata for this dataset.
  178. %if can_edit:
  179. You may be able to <a href="${h.url_for( controller='dataset', action='edit', dataset_id=dataset_id )}" target="galaxy_main">set it manually or retry auto-detection</a>.
  180. %endif
  181. </div>
  182. %endif
  183. <div>
  184. ${data.blurb}<br />
  185. format: <span class="${data.ext}">${data.ext}</span>,
  186. database:
  187. %if data.dbkey == '?' and can_edit:
  188. <a href="${h.url_for( controller='dataset', action='edit', dataset_id=dataset_id )}" target="galaxy_main">${_(data.dbkey)}</a>
  189. %else:
  190. <span class="${data.dbkey}">${_(data.dbkey)}</span>
  191. %endif
  192. </div>
  193. %if data.display_info():
  194. <div class="info">${_('Info: ')}${data.display_info()}</div>
  195. %endif
  196. <div>
  197. %if data.has_data():
  198. ${render_download_links( data, dataset_id )}
  199. <a href="${h.url_for( controller='dataset', action='show_params', dataset_id=dataset_id )}" target="galaxy_main" title="View Details" class="icon-button information tooltip"></a>
  200. %if for_editing:
  201. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  202. %if app.config.get_bool( 'enable_tracks', False ) and data.ext in app.datatypes_registry.get_available_tracks():
  203. <%
  204. if data.dbkey != '?':
  205. data_url = h.url_for( controller='tracks', action='list_tracks', dbkey=data.dbkey )
  206. data_url = data_url.replace( 'dbkey', 'f-dbkey' )
  207. else:
  208. data_url = h.url_for( controller='tracks', action='list_tracks' )
  209. %>
  210. <a data-url="${data_url}" class="icon-button vis-chart tooltip trackster-add"
  211. action-url="${h.url_for( controller='tracks', action='browser', dataset_id=dataset_id)}"
  212. new-url="${h.url_for( controller='tracks', action='index', dataset_id=dataset_id, default_dbkey=data.dbkey)}" title="Visualize in Trackster"></a>
  213. %endif
  214. %if trans.user:
  215. %if not display_structured:
  216. <div style="float: right">
  217. <a href="${h.url_for( controller='tag', action='retag', item_class=data.__class__.__name__, item_id=dataset_id )}" target="galaxy_main" title="Edit dataset tags" class="icon-button tags tooltip"></a>
  218. <a href="${h.url_for( controller='dataset', action='annotate', id=dataset_id )}" target="galaxy_main" title="Edit dataset annotation" class="icon-button annotate tooltip"></a>
  219. </div>
  220. %endif
  221. <div style="clear: both"></div>
  222. <div class="tag-area" style="display: none">
  223. <strong>Tags:</strong>
  224. <div class="tag-elt"></div>
  225. </div>
  226. <div id="${dataset_id}-annotation-area" class="annotation-area" style="display: none">
  227. <strong>Annotation:</strong>
  228. <div id="${dataset_id}-annotation-elt" style="margin: 1px 0px 1px 0px" class="annotation-elt tooltip editable-text" title="Edit dataset annotation"></div>
  229. </div>
  230. %endif
  231. %else:
  232. ## When displaying datasets for viewing, this is often needed to prevent peek from overlapping
  233. ## icons.
  234. <div style="clear: both"></div>
  235. %endif
  236. <div style="clear: both"></div>
  237. %for display_app in data.datatype.get_display_types():
  238. <% target_frame, display_links = data.datatype.get_display_links( data, display_app, app, request.base ) %>
  239. %if len( display_links ) > 0:
  240. ${data.datatype.get_display_label(display_app)}
  241. %for display_name, display_link in display_links:
  242. <a target="${target_frame}" href="${display_link}">${_(display_name)}</a>
  243. %endfor
  244. <br />
  245. %endif
  246. %endfor
  247. %for display_app in data.get_display_applications( trans ).itervalues():
  248. ${display_app.name}
  249. %for link_app in display_app.links.itervalues():
  250. <a target="${link_app.url.get( 'target_frame', '_blank' )}" href="${link_app.get_display_url( data, trans )}">${_(link_app.name)}</a>
  251. %endfor
  252. <br />
  253. %endfor
  254. %elif for_editing:
  255. <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a>
  256. %endif
  257. </div>
  258. %if data.peek != "no peek":
  259. <div><pre id="peek${data.id}" class="peek">${_(h.to_unicode(data.display_peek()))}</pre></div>
  260. %endif
  261. %else:
  262. <div>${_('Error: unknown dataset state "%s".') % data_state}</div>
  263. %endif
  264. ## Recurse for child datasets
  265. %if len( data.children ) > 0:
  266. ## FIXME: This should not be in the template, there should
  267. ## be a 'visible_children' method on dataset.
  268. <%
  269. children = []
  270. for child in data.children:
  271. if child.visible:
  272. children.append( child )
  273. %>
  274. %if len( children ) > 0:
  275. <div>
  276. There are ${len( children )} secondary datasets.
  277. %for idx, child in enumerate(children):
  278. ${render_dataset( child, idx + 1, show_deleted_on_refresh = show_deleted_on_refresh )}
  279. %endfor
  280. </div>
  281. %endif
  282. %endif
  283. <div style="clear: both;"></div>
  284. </div>
  285. </div>
  286. </%def>