Example #1
0
 add: function(options) {
     if (!options.id || this.list[options.id]) {
         Galaxy.emit.debug("form-repeat::add()", "Duplicate or invalid repeat block id.");
         return;
     }
     var button_delete = new Ui.Button({
         icon: "fa-trash-o",
         tooltip: _l("Delete this repeat block"),
         cls: "ui-button-icon-plain form-repeat-delete",
         onclick: function() {
             if (options.ondel) {
                 options.ondel();
             }
         }
     });
     var portlet = new Portlet.View({
         id: options.id,
         title: _l("placeholder"),
         cls: options.cls || "ui-portlet-section",
         operations: { button_delete: button_delete }
     });
     portlet.append(options.$el);
     portlet.$el.addClass("section-row").hide();
     this.list[options.id] = portlet;
     this.$list.append(portlet.$el.fadeIn("fast"));
     if (this.options.max > 0 && this.size() >= this.options.max) {
         this.button_new.disable();
     }
     this._refresh();
 },
 _getDatatype: function() {
     var self = this;
     var form = new Form({
         title: _l("Change datatype"),
         operations: {
             submit_datatype: new Ui.Button({
                 tooltip: _l("Change the datatype to a new type."),
                 title: _l("Change datatype"),
                 icon: "fa-exchange",
                 onclick: function() {
                     self._submit("datatype", form);
                 }
             }),
             submit_datatype_detect: new Ui.Button({
                 tooltip: _l("Detect the datatype and change it."),
                 title: _l("Detect datatype"),
                 icon: "fa-undo",
                 onclick: function() {
                     self._submit("datatype_detect", form);
                 }
             })
         }
     });
     return form;
 },
