|
77 | 77 | if (! that.is_showing ) { return; } |
78 | 78 | var scenarios = that.model.get('scenarios'); |
79 | 79 | var scenarioHTML = ''; |
80 | | - for (var i=0; i<scenarios.length; i++) |
81 | | - { |
82 | | - var ncn_id = scenarios[i].ncn_id; |
83 | | - scenarioHTML += |
84 | | - '<table width="100%" frame="void">' + |
85 | | - '<tr>' + |
86 | | - |
87 | | - // buttons |
88 | | - '<td width=19%>' + |
89 | | - // ingest |
90 | | - '<button type="button" class="btn btn-default" ' + |
91 | | - 'id="btn-ingest-scenario-' + ncn_id + '" title="Ingest scenario '+ ncn_id +'" >' + |
92 | | - '<i class="fa fa-sign-in fa-rotate-90"></i></button>' + |
93 | | - |
94 | | - // Add local product from file |
95 | | - '<button type="button" class="btn btn-default" ' + |
96 | | - 'id="btn-add-product-' + ncn_id + '" title="Add local product to '+ ncn_id+'" >' + |
97 | | - '<i class="fa fa-file-o"></i></button>' + |
98 | | - |
99 | | - // edit |
100 | | - '<button type="button" class="btn btn-default" ' + |
101 | | - 'id="btn-edit-scenario-' + ncn_id + '" title="Edit scenario '+ ncn_id + '" >' + |
102 | | - '<i class="fa fa-edit"></i></button>' + |
103 | | - |
104 | | - // delete |
105 | | - '<button type="button" class="btn btn-default" ' + |
106 | | - 'id="btn-delete-scenario-' + ncn_id + '" title="Delete scenario '+ ncn_id+'" >' + |
107 | | - '<i class="fa fa-trash-o"></i></button>' + |
108 | | - '</td>' + |
109 | | - |
110 | | - // id and name |
111 | | - '<td width=10% title="Scenario Id">' + ncn_id + '</td>' + |
112 | | - '<td colspan=2 title="Scenario Name">' + scenarios[i].scenario_name + '</td>' + |
113 | | - '</tr>' + |
114 | | - '<tr>' + |
115 | | - // '<td></td>' + |
116 | | - |
117 | | - // description text accross all columns |
118 | | - '<td colspan=3 title="Description">' + scenarios[i].scenario_description + '</td>' + |
119 | | - '</tr>' + |
120 | | - '<tr>' + |
121 | | - // '<td></td>' + |
122 | | - |
123 | | - // status |
124 | | - '<td><div id="div_status_' + ncn_id + '"/>' + scenarios[i].st_st + '</td>' + |
125 | | - |
126 | | - // stop button |
127 | | - '<td><button type="button" class="btn btn-default" ' + |
128 | | - 'id="btn-stop-scenario-' + ncn_id + '" title="Stop scenario'+ ncn_id+'" >' + |
129 | | - '<i class="fa fa-stop"></i></button>' + |
130 | | - '</td>' + |
131 | | - '<td>' + |
132 | | - |
133 | | - // progress bar |
134 | | - '<div id="pro_container_' + ncn_id + '" ' + |
135 | | - 'style="width:100%; height:10px; border:1px solid black; ' + |
136 | | - 'vertical-align:middle; padding:0">' + |
137 | | - '<div id="progress_bar_' + ncn_id + '" ' + |
138 | | - 'style="width:' + scenarios[i].st_done +'%; height:8px; border:none; background-color:#6666dd; ' + |
139 | | - 'padding:0; vertical-align:sub"/>' + |
140 | | - '</div>' + |
141 | | - |
142 | | - '</td>' + |
143 | | - '</tr>' + |
144 | | - '</table>' + |
145 | | - '<hr>'; |
| 80 | + var alertMessage = ''; |
| 81 | + |
| 82 | + if (scenarios) { |
| 83 | + for (var i=0; i<scenarios.length; i++) |
| 84 | + { |
| 85 | + var ncn_id = scenarios[i].ncn_id; |
| 86 | + scenarioHTML += |
| 87 | + '<table width="100%" frame="void">' + |
| 88 | + '<tr>' + |
| 89 | + |
| 90 | + // buttons |
| 91 | + '<td width=19%>' + |
| 92 | + // ingest |
| 93 | + '<button type="button" class="btn btn-default" ' + |
| 94 | + 'id="btn-ingest-scenario-' + ncn_id + '" title="Ingest scenario '+ ncn_id +'" >' + |
| 95 | + '<i class="fa fa-sign-in fa-rotate-90"></i></button>' + |
| 96 | + |
| 97 | + // Add local product from file |
| 98 | + '<button type="button" class="btn btn-default" ' + |
| 99 | + 'id="btn-add-product-' + ncn_id + '" title="Add local product to '+ ncn_id+'" >' + |
| 100 | + '<i class="fa fa-file-o"></i></button>' + |
| 101 | + |
| 102 | + // edit |
| 103 | + '<button type="button" class="btn btn-default" ' + |
| 104 | + 'id="btn-edit-scenario-' + ncn_id + '" title="Edit scenario '+ ncn_id + '" >' + |
| 105 | + '<i class="fa fa-edit"></i></button>' + |
| 106 | + |
| 107 | + // delete |
| 108 | + '<button type="button" class="btn btn-default" ' + |
| 109 | + 'id="btn-delete-scenario-' + ncn_id + '" title="Delete scenario '+ ncn_id+'" >' + |
| 110 | + '<i class="fa fa-trash-o"></i></button>' + |
| 111 | + '</td>' + |
| 112 | + |
| 113 | + // id and name |
| 114 | + '<td width=10% class="scenario-id" title="Scenario Id">' + ncn_id + '</td>' + |
| 115 | + '<td colspan=2 class="scenario-title" title="Scenario Name">' + scenarios[i].scenario_name + '</td>' + |
| 116 | + '</tr>' + |
| 117 | + '<tr>' + |
| 118 | + // '<td></td>' + |
| 119 | + |
| 120 | + // description text accross all columns |
| 121 | + '<td colspan=3 class="scenario-info" title="Description">' + scenarios[i].scenario_description + '</td>' + |
| 122 | + '</tr>' + |
| 123 | + '<tr>' + |
| 124 | + // '<td></td>' + |
| 125 | + |
| 126 | + // status |
| 127 | + '<td><div id="div_status_' + ncn_id + '"/>' + scenarios[i].st_st + '</td>' + |
| 128 | + |
| 129 | + // stop button |
| 130 | + '<td><button type="button" class="btn btn-default" ' + |
| 131 | + 'id="btn-stop-scenario-' + ncn_id + '" title="Stop scenario'+ ncn_id+'" >' + |
| 132 | + '<i class="fa fa-stop"></i></button>' + |
| 133 | + '</td>' + |
| 134 | + '<td>' + |
| 135 | + |
| 136 | + // progress bar |
| 137 | + '<div id="pro_container_' + ncn_id + '" ' + |
| 138 | + 'style="width:100%; height:10px; border:1px solid black; ' + |
| 139 | + 'vertical-align:middle; padding:0">' + |
| 140 | + '<div id="progress_bar_' + ncn_id + '" ' + |
| 141 | + 'style="width:' + scenarios[i].st_done +'%; height:8px; border:none; background-color:#6666dd; ' + |
| 142 | + 'padding:0; vertical-align:sub"/>' + |
| 143 | + '</div>' + |
| 144 | + |
| 145 | + '</td>' + |
| 146 | + '</tr>' + |
| 147 | + '</table>' + |
| 148 | + '<hr>'; |
| 149 | + } |
| 150 | + if (scenarios.length == 0) { |
| 151 | + alertMessage = "No ingestion scenario defined. Create a new one by clicking on the Create Scenario button below."; |
| 152 | + } |
| 153 | + } else { |
| 154 | + alertMessage = "Failed to fetch scenarios from the Ingestion Engine!"; |
146 | 155 | } |
147 | 156 |
|
| 157 | + that.$('#ingestion-alert').html(alertMessage); |
148 | 158 | that.$('#scenario-list').html(scenarioHTML); |
149 | 159 |
|
150 | | - for (var i=0; i<scenarios.length; i++) |
151 | | - { |
152 | | - var ncn_id = scenarios[i].ncn_id; |
153 | | - var sc_id = scenarios[i].id; |
154 | | - |
155 | | - that.$('#btn-ingest-scenario-' + ncn_id).on |
156 | | - ("click", _.bind(that.run_iet5_ajax, that, "ingestScenario", "Ingest", sc_id, ncn_id)); |
157 | | - that.$('#btn-delete-scenario-' + ncn_id).on |
158 | | - ("click", _.bind(that.run_iet5_ajax, that, "deleteScenario", "Delete", sc_id, ncn_id)); |
159 | | - that.$('#btn-stop-scenario-' + ncn_id).on |
160 | | - ("click", _.bind(that.run_iet5_ajax, that, "stopScenario", "Stop", sc_id, ncn_id)); |
161 | | - that.$('#btn-add-product-' + ncn_id).on("click", _.bind(that.onAddLocalProduct, that, sc_id, ncn_id)); |
162 | | - that.$('#btn-edit-scenario-' + ncn_id).on("click", _.bind(that.onEditScenario, that, ncn_id)); |
| 160 | + if (scenarios) { |
| 161 | + for (var i=0; i<scenarios.length; i++) |
| 162 | + { |
| 163 | + var ncn_id = scenarios[i].ncn_id; |
| 164 | + var sc_id = scenarios[i].id; |
| 165 | + |
| 166 | + that.$('#btn-ingest-scenario-' + ncn_id).on |
| 167 | + ("click", _.bind(that.run_iet5_ajax, that, "ingestScenario", "Ingest", sc_id, ncn_id)); |
| 168 | + that.$('#btn-delete-scenario-' + ncn_id).on |
| 169 | + ("click", _.bind(that.run_iet5_ajax, that, "deleteScenario", "Delete", sc_id, ncn_id)); |
| 170 | + that.$('#btn-stop-scenario-' + ncn_id).on |
| 171 | + ("click", _.bind(that.run_iet5_ajax, that, "stopScenario", "Stop", sc_id, ncn_id)); |
| 172 | + that.$('#btn-add-product-' + ncn_id).on("click", _.bind(that.onAddLocalProduct, that, sc_id, ncn_id)); |
| 173 | + that.$('#btn-edit-scenario-' + ncn_id).on("click", _.bind(that.onEditScenario, that, ncn_id)); |
163 | 174 |
|
| 175 | + } |
164 | 176 | } |
165 | | - |
166 | 177 | }, |
167 | 178 |
|
168 | 179 | run_iet5_ajax : function (url_key, op, sc_id, ncn_id) |
|
236 | 247 | this.$('#btn-iet5-addscenario').on("click", _.bind(this.onAddScenario, this)); |
237 | 248 | this.$('#btn-iet5-showlog').on("click", _.bind(this.onShowLog, this)); |
238 | 249 |
|
239 | | - this.updater.i = setInterval(_.bind(function() { |
240 | | - this.model.fetch(); |
241 | | - }, |
242 | | - this ), |
243 | | - 2250); |
| 250 | + this.$('#ingestion-alert').html("Loading scenarios from the Ingestion Engine ..."); |
| 251 | + |
| 252 | + this.updater.i = setInterval(_.bind(function() { this.model.fetch(); }, this ), 2250); |
244 | 253 |
|
245 | 254 | this.$el.draggable( |
246 | 255 | { |
|
0 commit comments