-
Notifications
You must be signed in to change notification settings - Fork 968
/
analysis.js
287 lines (258 loc) · 10.1 KB
/
analysis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
import jQuery from "jquery";
var $ = jQuery;
import GalaxyApp from "galaxy";
import Router from "layout/router";
import ToolPanel from "./panels/tool-panel";
import HistoryPanel from "./panels/history-panel";
import Page from "layout/page";
import ToolForm from "mvc/tool/tool-form";
import FormWrapper from "mvc/form/form-wrapper";
import UserPreferences from "mvc/user/user-preferences";
import CustomBuilds from "mvc/user/user-custom-builds";
import Tours from "mvc/tours";
import GridView from "mvc/grid/grid-view";
import GridShared from "mvc/grid/grid-shared";
import Workflows from "mvc/workflow/workflow";
import HistoryList from "mvc/history/history-list";
import ToolFormComposite from "mvc/tool/tool-form-composite";
import QueryStringParsing from "utils/query-string-parsing";
import Utils from "utils/utils";
import Ui from "mvc/ui/ui-misc";
import DatasetError from "mvc/dataset/dataset-error";
import DatasetEditAttributes from "mvc/dataset/dataset-edit-attributes";
import Citations from "components/citations.vue";
import Vue from "libs/vue";
/** define the 'Analyze Data'/analysis/main/home page for Galaxy
* * has a masthead
* * a left tool menu to allow the user to load tools in the center panel
* * a right history menu that shows the user's current data
* * a center panel
* Both panels (generally) persist while the center panel shows any
* UI needed for the current step of an analysis, like:
* * tool forms to set tool parameters,
* * tables showing the contents of datasets
* * etc.
*/
window.app = function app(options, bootstrapped) {
window.Galaxy = new GalaxyApp.GalaxyApp(options, bootstrapped);
Galaxy.debug("analysis app");
/** Routes */
var AnalysisRouter = Router.extend({
routes: {
"(/)": "home",
"(/)root*": "home",
"(/)tours(/)(:tour_id)": "show_tours",
"(/)user(/)": "show_user",
"(/)user(/)(:form_id)": "show_user_form",
"(/)workflow(/)": "show_workflows",
"(/)workflow/run(/)": "show_run",
"(/)pages(/)create(/)": "show_pages_create",
"(/)pages(/)edit(/)": "show_pages_edit",
"(/)pages(/)(:action_id)": "show_pages",
"(/)visualizations(/)edit(/)": "show_visualizations_edit",
"(/)visualizations/(:action_id)": "show_visualizations",
"(/)workflows/list_published(/)": "show_workflows_published",
"(/)histories(/)citations(/)": "show_history_citations",
"(/)histories(/)rename(/)": "show_histories_rename",
"(/)histories(/)permissions(/)": "show_histories_permissions",
"(/)histories(/)(:action_id)": "show_histories",
"(/)datasets(/)list(/)": "show_datasets",
"(/)workflow/import_workflow": "show_import_workflow",
"(/)custom_builds": "show_custom_builds",
"(/)datasets/edit": "show_dataset_edit_attributes",
"(/)datasets/error": "show_dataset_error"
},
require_login: ["show_user", "show_user_form", "show_workflows"],
authenticate: function(args, name) {
return (Galaxy.user && Galaxy.user.id) || this.require_login.indexOf(name) == -1;
},
show_tours: function(tour_id) {
if (tour_id) {
Tours.giveTour(tour_id);
} else {
this.page.display(new Tours.ToursView());
}
},
show_user: function() {
this.page.display(new UserPreferences.View());
},
show_user_form: function(form_id) {
var model = new UserPreferences.Model({
user_id: Galaxy.params.id
});
this.page.display(new FormWrapper.View(model.get(form_id)));
},
show_visualizations: function(action_id) {
this.page.display(
new GridShared.View({
action_id: action_id,
plural: "Visualizations",
item: "visualization"
})
);
},
show_visualizations_edit: function() {
this.page.display(
new FormWrapper.View({
url: `visualization/edit?id=${QueryStringParsing.get("id")}`,
redirect: "visualizations/list"
})
);
},
show_workflows_published: function() {
this.page.display(
new GridView({
url_base: `${Galaxy.root}workflow/list_published`,
dict_format: true
})
);
},
show_histories: function(action_id) {
this.page.display(new HistoryList.View({ action_id: action_id }));
},
show_history_citations: function() {
var citationInstance = Vue.extend(Citations);
var vm = document.createElement('div');
this.page.display(vm);
new citationInstance({propsData: {id: QueryStringParsing.get("id"), source: 'histories'}}).$mount(vm);
},
show_histories_rename: function() {
this.page.display(
new FormWrapper.View({
url: `history/rename?id=${QueryStringParsing.get("id")}`,
redirect: "histories/list"
})
);
},
show_histories_permissions: function() {
this.page.display(
new FormWrapper.View({
url: `history/permissions?id=${QueryStringParsing.get("id")}`,
redirect: "histories/list"
})
);
},
show_datasets: function() {
this.page.display(
new GridView({
url_base: `${Galaxy.root}dataset/list`,
dict_format: true
})
);
},
show_pages: function(action_id) {
this.page.display(
new GridShared.View({
action_id: action_id,
plural: "Pages",
item: "page"
})
);
},
show_pages_create: function() {
this.page.display(
new FormWrapper.View({
url: "page/create",
redirect: "pages/list"
})
);
},
show_pages_edit: function() {
this.page.display(
new FormWrapper.View({
url: `page/edit?id=${QueryStringParsing.get("id")}`,
redirect: "pages/list"
})
);
},
show_workflows: function() {
this.page.display(new Workflows.View());
},
show_run: function() {
this._loadWorkflow();
},
show_import_workflow: function() {
this.page.display(new Workflows.ImportWorkflowView());
},
show_custom_builds: function() {
var historyPanel = this.page.historyPanel.historyView;
if (!historyPanel || !historyPanel.model || !historyPanel.model.id) {
window.setTimeout(() => {
this.show_custom_builds();
}, 500);
return;
}
this.page.display(new CustomBuilds.View());
},
show_dataset_edit_attributes: function() {
this.page.display(new DatasetEditAttributes.View());
},
show_dataset_error: function() {
this.page.display(new DatasetError.View());
},
/** */
home: function(params) {
// TODO: to router, remove Globals
// load a tool by id (tool_id) or rerun a previous tool execution (job_id)
if (params.tool_id || params.job_id) {
if (params.tool_id === "upload1") {
this.page.toolPanel.upload.show();
this._loadCenterIframe("welcome");
} else {
this._loadToolForm(params);
}
} else {
// show the workflow run form
if (params.workflow_id) {
this._loadWorkflow();
// load the center iframe with controller.action: galaxy.org/?m_c=history&m_a=list -> history/list
} else if (params.m_c) {
this._loadCenterIframe(`${params.m_c}/${params.m_a}`);
// show the workflow run form
} else {
this._loadCenterIframe("welcome");
}
}
},
/** load the center panel with a tool form described by the given params obj */
_loadToolForm: function(params) {
//TODO: load tool form code async
params.id = decodeURIComponent(params.tool_id);
this.page.display(new ToolForm.View(params));
},
/** load the center panel iframe using the given url */
_loadCenterIframe: function(url, root) {
root = root || Galaxy.root;
url = root + url;
this.page.$("#galaxy_main").prop("src", url);
},
/** load workflow by its url in run mode */
_loadWorkflow: function() {
Utils.get({
url: `${Galaxy.root}api/workflows/${Utils.getQueryString("id")}/download?style=run`,
success: response => {
this.page.display(new ToolFormComposite.View(response));
},
error: response => {
var error_msg = response.err_msg || "Error occurred while loading the resource.";
var options = {
message: error_msg,
status: "danger",
persistent: true
};
this.page.display(new Ui.Message(options));
}
});
}
});
// render and start the router
$(() => {
Galaxy.page = new Page.View(
_.extend(options, {
Left: ToolPanel,
Right: HistoryPanel,
Router: AnalysisRouter
})
);
});
};