Example #3
0
 _renderMetaFileDownloadButton: function() {
     var urls = this.model.urls;
     return $(`
         <div class="metafile-dropdown dropdown">
             <a class="download-btn icon-btn" href="${urls.download}" data-toggle="dropdown" title="${_l(
         "Download"
     )}">
                 <span class="fa fa-floppy-o"></span>
             </a>
             <ul class="dropdown-menu" role="menu">
                 <li>
                     <a href="${urls.download}">
                         ${_l("Download dataset")}
                     </a>
                 </li>
                 ${_.map(
                     this.model.get("meta_files"),
                     meta_file =>
                         `<li>
                             <a href="${urls.meta_download + meta_file.file_type}">
                                 ${_l("Download")} ${meta_file.file_type}
                             </a>
                         </li>`
                 )}
             </ul>
         </div>`);
 },
 _getAttribute: function() {
     var self = this;
     var form = new Form({
         title: _l("Edit attributes"),
         operations: {
             submit_attributes: new Ui.Button({
                 tooltip: _l("Save attributes of the dataset."),
                 icon: "fa-floppy-o",
                 title: _l("Save"),
                 onclick: function() {
                     self._submit("attributes", form);
                 }
             }),
             submit_autodetect: new Ui.Button({
                 tooltip:
                     "This will inspect the dataset and attempt to correct the values of fields if they are not accurate.",
                 icon: "fa-undo",
                 title: "Auto-detect",
                 onclick: function() {
                     self._submit("autodetect", form);
                 }
             })
         }
     });
     return form;
 },
 this._loadDataset(dataset_id, (dataset, config) => {
     current_dataset = dataset;
     self.add(
         _.extend(
             {
                 menu: [
                     {
                         icon: "fa fa-chevron-circle-left",
                         tooltip: _l("Previous in History"),
                         onclick: function(frame) {
                             _loadDatasetOffset(current_dataset, -1, frame);
                         },
                         disabled: function() {
                             return !_findDataset(current_dataset, -1);
                         }
                     },
                     {
                         icon: "fa fa-chevron-circle-right",
                         tooltip: _l("Next in History"),
                         onclick: function(frame) {
                             _loadDatasetOffset(current_dataset, 1, frame);
                         },
                         disabled: function() {
                             return !_findDataset(current_dataset, 1);
                         }
                     }
                 ]
             },
             config
         )
     );
 });
        createList: function(name) {
            if (!this.workingElements.length) {
                var message = `${_l("No valid elements for final list")}. `;
                message += `<a class="cancel-create" href="javascript:void(0);">${_l("Cancel")}</a> `;
                message += _l("or");
                message += ` <a class="reset" href="javascript:void(0);">${_l("start over")}</a>.`;
                this._showAlert(message);
                return;
            }

            var creator = this;

            var elements = this.workingElements.map(element => creator._elementToJSON(element));

            creator.blocking = true;
            return creator
                .creationFn(elements, name, creator.hideOriginals)
                .always(() => {
                    creator.blocking = false;
                })
                .fail((xhr, status, message) => {
                    creator.trigger("error", {
                        xhr: xhr,
                        status: status,
                        message: _l("An error occurred while creating this collection")
                    });
                })
                .done(function(response, message, xhr) {
                    creator.trigger("collection:created", response, message, xhr);
                    creator.metric("collection:created", response);
                    if (typeof creator.oncreate === "function") {
                        creator.oncreate.call(this, response, message, xhr);
                    }
                });
        },
 initialize: function(options) {
     options = options || {};
     this.frames = new Frames.View({ visible: false });
     this.setElement(this.frames.$el);
     this.active = false;
     this.buttonActive = options.collection.add({
         id: "enable-scratchbook",
         icon: "fa-th",
         tooltip: _l("Enable/Disable Scratchbook"),
         onclick: () => {
             this.active = !this.active;
             this.buttonActive.set({
                 toggle: this.active,
                 show_note: this.active,
                 note_cls: this.active && "fa fa-check"
             });
             if (!this.active) {
                 this.frames.hide();
             }
         },
         onbeforeunload: () => {
             if (this.frames.length() > 0) {
                 return `You opened ${this.frames.length()} frame(s) which will be lost.`;
             }
         }
     });
     this.buttonLoad = options.collection.add({
         id: "show-scratchbook",
         icon: "fa-eye",
         tooltip: _l("Show/Hide Scratchbook"),
         show_note: true,
         visible: false,
         onclick: e => {
             if (this.frames.visible) {
                 this.frames.hide();
             } else {
                 this.frames.show();
             }
         }
     });
     this.frames
         .on("add remove", () => {
             if (this.frames.visible && this.frames.length() === 0) {
                 this.frames.hide();
             }
             this.buttonLoad.set({
                 note: this.frames.length(),
                 visible: this.frames.length() > 0
             });
         })
         .on("show hide ", () => {
             this.buttonLoad.set({
                 toggle: this.frames.visible,
                 icon: (this.frames.visible && "fa-eye") || "fa-eye-slash"
             });
         });
     this.history_cache = {};
 },
Example #8
0
        multiselectActions: function() {
            var panel = this;

            var actions = [
                {
                    html: _l("Hide datasets"),
                    func: function() {
                        var action = HDA_MODEL.HistoryDatasetAssociation.prototype.hide;
                        panel.getSelectedModels().ajaxQueue(action);
                    }
                },
                {
                    html: _l("Unhide datasets"),
                    func: function() {
                        var action = HDA_MODEL.HistoryDatasetAssociation.prototype.unhide;
                        panel.getSelectedModels().ajaxQueue(action);
                    }
                },
                {
                    html: _l("Delete datasets"),
                    func: function() {
                        var action = HDA_MODEL.HistoryDatasetAssociation.prototype["delete"];
                        panel.getSelectedModels().ajaxQueue(action);
                    }
                },
                {
                    html: _l("Undelete datasets"),
                    func: function() {
                        var action = HDA_MODEL.HistoryDatasetAssociation.prototype.undelete;
                        panel.getSelectedModels().ajaxQueue(action);
                    }
                }
            ];

            if (panel.purgeAllowed) {
                actions.push({
                    html: _l("Permanently delete datasets"),
                    func: function() {
                        if (
                            window.confirm(_l("This will permanently remove the data in your datasets. Are you sure?"))
                        ) {
                            var action = HDA_MODEL.HistoryDatasetAssociation.prototype.purge;
                            const historyContents = panel.getSelectedModels();
                            const selectedDatasets = historyContents.filter(
                                c => c.get("history_content_type") == "dataset"
                            );
                            historyContents.ajaxQueue(action, {}, selectedDatasets);
                        }
                    }
                });
            }
            actions = actions.concat(panel._collectionActions());
            return actions;
        },
 _isElementInvalid: function(element) {
     if (element.history_content_type === "dataset_collection") {
         return _l("is a collection, this is not allowed");
     }
     var validState = element.state === STATES.OK || _.contains(STATES.NOT_READY_STATES, element.state);
     if (!validState) {
         return _l("has errored, is paused, or is not accessible");
     }
     if (element.deleted || element.purged) {
         return _l("has been deleted or purged");
     }
     return null;
 },
 render: function(options) {
     var repo_queue_template = this.templateRepoQueue;
     var repositories = this.model.models;
     this.$el.html(
         repo_queue_template({
             title: _l("Repository Installation Queue"),
             repositories: repositories,
             empty: _l("No repositories in queue."),
             queue: toolshed_util.queueLength()
         })
     );
     $("#center").css("overflow", "auto");
     this.bindEvents();
 },
Example #11
0
/** Display a modal showing an error message but fallback to alert if there's no modal */
function errorModal(message, title, details) {
    if (!message) {
        return;
    }

    message = _l(message);
    title = _l(title) || _l("Error:");
    if (window.Galaxy && Galaxy.modal) {
        return _errorModal(message, title, details);
    }

    alert(`${title}\n\n${message}`);
    console.log("error details:", JSON.stringify(details));
}
Example #12
0
    add: function(options) {
        if (this.frame_counter >= this.options.frame_max) {
            Galaxy.modal.show({
                title: _l("Warning"),
                body: `You have reached the maximum number of allowed frames (${this.options.frame_max}).`,
                buttons: {
                    Close: function() {
                        Galaxy.modal.hide();
                    }
                }
            });
        } else {
            var frame_id = `#frame-${this.frame_uid++}`;
            if ($(frame_id).length !== 0) {
                Galaxy.modal.show({
                    title: _l("Error"),
                    body: "This frame already exists. This page might contain multiple frame managers.",
                    buttons: {
                        Close: function() {
                            Galaxy.modal.hide();
                        }
                    }
                });
            } else {
                // initialize new frame elements
                this.top = this.options.top_min;
                var frame = new FrameView(options);
                this.$el.append(frame.$el);

                // set dimensions
                options.width = this._toPixelCoord("width", this.options.frame.cols);
                options.height = this._toPixelCoord("height", this.options.frame.rows);

                // set default z-index and add to ui and frame list
                this.frame_z = parseInt(frame.$el.css("z-index"));
                this.frame_list[frame_id] = frame;
                this.frame_counter++;
                this._frameInit(frame, frame_id);
                this._frameResize(frame, {
                    width: options.width,
                    height: options.height
                });
                this._frameInsert(frame, { top: 0, left: 0 }, true);
                !this.visible && this.show();
                this.trigger("add");
            }
        }
    },
Example #13
0
 "click .purge-history": function() {
     if (window.confirm(_l("This will permanently remove the data. Are you sure?"))) {
         this.model.purge().done(data => {
             this.render();
         });
     }
 },
        _setUpBehaviors: function($where) {
            $where = $where || this.$el;
            _super.prototype._setUpBehaviors.call(this, $where);
            if (!this.model) {
                return;
            }

            // anon users shouldn't have access to any of the following
            if (!Galaxy.user || Galaxy.user.isAnonymous() || Galaxy.user.id !== this.model.get("user_id")) {
                return;
            }

            var panel = this;
            var nameSelector = "> .controls .name";
            $where
                .find(nameSelector)
                .attr("title", _l("Click to rename history"))
                .tooltip({ placement: "bottom" })
                .make_text_editable({
                    on_finish: function(newName) {
                        var previousName = panel.model.get("name");
                        if (newName && newName !== previousName) {
                            panel.$el.find(nameSelector).text(newName);
                            panel.model.save({ name: newName }).fail(() => {
                                panel.$el.find(nameSelector).text(panel.model.previous("name"));
                            });
                        } else {
                            panel.$el.find(nameSelector).text(previousName);
                        }
                    }
                });
        },
