Skip to content

Commit

Permalink
Fixed #2915 (#3004)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanZGenchev authored Nov 20, 2023
1 parent 30c346a commit 3b81dbc
Showing 1 changed file with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
$scope.datasource = evt.data;
}, true);

$scope.showProgress = function () {
$scope.state.isBusy = true;
messageHub.showStatusBusy("Executing query...");
};

$scope.hideProgress = function () {
$scope.state.isBusy = false;
messageHub.hideStatusBusy();
};

messageHub.onDidReceiveMessage("database.sql.execute", function (command) {
$scope.state.error = false;
$scope.state.isBusy = true;
$scope.showProgress();
let url = "/services/data/" + $scope.datasource;
let sql = command.data.trim().toLowerCase();
if (sql.startsWith('select')) {
Expand Down Expand Up @@ -82,13 +92,13 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
} else {
$scope.result = 'Empty result';
}
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (reject) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = reject.data.message;
console.error(reject);
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
} else if (sql.startsWith('call')) {
Expand Down Expand Up @@ -139,13 +149,13 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
} else {
$scope.result = 'Empty result';
}
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (reject) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = reject.data.message;
console.error(reject);
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
} else if (sql.startsWith('query: ')) {
Expand Down Expand Up @@ -176,13 +186,13 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
} else {
$scope.result = 'Empty result';
}
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (reject) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = reject.data.message;
console.error(reject);
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
} else if (sql.startsWith('update: ')) {
Expand All @@ -206,13 +216,13 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
$scope.result = 'Empty result';
}
$scope.result = result.data;
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (reject) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = reject.data.message;
console.error(reject);
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
} else {
Expand All @@ -236,13 +246,13 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
$scope.result = 'Empty result';
}
$scope.result = result.data;
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (reject) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = reject.data.message;
console.error(reject);
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
}
Expand Down Expand Up @@ -354,12 +364,12 @@ resultView.controller('DatabaseResultController', ['$scope', '$http', 'messageHu
} else {
$scope.result = 'Data anonymized.';
}
$scope.state.isBusy = false;
$scope.hideProgress();
}, function (result) {
cleanScope();
$scope.state.error = true;
$scope.errorMessage = result.data.errorMessage;
$scope.state.isBusy = false;
$scope.hideProgress();
}
);
}, true);
Expand Down

0 comments on commit 3b81dbc

Please sign in to comment.