mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 17:23:42 +08:00
bf91532260
- Remove ArrayController - Remove {{view}} from templates - Replace many cases of needs: [‘controller’] with inject - Enable Ember Legacy Views
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import { ajax } from 'discourse/lib/ajax';
|
|
import PreloadStore from 'preload-store';
|
|
|
|
const Backup = Discourse.Model.extend({
|
|
destroy() {
|
|
return ajax("/admin/backups/" + this.get("filename"), { type: "DELETE" });
|
|
},
|
|
|
|
restore() {
|
|
return ajax("/admin/backups/" + this.get("filename") + "/restore", {
|
|
type: "POST",
|
|
data: { client_id: window.MessageBus.clientId }
|
|
});
|
|
}
|
|
});
|
|
|
|
Backup.reopenClass({
|
|
find() {
|
|
return PreloadStore.getAndRemove("backups", () => ajax("/admin/backups.json"))
|
|
.then(backups => backups.map(backup => Backup.create(backup)));
|
|
},
|
|
|
|
start(withUploads) {
|
|
if (withUploads === undefined) { withUploads = true; }
|
|
return ajax("/admin/backups", {
|
|
type: "POST",
|
|
data: {
|
|
with_uploads: withUploads,
|
|
client_id: window.MessageBus.clientId
|
|
}
|
|
}).then(result => {
|
|
if (!result.success) { bootbox.alert(result.message); }
|
|
});
|
|
},
|
|
|
|
cancel() {
|
|
return ajax("/admin/backups/cancel.json")
|
|
.then(result => {
|
|
if (!result.success) { bootbox.alert(result.message); }
|
|
});
|
|
},
|
|
|
|
rollback() {
|
|
return ajax("/admin/backups/rollback.json")
|
|
.then(result => {
|
|
if (!result.success) {
|
|
bootbox.alert(result.message);
|
|
} else {
|
|
// redirect to homepage (session might be lost)
|
|
window.location.pathname = Discourse.getURL("/");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
export default Backup;
|