Example #15
0
        _renderSelectButton: function($where) {
            $where = $where || this.$el;
            // do not render selector option if no actions
            if (!this.multiselectActions().length) {
                return null;
            }
            // do not render (and remove even) if nothing to select
            if (!this.views.length) {
                this.hideSelectors();
                $where.find(".controls .actions .show-selectors-btn").remove();
                return null;
            }
            // don't bother rendering if there's one already
            var $existing = $where.find(".controls .actions .show-selectors-btn");
            if ($existing.length) {
                return $existing;
            }

            return faIconButton({
                title: _l("Operations on multiple datasets"),
                classes: "show-selectors-btn",
                faIcon: "fa-check-square-o",
                tooltipConfig: { placement: "top" }
            }).prependTo($where.find(".controls .actions"));
        },
Example #16
0
// ----------------------------------------------------------------------------
/** display a modal (with details) about a failed Backbone ajax operation */
function ajaxErrorModal(model, xhr, options, message, title) {
    message = message || DEFAULT_AJAX_ERR_MSG;
    message += ` ${CONTACT_MSG}`;
    title = title || _l("An error occurred");
    var details = _ajaxDetails(model, xhr, options);
    return errorModal(message, title, details);
}
Example #17
0
 func: function() {
     if (Galaxy && Galaxy.currHistoryPanel && confirm(_l("Really delete the current history?"))) {
         Galaxy.currHistoryPanel.model._delete().done(() => {
             Galaxy.currHistoryPanel.loadCurrentHistory();
         });
     }
 }
Example #18
0
 error: function(response) {
     Galaxy.emit.debug("tool-form-composite::submit", "Submission failed.", response);
     var input_found = false;
     if (response && response.err_data) {
         for (var i in self.forms) {
             var form = self.forms[i];
             var step_related_errors = response.err_data[form.model.get("step_index")];
             if (step_related_errors) {
                 var error_messages = form.data.matchResponse(step_related_errors);
                 for (var input_id in error_messages) {
                     form.highlight(input_id, error_messages[input_id]);
                     input_found = true;
                     break;
                 }
             }
         }
     }
     if (!input_found) {
         self.modal.show({
             title: _l("Workflow submission failed"),
             body: self._templateError(job_def, response && response.err_msg),
             buttons: {
                 Close: function() {
                     self.modal.hide();
                 }
             }
         });
     }
 },
Example #19
0
            success: response => {
                // show dialog
                Galaxy.modal.show({
                    title: _l("New Visualization"),
                    body: this.template_view_new(response),
                    buttons: {
                        Cancel: () => {
                            window.top.location = `${getAppRoot()}visualizations/list`;
                        },
                        Create: () => {
                            this.create_browser($("#new-title").val(), $("#new-dbkey").val());
                            Galaxy.modal.hide();
                        }
                    }
                });

                // select default
                var dbkeys_in_genomes = response.map(r => r[1]);
                if (
                    window.galaxy_config.app.default_dbkey &&
                    _.contains(dbkeys_in_genomes, window.galaxy_config.app.default_dbkey)
                ) {
                    $("#new-dbkey").val(window.galaxy_config.app.default_dbkey);
                }

                // change focus
                $("#new-title").focus();
                $("select[name='dbkey']").select2();

                // to support the large number of options for dbkey, enable scrolling in overlay.
                $("#overlay").css("overflow", "auto");
            }
