Skip to content

Commit

Permalink
Merge pull request #941 from mtho11/ds_add_via_existing_driver2
Browse files Browse the repository at this point in the history
Fix Add Datasource via existing driver Issue
(cherry picked from commit e928b35)
  • Loading branch information
Dan Clarizio authored and simaishi committed Apr 20, 2017
1 parent c569c29 commit 7540570
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ function MwAddDatasourceCtrl($scope, $rootScope, miqService, mwAddDatasourceServ
'driverClass': vm.step2DsModel.driverClass,
'datasourceProperties': dsPropsHash(vm.step3DsModel.dsProps),
'connectionUrl': vm.step3DsModel.connectionUrl,
'userName': vm.step3DsModel.userName,
'password': vm.step3DsModel.password,
'securityDomain': vm.step3DsModel.securityDomain,
};
};

Expand Down Expand Up @@ -74,6 +71,20 @@ function MwAddDatasourceCtrl($scope, $rootScope, miqService, mwAddDatasourceServ
driverClass: '',
});
}
if (vm.step3DsModel.userName !== '' && vm.step3DsModel.password !== '') {
angular.extend(payload,
{
userName: vm.step3DsModel.userName,
password: vm.step3DsModel.password,
});
}
if (vm.step3DsModel.securityDomain !== '') {
angular.extend(payload,
{
securityDomain: vm.step3DsModel.securityDomain,
});
}

mwAddDatasourceService.sendAddDatasource(payload).then(
function(result) { // success
miqService.miqFlash(result.data.status, result.data.msg);
Expand All @@ -88,15 +99,13 @@ function MwAddDatasourceCtrl($scope, $rootScope, miqService, mwAddDatasourceServ
$scope.$watch(angular.bind(this, function() {
return vm.step2DsModel.selectedJdbcDriver;
}), function(driverSelection) {
var dsSelection = mwAddDatasourceService.findDsSelectionFromDriver(driverSelection);
if (dsSelection) {
vm.step1DsModel.datasourceName = dsSelection.name;
vm.step1DsModel.jndiName = dsSelection.jndiName;
vm.step2DsModel.jdbcDriverName = dsSelection.driverName;
vm.step3DsModel.connectionUrl = '';
if (driverSelection) {
vm.step1DsModel.datasourceName = driverSelection.id;
vm.step2DsModel.jdbcDriverName = driverSelection.label;
vm.step2DsModel.jdbcModuleName = driverSelection.moduleName;
}
if (mwAddDatasourceService.isXaDriver(driverSelection)) {
vm.step2DsModel.xaDsClass = driverSelection.xaDsClass;
vm.step2DsModel.driverClass = driverSelection.xaDsClass;
} else {
vm.step2DsModel.driverClass = driverSelection.driverClass;
}
Expand All @@ -122,23 +131,24 @@ function MwAddDatasourceCtrl($scope, $rootScope, miqService, mwAddDatasourceServ
vm.step2DsModel.jdbcModuleName = dsSelection.driverModuleName;
vm.step2DsModel.driverClass = dsSelection.driverClass;

mwAddDatasourceService.getExistingJdbcDrivers(serverId).then(function(result) {
var filteredResult;
if (vm.chooseDsModel.xaDatasource) {
filteredResult = _.filter(result, function(item) {
return item.xaDsClass != null;
});
} else {
filteredResult = _.filter(result, function(item) {
return item.driverClass != null;
});
}
vm.step2DsModel.existingJdbcDrivers = filteredResult;
mwAddDatasourceService.getExistingJdbcDrivers(serverId).then(function(drivers) {
vm.step2DsModel.existingJdbcDrivers = vm.filterXa(vm.chooseDsModel.xaDatasource, drivers);
}).catch(function(errorMsg) {
miqService.miqFlash(errorMsg.data.status, errorMsg.data.msg);
});
};

vm.filterXa = function(isXa, drivers) {
var filteredDrivers;

if (isXa) {
filteredDrivers = _.filter(drivers, function(driver) { return driver.xaDsClass != null; });
} else {
filteredDrivers = _.filter(drivers, function(driver) { return driver.driverClass != null; });
}
return filteredDrivers;
};

vm.addDatasourceStep1Back = function() {
vm.dsModel.step = 'CHOOSE_DS';
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function MwAddDatasourceService($http, $q) {
.map(function(driver) {
return {'id': driver.properties['Driver Name'].toUpperCase(),
'label': driver.properties['Driver Name'],
'moduleName': driver.properties['Module Name'],
'xaDsClass': driver.properties['XA DS Class'],
'driverClass': driver.properties['Driver Class']};
})
Expand Down

0 comments on commit 7540570

Please sign in to comment.