Ensure that Utilities(Backup/Restore/Maintenence/Import-Export) should not be started

if binary path is wrong and also added 'Stop Process' button to cancel the process.
This commit is contained in:
Akshay Joshi
2018-10-22 12:35:21 +05:30
parent 370df47042
commit 6bc6bc7f60
49 changed files with 731 additions and 101 deletions

View File

@@ -10,6 +10,8 @@
import gettext from '../../../../static/js/gettext';
import Backform from '../../../../static/js/backform.pgadmin';
import {Dialog} from '../../../../static/js/alertify/dialog';
import url_for from 'sources/url_for';
import axios from 'axios/index';
export class BackupDialog extends Dialog {
constructor(pgBrowser, $, alertify, BackupModel, backform = Backform) {
@@ -19,6 +21,13 @@ export class BackupDialog extends Dialog {
);
}
url_for_utility_exists(id, params){
return url_for('backup.utility_exists', {
'sid': id,
'backup_obj_type': params == null ? 'objects' : 'servers',
});
}
draw(action, aciTreeItem, params) {
const serverInformation = this.retrieveAncestorOfTypeServer(aciTreeItem);
@@ -30,17 +39,40 @@ export class BackupDialog extends Dialog {
return;
}
const typeOfDialog = BackupDialog.typeOfDialog(params);
const baseUrl = this.url_for_utility_exists(serverInformation._id, params);
// Check pg_dump or pg_dumpall utility exists or not.
let that = this;
let service = axios.create({});
service.get(
baseUrl
).then(function(res) {
if (!res.data.success) {
that.alertify.alert(
gettext('Utility not found'),
res.data.errormsg
);
return;
}
if (!this.canExecuteOnCurrentDatabase(aciTreeItem)) {
const typeOfDialog = BackupDialog.typeOfDialog(params);
if (!that.canExecuteOnCurrentDatabase(aciTreeItem)) {
return;
}
const dialog = that.createOrGetDialog(
BackupDialog.dialogTitle(typeOfDialog),
typeOfDialog
);
dialog(true).resizeTo('60%', '50%');
}).catch(function() {
that.alertify.alert(
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);
return;
}
const dialog = this.createOrGetDialog(
BackupDialog.dialogTitle(typeOfDialog),
typeOfDialog
);
dialog(true).resizeTo('60%', '50%');
});
}
static typeOfDialog(params) {

View File

@@ -147,9 +147,16 @@ export class BackupDialogWrapper extends DialogWrapper {
service.post(
baseUrl,
this.view.model.toJSON()
).then(function () {
dialog.alertify.success(gettext('Backup job created.'), 5);
dialog.pgBrowser.Events.trigger('pgadmin-bgprocess:created', dialog);
).then(function (res) {
if (res.data.success) {
dialog.alertify.success(gettext('Backup job created.'), 5);
dialog.pgBrowser.Events.trigger('pgadmin-bgprocess:created', dialog);
} else {
dialog.alertify.alert(
gettext('Backup job creation failed.'),
res.data.errormsg
);
}
}).catch(function (error) {
try {
const err = error.response.data;