PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/root/index.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 243 lines | 218 code | 22 blank | 3 comment | 6 complexity | 1a192558c6640a1f27e44c623564ef55 MD5 | raw file
  1<%inherit file="/webapps/galaxy/base_panels.mako"/>
  2
  3<%def name="late_javascripts()">
  4    ${parent.late_javascripts()}
  5    <script type="text/javascript">
  6    // Set up GalaxyAsync object.
  7    var galaxy_async = new GalaxyAsync();
  8    galaxy_async.set_func_url(galaxy_async.set_user_pref, "${h.url_for( controller='user', action='set_user_pref_async' )}");
  9    
 10    $(function(){
 11        // Init history options.
 12        $("#history-options-button").css( "position", "relative" );
 13        make_popupmenu( $("#history-options-button"), {
 14            "History Lists": null,
 15            "Saved Histories": function() {
 16                galaxy_main.location = "${h.url_for( controller='history', action='list')}";
 17            },
 18            "Histories Shared with Me": function() {
 19                galaxy_main.location = "${h.url_for( controller='history', action='list_shared')}";
 20            },
 21            "Current History": null,
 22            "Create New": function() {
 23                galaxy_history.location = "${h.url_for( controller='root', action='history_new' )}";
 24            },
 25            "Clone": function() {
 26                galaxy_main.location = "${h.url_for( controller='history', action='clone')}";
 27            },
 28            "Copy Datasets": function() {
 29                galaxy_main.location = "${h.url_for( controller='dataset', action='copy_datasets' )}";
 30            },
 31            "Share or Publish": function() {
 32                galaxy_main.location = "${h.url_for( controller='history', action='sharing' )}";
 33            },
 34            "Extract Workflow": function() {
 35                galaxy_main.location = "${h.url_for( controller='workflow', action='build_from_current_history' )}";
 36            },
 37            "Dataset Security": function() {
 38                galaxy_main.location = "${h.url_for( controller='root', action='history_set_default_permissions' )}";
 39            },
 40            "Show Deleted Datasets": function() {
 41                galaxy_history.location = "${h.url_for( controller='root', action='history', show_deleted=True)}";
 42            },
 43            "Show Hidden Datasets": function() {
 44                galaxy_history.location = "${h.url_for( controller='root', action='history', show_hidden=True)}";
 45            },
 46            "Show Structure": function() {
 47                galaxy_main.location = "${h.url_for( controller='history', action='display_structured' )}";
 48            },
 49            "Export to File": function() {
 50                galaxy_main.location = "${h.url_for( controller='history', action='export_archive' )}";
 51            },
 52            "Delete": function() {
 53                if ( confirm( "Really delete the current history?" ) ) {
 54                    galaxy_main.location = "${h.url_for( controller='history', action='delete_current' )}";
 55                }
 56            },
 57            "Other Actions": null,
 58            "Import from File": function() {
 59                galaxy_main.location = "${h.url_for( controller='history', action='import_archive' )}";
 60            }
 61        });
 62        
 63        var menu_options = {}; // Holds dictionary of { label: toggle_fn }
 64        
 65        SHOW_TOOL = "Show Tool Search";
 66        HIDE_TOOL = "Hide Tool Search";
 67        SHOW_RECENT = "Show Recently Used";
 68        HIDE_RECENT = "Hide Recently Used";
 69        
 70        var toggle_tool_search_fn = function() {
 71            // Show/hide menu and update vars, user preferences.
 72            var menu = $("#galaxy_tools").contents().find('#tool-search'),
 73                pref_value, menu_option_text, old_text;
 74            if (menu.is(":visible")) {
 75                // Hide menu.
 76                pref_value = "False";
 77                menu_option_text = SHOW_TOOL;
 78                old_text = HIDE_TOOL;
 79                
 80                // Reset search.
 81                reset_tool_search(true);
 82            } else {
 83                // Show menu.
 84                pref_value = "True";
 85                menu_option_text = HIDE_TOOL;
 86                old_text = SHOW_TOOL;
 87            }
 88            menu.toggle();
 89    
 90            // Update menu option.
 91            delete menu_options[old_text];
 92            
 93            var new_menu_options = {}; 
 94            // Because we always want tool menu to be the first link in the dropdown,
 95            // we re-create the menu_options dictionary by creating a new
 96            // dict and then appending the old dict to it
 97            new_menu_options[menu_option_text] = toggle_tool_search_fn;
 98            menu_options = $.extend( new_menu_options, menu_options );
 99            make_popupmenu( $("#tools-options-button"), menu_options );
100            galaxy_async.set_user_pref("show_tool_search", pref_value);
101        };
102        
103        var toggle_recently_used_fn = function() {
104            // Show/hide menu.
105            var ru_menu = $('#galaxy_tools').contents().find('#recently_used_wrapper'),
106                ru_menu_body = ru_menu.find(".toolSectionBody"),
107                pref_value, old_text, menu_option_text;
108            if (ru_menu.hasClass("user_pref_visible")) {
109                // Hide menu.
110                ru_menu_body.slideUp();
111                ru_menu.slideUp();
112                
113                // Set vars used below and in tool menu frame.
114                pref_value = "False";
115                old_text = HIDE_RECENT;
116                menu_option_text = SHOW_RECENT;
117            } else {
118                // "Show" menu.
119                if (!$('#galaxy_tools').contents().find('#tool-search-query').hasClass("search_active")) {
120                    // Default.
121                    ru_menu.slideDown();
122                } else {
123                    // Search active: tf there are matching tools in RU menu, show menu.
124                    if ( ru_menu.find(".toolTitle.search_match").length !== 0 ) {
125                        ru_menu.slideDown();
126                        ru_menu_body.slideDown();
127                    }
128                }
129                // Set vars used below and in tool menu frame.
130                pref_value = "True";
131                old_text = SHOW_RECENT;
132                menu_option_text = HIDE_RECENT;
133            }
134            
135            // Update menu class and option.
136            ru_menu.toggleClass("user_pref_hidden user_pref_visible");
137            delete menu_options[old_text];
138            menu_options[menu_option_text] = toggle_recently_used_fn;
139            make_popupmenu( $("#tools-options-button"), menu_options );
140            galaxy_async.set_user_pref("show_recently_used_menu", pref_value);
141        };
142        
143        // Init tool options.
144        ## Search tools menu item.
145        %if trans.app.toolbox_search.enabled:
146            <% 
147                show_tool_search = True
148                if trans.user:
149                    show_tool_search = trans.user.preferences.get( "show_tool_search", "False" ) == "True"
150                    
151                if show_tool_search:
152                    action = "HIDE_TOOL"
153                else:
154                    action = "SHOW_TOOL"
155            %>
156            menu_options[ ${action} ] = toggle_tool_search_fn;
157        %endif
158        ## Recently used tools menu.
159        %if trans.user:
160            <%
161                if trans.user.preferences.get( 'show_recently_used_menu', 'False' ) == 'True':
162                    action = "HIDE_RECENT"
163                else:
164                    action = "SHOW_RECENT"
165            %>
166            menu_options[ ${action} ] = toggle_recently_used_fn;
167        %endif
168        
169        
170        make_popupmenu( $("#tools-options-button"), menu_options );
171    });
172    </script>
173</%def>
174
175<%def name="init()">
176<%
177    if trans.app.config.cloud_controller_instance:
178        self.has_left_panel=False
179        self.has_right_panel=False
180        self.active_view="cloud"
181    else:
182        self.has_left_panel=True
183        self.has_right_panel=True
184        self.active_view="analysis"
185%>
186%if trans.app.config.require_login and not trans.user:
187    <script type="text/javascript">
188        if ( window != top ) {
189            top.location.href = location.href;
190        }
191    </script>
192%endif
193</%def>
194
195<%def name="left_panel()">
196    <div class="unified-panel-header" unselectable="on">
197        <div class='unified-panel-header-inner'>
198            <div style="float: right">
199                <a class='panel-header-button popup' id="tools-options-button" href="#">${_('Options')}</a>
200            </div>
201            ${n_('Tools')}
202        </div>
203    </div>
204    <div class="unified-panel-body" style="overflow: hidden;">
205        <iframe name="galaxy_tools" id="galaxy_tools" src="${h.url_for( controller='root', action='tool_menu' )}" frameborder="0" style="position: absolute; margin: 0; border: 0 none; height: 100%; width: 100%;"> </iframe>
206    </div>
207</%def>
208
209<%def name="center_panel()">
210
211    ## If a specific tool id was specified, load it in the middle frame
212    <%
213    if trans.app.config.require_login and not trans.user:
214        center_url = h.url_for( controller='user', action='login' )
215    elif tool_id is not None:
216        center_url = h.url_for( 'tool_runner', tool_id=tool_id, from_noframe=True )
217    elif workflow_id is not None:
218        center_url = h.url_for( controller='workflow', action='run', id=workflow_id )
219    elif m_c is not None:
220        center_url = h.url_for( controller=m_c, action=m_a )
221    elif trans.app.config.cloud_controller_instance:
222        center_url = h.url_for( controller='cloud', action='list' )
223    else:
224        center_url = h.url_for( '/static/welcome.html' )
225    %>
226    
227    <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${center_url}"> </iframe>
228
229</%def>
230
231<%def name="right_panel()">
232    <div class="unified-panel-header" unselectable="on">
233        <div class="unified-panel-header-inner">
234            <div style="float: right">
235                <a id="history-options-button" class='panel-header-button popup' href="${h.url_for( controller='root', action='history_options' )}" target="galaxy_main">${_('Options')}</a>
236            </div>
237            <div class="panel-header-text">${_('History')}</div>
238        </div>
239    </div>
240    <div class="unified-panel-body" style="overflow: hidden;">
241        <iframe name="galaxy_history" width="100%" height="100%" frameborder="0" style="position: absolute; margin: 0; border: 0 none; height: 100%;" src="${h.url_for( controller='root', action='history' )}"></iframe>
242    </div>
243</%def>