mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
This reverts commit b0839ccf27.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import Backup from "admin/models/backup";
|
||||
import Route from "@ember/routing/route";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Route.extend({
|
||||
activate() {
|
||||
this.messageBus.subscribe("/admin/backups", this.onMessage);
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe("/admin/backups", this.onMessage);
|
||||
this.messageBus.subscribe("/admin/backups", (backups) =>
|
||||
this.controller.set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
model() {
|
||||
@@ -17,11 +17,7 @@ export default Route.extend({
|
||||
);
|
||||
},
|
||||
|
||||
@bind
|
||||
onMessage(backups) {
|
||||
this.controller.set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
);
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe("/admin/backups");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,19 +10,46 @@ import { extractError } from "discourse/lib/ajax-error";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
const LOG_CHANNEL = "/admin/backups/logs";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
dialog: service(),
|
||||
|
||||
activate() {
|
||||
this.messageBus.subscribe(LOG_CHANNEL, this.onMessage);
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe(LOG_CHANNEL, this.onMessage);
|
||||
this.messageBus.subscribe(LOG_CHANNEL, (log) => {
|
||||
if (log.message === "[STARTED]") {
|
||||
User.currentProp("hideReadOnlyAlert", true);
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
true
|
||||
);
|
||||
this.controllerFor("adminBackupsLogs").get("logs").clear();
|
||||
} else if (log.message === "[FAILED]") {
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.operations.failed", {
|
||||
operation: log.operation,
|
||||
})
|
||||
);
|
||||
} else if (log.message === "[SUCCESS]") {
|
||||
User.currentProp("hideReadOnlyAlert", false);
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
if (log.operation === "restore") {
|
||||
// redirect to homepage when the restore is done (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
} else {
|
||||
this.controllerFor("adminBackupsLogs")
|
||||
.get("logs")
|
||||
.pushObject(EmberObject.create(log));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
model() {
|
||||
@@ -37,31 +64,8 @@ export default DiscourseRoute.extend({
|
||||
);
|
||||
},
|
||||
|
||||
@bind
|
||||
onMessage(log) {
|
||||
if (log.message === "[STARTED]") {
|
||||
User.currentProp("hideReadOnlyAlert", true);
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", true);
|
||||
this.controllerFor("adminBackupsLogs").get("logs").clear();
|
||||
} else if (log.message === "[FAILED]") {
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.operations.failed", {
|
||||
operation: log.operation,
|
||||
})
|
||||
);
|
||||
} else if (log.message === "[SUCCESS]") {
|
||||
User.currentProp("hideReadOnlyAlert", false);
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||
if (log.operation === "restore") {
|
||||
// redirect to homepage when the restore is done (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
} else {
|
||||
this.controllerFor("adminBackupsLogs")
|
||||
.get("logs")
|
||||
.pushObject(EmberObject.create(log));
|
||||
}
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe(LOG_CHANNEL);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
Reference in New Issue
Block a user