mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
push updates to backups list to client
This commit is contained in:
parent
38b6c1d67f
commit
d233ecbe34
4 changed files with 32 additions and 27 deletions
|
@ -1,7 +1,15 @@
|
||||||
import Backup from 'admin/models/backup';
|
import Backup from 'admin/models/backup';
|
||||||
|
|
||||||
export default Ember.Route.extend({
|
export default Ember.Route.extend({
|
||||||
|
activate() {
|
||||||
|
this.messageBus.subscribe("/admin/backups", backups => this.controller.set("model", backups));
|
||||||
|
},
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
return Backup.find();
|
return Backup.find();
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivate() {
|
||||||
|
this.messageBus.unsubscribe("/admin/backups");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,26 +9,24 @@ const LOG_CHANNEL = "/admin/backups/logs";
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this.messageBus.subscribe(LOG_CHANNEL, this._processLogMessage.bind(this));
|
this.messageBus.subscribe(LOG_CHANNEL, (log) => {
|
||||||
},
|
if (log.message === "[STARTED]") {
|
||||||
|
this.controllerFor("adminBackups").set("model.isOperationRunning", true);
|
||||||
_processLogMessage(log) {
|
this.controllerFor("adminBackupsLogs").get('logs').clear();
|
||||||
if (log.message === "[STARTED]") {
|
} else if (log.message === "[FAILED]") {
|
||||||
this.controllerFor("adminBackups").set("model.isOperationRunning", true);
|
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||||
this.controllerFor("adminBackupsLogs").get('logs').clear();
|
bootbox.alert(I18n.t("admin.backups.operations.failed", { operation: log.operation }));
|
||||||
} else if (log.message === "[FAILED]") {
|
} else if (log.message === "[SUCCESS]") {
|
||||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
Discourse.User.currentProp("hideReadOnlyAlert", false);
|
||||||
bootbox.alert(I18n.t("admin.backups.operations.failed", { operation: log.operation }));
|
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||||
} else if (log.message === "[SUCCESS]") {
|
if (log.operation === "restore") {
|
||||||
Discourse.User.currentProp("hideReadOnlyAlert", false);
|
// redirect to homepage when the restore is done (session might be lost)
|
||||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
window.location.pathname = Discourse.getURL("/");
|
||||||
if (log.operation === "restore") {
|
}
|
||||||
// redirect to homepage when the restore is done (session might be lost)
|
} else {
|
||||||
window.location.pathname = Discourse.getURL("/");
|
this.controllerFor("adminBackupsLogs").get('logs').pushObject(Em.Object.create(log));
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
this.controllerFor("adminBackupsLogs").get('logs').pushObject(Em.Object.create(log));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
|
@ -122,12 +120,7 @@ export default Discourse.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadSuccess(filename) {
|
uploadSuccess(filename) {
|
||||||
const self = this;
|
bootbox.alert(I18n.t("admin.backups.upload.success", { filename: filename }));
|
||||||
bootbox.alert(I18n.t("admin.backups.upload.success", { filename: filename }), function() {
|
|
||||||
Backup.find().then(function (backups) {
|
|
||||||
self.controllerFor("adminBackupsIndex").set("model", backups);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
uploadError(filename, message) {
|
uploadError(filename, message) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Jobs
|
module Jobs
|
||||||
|
|
||||||
class BackupChunksMerger < Jobs::Base
|
class BackupChunksMerger < Jobs::Base
|
||||||
sidekiq_options retry: false
|
sidekiq_options queue: 'critical', retry: false
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
filename = args[:filename]
|
filename = args[:filename]
|
||||||
|
@ -19,6 +19,10 @@ module Jobs
|
||||||
|
|
||||||
# merge all chunks
|
# merge all chunks
|
||||||
HandleChunkUpload.merge_chunks(chunks, upload_path: backup_path, tmp_upload_path: tmp_backup_path, model: Backup, identifier: identifier, filename: filename, tmp_directory: tmp_directory)
|
HandleChunkUpload.merge_chunks(chunks, upload_path: backup_path, tmp_upload_path: tmp_backup_path, model: Backup, identifier: identifier, filename: filename, tmp_directory: tmp_directory)
|
||||||
|
|
||||||
|
# push an updated list to the clients
|
||||||
|
data = ActiveModel::ArraySerializer.new(Backup.all, each_serializer: BackupSerializer).as_json
|
||||||
|
MessageBus.publish("/admin/backups", data, user_ids: User.staff.pluck(:id))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2894,7 +2894,7 @@ en:
|
||||||
label: "Upload"
|
label: "Upload"
|
||||||
title: "Upload a backup to this instance"
|
title: "Upload a backup to this instance"
|
||||||
uploading: "Uploading..."
|
uploading: "Uploading..."
|
||||||
success: "'{{filename}}' has successfully been uploaded."
|
success: "'{{filename}}' has successfully been uploaded. The file is now being processed and will take up to a minute to show up in the list."
|
||||||
error: "There has been an error while uploading '{{filename}}': {{message}}"
|
error: "There has been an error while uploading '{{filename}}': {{message}}"
|
||||||
operations:
|
operations:
|
||||||
is_running: "An operation is currently running..."
|
is_running: "An operation is currently running..."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue