session-desktop/js/views/debug_log_view.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-03-05 23:57:23 +01:00
/* global i18n: false */
/* global Whisper: false */
// eslint-disable-next-line func-names
2018-04-27 23:25:04 +02:00
(function() {
'use strict';
window.Whisper = window.Whisper || {};
Whisper.DebugLogLinkView = Whisper.View.extend({
templateName: 'debug-log-link',
initialize(options) {
this.url = options.url;
},
render_attributes() {
return {
url: this.url,
reportIssue: i18n('reportIssue'),
};
},
});
Whisper.DebugLogView = Whisper.View.extend({
templateName: 'debug-log',
className: 'debug-log modal',
initialize() {
this.render();
this.$('textarea').val(i18n('loading'));
2021-10-11 05:20:33 +02:00
const operatingSystemInfo = `Operating System: ${window.getOSRelease()}`;
2021-10-11 03:28:34 +02:00
2021-10-11 05:20:33 +02:00
const commitHashInfo = window.getCommitHash() ? `Commit Hash: ${window.getCommitHash()}` : '';
2018-03-05 23:57:23 +01:00
// eslint-disable-next-line more/no-then
2018-04-27 23:25:04 +02:00
window.log.fetch().then(text => {
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text;
this.$('textarea').val(debugLogWithSystemInfo);
});
},
events: {
2022-03-07 03:21:24 +01:00
'click .submit': 'saveLogToDesktop',
'click .close': 'close',
},
render_attributes: {
title: i18n('debugLog'),
cancel: i18n('cancel'),
2022-03-07 03:21:24 +01:00
saveLogToDesktop: i18n('saveLogToDesktop'),
debugLogExplanation: i18n('debugLogExplanation'),
},
close() {
window.closeDebugLog();
},
2022-03-07 03:21:24 +01:00
async saveLogToDesktop(e) {
e.preventDefault();
const text = this.$('textarea').val();
if (text.length === 0) {
return;
}
2021-10-29 06:27:42 +02:00
window.saveLog(text);
2022-01-05 04:37:54 +01:00
window.closeDebugLog();
},
});
2018-04-27 23:25:04 +02:00
})();