2019-11-09 03:13:35 +08:00
|
|
|
import EmberObject from "@ember/object";
|
2020-05-28 20:42:36 +08:00
|
|
|
import MessageBus from "message-bus-client";
|
2016-07-01 01:55:44 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2016-07-05 02:15:51 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
export default class Backup extends EmberObject {
|
|
|
|
static find() {
|
2021-01-20 13:04:21 +08:00
|
|
|
return ajax("/admin/backups.json");
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2015-08-28 02:02:13 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
static start(withUploads) {
|
2015-08-28 02:02:13 +08:00
|
|
|
if (withUploads === undefined) {
|
|
|
|
withUploads = true;
|
|
|
|
}
|
2016-07-01 01:55:44 +08:00
|
|
|
return ajax("/admin/backups", {
|
2015-08-28 02:02:13 +08:00
|
|
|
type: "POST",
|
|
|
|
data: {
|
|
|
|
with_uploads: withUploads,
|
2020-05-28 20:42:36 +08:00
|
|
|
client_id: MessageBus.clientId,
|
2015-08-28 02:02:13 +08:00
|
|
|
},
|
|
|
|
});
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2015-08-28 02:02:13 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
static cancel() {
|
2017-03-23 10:29:35 +08:00
|
|
|
return ajax("/admin/backups/cancel.json", {
|
|
|
|
type: "DELETE",
|
|
|
|
});
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2015-08-28 02:02:13 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
static rollback() {
|
2017-03-23 10:29:35 +08:00
|
|
|
return ajax("/admin/backups/rollback.json", {
|
|
|
|
type: "POST",
|
2015-08-28 02:02:13 +08:00
|
|
|
});
|
2023-03-17 18:18:42 +08:00
|
|
|
}
|
2015-08-28 02:02:13 +08:00
|
|
|
|
2023-03-17 18:18:42 +08:00
|
|
|
destroy() {
|
|
|
|
return ajax("/admin/backups/" + this.filename, { type: "DELETE" });
|
|
|
|
}
|
|
|
|
|
|
|
|
restore() {
|
|
|
|
return ajax("/admin/backups/" + this.filename + "/restore", {
|
|
|
|
type: "POST",
|
|
|
|
data: { client_id: MessageBus.clientId },
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|