PageRenderTime 32ms CodeModel.GetById 22ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

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