|
20 | 20 | hideFileTree: hideFileTree, |
21 | 21 | isText: isText, |
22 | 22 | dataForTheTree: [], |
23 | | - groups: mlcpGroups.groups(entityName, flowName), |
| 23 | + groups: mlcpGroups.groups(entityName, flowName, mlcpOptions), |
24 | 24 | treeOptions: { |
25 | 25 | nodeChildren: 'children', |
26 | 26 | dirSelectable: false, |
|
29 | 29 | } |
30 | 30 | }); |
31 | 31 |
|
| 32 | + $scope.errorMessage = null; |
| 33 | + $scope.hasError = false; |
| 34 | + |
32 | 35 | $scope.mlcp = angular.extend({ |
33 | 36 | input_file_type: 'documents', |
34 | 37 | }, mlcpOptions); |
35 | | - |
| 38 | + |
| 39 | + |
36 | 40 | function ok() { |
37 | | - $uibModalInstance.close($scope.mlcp); |
| 41 | + if(isValidInputFilePath) { |
| 42 | + $uibModalInstance.close($scope.mlcp); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + function isValidInputFilePath() { |
| 47 | + if($scope.mlcp.input_file_path) { |
| 48 | + $scope.hasError = false; |
| 49 | + $scope.errorMessage = null; |
| 50 | + return true; |
| 51 | + } else { |
| 52 | + $scope.hasError = true; |
| 53 | + $scope.errorMessage = 'The Location of Files to Load is required.'; |
| 54 | + } |
38 | 55 | } |
39 | 56 |
|
40 | 57 | function cancel() { |
|
109 | 126 |
|
110 | 127 | function buildMlcpOptions() { |
111 | 128 | var options = []; |
112 | | - options.push('import'); |
113 | | - options.push('-mode'); |
114 | | - options.push('local'); |
115 | | - options.push('-host'); |
116 | | - options.push(DataHub.status.mlHost); |
117 | | - options.push('-port'); |
118 | | - options.push(DataHub.status.mlStagingPort); |
119 | | - options.push('-username'); |
120 | | - options.push(DataHub.status.mlUsername); |
121 | | - options.push('-password'); |
122 | | - options.push(DataHub.status.mlPassword); |
123 | | - |
124 | | - options.push('-input_file_path'); |
125 | | - options.push($scope.mlcp.input_file_path); |
126 | | - options.push('-input_file_type'); |
127 | | - options.push($scope.mlcp.input_file_type); |
128 | | - options.push('-output_uri_replace'); |
129 | | - options.push('"' + $scope.mlcp.input_file_path + ',\'\'"'); |
130 | | - |
| 129 | + var inputFilePath = $scope.mlcp.input_file_path; |
| 130 | + var input_file_type = $scope.mlcp.input_file_type; |
| 131 | + $scope.mlcp = {}; |
| 132 | + addMlcpOption(options, 'import', null, false); |
| 133 | + addMlcpOption(options, 'mode', 'local', false); |
| 134 | + addMlcpOption(options, 'host', DataHub.status.mlHost, false); |
| 135 | + addMlcpOption(options, 'port', DataHub.status.mlStagingPort, false); |
| 136 | + addMlcpOption(options, 'username', DataHub.status.mlUsername, false); |
| 137 | + addMlcpOption(options, 'password', DataHub.status.mlPassword, false); |
| 138 | + addMlcpOption(options, 'input_file_path', inputFilePath, true); |
| 139 | + addMlcpOption(options, 'input_file_type', input_file_type, true); |
| 140 | + addMlcpOption(options, 'output_uri_replace', '"' + inputFilePath + ',\'\'"', true); |
| 141 | + |
131 | 142 | angular.forEach(self.groups, function(group) { |
132 | 143 | if (isGroupVisible(group.category)) { |
133 | 144 | $.each(group.settings, function(i, setting) { |
|
137 | 148 | if (setting.type !== 'boolean') { |
138 | 149 | value = '"' + setting.value + '"'; |
139 | 150 | } |
140 | | - options.push('-' + key); |
141 | | - options.push(value); |
| 151 | + addMlcpOption(options, key, value, true); |
142 | 152 | } |
143 | 153 | }); |
144 | 154 | } |
145 | 155 | }); |
146 | 156 | return options; |
147 | 157 | } |
| 158 | + |
| 159 | + function addMlcpOption(options, key, value, isOtherOption) { |
| 160 | + options.push('-' + key); |
| 161 | + if(value) { |
| 162 | + options.push(value); |
| 163 | + if(isOtherOption) { |
| 164 | + $scope.mlcp[key] = value; |
| 165 | + } |
| 166 | + } |
| 167 | + } |
148 | 168 |
|
149 | 169 | function updateMlcpCommand() { |
150 | 170 | var mlcpCommand = 'mlcp'; |
|
157 | 177 | } |
158 | 178 |
|
159 | 179 | $scope.$watch('mlcp.input_file_path', function(value) { |
160 | | - searchPath(value); |
| 180 | + if(isValidInputFilePath(value)) { |
| 181 | + searchPath(value); |
| 182 | + } |
161 | 183 | }); |
162 | 184 |
|
163 | 185 | $scope.$watch('mlcp', function(value) { |
|
0 commit comments