mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: backup logs on Firefox
FIX: debounce backup logs in order to prevent Firefox crash FIX: 'Invalid date' in backup logs in Firefox
This commit is contained in:
parent
6ae40dc1f8
commit
c9a007d5fb
3 changed files with 17 additions and 15 deletions
|
@ -9,7 +9,7 @@ export default Discourse.View.extend({
|
|||
this.setProperties({ formattedLogs: "", index: 0 });
|
||||
},
|
||||
|
||||
_updateFormattedLogs: function() {
|
||||
_updateFormattedLogs: Discourse.debounce(function() {
|
||||
var logs = this.get("controller.model");
|
||||
if (logs.length === 0) {
|
||||
this._reset(); // reset the cached logs whenever the model is reset
|
||||
|
@ -17,7 +17,7 @@ export default Discourse.View.extend({
|
|||
// do the log formatting only once for HELLish performance
|
||||
var formattedLogs = this.get("formattedLogs");
|
||||
for (var i = this.get("index"), length = logs.length; i < length; i++) {
|
||||
var date = moment(logs[i].get("timestamp")).format("YYYY-MM-DD HH:mm:ss"),
|
||||
var date = logs[i].get("timestamp"),
|
||||
message = Handlebars.Utils.escapeExpression(logs[i].get("message"));
|
||||
formattedLogs += "[" + date + "] " + message + "\n";
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export default Discourse.View.extend({
|
|||
// force rerender
|
||||
this.rerender();
|
||||
}
|
||||
}.observes("controller.model.@each"),
|
||||
}, 150).observes("controller.model.@each"),
|
||||
|
||||
render: function(buffer) {
|
||||
var formattedLogs = this.get("formattedLogs");
|
||||
|
|
|
@ -327,19 +327,20 @@ module BackupRestore
|
|||
end
|
||||
|
||||
def log(message)
|
||||
timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
puts(message) rescue nil
|
||||
publish_log(message) rescue nil
|
||||
save_log(message)
|
||||
publish_log(message, timestamp) rescue nil
|
||||
save_log(message, timestamp)
|
||||
end
|
||||
|
||||
def publish_log(message)
|
||||
def publish_log(message, timestamp)
|
||||
return unless @publish_to_message_bus
|
||||
data = { timestamp: Time.now, operation: "backup", message: message }
|
||||
data = { timestamp: timestamp, operation: "backup", message: message }
|
||||
MessageBus.publish(BackupRestore::LOGS_CHANNEL, data, user_ids: [@user_id])
|
||||
end
|
||||
|
||||
def save_log(message)
|
||||
@logs << "[#{Time.now}] #{message}"
|
||||
def save_log(message, timestamp)
|
||||
@logs << "[#{timestamp}] #{message}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -339,19 +339,20 @@ module BackupRestore
|
|||
end
|
||||
|
||||
def log(message)
|
||||
timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
puts(message) rescue nil
|
||||
publish_log(message) rescue nil
|
||||
save_log(message)
|
||||
publish_log(message, timestamp) rescue nil
|
||||
save_log(message, timestamp)
|
||||
end
|
||||
|
||||
def publish_log(message)
|
||||
def publish_log(message, timestamp)
|
||||
return unless @publish_to_message_bus
|
||||
data = { timestamp: Time.now, operation: "restore", message: message }
|
||||
data = { timestamp: timestamp, operation: "restore", message: message }
|
||||
MessageBus.publish(BackupRestore::LOGS_CHANNEL, data, user_ids: [@user_id])
|
||||
end
|
||||
|
||||
def save_log(message)
|
||||
@logs << "[#{Time.now}] #{message}"
|
||||
def save_log(message, timestamp)
|
||||
@logs << "[#{timestamp}] #{message}"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue