feat: remove the debug window since log files are too large to render effectively
lets just save to the users computer so that they can view it themselvespull/3145/head
parent
e22d044913
commit
01948b9088
@ -1,28 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none';
|
||||
child-src 'self';
|
||||
connect-src 'self' https: wss:;
|
||||
font-src 'self';
|
||||
form-action 'self';
|
||||
frame-src 'none';
|
||||
img-src 'self' blob: data:;
|
||||
media-src 'self' blob:;
|
||||
object-src 'none';
|
||||
script-src 'self' 'unsafe-inline';
|
||||
style-src 'self' 'unsafe-inline';"
|
||||
/>
|
||||
<!-- Load first to prevent font swapping on start -->
|
||||
<link href="stylesheets/fonts.css" rel="stylesheet" type="text/css" />
|
||||
<link href="stylesheets/dist/manifest.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
require('./ts/mains/debug_log_start.js');
|
||||
</script>
|
||||
</html>
|
@ -1,35 +0,0 @@
|
||||
/* global window */
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
const { ipcRenderer } = require('electron');
|
||||
const url = require('url');
|
||||
|
||||
const os = require('os');
|
||||
|
||||
const i18n = require('./ts/util/i18n');
|
||||
|
||||
const config = url.parse(window.location.toString(), true).query;
|
||||
const { locale } = config;
|
||||
const localeMessages = ipcRenderer.sendSync('locale-data');
|
||||
|
||||
window._ = require('lodash');
|
||||
|
||||
window.getVersion = () => config.version;
|
||||
window.theme = config.theme;
|
||||
window.i18n = i18n.setupi18n(locale, localeMessages);
|
||||
|
||||
// got.js appears to need this to successfully submit debug logs to the cloud
|
||||
window.nodeSetImmediate = setImmediate;
|
||||
|
||||
window.getNodeVersion = () => config.node_version;
|
||||
window.getEnvironment = () => config.environment;
|
||||
|
||||
require('./ts/util/logging');
|
||||
|
||||
window.getOSRelease = () =>
|
||||
`${os.type()} ${os.release()}, Node.js ${config.node_version} ${os.platform()} ${os.arch()}`;
|
||||
window.getCommitHash = () => config.commitHash;
|
||||
|
||||
window.closeDebugLog = () => ipcRenderer.send('close-debug-log');
|
||||
|
||||
window.saveLog = logText => ipcRenderer.send('save-debug-log', logText);
|
@ -1,128 +0,0 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { SessionTheme } from '../themes/SessionTheme';
|
||||
import { switchThemeTo } from '../themes/switchTheme';
|
||||
import { fetchNodeLog } from '../util/logging';
|
||||
import { SessionButton, SessionButtonType } from './basic/SessionButton';
|
||||
import { SessionIconButton } from './icon';
|
||||
|
||||
const StyledContent = styled.div`
|
||||
background-color: var(--modal-background-content-color);
|
||||
color: var(--modal-text-color);
|
||||
font-family: var(--font-default);
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
height: 100%;
|
||||
|
||||
.session-button {
|
||||
margin: 1rem auto 1rem 0;
|
||||
padding: 1rem;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.session-icon-button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: var(--modal-text-color);
|
||||
}
|
||||
|
||||
textarea {
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: var(--margins-md);
|
||||
background-color: var(--input-background-color);
|
||||
color: var(--input-text-color);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
resize: none;
|
||||
min-height: 100px;
|
||||
|
||||
font-family: var(--font-debug);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
`;
|
||||
|
||||
const DebugLogTextArea = (props: { content: string }) => {
|
||||
return <textarea spellCheck="false" rows={10} value={props.content} style={{ height: '100%' }} />;
|
||||
};
|
||||
|
||||
const DebugLogButtons = (props: { content: string }) => {
|
||||
return (
|
||||
<div className="buttons">
|
||||
<SessionButton
|
||||
text={window.i18n('saveLogToDesktop')}
|
||||
buttonType={SessionButtonType.Simple}
|
||||
onClick={() => {
|
||||
if (props.content.length <= 20) {
|
||||
// loading
|
||||
return;
|
||||
}
|
||||
(window as any).saveLog(props.content);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const DebugLogViewAndSave = () => {
|
||||
const [content, setContent] = useState(window.i18n('loading'));
|
||||
|
||||
useEffect(() => {
|
||||
const operatingSystemInfo = `Operating System ${window.getOSRelease()}`;
|
||||
|
||||
const commitHashInfo = window.getCommitHash() ? `Commit ${window.getCommitHash()}` : '';
|
||||
|
||||
// eslint-disable-next-line more/no-then
|
||||
fetchNodeLog()
|
||||
.then((text: any) => {
|
||||
const debugLogWithSystemInfo = `${operatingSystemInfo} ${commitHashInfo} ${text}`;
|
||||
setContent(debugLogWithSystemInfo);
|
||||
})
|
||||
// eslint-disable-next-line no-console
|
||||
.catch(console.error);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<DebugLogTextArea content={content} />
|
||||
<DebugLogButtons content={content} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const DebugLogView = () => {
|
||||
useEffect(() => {
|
||||
if (window.theme) {
|
||||
void switchThemeTo({
|
||||
theme: window.theme,
|
||||
usePrimaryColor: true,
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<SessionTheme>
|
||||
<StyledContent>
|
||||
<div>
|
||||
<SessionIconButton
|
||||
aria-label="close debug log"
|
||||
iconType="exit"
|
||||
iconSize="medium"
|
||||
onClick={() => {
|
||||
window.closeDebugLog();
|
||||
}}
|
||||
/>
|
||||
<h1> {window.i18n('debugLog')} </h1>
|
||||
<p> {window.i18n('debugLogExplanation')}</p>
|
||||
</div>
|
||||
<DebugLogViewAndSave />
|
||||
</StyledContent>
|
||||
</SessionTheme>
|
||||
);
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { DebugLogView } from '../components/DebugLogView';
|
||||
|
||||
const container = document.getElementById('root');
|
||||
const root = createRoot(container!);
|
||||
root.render(<DebugLogView />);
|
Loading…
Reference in New Issue