Untangle a lot of incorrect exports, start to standardize away from default and use explicit exports.

This commit is contained in:
Dannon Baker
2018-10-08 10:54:14 -04:00
parent 13b0baf356
commit cbbc375e81
18 changed files with 83 additions and 170 deletions
+4 -4
View File
@@ -2,8 +2,8 @@
import "bootstrap";
export { GalaxyApp } from "galaxy";
import WorkflowView from "mvc/workflow/workflow-view";
import { Trackster } from "viz/trackster";
export { default as Trackster } from "viz/trackster";
import { TracksterUIView } from "viz/trackster";
export { TracksterUI } from "viz/trackster";
import Circster from "viz/circster";
export { PhylovizView as phyloviz } from "viz/phyloviz";
export { SweepsterVisualization, SweepsterVisualizationView } from "viz/sweepster";
@@ -24,7 +24,7 @@ export { default as HDAListItemEdit } from "mvc/history/hda-li-edit";
export { default as HDAModel } from "mvc/history/hda-model";
import addLogging from "utils/add-logging";
export { default as LegacyGridView } from "legacy/grid/grid-view";
export { default as run_stats } from "reports/run_stats";
export { create_chart, create_histogram } from "reports/run_stats";
export { default as ToolshedGroups } from "toolshed/toolshed.groups";
export { chart, chartUtilities } from "./chart";
@@ -52,7 +52,7 @@ export function adminToolshed(options) {
}
export function trackster(options) {
new Trackster.GalaxyApp(options);
new TracksterUIView(options);
}
export function circster(options) {
+6 -6
View File
@@ -2,9 +2,9 @@
import * as Backbone from "backbone";
import * as _ from "underscore";
import Frames from "mvc/ui/ui-frames";
import DATA from "mvc/dataset/data";
import { Dataset, createTabularDatasetChunkedView, TabularDataset } from "mvc/dataset/data";
import visualization from "viz/visualization";
import trackster from "viz/trackster";
import { TracksterUI } from "viz/trackster";
import _l from "utils/localization";
/* global Galaxy */
@@ -145,7 +145,7 @@ export default Backbone.View.extend({
_loadDataset: function(dataset_id, callback) {
var self = this;
var dataset = new DATA.Dataset({ id: dataset_id });
var dataset = new Dataset({ id: dataset_id });
$.when(dataset.fetch()).then(() => {
var is_tabular = _.find(
["tabular", "interval"],
@@ -162,8 +162,8 @@ export default Backbone.View.extend({
? {
title: title,
url: null,
content: DATA.createTabularDatasetChunkedView({
model: new DATA.TabularDataset(dataset.toJSON()),
content: createTabularDatasetChunkedView({
model: new TabularDataset(dataset.toJSON()),
embedded: true,
height: "100%"
}).$el
@@ -182,7 +182,7 @@ export default Backbone.View.extend({
var self = this;
var viz = new visualization.Visualization({ id: viz_id });
$.when(viz.fetch()).then(() => {
var ui = new trackster.TracksterUI(Galaxy.root);
var ui = new TracksterUI(Galaxy.root);
// Construct frame config based on dataset's type.
var frame_config = {
+9 -33
View File
@@ -1,6 +1,10 @@
/* global Backbone */
/* global Galaxy */
/* global _ */
/* global $ */
import _l from "utils/localization";
import mod_icon_btn from "mvc/ui/icon-button";
// Additional dependencies: jQuery, underscore.
/**
* Dataset metedata.
*/
@@ -10,7 +14,7 @@ var DatasetMetadata = Backbone.Model.extend({});
* A dataset. In Galaxy, datasets are associated with a history, so
* this object is also known as a HistoryDatasetAssociation.
*/
var Dataset = Backbone.Model.extend({
export var Dataset = Backbone.Model.extend({
defaults: {
id: "",
type: "",
@@ -64,7 +68,7 @@ var Dataset = Backbone.Model.extend({
/**
* A tabular dataset. This object extends dataset to provide incremental chunked data.
*/
var TabularDataset = Dataset.extend({
export var TabularDataset = Dataset.extend({
defaults: _.extend({}, Dataset.prototype.defaults, {
chunk_url: null,
first_data_chunk: null,
@@ -116,7 +120,7 @@ var TabularDataset = Dataset.extend({
}
});
var DatasetCollection = Backbone.Collection.extend({
export var DatasetCollection = Backbone.Collection.extend({
model: Dataset
});
@@ -561,31 +565,11 @@ var TabularButtonTracksterView = Backbone.View.extend({
}
});
// -- Utility functions. --
/**
* Create a model, attach it to a view, render view, and attach it to a parent element.
*/
var createModelAndView = (model, view, model_config, parent_elt) => {
// Create model, view.
var a_view = new view({
model: new model(model_config)
});
// Render view and add to parent element.
a_view.render();
if (parent_elt) {
parent_elt.append(a_view.$el);
}
return a_view;
};
/**
* Create a tabular dataset chunked view (and requisite tabular dataset model)
* and appends to parent_elt.
*/
var createTabularDatasetChunkedView = options => {
export var createTabularDatasetChunkedView = options => {
// If no model, create and set model from dataset config.
if (!options.model) {
options.model = new TabularDataset(options.dataset_config);
@@ -615,11 +599,3 @@ var createTabularDatasetChunkedView = options => {
return view;
};
export default {
Dataset: Dataset,
TabularDataset: TabularDataset,
DatasetCollection: DatasetCollection,
TabularDatasetChunkedView: TabularDatasetChunkedView,
createTabularDatasetChunkedView: createTabularDatasetChunkedView
};
@@ -23,7 +23,7 @@ var _super = CONTROLLED_FETCH_COLLECTION.PaginatedCollection;
* HDAs or child dataset collections on one level.
* This is why this does not inherit from any of the DatasetCollections (currently).
*/
var HistoryContents = _super.extend(BASE_MVC.LoggableMixin).extend({
export var HistoryContents = _super.extend(BASE_MVC.LoggableMixin).extend({
_logNamespace: "history",
// ........................................................................ set up
@@ -517,8 +517,3 @@ var HistoryContents = _super.extend(BASE_MVC.LoggableMixin).extend({
return ["HistoryContents(", [this.historyId, this.length].join(), ")"].join("");
}
});
//==============================================================================
export default {
HistoryContents: HistoryContents
};
@@ -3,7 +3,7 @@ import _l from "utils/localization";
import AjaxQueue from "utils/ajax-queue";
import Utils from "utils/utils";
import GridView from "mvc/grid/grid-view";
import HistoryModel from "mvc/history/history-model";
import { History } from "mvc/history/history-model";
import historyCopyDialog from "mvc/history/copy-dialog";
import LoadingIndicator from "ui/loading-indicator";
import * as Backbone from "backbone";
@@ -61,7 +61,7 @@ var HistoryGridView = GridView.extend({
ajaxQueue.start();
},
_showCopyDialog: function(id) {
var history = new HistoryModel.History({ id: id });
var history = new History({ id: id });
history
.fetch()
.fail(() => {
@@ -1,6 +1,6 @@
import _ from "underscore";
import Backbone from "backbone";
import HISTORY_CONTENTS from "mvc/history/history-contents";
import { HistoryContents } from "mvc/history/history-contents";
import CONTROLLED_FETCH_COLLECTION from "mvc/base/controlled-fetch-collection";
import UTILS from "utils/utils";
import BASE_MVC from "mvc/base-mvc";
@@ -15,7 +15,7 @@ import _l from "utils/localization";
* @name History
* @augments Backbone.Model
*/
var History = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend(
export var History = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend(
BASE_MVC.mixin(
BASE_MVC.SearchableModelMixin,
/** @lends History.prototype */ {
@@ -36,7 +36,7 @@ var History = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend(
contents_states: {}
},
contentsClass: HISTORY_CONTENTS.HistoryContents,
contentsClass: HistoryContents,
/** What model fields to search with */
searchAttributes: ["name", "annotation", "tags"],
@@ -375,7 +375,7 @@ var _collectionSuper = CONTROLLED_FETCH_COLLECTION.InfinitelyScrollingCollection
* that maintains the current history as the first in the collection.
* New or copied histories become the current history.
*/
var HistoryCollection = _collectionSuper.extend(BASE_MVC.LoggableMixin).extend({
export var HistoryCollection = _collectionSuper.extend(BASE_MVC.LoggableMixin).extend({
_logNamespace: "history",
model: History,
@@ -535,9 +535,3 @@ var HistoryCollection = _collectionSuper.extend(BASE_MVC.LoggableMixin).extend({
return `HistoryCollection(${this.length},current:${this.currentHistoryId})`;
}
});
//==============================================================================
export default {
History: History,
HistoryCollection: HistoryCollection
};
@@ -1,4 +1,6 @@
import HISTORY_MODEL from "mvc/history/history-model";
/* global $ */
/* global _ */
/* global Galaxy */
import HISTORY_VIEW_EDIT from "mvc/history/history-view-edit";
import BASE_MVC from "mvc/base-mvc";
import _l from "utils/localization";
@@ -454,7 +456,7 @@ var CurrentHistoryView = _super.extend(
}
});
}
return jQuery.when();
return $.when();
},
/** delete any hidden datasets */
@@ -468,7 +470,7 @@ var CurrentHistoryView = _super.extend(
{ deleted: true, visible: true }
);
}
return jQuery.when();
return $.when();
},
/** Return a string rep of the history */
@@ -1,8 +1,8 @@
import * as _ from "underscore";
import _l from "utils/localization";
import LIST_VIEW from "mvc/list/list-view";
import HISTORY_MODEL from "mvc/history/history-model";
import HISTORY_CONTENTS from "mvc/history/history-contents";
import { History } from "mvc/history/history-model";
import { HistoryContents } from "mvc/history/history-contents";
import HDA_LI from "mvc/history/hda-li";
import HDCA_LI from "mvc/history/hdca-li";
import ERROR_MODAL from "mvc/ui/error-modal";
@@ -38,7 +38,7 @@ var HistoryView = _super.extend(
/** class to use for constructing the HDCA views */
HDCAViewClass: HDCA_LI.HDCAListItemView,
/** class to used for constructing collection of sub-view models */
collectionClass: HISTORY_CONTENTS.HistoryContents,
collectionClass: HistoryContents,
/** key of attribute in model to assign to this.collection */
modelCollectionKey: "contents",
@@ -106,7 +106,7 @@ var HistoryView = _super.extend(
loadHistory: function(historyId, options, contentsOptions) {
contentsOptions = _.extend(contentsOptions || { silent: true });
this.info("loadHistory:", historyId, options, contentsOptions);
this.setModel(new HISTORY_MODEL.History({ id: historyId }));
this.setModel(new History({ id: historyId }));
contentsOptions.silent = true;
this.trigger("loading");
@@ -652,11 +652,11 @@ export function historyEntry(options) {
}
let viewClass = options.userIsOwner ? HistoryViewEdit.HistoryViewEdit : HistoryView.HistoryView;
let historyModel = new HISTORY_MODEL.History(options.historyJSON);
let history = new History(options.historyJSON);
// attach the copy dialog to the import button now that we have a history
$("#import").click(function() {
HistoryCopyDialog(historyModel, {
HistoryCopyDialog(history, {
useImport: true,
// use default datasets option to match the toggle-deleted button
allDatasets: $("#toggle-deleted").modeButton("getMode").mode === "showing_deleted"
@@ -677,13 +677,13 @@ export function historyEntry(options) {
return this.$el.parent();
}
: undefined,
model: historyModel,
model: history,
show_deleted: options.showDeletedJson,
show_hidden: options.showHiddenJson,
purgeAllowed: options.allow_user_dataset_purge
});
historyView.trigger("loading");
historyModel
history
.fetchContents({ silent: true })
.fail(function() {
alert("Galaxy history failed to load");
@@ -1,7 +1,7 @@
import _l from "utils/localization";
import _ from "underscore";
import Backbone from "backbone";
import HISTORY_MODEL from "mvc/history/history-model";
import { HistoryCollection } from "mvc/history/history-model";
import HISTORY_VIEW_EDIT from "mvc/history/history-view-edit";
import JOB_STATES_MODEL from "mvc/history/job-states-model";
import historyCopyDialog from "mvc/history/copy-dialog";
@@ -317,7 +317,7 @@ var MultiPanelColumns = Backbone.View.extend(baseMVC.LoggableMixin).extend({
// console.log( 'setCollection:', collection );
this.stopListening(this.collection);
this.collection = collection || new HISTORY_MODEL.HistoryCollection();
this.collection = collection || new HistoryCollection();
this.setUpCollectionListeners();
this.createColumns();
+7 -55
View File
@@ -1,11 +1,15 @@
/**
* Model, view, and controller objects for Galaxy tools and tool panel.
*/
/* global Backbone */
/* global d3 */
/* global $ */
/* global ga */
/* global Galaxy */
import * as _ from "libs/underscore";
import util from "viz/trackster/util";
import data from "mvc/dataset/data";
import ToolForm from "mvc/tool/tool-form";
import { DatasetCollection } from "mvc/dataset/data";
/**
* Mixin for tracking model visibility.
@@ -270,18 +274,13 @@ var Tool = Backbone.Model.extend({
// Run job and resolve run_deferred to tool outputs.
$.when(ss_deferred.go()).then(result => {
run_deferred.resolve(new data.DatasetCollection(result));
run_deferred.resolve(new DatasetCollection(result));
});
return run_deferred;
}
});
_.extend(Tool.prototype, VisibilityMixin);
/**
* Tool view.
*/
var ToolView = Backbone.View.extend({});
/**
* Wrap collection of tools for fast access/manipulation.
*/
@@ -752,53 +751,6 @@ var ToolFormView = Backbone.View.extend({
}
});
/**
* Integrated tool menu + tool execution.
*/
var IntegratedToolMenuAndView = Backbone.View.extend({
className: "toolMenuAndView",
initialize: function() {
this.tool_panel_view = new ToolPanelView({
collection: this.collection
});
this.tool_form_view = new ToolFormView();
},
render: function() {
// Render and append tool panel.
this.tool_panel_view.render();
this.tool_panel_view.$el.css("float", "left");
this.$el.append(this.tool_panel_view.$el);
// Append tool form view.
this.tool_form_view.$el.hide();
this.$el.append(this.tool_form_view.$el);
// On tool link click, show tool.
var self = this;
this.tool_panel_view.on("tool_link_click", (e, tool) => {
// Prevents click from activating link:
e.preventDefault();
// Show tool that was clicked on:
self.show_tool(tool);
});
},
/**
* Fetch and display tool.
*/
show_tool: function(tool) {
var self = this;
tool.fetch().done(() => {
self.tool_form_view.model = tool;
self.tool_form_view.render();
self.tool_form_view.$el.show();
$("#left").width("650px");
});
}
});
// TODO: move into relevant views
var templates = {
// the search bar at the top of the tool panel
@@ -1,3 +1,4 @@
/* global $ */
import * as d3 from "../libs/d3";
import { event as currentEvent } from "../libs/d3";
+8 -9
View File
@@ -1,7 +1,10 @@
/* global Backbone */
/* global $ */
import _l from "utils/localization";
import * as d3 from "libs/d3";
import visualization_mod from "viz/visualization";
import data_mod from "mvc/dataset/data";
import { Dataset } from "mvc/dataset/data";
import mod_icon_btn from "mvc/ui/icon-button";
/**
* Base class of any menus that takes in user interaction. Contains checking methods.
@@ -236,7 +239,7 @@ var PhyloTree = visualization_mod.Visualization.extend({
initialize: function(options) {
this.set(
"dataset",
new data_mod.Dataset({
new Dataset({
id: options.dataset_id
})
);
@@ -306,7 +309,7 @@ var PhyloTree = visualization_mod.Visualization.extend({
}
}
var config = jQuery.extend(true, {}, this.attributes);
var config = $.extend(true, {}, this.attributes);
config.selectedNode = null;
show_message("Saving to Galaxy", "progress");
@@ -581,7 +584,7 @@ var PhylovizLinearView = PhylovizLayoutBase.extend({
}
});
var PhylovizView = Backbone.View.extend({
export var PhylovizView = Backbone.View.extend({
className: "phyloviz",
initialize: function(options) {
@@ -986,7 +989,7 @@ var NodeSelectionView = UserMenuBase.extend({
}
});
};
})(jQuery);
})($);
self.UI.enableEdit.off().on("click", () => {
self.toggleUI();
@@ -1102,7 +1105,3 @@ var PhyloVizSearch = UserMenuBase.extend({
});
}
});
export default {
PhylovizView: PhylovizView
};
+8 -11
View File
@@ -1,16 +1,18 @@
import _l from "utils/localization";
/**
* Visualization and components for Sweepster, a visualization for exploring a tool's parameter space via
* genomic visualization.
*/
/* global Backbone */
/* global Galaxy */
/* global $ */
import _l from "utils/localization";
import * as _ from "libs/underscore";
import * as d3 from "libs/d3";
import util from "viz/trackster/util";
import visualization from "viz/visualization";
import tracks from "viz/trackster/tracks";
import tools from "mvc/tool/tools";
import data from "mvc/dataset/data";
import { Dataset } from "mvc/dataset/data";
import config from "utils/config";
import mod_icon_btn from "mvc/ui/icon-button";
/**
@@ -313,7 +315,7 @@ var TrackCollection = Backbone.Collection.extend({
/**
* Sweepster visualization model.
*/
var SweepsterVisualization = visualization.Visualization.extend({
export var SweepsterVisualization = visualization.Visualization.extend({
defaults: _.extend({}, visualization.Visualization.prototype.defaults, {
dataset: null,
tool: null,
@@ -324,7 +326,7 @@ var SweepsterVisualization = visualization.Visualization.extend({
}),
initialize: function(options) {
this.set("dataset", new data.Dataset(options.dataset));
this.set("dataset", new Dataset(options.dataset));
this.set("tool", new tools.Tool(options.tool));
this.set("regions", new visualization.GenomeRegionCollection(options.regions));
this.set("tracks", new TrackCollection(options.tracks));
@@ -706,7 +708,7 @@ var ToolParameterTreeView = Backbone.View.extend({
/**
* Sweepster visualization view. View requires rendering in 3-panel setup for now.
*/
var SweepsterVisualizationView = Backbone.View.extend({
export var SweepsterVisualizationView = Backbone.View.extend({
className: "Sweepster",
helpText:
@@ -1048,8 +1050,3 @@ var SweepsterVisualizationView = Backbone.View.extend({
});
}
});
export default {
SweepsterVisualization: SweepsterVisualization,
SweepsterVisualizationView: SweepsterVisualizationView
};
+2 -8
View File
@@ -22,12 +22,11 @@ import "libs/jquery/jquery.rating";
import "ui/editable-text";
/* global Galaxy */
/* global $ */
/**
* User interface controls for trackster
*/
class TracksterUI extends Backbone.Model {
export class TracksterUI extends Backbone.Model {
constructor(options) {
super(options);
}
@@ -370,7 +369,7 @@ class TracksterUI extends Backbone.Model {
}
}
class TracksterUIView extends Backbone.View {
export class TracksterUIView extends Backbone.View {
constructor(options) {
super(options);
}
@@ -624,8 +623,3 @@ class TracksterUIView extends Backbone.View {
this.ui.view.editor = true;
}
}
export default {
TracksterUI: TracksterUI,
GalaxyApp: TracksterUIView
};
@@ -7,7 +7,7 @@ import util from "viz/trackster/util";
import slotting from "viz/trackster/slotting";
import painters from "viz/trackster/painters";
import filters_mod from "viz/trackster/filters";
import data from "mvc/dataset/data";
import { Dataset } from "mvc/dataset/data";
import tools_mod from "mvc/tool/tools";
import config_mod from "utils/config";
import bbi from "viz/bbi-data-manager";
@@ -2037,7 +2037,7 @@ var TracksterToolView = Backbone.View.extend({
// Run tool.
this.run(url_params, new_track, track_data => {
new_track.set_dataset(new data.Dataset(track_data));
new_track.set_dataset(new Dataset(track_data));
new_track.tiles_div.text("Running job.");
new_track.init();
});
@@ -2342,8 +2342,7 @@ var Track = function(view, container, obj_dict) {
this.dataset = null;
if (obj_dict.dataset) {
// Dataset can be a Backbone model or a dict that can be used to create a model.
this.dataset =
obj_dict.dataset instanceof Backbone.Model ? obj_dict.dataset : new data.Dataset(obj_dict.dataset);
this.dataset = obj_dict.dataset instanceof Backbone.Model ? obj_dict.dataset : new Dataset(obj_dict.dataset);
}
this.dataset_check_type = "converted_datasets_state";
this.data_url_extra_params = {};
+6 -2
View File
@@ -1,6 +1,10 @@
/* global Galaxy */
/* global $ */
/* global Backbone */
import _l from "utils/localization";
import * as _ from "libs/underscore";
import data_mod from "mvc/dataset/data";
import { Dataset } from "mvc/dataset/data";
import util_mod from "viz/trackster/util";
import config_mod from "utils/config";
import GridView from "mvc/grid/grid-view";
@@ -942,7 +946,7 @@ var BackboneTrack = Backbone.Model.extend(CustomToJSON).extend(
},
initialize: function(options) {
this.set("dataset", new data_mod.Dataset(options.dataset));
this.set("dataset", new Dataset(options.dataset));
// -- Set up config settings. --
var models = [
@@ -54,7 +54,7 @@
// FIXME: deliberate global required for now due to requireJS integration.
view = null;
var ui = new (window.bundleEntries.Trackster.TracksterUI)( "${h.url_for('/')}" );
var ui = new (window.bundleEntries.TracksterUI)( "${h.url_for('/')}" );
var container_element = $("#${trans.security.encode_id( visualization.id )}");
$(function() {
+6 -6
View File
@@ -6,12 +6,12 @@ ${parent.javascripts()}
<script type="text/javascript">
$(function(){
window.bundleEntries.run_stats.create_chart(${jf_hr_data}, "jf_hr_chart", "hours", "Jobs Finished per Hour");
window.bundleEntries.run_stats.create_chart(${jf_dy_data}, "jf_dy_chart", "days", "Jobs Finished per Day");
window.bundleEntries.run_stats.create_chart(${jc_hr_data}, "jc_hr_chart", "hours", "Jobs Created per Hour");
window.bundleEntries.run_stats.create_chart(${jc_dy_data}, "jc_dy_chart", "days", "Jobs Created per Day");
window.bundleEntries.run_stats.create_histogram(${et_hr_data}, "et_hr_chart", "Job Run Times (past day)");
window.bundleEntries.run_stats.create_histogram(${et_dy_data}, "et_dy_chart", "Job Run Time (past 30 days)");
window.bundleEntries.create_chart(${jf_hr_data}, "jf_hr_chart", "hours", "Jobs Finished per Hour");
window.bundleEntries.create_chart(${jf_dy_data}, "jf_dy_chart", "days", "Jobs Finished per Day");
window.bundleEntries.create_chart(${jc_hr_data}, "jc_hr_chart", "hours", "Jobs Created per Hour");
window.bundleEntries.create_chart(${jc_dy_data}, "jc_dy_chart", "days", "Jobs Created per Day");
window.bundleEntries.create_histogram(${et_hr_data}, "et_hr_chart", "Job Run Times (past day)");
window.bundleEntries.create_histogram(${et_dy_data}, "et_dy_chart", "Job Run Time (past 30 days)");
});
</script>
</%def>