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

@@ -11,6 +11,8 @@ import gettext from '../../../../static/js/gettext';
import {sprintf} from 'sprintf-js';
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 RestoreDialog extends Dialog {
constructor(pgBrowser, $, alertify, RestoreModel, backform = Backform) {
@@ -19,6 +21,12 @@ export class RestoreDialog extends Dialog {
pgBrowser, $, alertify, RestoreModel, backform);
}
url_for_utility_exists(id){
return url_for('restore.utility_exists', {
'sid': id,
});
}
draw(action, aciTreeItem) {
const serverInformation = this.retrieveAncestorOfTypeServer(aciTreeItem);
@@ -31,23 +39,43 @@ export class RestoreDialog extends Dialog {
return;
}
if (!this.canExecuteOnCurrentDatabase(aciTreeItem)) {
const baseUrl = this.url_for_utility_exists(serverInformation._id);
// Check pg_restore 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 (!that.canExecuteOnCurrentDatabase(aciTreeItem)) {
return;
}
let aciTreeItem1 = aciTreeItem || that.pgBrowser.treeMenu.selected();
let item = that.pgBrowser.treeMenu.findNodeByDomElement(aciTreeItem1);
const data = item.getData();
const node = that.pgBrowser.Nodes[data._type];
if (!node)
return;
let title = sprintf(gettext('Restore (%s: %s)'), node.label, data.label);
that.createOrGetDialog(title, 'restore');
that.alertify.pg_restore(title, aciTreeItem1, data, node).resizeTo('65%', '60%');
}).catch(function() {
that.alertify.alert(
gettext('Utility not found'),
gettext('Failed to fetch Utility information')
);
return;
}
let aciTreeItem1 = aciTreeItem || this.pgBrowser.treeMenu.selected();
let item = this.pgBrowser.treeMenu.findNodeByDomElement(aciTreeItem1);
const data = item.getData();
const node = this.pgBrowser.Nodes[data._type];
if (!node)
return;
let title = sprintf(gettext('Restore (%s: %s)'), node.label, data.label);
this.createOrGetDialog(title, 'restore');
this.alertify.pg_restore(title, aciTreeItem1, data, node).resizeTo('65%', '60%');
});
}
dialogName() {

View File

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