2014-06-23 18:24:37 +04:00
|
|
|
var DebugController = Ember.Controller.extend(Ember.Evented, {
|
2014-04-08 02:01:46 +04:00
|
|
|
uploadButtonText: 'Import',
|
2014-06-23 18:24:37 +04:00
|
|
|
|
|
|
|
exportPath: function () {
|
|
|
|
return this.get('ghostPaths').apiUrl('db');
|
|
|
|
}.property(),
|
|
|
|
|
2014-04-08 02:01:46 +04:00
|
|
|
actions: {
|
2014-06-23 18:24:37 +04:00
|
|
|
onUpload: function (file) {
|
|
|
|
var self = this,
|
|
|
|
formData = new FormData();
|
|
|
|
|
2014-04-08 02:01:46 +04:00
|
|
|
this.set('uploadButtonText', 'Importing');
|
2014-06-23 18:24:37 +04:00
|
|
|
|
|
|
|
formData.append('importfile', file);
|
|
|
|
|
|
|
|
ic.ajax.request(this.get('ghostPaths').apiUrl('db'), {
|
|
|
|
type: 'POST',
|
|
|
|
headers: {
|
|
|
|
'X-CSRF-Token': $('meta[name="csrf-param"]').attr('content')
|
|
|
|
},
|
|
|
|
data: formData,
|
|
|
|
dataType: 'json',
|
|
|
|
cache: false,
|
|
|
|
contentType: false,
|
|
|
|
processData: false
|
|
|
|
}).then(function () {
|
|
|
|
self.notifications.showSuccess('Import successful.');
|
|
|
|
}).catch(function (response) {
|
|
|
|
self.notifications.showErrors(response);
|
|
|
|
}).finally(function () {
|
|
|
|
self.set('uploadButtonText', 'Import');
|
|
|
|
self.trigger('reset');
|
|
|
|
});
|
2014-04-08 02:01:46 +04:00
|
|
|
},
|
2014-06-23 18:24:37 +04:00
|
|
|
|
|
|
|
exportData: function () {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
ic.ajax.request(this.get('ghostPaths').apiUrl('db'), {
|
|
|
|
type: 'GET'
|
|
|
|
}).then(function () {
|
|
|
|
self.notifications.showSuccess('Data exported successfully.');
|
|
|
|
}).catch(function (response) {
|
|
|
|
self.notifications.showErrors(response);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-04-08 02:01:46 +04:00
|
|
|
sendTestEmail: function () {
|
2014-06-23 18:24:37 +04:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
ic.ajax.request(this.get('ghostPaths').apiUrl('mail', 'test'), {
|
|
|
|
type: 'POST',
|
|
|
|
headers: {
|
|
|
|
'X-CSRF-Token': $('meta[name="csrf-param"]').attr('content')
|
|
|
|
}
|
|
|
|
}).then(function () {
|
|
|
|
self.notifications.showSuccess('Check your email for the test message:');
|
|
|
|
}).catch(function (response) {
|
|
|
|
self.notifications.showErrors(response);
|
|
|
|
});
|
2014-04-08 02:01:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-23 18:24:37 +04:00
|
|
|
export default DebugController;
|