|
8 | 8 | .controller('loadDataModalController', LoadDataModalController) |
9 | 9 | .controller('entityModalController', EntityModalController) |
10 | 10 | .controller('flowModalController', FlowModalController); |
11 | | - |
| 11 | + |
12 | 12 | function GetByFieldAndValue() { |
13 | 13 | return function(field, value, collection) { |
14 | 14 | var i=0, len=collection.length; |
|
91 | 91 | $scope.mlcpInitialCommand = ''; |
92 | 92 | $scope.mlcpCommand = ''; |
93 | 93 | $scope.groups = []; |
94 | | - |
| 94 | + |
95 | 95 | $scope.ok = function() { |
96 | 96 | $uibModalInstance.close($scope.loadDataForm); |
97 | 97 | }; |
98 | 98 |
|
99 | 99 | $scope.cancel = function() { |
100 | 100 | $uibModalInstance.dismiss(); |
101 | 101 | }; |
102 | | - |
| 102 | + |
103 | 103 | $scope.download = function() { |
104 | 104 | $scope.loading = true; |
105 | 105 | DataHub.downloadMlcpOptionsFile($scope.loadDataForm) |
|
153 | 153 | $scope.loadTree(data, node); |
154 | 154 | }); |
155 | 155 | }; |
156 | | - |
| 156 | + |
157 | 157 | $scope.loadTree = function(data, node) { |
158 | 158 | if (node == null) { // jshint ignore:line |
159 | 159 | //initialize root |
|
163 | 163 | } |
164 | 164 | $scope.showInputPathTreeBrowser = true; |
165 | 165 | }; |
166 | | - |
| 166 | + |
167 | 167 | $scope.searchPathThenHideTree = function(basePath, node) { |
168 | 168 | DataHub.searchPath(basePath).success(function(data) { |
169 | 169 | $scope.loadTree(data, node); |
|
172 | 172 | $scope.showInputPathTreeBrowser = false; |
173 | 173 | }); |
174 | 174 | }; |
175 | | - |
| 175 | + |
176 | 176 | $scope.dataForTheTree = []; |
177 | | - |
| 177 | + |
178 | 178 | $scope.searchPathThenHideTree($scope.loadDataForm.inputPath); |
179 | 179 | $scope.mlcpInitialCommand = constructInitialMlcpCommand(DataHub); |
180 | | - |
| 180 | + |
181 | 181 | $scope.updateMlcpCommand = function() { |
182 | 182 | $scope.mlcpCommand = updateMlcpCommand($scope.mlcpInitialCommand, $scope.loadDataForm, $scope.groups); |
183 | 183 | }; |
184 | | - |
| 184 | + |
185 | 185 | $scope.loadSettings = function() { |
186 | 186 | DataHub.getJsonFile('/json/inputOptions.json') |
187 | 187 | .success(function(data) { |
|
197 | 197 | $scope.updateMlcpCommand(); |
198 | 198 | }); |
199 | 199 | }; |
200 | | - |
| 200 | + |
201 | 201 | $scope.loadSettings(); |
202 | | - |
| 202 | + |
203 | 203 | $scope.isText = function(type) { |
204 | 204 | if(type === 'string' || type === 'comma-list' || type === 'number' || type === 'character') { |
205 | 205 | return true; |
206 | 206 | } else { |
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | }; |
210 | | - |
| 210 | + |
211 | 211 | $scope.hideInputPathTreeBrowser = function() { |
212 | 212 | $scope.showInputPathTreeBrowser = false; |
213 | 213 | }; |
214 | | - |
| 214 | + |
215 | 215 | $scope.showBasedOnCategoryAndInputFileType = function(category, inputFileType) { |
216 | 216 | return showBasedOnCategoryAndInputFileType(category, inputFileType); |
217 | 217 | }; |
218 | | - |
| 218 | + |
219 | 219 | $scope.showIfHasNoFilterFieldOrWithSpecifiedValue = function(field,value,collection) { |
220 | 220 | if(angular.isUndefined(field) || $filter('GetByFieldAndValue')(field,value,collection)) { |
221 | 221 | return true; |
222 | 222 | } |
223 | 223 | return false; |
224 | 224 | }; |
225 | | - |
| 225 | + |
226 | 226 | $scope.makeDefaultValueReadOnlyIfApplicable = function($event) { |
227 | 227 | var elem = $event.currentTarget; |
228 | | - var readOnlyLengthData = elem.getAttribute("data-read-only-length"); |
| 228 | + var readOnlyLengthData = elem.getAttribute('data-read-only-length'); |
229 | 229 | if(readOnlyLengthData) { |
230 | | - var readOnlyLength = parseInt(readOnlyLengthData); |
231 | | - if (($event.which != 37 && ($event.which != 39)) |
232 | | - && ((elem.selectionStart < readOnlyLength) |
233 | | - || ((elem.selectionStart === readOnlyLength) && ($event.which === 8)))) { |
| 230 | + var readOnlyLength = parseInt(readOnlyLengthData); |
| 231 | + if (($event.which !== 37 && ($event.which !== 39)) && |
| 232 | + ((elem.selectionStart < readOnlyLength) || |
| 233 | + ((elem.selectionStart === readOnlyLength) && |
| 234 | + ($event.which === 8)))) { |
234 | 235 | $event.preventDefault(); |
235 | | - return false; |
236 | | - } |
| 236 | + return false; |
| 237 | + } |
237 | 238 | } |
238 | 239 | }; |
239 | 240 | } |
240 | | - |
| 241 | + |
241 | 242 | /* |
242 | | - * update $scope.groups and add a ReadOnlyLength |
243 | | - * for options with default value to disable removal of default value |
| 243 | + * update $scope.groups and add a ReadOnlyLength |
| 244 | + * for options with default value to disable removal of default value |
244 | 245 | * for options with type 'comma-list', set it to the length of the default value |
245 | 246 | * for options with type 'string', set it to -1 which means it should be readonly |
246 | 247 | */ |
|
250 | 251 | if(setting.Value) { |
251 | 252 | if(setting.Type === 'comma-list') { |
252 | 253 | setting.ReadOnlyLength = setting.Value.length; |
253 | | - } else if(setting.Type === 'string') { |
| 254 | + } |
| 255 | + else if(setting.Type === 'string') { |
254 | 256 | setting.ReadOnlyLength = -1; |
255 | | - } |
| 257 | + } |
256 | 258 | } |
257 | 259 | }); |
258 | 260 | }); |
259 | 261 | } |
260 | | - |
| 262 | + |
261 | 263 | function updateGroupsBasedOnPreviousSettings(groups, otherOptions) { |
262 | 264 | if(otherOptions !== null) { |
263 | 265 | var optionsMap = $.parseJSON(otherOptions); |
|
271 | 273 | }); |
272 | 274 | } |
273 | 275 | } |
274 | | - |
| 276 | + |
275 | 277 | function showBasedOnCategoryAndInputFileType(category, inputFileType) { |
276 | 278 | if(category === 'Delimited text options' && inputFileType !== 'delimited_text') { |
277 | 279 | return false; |
|
280 | 282 | } |
281 | 283 | return true; |
282 | 284 | } |
283 | | - |
| 285 | + |
284 | 286 | function constructInitialMlcpCommand(DataHub) { |
285 | 287 | var mlcpCommand = 'mlcp'; |
286 | 288 | var mlcpExtension = '.sh'; |
|
294 | 296 | mlcpCommand += ' -password ' + DataHub.status.mlPassword; |
295 | 297 | return mlcpCommand; |
296 | 298 | } |
297 | | - |
| 299 | + |
298 | 300 | function updateMlcpCommand(initialMlcpCommand, loadDataForm, groups) { |
299 | 301 | var mlcpCommand = initialMlcpCommand; |
300 | 302 | mlcpCommand += ' -input_file_path ' + loadDataForm.inputPath; |
301 | 303 | mlcpCommand += ' -input_file_type ' + loadDataForm.inputFileType; |
302 | 304 | mlcpCommand += ' -output_uri_replace "' + loadDataForm.inputPath + ',\'\'"'; |
303 | | - |
| 305 | + |
304 | 306 | var otherOptions = []; |
305 | 307 | $.each(groups, function(i, group) { |
306 | 308 | if(showBasedOnCategoryAndInputFileType(group.category, loadDataForm.inputFileType)) { |
|
316 | 318 | }); |
317 | 319 | } |
318 | 320 | }); |
319 | | - |
| 321 | + |
320 | 322 | loadDataForm.otherOptions = otherOptions.length > 0 ? JSON.stringify(otherOptions) : null; |
321 | 323 | return mlcpCommand; |
322 | 324 | } |
|
0 commit comments