PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

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