/templates/library/common/common.mako

https://bitbucket.org/h_morita_dbcls/galaxy-central · Mako · 415 lines · 407 code · 2 blank · 6 comment · 3 complexity · 2a358aef0fcdb3b1eeac5df8a35b0ccd MD5 · raw file

  1. <%def name="render_template_info( cntrller, item_type, library_id, widgets, info_association, inherited, folder_id=None, ldda_id=None, editable=True )">
  2. <%
  3. if item_type == 'library':
  4. item = trans.sa_session.query( trans.app.model.Library ).get( trans.security.decode_id( library_id ) )
  5. elif item_type == 'folder':
  6. item = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) )
  7. elif item_type == 'ldda':
  8. item = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
  9. if trans.user_is_admin() and cntrller == 'library_admin':
  10. can_modify = True
  11. elif cntrller == 'library':
  12. can_modify = trans.app.security_agent.can_modify_library_item( trans.get_current_user_roles(), item )
  13. else:
  14. can_modify = False
  15. %>
  16. %if widgets:
  17. %if editable and can_modify:
  18. <p/>
  19. <div class="toolForm">
  20. <div class="toolFormTitle">
  21. %if inherited:
  22. Other information <i>- this is an inherited template and is not required to be used with this ${item_type}</i>
  23. %else:
  24. Other information
  25. %endif
  26. %if info_association and not inherited and can_modify:
  27. ## "inherited" will be true only if the info_association is not associated with the current item,
  28. ## in which case we do not want to render the following popup menu.
  29. <a id="item-${item.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
  30. <div popupmenu="item-${item.id}-popup">
  31. <a class="action-button" href="${h.url_for( controller='library_common', action='edit_template', cntrller=cntrller, item_type=item_type, library_id=library_id, folder_id=folder_id, ldda_id=ldda_id, show_deleted=show_deleted )}">Edit template</a>
  32. <a class="action-button" href="${h.url_for( controller='library_common', action='delete_template', cntrller=cntrller, item_type=item_type, library_id=library_id, folder_id=folder_id, ldda_id=ldda_id, show_deleted=show_deleted )}">Delete template</a>
  33. %if item_type not in [ 'ldda', 'library_dataset' ]:
  34. %if info_association.inheritable:
  35. <a class="action-button" href="${h.url_for( controller='library_common', action='manage_template_inheritance', cntrller=cntrller, item_type=item_type, library_id=library_id, folder_id=folder_id, ldda_id=ldda_id, show_deleted=show_deleted )}">Dis-inherit template</a>
  36. %else:
  37. <a class="action-button" href="${h.url_for( controller='library_common', action='manage_template_inheritance', cntrller=cntrller, item_type=item_type, library_id=library_id, folder_id=folder_id, ldda_id=ldda_id, show_deleted=show_deleted )}">Inherit template</a>
  38. %endif
  39. %endif
  40. </div>
  41. %endif
  42. </div>
  43. <div class="toolFormBody">
  44. <form name="edit_info" action="${h.url_for( controller='library_common', action='edit_template_info', cntrller=cntrller, item_type=item_type, library_id=library_id, num_widgets=len( widgets ), folder_id=folder_id, ldda_id=ldda_id, show_deleted=show_deleted )}" method="post">
  45. %for i, field in enumerate( widgets ):
  46. <div class="form-row">
  47. <label>${field[ 'label' ]}</label>
  48. ${field[ 'widget' ].get_html()}
  49. <div class="toolParamHelp" style="clear: both;">
  50. ${field[ 'helptext' ]}
  51. </div>
  52. <div style="clear: both"></div>
  53. </div>
  54. %endfor
  55. <div class="form-row">
  56. <input type="submit" name="edit_info_button" value="Save"/>
  57. </div>
  58. </form>
  59. </div>
  60. </div>
  61. <p/>
  62. %else:
  63. <% contents = False %>
  64. %for i, field in enumerate( widgets ):
  65. %if field[ 'widget' ].value:
  66. <%
  67. contents = True
  68. break
  69. %>
  70. %endif
  71. %endfor
  72. %if contents:
  73. <p/>
  74. <div class="toolForm">
  75. <div class="toolFormTitle">Other information about ${item.name}</div>
  76. <div class="toolFormBody">
  77. %for i, field in enumerate( widgets ):
  78. %if field[ 'widget' ].value:
  79. <div class="form-row">
  80. <label>${field[ 'label' ]}</label>
  81. <pre>${field[ 'widget' ].value}</pre>
  82. <div class="toolParamHelp" style="clear: both;">
  83. ${field[ 'helptext' ]}
  84. </div>
  85. <div style="clear: both"></div>
  86. </div>
  87. %endif
  88. %endfor
  89. </div>
  90. </div>
  91. <p/>
  92. %endif
  93. %endif
  94. %endif
  95. </%def>
  96. <%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, widgets, roles, history, show_deleted )">
  97. <% import os, os.path %>
  98. %if upload_option in [ 'upload_file', 'upload_directory', 'upload_paths' ]:
  99. <div class="toolForm" id="upload_library_dataset">
  100. %if upload_option == 'upload_directory':
  101. <div class="toolFormTitle">Upload a directory of files</div>
  102. %elif upload_option == 'upload_paths':
  103. <div class="toolFormTitle">Upload files from filesystem paths</div>
  104. %else:
  105. <div class="toolFormTitle">Upload files</div>
  106. %endif
  107. <div class="toolFormBody">
  108. <form name="upload_library_dataset" action="${action}" enctype="multipart/form-data" method="post">
  109. <input type="hidden" name="tool_id" value="upload1"/>
  110. <input type="hidden" name="tool_state" value="None"/>
  111. <input type="hidden" name="cntrller" value="${cntrller}"/>
  112. <input type="hidden" name="library_id" value="${library_id}"/>
  113. <input type="hidden" name="folder_id" value="${folder_id}"/>
  114. <input type="hidden" name="upload_option" value="${upload_option}"/>
  115. <input type="hidden" name="show_deleted" value="${show_deleted}"/>
  116. %if replace_dataset not in [ None, 'None' ]:
  117. <input type="hidden" name="replace_id" value="${trans.security.encode_id( replace_dataset.id )}"/>
  118. <div class="form-row">
  119. You are currently selecting a new file to replace '<a href="${h.url_for( controller='library_common', action='ldda_info', cntrller=cntrller, library_id=library_id, folder_id=folder_id, id=trans.security.encode_id( replace_dataset.library_dataset_dataset_association.id ) )}">${replace_dataset.name}</a>'.
  120. <div style="clear: both"></div>
  121. </div>
  122. %endif
  123. <div class="form-row">
  124. <label>File Format:</label>
  125. <div class="form-row-input">
  126. <select name="file_type">
  127. <option value="auto" selected>Auto-detect</option>
  128. %for file_format in file_formats:
  129. <option value="${file_format}">${file_format}</option>
  130. %endfor
  131. </select>
  132. </div>
  133. <div style="clear: both"></div>
  134. </div>
  135. %if upload_option == 'upload_file':
  136. <div class="form-row">
  137. <input type="hidden" name="async_datasets" value="None"/>
  138. <div style="clear: both"></div>
  139. </div>
  140. <div class="form-row">
  141. <label>File:</label>
  142. <div class="form-row-input">
  143. <input type="file" name="files_0|file_data" galaxy-ajax-upload="true"/>
  144. </div>
  145. <div style="clear: both"></div>
  146. </div>
  147. <div class="form-row">
  148. <label>URL/Text:</label>
  149. <div class="form-row-input">
  150. <textarea name="files_0|url_paste" rows="5" cols="35"></textarea>
  151. </div>
  152. <div class="toolParamHelp" style="clear: both;">
  153. Specify a list of URLs (one per line) or paste the contents of a file.
  154. </div>
  155. <div style="clear: both"></div>
  156. </div>
  157. %elif upload_option == 'upload_directory':
  158. <%
  159. if ( trans.user_is_admin() and cntrller == 'library_admin' ):
  160. import_dir = trans.app.config.library_import_dir
  161. else:
  162. # Directories of files from the Data Libraries view are restricted to a
  163. # sub-directory named the same as the current user's email address
  164. # contained within the configured setting for user_library_import_dir
  165. import_dir = os.path.join( trans.app.config.user_library_import_dir, trans.user.email )
  166. %>
  167. <div class="form-row">
  168. <%
  169. # See if we have any contained sub-directories, if not the only option
  170. # in the server_dir select list will be library_import_dir
  171. contains_directories = False
  172. for entry in os.listdir( import_dir ):
  173. if os.path.isdir( os.path.join( import_dir, entry ) ):
  174. contains_directories = True
  175. break
  176. %>
  177. <label>Server Directory</label>
  178. <div class="form-row-input">
  179. <select name="server_dir">
  180. %if contains_directories:
  181. <option>None</option>
  182. %for entry in os.listdir( import_dir ):
  183. ## Do not include entries that are not directories
  184. %if os.path.isdir( os.path.join( import_dir, entry ) ):
  185. <option>${entry}</option>
  186. %endif
  187. %endfor
  188. %else:
  189. %if ( trans.user_is_admin() and cntrller == 'library_admin' ):
  190. <option>${import_dir}</option>
  191. %else:
  192. <option>${trans.user.email}</option>
  193. %endif
  194. %endif
  195. </select>
  196. </div>
  197. <div class="toolParamHelp" style="clear: both;">
  198. %if contains_directories:
  199. Upload all files in a sub-directory of <strong>${import_dir}</strong> on the Galaxy server.
  200. %else:
  201. Upload all files in <strong>${import_dir}</strong> on the Galaxy server.
  202. %endif
  203. </div>
  204. <div style="clear: both"></div>
  205. </div>
  206. %elif upload_option == 'upload_paths':
  207. <div class="form-row">
  208. <label>Paths to upload</label>
  209. <div class="form-row-input">
  210. <textarea name="filesystem_paths" rows="10" cols="35"></textarea>
  211. </div>
  212. <div class="toolParamHelp" style="clear: both;">
  213. Upload all files pasted in the box. The (recursive) contents of any pasted directories will be added as well.
  214. </div>
  215. </div>
  216. <div class="form-row">
  217. <label>Preserve directory structure?</label>
  218. <div class="form-row-input">
  219. <input type="checkbox" name="dont_preserve_dirs" value="No"/>No
  220. </div>
  221. <div class="toolParamHelp" style="clear: both;">
  222. If checked, all files in subdirectories on the filesystem will be placed at the top level of the folder, instead of into subfolders.
  223. </div>
  224. </div>
  225. %endif
  226. %if upload_option in ( 'upload_directory', 'upload_paths' ):
  227. <div class="form-row">
  228. <label>Copy data into Galaxy?</label>
  229. <div class="form-row-input">
  230. <input type="checkbox" name="link_data_only" value="No"/>No
  231. </div>
  232. <div class="toolParamHelp" style="clear: both;">
  233. Normally data uploaded with this tool is copied into Galaxy's "files" directory
  234. so any later changes to the data will not affect Galaxy. However, this may not
  235. be desired (especially for large NGS datasets), so use of this option will
  236. force Galaxy to always read the data from its original path.
  237. %if upload_option == 'upload_directory':
  238. Any symlinks encountered in the upload directory will be dereferenced once -
  239. that is, Galaxy will point directly to the file that is linked, but no other
  240. symlinks further down the line will be dereferenced.
  241. %endif
  242. </div>
  243. </div>
  244. %endif
  245. <div class="form-row">
  246. <label>
  247. Convert spaces to tabs:
  248. </label>
  249. <div class="form-row-input">
  250. ## The files grouping only makes sense in the upload_file context.
  251. %if upload_option == 'upload_file':
  252. <input type="checkbox" name="files_0|space_to_tab" value="Yes"/>Yes
  253. %else:
  254. <input type="checkbox" name="space_to_tab" value="Yes"/>Yes
  255. %endif
  256. </div>
  257. <div class="toolParamHelp" style="clear: both;">
  258. Use this option if you are entering intervals by hand.
  259. </div>
  260. </div>
  261. <div style="clear: both"></div>
  262. <div class="form-row">
  263. <label>Genome:</label>
  264. <div class="form-row-input">
  265. <select name="dbkey" last_selected_value="?">
  266. %for dbkey in dbkeys:
  267. %if dbkey[1] == last_used_build:
  268. <option value="${dbkey[1]}" selected>${dbkey[0]}</option>
  269. %else:
  270. <option value="${dbkey[1]}">${dbkey[0]}</option>
  271. %endif
  272. %endfor
  273. </select>
  274. </div>
  275. <div style="clear: both"></div>
  276. </div>
  277. <div class="form-row">
  278. <label>Message:</label>
  279. <div class="form-row-input">
  280. <textarea name="message" rows="3" cols="35"></textarea>
  281. </div>
  282. <div class="toolParamHelp" style="clear: both;">
  283. This information will be displayed in the "Information" column for this dataset in the data library browser
  284. </div>
  285. <div style="clear: both"></div>
  286. </div>
  287. %if roles:
  288. <div class="form-row">
  289. <label>Restrict dataset access to specific roles:</label>
  290. <div class="form-row-input">
  291. <select name="roles" multiple="true" size="5">
  292. %for role in roles:
  293. <option value="${role.id}">${role.name}</option>
  294. %endfor
  295. </select>
  296. </div>
  297. <div class="toolParamHelp" style="clear: both;">
  298. Multi-select list - hold the appropriate key while clicking to select multiple roles. More restrictions can be applied after the upload is complete. Selecting no roles makes a dataset public.
  299. </div>
  300. </div>
  301. <div style="clear: both"></div>
  302. %endif
  303. %if widgets:
  304. %for i, field in enumerate( widgets ):
  305. <div class="form-row">
  306. <label>${field[ 'label' ]}</label>
  307. <div class="form-row-input">
  308. ${field[ 'widget' ].get_html()}
  309. </div>
  310. <div class="toolParamHelp" style="clear: both;">
  311. %if field[ 'helptext' ]:
  312. ${field[ 'helptext' ]}<br/>
  313. %endif
  314. *Inherited template field
  315. </div>
  316. <div style="clear: both"></div>
  317. </div>
  318. %endfor
  319. %endif
  320. <div class="form-row">
  321. <input type="submit" class="primary-button" name="runtool_btn" value="Upload to library"/>
  322. </div>
  323. </form>
  324. </div>
  325. </div>
  326. ## Script to replace dbkey select with select+search.
  327. <script type="text/javascript">
  328. // Replace dbkey select with search+select.
  329. jQuery(document).ready( function() {
  330. replace_big_select_inputs();
  331. });
  332. </script>
  333. %elif upload_option == 'import_from_history':
  334. <div class="toolForm">
  335. <div class="toolFormTitle">Active datasets in your current history (${history.name})</div>
  336. <div class="toolFormBody">
  337. %if history and history.active_datasets:
  338. <form name="add_history_datasets_to_library" action="${h.url_for( controller='library_common', action='add_history_datasets_to_library', cntrller=cntrller, library_id=library_id )}" enctype="multipart/form-data" method="post">
  339. <input type="hidden" name="folder_id" value="${folder_id}"/>
  340. <input type="hidden" name="upload_option" value="${upload_option}"/>
  341. %if replace_dataset not in [ None, 'None' ]:
  342. <input type="hidden" name="replace_id" value="${trans.security.encode_id( replace_dataset.id )}"/>
  343. <div class="form-row">
  344. You are currently selecting a new file to replace '<a href="${h.url_for( controller='library_common', action='ldda_info', cntrller=cntrller, library_id=library_id, folder_id=folder_id, id=trans.security.encode_id( replace_dataset.library_dataset_dataset_association.id ) )}">${replace_dataset.name}</a>'.
  345. <div style="clear: both"></div>
  346. </div>
  347. %endif
  348. %for hda in history.active_datasets:
  349. <div class="form-row">
  350. <input name="hda_ids" value="${trans.security.encode_id( hda.id )}" type="checkbox"/>${hda.hid}: ${hda.name}
  351. </div>
  352. %endfor
  353. <div class="form-row">
  354. <input type="submit" name="add_history_datasets_to_library_button" value="Import to library"/>
  355. </div>
  356. </form>
  357. %else:
  358. <p/>
  359. Your current history is empty
  360. <p/>
  361. %endif
  362. </div>
  363. </div>
  364. %endif
  365. </%def>
  366. <%def name="render_actions_on_multiple_items()">
  367. <tfoot>
  368. <tr>
  369. <td colspan="4" style="padding-left: 42px;">
  370. For selected items:
  371. <select name="do_action" id="action_on_selected_items">
  372. %if ( trans.user_is_admin() and cntrller=='library_admin' ):
  373. <option value="manage_permissions">Edit permissions</option>
  374. <option value="delete">Delete</option>
  375. %elif cntrller=='library':
  376. %if default_action == 'add':
  377. <option value="add" selected>Import into your current history</option>
  378. %else:
  379. <option value="add">Import into your current history</option>
  380. %endif
  381. %if default_action == 'manage_permissions':
  382. <option value="manage_permissions" selected>Edit permissions</option>
  383. # This condition should not contain an else clause because the user is not authorized
  384. # to manage dataset permissions unless the default action is 'manage_permissions'
  385. %endif
  386. %if 'gz' in comptypes:
  387. <option value="tgz"
  388. %if default_action == 'download':
  389. selected
  390. %endif>
  391. >Download as a .tar.gz file</option>
  392. %endif
  393. %if 'bz2' in comptypes:
  394. <option value="tbz">Download as a .tar.bz2 file</option>
  395. %endif
  396. %if 'zip' in comptypes:
  397. <option value="zip">Download as a .zip file</option>
  398. %endif
  399. %if 'ngxzip' in comptypes:
  400. ## We can safely have two default selected items since ngxzip, if present, will always be the only available type.
  401. <option value="ngxzip"
  402. %if default_action == 'download':
  403. selected
  404. %endif>
  405. >Download as a .zip file</option>
  406. %endif
  407. %endif
  408. </select>
  409. <input type="submit" class="primary-button" name="action_on_datasets_button" id="action_on_datasets_button" value="Go"/>
  410. </td>
  411. </tr>
  412. </tfoot>
  413. </%def>