Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

219 - Fix Bugs in Load Data Feature #220

Merged
merged 4 commits into from
Apr 25, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 47 additions & 25 deletions quick-start/src/main/resources/static/app/mlcp/mlcp.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
hideFileTree: hideFileTree,
isText: isText,
dataForTheTree: [],
groups: mlcpGroups.groups(entityName, flowName),
groups: mlcpGroups.groups(entityName, flowName, mlcpOptions),
treeOptions: {
nodeChildren: 'children',
dirSelectable: false,
Expand All @@ -29,12 +29,29 @@
}
});

$scope.errorMessage = null;
$scope.hasError = false;

$scope.mlcp = angular.extend({
input_file_type: 'documents',
}, mlcpOptions);



function ok() {
$uibModalInstance.close($scope.mlcp);
if(isValidInputFilePath) {
$uibModalInstance.close($scope.mlcp);
}
}

function isValidInputFilePath() {
if($scope.mlcp.input_file_path) {
$scope.hasError = false;
$scope.errorMessage = null;
return true;
} else {
$scope.hasError = true;
$scope.errorMessage = 'The Location of Files to Load is required.';
}
}

function cancel() {
Expand Down Expand Up @@ -109,25 +126,19 @@

function buildMlcpOptions() {
var options = [];
options.push('import');
options.push('-mode');
options.push('local');
options.push('-host');
options.push(DataHub.status.mlHost);
options.push('-port');
options.push(DataHub.status.mlStagingPort);
options.push('-username');
options.push(DataHub.status.mlUsername);
options.push('-password');
options.push(DataHub.status.mlPassword);

options.push('-input_file_path');
options.push($scope.mlcp.input_file_path);
options.push('-input_file_type');
options.push($scope.mlcp.input_file_type);
options.push('-output_uri_replace');
options.push('"' + $scope.mlcp.input_file_path + ',\'\'"');

var inputFilePath = $scope.mlcp.input_file_path;
var input_file_type = $scope.mlcp.input_file_type;
$scope.mlcp = {};
addMlcpOption(options, 'import', null, false);
addMlcpOption(options, 'mode', 'local', false);
addMlcpOption(options, 'host', DataHub.status.mlHost, false);
addMlcpOption(options, 'port', DataHub.status.mlStagingPort, false);
addMlcpOption(options, 'username', DataHub.status.mlUsername, false);
addMlcpOption(options, 'password', DataHub.status.mlPassword, false);
addMlcpOption(options, 'input_file_path', inputFilePath, true);
addMlcpOption(options, 'input_file_type', input_file_type, true);
addMlcpOption(options, 'output_uri_replace', '"' + inputFilePath + ',\'\'"', true);

angular.forEach(self.groups, function(group) {
if (isGroupVisible(group.category)) {
$.each(group.settings, function(i, setting) {
Expand All @@ -137,14 +148,23 @@
if (setting.type !== 'boolean') {
value = '"' + setting.value + '"';
}
options.push('-' + key);
options.push(value);
addMlcpOption(options, key, value, true);
}
});
}
});
return options;
}

function addMlcpOption(options, key, value, isOtherOption) {
options.push('-' + key);
if(value) {
options.push(value);
if(isOtherOption) {
$scope.mlcp[key] = value;
}
}
}

function updateMlcpCommand() {
var mlcpCommand = 'mlcp';
Expand All @@ -157,7 +177,9 @@
}

$scope.$watch('mlcp.input_file_path', function(value) {
searchPath(value);
if(isValidInputFilePath(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first time you open this dialog ever you get the error right off the bat. We need to set a default value for input_file_path or something.

searchPath(value);
}
});

$scope.$watch('mlcp', function(value) {
Expand Down
14 changes: 12 additions & 2 deletions quick-start/src/main/resources/static/app/mlcp/mlcp.groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

function MlcpGroupsFactory() {
return {
groups: function(entityName, flowName) {
return [
groups: function(entityName, flowName, previousOptions) {
var groups = [
{
category: 'General Options',
settings: [
Expand Down Expand Up @@ -237,6 +237,16 @@
]
}
];
angular.forEach(previousOptions, function(value, key) {
angular.forEach(groups, function(group) {
angular.forEach(group.settings, function(setting) {
if (setting.field === key) {
setting.value = value.replace(/"/g, '');
}
});
});
});
return groups;
}
};
}
Expand Down
7 changes: 7 additions & 0 deletions quick-start/src/main/resources/static/app/mlcp/mlcp.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
<h4 class="modal-title" id="myModalLabel">Load Data</h4>
</div>
<div class="modal-body" id="myModalBody">
<div class="row" ng-show="hasError">
<div class="col-xs-12 col-md-12">
<div class="alert alert-danger">
{{ errorMessage }}
</div>
</div>
</div>
<div class="row">
<div id="details" class="col-xs-12 col-md-12">
<form ng-submit="ctrl.ok()">
Expand Down