1 | var OAAS_CONTROLLER = (function (my, Backbone, OAAS_VIEW, OAAS_MODEL, _, $) {
|
---|
2 | my.JobVisualExtensionListener = function (model, element) {
|
---|
3 | var extension = new OAAS_MODEL.VisualExtension({ id: model.get('algorithmName') });
|
---|
4 | extension.fetch({ cache: true,
|
---|
5 | success: function () {
|
---|
6 | //eval extension.js -> execute addVisualExtension(model, element):
|
---|
7 | var js = extension.get('ScenarioJs');
|
---|
8 | if (js != null) {
|
---|
9 | (function (model, element) {
|
---|
10 | addExtension = undefined;
|
---|
11 | eval(js);
|
---|
12 | if (addExtension)
|
---|
13 | addExtension(model, element);
|
---|
14 | } (model, element));
|
---|
15 | }
|
---|
16 | },
|
---|
17 | error: function (model, response, options) {
|
---|
18 |
|
---|
19 | }
|
---|
20 | });
|
---|
21 | },
|
---|
22 | my.JobPageController = function () {
|
---|
23 | this.create = function () {
|
---|
24 | var self = this;
|
---|
25 | var jobList = new OAAS_MODEL.JobList();
|
---|
26 | var jobOverview = new OAAS_VIEW.JobOverView({ collection: jobList, el: $('#jobOverview') });
|
---|
27 |
|
---|
28 | var listener = {};
|
---|
29 | // add listener capabilities to instance
|
---|
30 | _.extend(listener, Backbone.Events);
|
---|
31 |
|
---|
32 | listener.listenTo(jobList, 'updated', function (evt) {
|
---|
33 | // refresh overview
|
---|
34 | jobOverview.render();
|
---|
35 | });
|
---|
36 |
|
---|
37 | listener.listenTo(jobOverview, 'jobSelected', function (jobId) {
|
---|
38 | var runList = new OAAS_MODEL.RunList({ jobId: jobId });
|
---|
39 | var lv = new OAAS_VIEW.LoadingView({ el: $('#jobDetails'), model: 'Loading results of job...' });
|
---|
40 | lv.render();
|
---|
41 | runList.fetch({ cache: false,
|
---|
42 | success: function () {
|
---|
43 | $('#jobDetails').empty();
|
---|
44 | var div = $('<div/>').appendTo($('#jobDetails'));
|
---|
45 | if (runList.models && runList.models.length == 0) {
|
---|
46 | $('<p/>').text('No job results available!').appendTo(div);
|
---|
47 | return;
|
---|
48 | }
|
---|
49 | // else draw the result view
|
---|
50 | var rv = new OAAS_VIEW.ResultView({ model: runList, el: div });
|
---|
51 | listener.listenTo(rv, 'renderVisualExtension', my.JobVisualExtensionListener);
|
---|
52 | rv.render();
|
---|
53 | var av = new OAAS_VIEW.AccordionView({ el: div });
|
---|
54 | av.render();
|
---|
55 | },
|
---|
56 | error: function (model, response, options) {
|
---|
57 | $('#jobDetails').empty();
|
---|
58 | var lv = new OAAS_VIEW.LoadingView({ el: $('#jobDetails'), model: 'Error during retrieval!' });
|
---|
59 | lv.render();
|
---|
60 | }
|
---|
61 | });
|
---|
62 | });
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | jobList.poll();
|
---|
67 | }
|
---|
68 | }
|
---|
69 | return my;
|
---|
70 | } (OAAS_CONTROLLER || {}, Backbone, OAAS_VIEW, OAAS_MODEL, _, $)); |
---|