Skip to content

A platform for community discussion. Free, open, simple.

push updates to backups list to client

Régis Hanold233ecbe34f3
diff --git a/app/assets/javascripts/admin/routes/admin-backups-index.js.es6 b/app/assets/javascripts/admin/routes/admin-backups-index.js.es6
index fce0b126d36..8c77fdd1aef 100644
--- a/app/assets/javascripts/admin/routes/admin-backups-index.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-backups-index.js.es6
@@ -1,7 +1,15 @@
import Backup from 'admin/models/backup';
export default Ember.Route.extend({
+ activate() {
+ this.messageBus.subscribe("/admin/backups", backups => this.controller.set("model", backups));
+ },
+
model() {
return Backup.find();
+ },
+
+ deactivate() {
+ this.messageBus.unsubscribe("/admin/backups");
}
});
diff --git a/app/assets/javascripts/admin/routes/admin-backups.js.es6 b/app/assets/javascripts/admin/routes/admin-backups.js.es6
index 92ac4652fa6..f992b5fc93f 100644
--- a/app/assets/javascripts/admin/routes/admin-backups.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-backups.js.es6
@@ -9,26 +9,24 @@ const LOG_CHANNEL = "/admin/backups/logs";
export default Discourse.Route.extend({
activate() {
- this.messageBus.subscribe(LOG_CHANNEL, this._processLogMessage.bind(this));
- },
-
- _processLogMessage(log) {
- if (log.message === "[STARTED]") {
- 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);
- bootbox.alert(I18n.t("admin.backups.operations.failed", { operation: log.operation }));
- } else if (log.message === "[SUCCESS]") {
- Discourse.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.pathname = Discourse.getURL("/");
+ this.messageBus.subscribe(LOG_CHANNEL, (log) => {
+ if (log.message === "[STARTED]") {
+ 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);
+ bootbox.alert(I18n.t("admin.backups.operations.failed", { operation: log.operation }));
+ } else if (log.message === "[SUCCESS]") {
+ Discourse.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.pathname = Discourse.getURL("/");
+ }
+ } else {
+ this.controllerFor("adminBackupsLogs").get('logs').pushObject(Em.Object.create(log));
}
- } else {
- this.controllerFor("adminBackupsLogs").get('logs').pushObject(Em.Object.create(log));
- }
+ });
},
model() {
@@ -122,12 +120,7 @@ export default Discourse.Route.extend({
},
uploadSuccess(filename) {
- const self = this;
- bootbox.alert(I18n.t("admin.backups.upload.success", { filename: filename }), function() {
- Backup.find().then(function (backups) {
- self.controllerFor("adminBackupsIndex").set("model", backups);
- });
- });
+ bootbox.alert(I18n.t("admin.backups.upload.success", { filename: filename }));
},
uploadError(filename, message) {
diff --git a/app/jobs/regular/backup_chunks_merger.rb b/app/jobs/regular/backup_chunks_merger.rb
index 97846fd4761..23cda4d2640 100644
--- a/app/jobs/regular/backup_chunks_merger.rb
+++ b/app/jobs/regular/backup_chunks_merger.rb
@@ -1,7 +1,7 @@
module Jobs
class BackupChunksMerger < Jobs::Base
- sidekiq_options retry: false
+ sidekiq_options queue: 'critical', retry: false
def execute(args)
filename = args[:filename]
@@ -19,6 +19,10 @@ module Jobs
# 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)
+
+ # 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
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 55348072830..0f716141286 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2894,7 +2894,7 @@ en:
label: "Upload"
title: "Upload a backup to this instance"
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}}"
operations:
is_running: "An operation is currently running..."