Skip to content

Commit 3dd54b5

Browse files
committed
- Fixed issue in saving options and loading of previous options
- Also added validation for missing input file path
1 parent 6db9add commit 3dd54b5

File tree

3 files changed

+66
-27
lines changed

3 files changed

+66
-27
lines changed

quick-start/src/main/resources/static/app/mlcp/mlcp.controller.js

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
hideFileTree: hideFileTree,
2121
isText: isText,
2222
dataForTheTree: [],
23-
groups: mlcpGroups.groups(entityName, flowName),
23+
groups: mlcpGroups.groups(entityName, flowName, mlcpOptions),
2424
treeOptions: {
2525
nodeChildren: 'children',
2626
dirSelectable: false,
@@ -29,12 +29,29 @@
2929
}
3030
});
3131

32+
$scope.errorMessage = null;
33+
$scope.hasError = false;
34+
3235
$scope.mlcp = angular.extend({
3336
input_file_type: 'documents',
3437
}, mlcpOptions);
35-
38+
39+
3640
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+
}
3855
}
3956

4057
function cancel() {
@@ -109,25 +126,19 @@
109126

110127
function buildMlcpOptions() {
111128
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+
131142
angular.forEach(self.groups, function(group) {
132143
if (isGroupVisible(group.category)) {
133144
$.each(group.settings, function(i, setting) {
@@ -137,14 +148,23 @@
137148
if (setting.type !== 'boolean') {
138149
value = '"' + setting.value + '"';
139150
}
140-
options.push('-' + key);
141-
options.push(value);
151+
addMlcpOption(options, key, value, true);
142152
}
143153
});
144154
}
145155
});
146156
return options;
147157
}
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+
}
148168

149169
function updateMlcpCommand() {
150170
var mlcpCommand = 'mlcp';
@@ -157,7 +177,9 @@
157177
}
158178

159179
$scope.$watch('mlcp.input_file_path', function(value) {
160-
searchPath(value);
180+
if(isValidInputFilePath(value)) {
181+
searchPath(value);
182+
}
161183
});
162184

163185
$scope.$watch('mlcp', function(value) {

quick-start/src/main/resources/static/app/mlcp/mlcp.groups.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
function MlcpGroupsFactory() {
1010
return {
11-
groups: function(entityName, flowName) {
12-
return [
11+
groups: function(entityName, flowName, previousOptions) {
12+
var groups = [
1313
{
1414
category: 'General Options',
1515
settings: [
@@ -237,6 +237,16 @@
237237
]
238238
}
239239
];
240+
angular.forEach(previousOptions, function(value, key) {
241+
$.each(groups, function(i, group) {
242+
$.each(group.settings, function(i, setting) {
243+
if (setting.field === key) {
244+
setting.value = value.replace(/"/g, '');
245+
}
246+
});
247+
});
248+
});
249+
return groups;
240250
}
241251
};
242252
}

quick-start/src/main/resources/static/app/mlcp/mlcp.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
<h4 class="modal-title" id="myModalLabel">Load Data</h4>
55
</div>
66
<div class="modal-body" id="myModalBody">
7+
<div class="row" ng-show="hasError">
8+
<div class="col-xs-12 col-md-12">
9+
<div class="alert alert-danger">
10+
{{ errorMessage }}
11+
</div>
12+
</div>
13+
</div>
714
<div class="row">
815
<div id="details" class="col-xs-12 col-md-12">
916
<form ng-submit="ctrl.ok()">

0 commit comments

Comments
 (0)