提交 c73d567d 编写于 作者: S Sercan

refactoring on dumps

上级 877d34cc
......@@ -27,5 +27,4 @@ npm-container
momentjs:moment
arch:ace-editor
aldeed:collection2
meteorhacks:kadira
ephemer:reactive-datatables-modified
......@@ -27,7 +27,6 @@ diff-sequence@1.0.1
ecmascript@0.1.6
ecmascript-runtime@0.2.6
ejson@1.0.7
email@1.0.8
ephemer:reactive-datatables-modified@1.1.0
es5-shim@4.1.14
fastclick@1.0.7
......@@ -50,14 +49,11 @@ jquery@1.11.4
launch-screen@1.0.4
less@2.5.1
livedata@1.0.15
localstorage@1.0.5
logging@1.0.8
mdg:validation-error@0.2.0
meteor@1.1.10
meteor-base@1.0.1
meteorhacks:async@1.0.0
meteorhacks:kadira@2.27.2
meteorhacks:meteorx@1.4.1
meteorhacks:npm@1.5.0
minifiers@1.1.7
minimongo@1.0.10
......@@ -66,7 +62,6 @@ mobile-status-bar@1.0.6
momentjs:moment@2.10.6
mongo@1.1.3
mongo-id@1.0.1
mongo-livedata@1.0.9
npm-container@1.2.0
npm-mongo@1.4.39_1
observe-sequence@1.0.7
......
......@@ -51,21 +51,31 @@ Template.databaseDumpRestore.events({
var table = $('#tblDumps').DataTable();
if (table.row(this).data()) {
var laddaButton = $('#btnTakeDump').ladda();
laddaButton.ladda('start');
var dumpInfo = table.row(this).data();
dumpInfo.status = DUMP_STATUS.IN_PROGRESS;
Meteor.call('updateDump', dumpInfo); // this is a simple update to notify user on UI
Meteor.call('restoreDump', connection, dumpInfo, function (err) {
if (err) {
toastr.error("Couldn't restore dump, " + err.message);
}
else {
toastr.success('A background process to restore the dump(' + dumpInfo.filePath + ') has started, whenever it finishes you can see the result on this page');
}
Ladda.stopAll();
swal({
title: "Are you sure?",
text: "All collections will be dropped, and restored !",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, do it!",
closeOnConfirm: false
}, function () {
var laddaButton = $('#btnTakeDump').ladda();
laddaButton.ladda('start');
var dumpInfo = table.row(this).data();
dumpInfo.status = DUMP_STATUS.IN_PROGRESS;
Meteor.call('updateDump', dumpInfo); // this is a simple update to notify user on UI
Meteor.call('restoreDump', connection, dumpInfo, function (err) {
if (err) {
toastr.error("Couldn't restore dump, " + err.message);
}
else {
toastr.success('A background process to restore the dump(' + dumpInfo.filePath + ') has started, whenever it finishes you can see the result on this page');
}
Ladda.stopAll();
});
});
}
}
......@@ -74,7 +84,7 @@ Template.databaseDumpRestore.events({
Template.databaseDumpRestore.helpers({
'getDumps': function () {
return function () {
return Dumps.find().fetch(); // or .map()
return Dumps.find({}, {sort: {date: -1}}).fetch(); // or .map()
};
},
......
......@@ -8,7 +8,7 @@ Meteor.methods({
var path = dumpInfo.filePath.substring(0, dumpInfo.filePath.indexOf('/'));
var fileName = dumpInfo.filePath.substring(dumpInfo.filePath.indexOf('/') + 1);
console.log('[DUMP] Restoring dump ' + JSON.stringify(dumpInfo) + ' to the ' + connectionUrl);
console.log('[DUMP]', 'Restoring dump ' + JSON.stringify(dumpInfo) + ' to the ' + connectionUrl);
try {
restore({
uri: connectionUrl,
......@@ -17,13 +17,13 @@ Meteor.methods({
drop: true,
callback: Meteor.bindEnvironment(function () {
dumpInfo.status = DUMP_STATUS.FINISHED;
console.log("[DUMP] Dump has successfuly restored: " + JSON.stringify(dumpInfo));
console.log("[DUMP]','Dump has successfuly restored: " + JSON.stringify(dumpInfo));
Meteor.call('updateDump', dumpInfo);
})
});
}
catch (ex) {
console.log('[DUMP] Unexpected exception during dump process: ', ex);
console.log('[DUMP]', 'Unexpected exception during dump process: ', ex);
dumpInfo.status = DUMP_STATUS.ERROR;
Meteor.call('updateDump', dumpInfo);
}
......@@ -35,8 +35,9 @@ Meteor.methods({
var fileName = connection.databaseName + "_" + date.getTime() + ".tar";
var fullFilePath = path + "/" + fileName;
var backup = Meteor.npmRequire('mongodb-backup');
var fs = Meteor.npmRequire('fs');
console.log('[DUMP] Taking dump to the path: ' + path + " with fileName: " + fileName);
console.log('[DUMP]', 'Taking dump to the path: ' + path + " with fileName: " + fileName);
try {
backup({
uri: connectionUrl,
......@@ -44,7 +45,6 @@ Meteor.methods({
tar: fileName,
//stream :
callback: Meteor.bindEnvironment(function () {
var fs = Meteor.npmRequire('fs');
var stats = fs.statSync(fullFilePath);
var dump = {
......@@ -55,14 +55,15 @@ Meteor.methods({
status: DUMP_STATUS.NOT_IMPORTED
};
console.log("[DUMP] Trying to save dump: " + JSON.stringify(dump));
console.log("[DUMP]','Trying to save dump: " + JSON.stringify(dump));
Meteor.call('saveDump', dump);
console.log('[DUMP] Dump process has finished');
console.log('[DUMP]', 'Dump process has finished');
})
});
}
catch (ex) {
console.log('Unexpected exception during dump process: ', ex);
console.log('[DUMP]', 'Unexpected exception during dump process: ', ex);
}
}
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册