FIX: Backup logs were usually missing the first few lines
And because of debouncing, the log wasn't always reset at the beginning of a backup or restore.
This commit is contained in:
parent
18d5d51d98
commit
681262ddce
|
@ -2,6 +2,7 @@ import debounce from "discourse/lib/debounce";
|
|||
import { renderSpinner } from "discourse/helpers/loading-spinner";
|
||||
import { escapeExpression } from "discourse/lib/utilities";
|
||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||
import { observes, on } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Component.extend(
|
||||
bufferedRender({
|
||||
|
@ -21,11 +22,21 @@ export default Ember.Component.extend(
|
|||
$div.scrollTop = $div.scrollHeight;
|
||||
},
|
||||
|
||||
@on("init")
|
||||
@observes("logs.[]")
|
||||
_resetFormattedLogs() {
|
||||
if (this.get("logs").length === 0) {
|
||||
this._reset(); // reset the cached logs whenever the model is reset
|
||||
this.rerenderBuffer();
|
||||
}
|
||||
},
|
||||
|
||||
@on("init")
|
||||
@observes("logs.[]")
|
||||
_updateFormattedLogs: debounce(function() {
|
||||
const logs = this.get("logs");
|
||||
if (logs.length === 0) {
|
||||
this._reset(); // reset the cached logs whenever the model is reset
|
||||
} else {
|
||||
if (logs.length === 0) return;
|
||||
|
||||
// do the log formatting only once for HELLish performance
|
||||
let formattedLogs = this.get("formattedLogs");
|
||||
for (let i = this.get("index"), length = logs.length; i < length; i++) {
|
||||
|
@ -40,11 +51,9 @@ export default Ember.Component.extend(
|
|||
});
|
||||
// force rerender
|
||||
this.rerenderBuffer();
|
||||
}
|
||||
|
||||
Ember.run.scheduleOnce("afterRender", this, this._scrollDown);
|
||||
}, 150)
|
||||
.observes("logs.[]")
|
||||
.on("init"),
|
||||
}, 150),
|
||||
|
||||
buildBuffer(buffer) {
|
||||
const formattedLogs = this.get("formattedLogs");
|
||||
|
|
|
@ -1,24 +1,17 @@
|
|||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import Backup from "admin/models/backup";
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
adminBackupsLogs: Ember.inject.controller(),
|
||||
|
||||
_startBackup(withUploads) {
|
||||
this.currentUser.set("hideReadOnlyAlert", true);
|
||||
Backup.start(withUploads).then(() => {
|
||||
this.get("adminBackupsLogs.logs").clear();
|
||||
this.send("backupStarted");
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
startBackup() {
|
||||
this._startBackup();
|
||||
startBackupWithUploads() {
|
||||
this.send("closeModal");
|
||||
this.send("startBackup", true);
|
||||
},
|
||||
|
||||
startBackupWithoutUpload() {
|
||||
this._startBackup(false);
|
||||
startBackupWithoutUploads() {
|
||||
this.send("closeModal");
|
||||
this.send("startBackup", false);
|
||||
},
|
||||
|
||||
cancel() {
|
||||
|
|
|
@ -10,6 +10,7 @@ export default Discourse.Route.extend({
|
|||
activate() {
|
||||
this.messageBus.subscribe(LOG_CHANNEL, log => {
|
||||
if (log.message === "[STARTED]") {
|
||||
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
true
|
||||
|
@ -62,15 +63,14 @@ export default Discourse.Route.extend({
|
|||
},
|
||||
|
||||
actions: {
|
||||
startBackup() {
|
||||
showStartBackupModal() {
|
||||
showModal("admin-start-backup", { admin: true });
|
||||
this.controllerFor("modal").set("modalClass", "start-backup-modal");
|
||||
},
|
||||
|
||||
backupStarted() {
|
||||
this.controllerFor("adminBackups").set("isOperationRunning", true);
|
||||
startBackup(withUploads) {
|
||||
this.transitionTo("admin.backups.logs");
|
||||
this.send("closeModal");
|
||||
Backup.start(withUploads);
|
||||
},
|
||||
|
||||
destroyBackup(backup) {
|
||||
|
@ -100,17 +100,8 @@ export default Discourse.Route.extend({
|
|||
I18n.t("yes_value"),
|
||||
function(confirmed) {
|
||||
if (confirmed) {
|
||||
Discourse.User.currentProp("hideReadOnlyAlert", true);
|
||||
backup.restore().then(function() {
|
||||
self
|
||||
.controllerFor("adminBackupsLogs")
|
||||
.get("logs")
|
||||
.clear();
|
||||
self
|
||||
.controllerFor("adminBackups")
|
||||
.set("model.isOperationRunning", true);
|
||||
self.transitionTo("admin.backups.logs");
|
||||
});
|
||||
backup.restore();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
label="admin.backups.operations.cancel.label"
|
||||
icon="times"}}
|
||||
{{else}}
|
||||
{{d-button action="startBackup"
|
||||
{{d-button action="showStartBackupModal"
|
||||
class="btn-primary"
|
||||
title="admin.backups.operations.backup.title"
|
||||
label="admin.backups.operations.backup.label"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{#d-modal-body title="admin.backups.operations.backup.confirm"}}
|
||||
<button {{action "startBackup"}} class="btn btn-primary">{{i18n 'yes_value'}}</button>
|
||||
<button {{action "startBackupWithoutUpload"}} class="btn">{{i18n 'admin.backups.operations.backup.without_uploads'}}</button>
|
||||
<button {{action "startBackupWithUploads"}} class="btn btn-primary">{{i18n 'yes_value'}}</button>
|
||||
<button {{action "startBackupWithoutUploads"}} class="btn">{{i18n 'admin.backups.operations.backup.without_uploads'}}</button>
|
||||
<button {{action "cancel"}} class="btn">{{i18n 'no_value'}}</button>
|
||||
{{/d-modal-body}}
|
||||
|
|
Loading…
Reference in New Issue