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() {
|
2018-03-05 23:54:33 +01:00
|
|
|
'use strict';
|
2015-09-16 08:28:00 +02:00
|
|
|
|
2018-03-05 23:54:33 +01:00
|
|
|
window.Whisper = window.Whisper || {};
|
2017-10-04 23:40:35 +02:00
|
|
|
|
2018-03-05 23:54:33 +01:00
|
|
|
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'));
|
2015-09-16 08:28:00 +02:00
|
|
|
|
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()}` : '';
|
2021-10-06 02:35:57 +02:00
|
|
|
|
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 => {
|
2021-10-06 02:35:57 +02:00
|
|
|
const debugLogWithSystemInfo = operatingSystemInfo + commitHashInfo + text;
|
|
|
|
|
|
|
|
this.$('textarea').val(debugLogWithSystemInfo);
|
2018-03-05 23:54:33 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
events: {
|
2022-03-07 03:21:24 +01:00
|
|
|
'click .submit': 'saveLogToDesktop',
|
2018-03-05 23:54:33 +01:00
|
|
|
'click .close': 'close',
|
|
|
|
},
|
|
|
|
render_attributes: {
|
2022-03-03 03:56:36 +01:00
|
|
|
title: i18n('debugLog'),
|
2018-03-05 23:54:33 +01:00
|
|
|
cancel: i18n('cancel'),
|
2022-03-07 03:21:24 +01:00
|
|
|
saveLogToDesktop: i18n('saveLogToDesktop'),
|
2018-03-05 23:54:33 +01:00
|
|
|
debugLogExplanation: i18n('debugLogExplanation'),
|
|
|
|
},
|
2018-07-04 00:33:50 +02:00
|
|
|
close() {
|
|
|
|
window.closeDebugLog();
|
2018-03-05 23:54:33 +01:00
|
|
|
},
|
2022-03-07 03:21:24 +01:00
|
|
|
async saveLogToDesktop(e) {
|
2018-03-05 23:54:33 +01:00
|
|
|
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-03-05 23:54:33 +01:00
|
|
|
},
|
|
|
|
});
|
2018-04-27 23:25:04 +02:00
|
|
|
})();
|