mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
4f727ed068
closes #2422 - updated to use new change password method - have all save settings use notifications - create assetUrl helper for creating asset paths with subdir's properly prefixed - move all url based helpers onto a url object in ghost-paths
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
var DebugController = Ember.Controller.extend(Ember.Evented, {
|
|
uploadButtonText: 'Import',
|
|
|
|
exportPath: function () {
|
|
return this.get('ghostPaths.url').api('db') +
|
|
'?access_token=' + this.get('session.access_token');
|
|
}.property(),
|
|
|
|
actions: {
|
|
onUpload: function (file) {
|
|
var self = this,
|
|
formData = new FormData();
|
|
|
|
this.set('uploadButtonText', 'Importing');
|
|
|
|
formData.append('importfile', file);
|
|
|
|
ic.ajax.request(this.get('ghostPaths.url').api('db'), {
|
|
type: 'POST',
|
|
data: formData,
|
|
dataType: 'json',
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false
|
|
}).then(function () {
|
|
self.notifications.showSuccess('Import successful.');
|
|
}).catch(function (response) {
|
|
self.notifications.showAPIError(response);
|
|
}).finally(function () {
|
|
self.set('uploadButtonText', 'Import');
|
|
self.trigger('reset');
|
|
});
|
|
},
|
|
|
|
exportData: function () {
|
|
var self = this;
|
|
|
|
ic.ajax.request(this.get('ghostPaths.url').api('db'), {
|
|
type: 'GET'
|
|
}).then(function () {
|
|
self.notifications.showSuccess('Data exported successfully.');
|
|
}).catch(function (response) {
|
|
self.notifications.showErrors(response);
|
|
});
|
|
},
|
|
|
|
sendTestEmail: function () {
|
|
var self = this;
|
|
|
|
ic.ajax.request(this.get('ghostPaths.url').api('mail', 'test'), {
|
|
type: 'POST'
|
|
}).then(function () {
|
|
self.notifications.showSuccess('Check your email for the test message:');
|
|
}).catch(function (response) {
|
|
self.notifications.showErrors(response);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default DebugController;
|