Example #20
0
 /**
  * Handle unsaved changes in visualization.
  */
 handle_unsaved_changes(view) {
     let Galaxy = getGalaxyInstance();
     if (view.has_changes) {
         Galaxy.modal.show({
             title: _l("Close visualization"),
             body: "There are unsaved changes to your visualization which will be lost if you do not save them.",
             buttons: {
                 Cancel: () => {
                     Galaxy.modal.hide();
                 },
                 "Leave without Saving": () => {
                     $(window).off("beforeunload");
                     window.top.location = `${getAppRoot()}visualizations/list`;
                 },
                 Save: () => {
                     $.when(this.save_viz()).then(() => {
                         window.top.location = `${getAppRoot()}visualizations/list`;
                     });
                 }
             }
         });
     } else {
         window.top.location = `${getAppRoot()}visualizations/list`;
     }
 }
Example #21
0
HDAListItemView.prototype.templates = (() => {
    var titleBarTemplate = dataset => `
        <div class="title-bar clear" tabindex="0">
            <span class="state-icon"></span>
            <div class="title">
                <span class="hid">${dataset.hid}</span>
                <span class="name">${_.escape(dataset.name)}</span>
            </div>
            </br>
            ${HISTORY_ITEM_LI.nametagTemplate(dataset)}
        </div>
    `;

    var warnings = _.extend({}, _super.prototype.templates.warnings, {
        hidden: BASE_MVC.wrapTemplate(
            [
                // add a warning when hidden
                "<% if( !dataset.visible ){ %>",
                '<div class="hidden-msg warningmessagesmall">',
                _l("This dataset has been hidden"),
                "</div>",
                "<% } %>"
            ],
            "dataset"
        )
    });

    return _.extend({}, _super.prototype.templates, {
        titleBar: titleBarTemplate,
        warnings: warnings
    });
})();
Example #22
0
 initialize: function(options) {
     this.list = {};
     this.options = Utils.merge(options, {
         title: _l("Repeat"),
         empty_text: "Not available.",
         max: null,
         min: null
     });
     this.button_new = new Ui.Button({
         icon: "fa-plus",
         title: `Insert ${this.options.title}`,
         tooltip: `Add new ${this.options.title} block`,
         cls: "btn btn-secondary float-none form-repeat-add",
         onclick: function() {
             if (options.onnew) {
                 options.onnew();
             }
         }
     });
     this.setElement(
         $("<div/>")
             .append((this.$list = $("<div/>")))
             .append($("<div/>").append(this.button_new.$el))
     );
 },
Example #23
0
/** private helper that builds the modal and handles adding details */
function _errorModal(message, title, details) {
    // create and return the modal, adding details button only if needed
    Galaxy.modal.show({
        title: title,
        body: message,
        closing_events: true,
        buttons: {
            Ok: function() {
                Galaxy.modal.hide();
            }
        }
    });
    Galaxy.modal.$el.addClass("error-modal");

    if (details) {
        Galaxy.modal
            .$(".error-details")
            .add(Galaxy.modal.$('button:contains("Details")'))
            .remove();
        $("<div/>")
            .addClass("error-details")
            .hide()
            .appendTo(Galaxy.modal.$(".modal-content"))
            .append([$("<p/>").text(DETAILS_MSG), $("<pre/>").text(JSON.stringify(details, null, "  "))]);

        $(`<button id="button-1" class="float-left">${_l("Details")}</button>`)
            .appendTo(Galaxy.modal.$(".buttons"))
            .click(() => {
                Galaxy.modal.$(".error-details").toggle();
            });
    }
    return Galaxy.modal;
}
 .fail((xhr, status, message) => {
     creator.trigger("error", {
         xhr: xhr,
         status: status,
         message: _l("An error occurred while creating this collection")
     });
 })
