Skip to content

Commit

Permalink
feat: gave device deployment log files more descriptive file names
Browse files Browse the repository at this point in the history
TIcket: MEN-7221
Changelog: Title
Signed-off-by: Manuel Zedel <[email protected]>
  • Loading branch information
mzedel committed May 29, 2024
1 parent 7fed1ff commit 7ac48f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 5 additions & 11 deletions src/js/components/common/dialogs/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,26 @@ import CopyToClipboard from 'react-copy-to-clipboard';

import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material';

import { createFileDownload } from '../../../helpers';
import { Code } from '../copy-code';

const wrapperStyle = { marginRight: 10, display: 'inline-block' };

const dialogTypes = {
'deviceLog': {
title: 'Deployment log for device',
filename: 'deviceLog'
filename: ({ device, releaseName, date }) => `deployment-log-${device}-${releaseName}-${date}.log`
},
'configUpdateLog': {
title: 'Config update log for device',
filename: 'updateLog'
},
'monitorLog': {
title: 'Alert log for device',
filename: 'monitorLog'
filename: () => 'configuration-update.log'
}
};

export const LogDialog = ({ logData = '', onClose, type = 'deviceLog' }) => {
export const LogDialog = ({ context = {}, logData = '', onClose, type = 'deviceLog' }) => {
const [copied, setCopied] = useState(false);

const exportLog = () => {
const uriContent = `data:application/octet-stream,${encodeURIComponent(logData)}`;
window.open(uriContent, dialogTypes[type].filename);
};
const exportLog = () => createFileDownload(logData, dialogTypes[type].filename(context), '');

return (
<Dialog open={true}>
Expand Down
8 changes: 7 additions & 1 deletion src/js/components/deployments/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ export const DeploymentReport = ({ abort, onClose, past, retry, type }) => {
onAbort={abort}
innerRef={rolloutSchedule}
/>
{Boolean(deviceId.length) && <LogDialog logData={logData} onClose={() => setDeviceId('')} />}
{Boolean(deviceId.length) && (
<LogDialog
context={{ device: deviceId, releaseName: deployment.artifact_name, date: deployment.finished }}
logData={logData}
onClose={() => setDeviceId('')}
/>
)}
</div>
<Divider className={classes.divider} light />
</Drawer>
Expand Down

0 comments on commit 7ac48f1

Please sign in to comment.