Skip to content

Commit

Permalink
Merge pull request #267 from Ontotext-AD/GDB-5035-jdbc-column-suggest…
Browse files Browse the repository at this point in the history
…ions-warning-fix

GDB-5035 JDBC UI Columns suggestions warning fix
  • Loading branch information
teodossidossev authored Oct 7, 2020
2 parents 20a35b0 + f33be02 commit 2552439
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions src/js/angular/jdbc/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,29 +333,37 @@ function JdbcCreateCtrl($scope, $location, toastr, $repositories, $window, $time
}

$scope.getColumnsSuggestions = function () {
ModalService.openSimpleModal({
title: 'Warning',
message: 'Are you sure you want to get suggestions for all columns? This action will overwrite all column type mappings!',
warning: true
}).result
.then(function () {
JdbcRestService.getColumnNames($scope.currentQuery.query).success(function (columns) {
JdbcRestService.getColumnsTypeSuggestion($scope.currentQuery.query, columns).success(function (columnTypes) {
let suggestedColumns = [];
_.forEach(columnTypes, function (value, key) {
suggestedColumns.push({
column_name: key,
column_type: value.column_type,
nullable: false,
sparql_type: ''
});
});
$scope.currentQuery.columns = suggestedColumns;
$scope.currentQuery.isPristine = false;
if ($scope.currentQuery.columns && $scope.currentQuery.columns.length > 0) {
ModalService.openSimpleModal({
title: 'Warning',
message: 'Are you sure you want to get suggestions for all columns? This action will overwrite all column type mappings!',
warning: true
}).result
.then(function () {
getSuggestions();
});
} else {
getSuggestions();
}
};

function getSuggestions() {
JdbcRestService.getColumnNames($scope.currentQuery.query).success(function (columns) {
JdbcRestService.getColumnsTypeSuggestion($scope.currentQuery.query, columns).success(function (columnTypes) {
let suggestedColumns = [];
_.forEach(columnTypes, function (value, key) {
suggestedColumns.push({
column_name: key,
column_type: value.column_type,
nullable: false,
sparql_type: ''
});
});
$scope.currentQuery.columns = suggestedColumns;
$scope.currentQuery.isPristine = false;
});
};
});
}

$scope.deleteColumn = function (columnName, index) {
ModalService.openSimpleModal({
Expand Down

0 comments on commit 2552439

Please sign in to comment.