Example #25
0
 xhr.fail((xhr, status, message) => {
     // Exception messages are hidden within error page including:  '...not allowed in this Galaxy instance.'
     // unbury and re-add to xhr
     var error = _l("Unable to purge dataset");
     var messageBuriedInUnfortunatelyFormattedError =
         "Removal of datasets by users " + "is not allowed in this Galaxy instance";
     if (xhr.responseJSON && xhr.responseJSON.error) {
         error = xhr.responseJSON.error;
     } else if (xhr.responseText.indexOf(messageBuriedInUnfortunatelyFormattedError) !== -1) {
         error = messageBuriedInUnfortunatelyFormattedError;
     }
     xhr.responseText = error;
     hda.trigger("error", hda, xhr, options, _l(error), {
         error: error
     });
 });
Example #26
0
 initialize: function(options) {
     var self = this;
     this.model = (options && options.model) || new Backbone.Model(options);
     this.setElement($("<div/>").addClass("corner frame"));
     this.$el
         .append(
             $("<div/>")
                 .addClass("f-header corner")
                 .append($("<div/>").addClass("f-title"))
                 .append(
                     $("<div/>")
                         .addClass("f-icon f-close fa fa-close")
                         .tooltip({
                             title: _l("Close"),
                             placement: "bottom"
                         })
                 )
         )
         .append($("<div/>").addClass("f-content"))
         .append(
             $("<div/>")
                 .addClass("f-resize f-icon corner fa fa-expand")
                 .tooltip({ title: "Resize" })
         )
         .append($("<div/>").addClass("f-cover"));
     this.$header = this.$(".f-header");
     this.$title = this.$(".f-title");
     this.$content = this.$(".f-content");
     this.render();
     this.listenTo(this.model, "change", this.render, this);
 },
Example #27
0
 _getConversion: function() {
     var self = this;
     var form = new Form({
         title: _l("Convert to new format"),
         operations: {
             submit_conversion: new Ui.Button({
                 tooltip: _l("Convert the datatype to a new format."),
                 title: _l("Convert datatype"),
                 icon: "fa-exchange",
                 onclick: function() {
                     self._submit("conversion", form);
                 }
             })
         }
     });
     return form;
 },
Example #28
0
 _getPermission: function() {
     var self = this;
     var form = new Form({
         title: _l("Manage dataset permissions"),
         operations: {
             submit_permission: new Ui.Button({
                 tooltip: _l("Save permissions."),
                 title: _l("Save permissions"),
                 icon: "fa-floppy-o ",
                 onclick: function() {
                     self._submit("permission", form);
                 }
             })
         }
     });
     return form;
 },
Example #29
0
 show: function() {
     var self = this;
     if (!Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model) {
         window.setTimeout(() => {
             self.show();
         }, 500);
         return;
     }
     this.current_user = Galaxy.user.id;
     if (!this.modal) {
         this.tabs = new Tabs.View();
         this.default_view = new UploadViewDefault(this);
         this.tabs.add({
             id: "regular",
             title: _l("Regular"),
             $el: this.default_view.$el
         });
         this.composite_view = new UploadViewComposite(this);
         this.tabs.add({
             id: "composite",
             title: _l("Composite"),
             $el: this.composite_view.$el
         });
         this.collection_view = new UploadViewCollection(this);
         this.tabs.add({
             id: "collection",
             title: _l("Collection"),
             $el: this.collection_view.$el
         });
         this.rule_based_view = new UploadViewRuleBased(this);
         this.tabs.add({
             id: "rule-based",
             title: _l("Rule-based"),
             $el: this.rule_based_view.$el
         });
         this.modal = new Modal.View({
             title: _l("Download from web or upload from disk"),
             body: this.tabs.$el,
             height: this.options.height,
             width: this.options.width,
             closing_events: true,
             title_separator: false
         });
     }
     this.modal.show();
 },
Example #30
0
 onfirstsearch: searchFor => {
     this.$("#search-histories").searchInput("toggle-loading");
     this.renderInfo(_l("loading all histories for search"));
     this.collection.fetchAll().done(() => {
         this.$("#search-histories").searchInput("toggle-loading");
         this.renderInfo("");
     });
 },