Skip to content

Commit f004314

Browse files
DrewManleySbethmtiffanynchaujackyuan1CedarCooper
committed
Added process logs --since alert and link to documentation
Co-authored-by: Sarah Moosa <[email protected]> Co-authored-by: Tiffany Chau <[email protected]> Co-authored-by: Jack Yuan <[email protected]> Co-authored-by: Cedar Cooper <[email protected]>
1 parent 1806a08 commit f004314

File tree

3 files changed

+66
-41
lines changed

3 files changed

+66
-41
lines changed

src/components/display/ProcessLogsTable.tsx

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React, { useEffect, useState } from "react";
2-
import { useDispatch } from "react-redux";
3-
import { buildOptionsObj } from "../helper/processLogHelper";
4-
import { getLogs } from "../helper/commands";
5-
import * as actions from "../../redux/actions/actions";
6-
import "./ProcessLogsCard";
1+
import React, { useEffect, useState } from 'react';
2+
import { useDispatch } from 'react-redux';
3+
import { buildOptionsObj } from '../helper/processLogHelper';
4+
import { getLogs } from '../helper/commands';
5+
import * as actions from '../../redux/actions/actions';
6+
import './ProcessLogsCard';
77

8-
import store from "../../renderer/store";
9-
import { DataGrid } from "@mui/x-data-grid";
10-
import { Checkbox, FormControlLabel, FormGroup, Button } from "@mui/material"; // use for container selection
11-
import { CSVLink } from "react-csv";
8+
import store from '../../renderer/store';
9+
import { DataGrid } from '@mui/x-data-grid';
10+
import { Checkbox, FormControlLabel, FormGroup, Button } from '@mui/material'; // use for container selection
11+
import { CSVLink } from 'react-csv';
1212

1313
/**
1414
* Displays process logs as table
@@ -24,7 +24,7 @@ const ProcessLogsTable = () => {
2424

2525
// grab clicked container
2626
const urlString = window.location.href;
27-
const containerID = urlString.split("/");
27+
const containerID = urlString.split('/');
2828
const id = containerID[containerID.length - 1];
2929

3030
// access runningList from state
@@ -34,7 +34,7 @@ const ProcessLogsTable = () => {
3434
const [rows, setRows] = useState([]);
3535

3636
const [csvData, setCsvData] = useState([
37-
["container", "type", "time", "message"],
37+
['container', 'type', 'time', 'message'],
3838
]);
3939

4040
const [logs, setLogs] = useState({ stdout: [], stderr: [] });
@@ -61,10 +61,10 @@ const ProcessLogsTable = () => {
6161
};
6262

6363
const columns = [
64-
{ field: "container", headerName: "Container", width: 150 },
65-
{ field: "type", headerName: "Log Type", width: 120 },
66-
{ field: "time", headerName: "Timestamp", width: 200 },
67-
{ field: "message", headerName: "Message", width: 550 },
64+
{ field: 'container', headerName: 'Container', width: 150 },
65+
{ field: 'type', headerName: 'Log Type', width: 120 },
66+
{ field: 'time', headerName: 'Timestamp', width: 200 },
67+
{ field: 'message', headerName: 'Message', width: 550 },
6868
];
6969

7070
const createContainerCheckboxes = (currId: string) => {
@@ -142,34 +142,34 @@ const ProcessLogsTable = () => {
142142
if (stdout) {
143143
stdout.forEach((log, index) => {
144144
const currCont = runningList.find(
145-
(el) => el.ID === log["containerName"]
145+
(el) => el.ID === log['containerName']
146146
);
147147
newRows.push({
148148
container: currCont.Name,
149-
type: "stdout",
150-
time: log["timeStamp"],
151-
message: log["logMsg"],
149+
type: 'stdout',
150+
time: log['timeStamp'],
151+
message: log['logMsg'],
152152
id: Math.random() * 100,
153153
});
154-
newCSV.push([currCont.Name, "stdout", log["timeStamp"], log["logMsg"]]);
154+
newCSV.push([currCont.Name, 'stdout', log['timeStamp'], log['logMsg']]);
155155
});
156156

157157
stderr.forEach((log, index) => {
158158
const currCont = runningList.find(
159-
(el) => el.ID === log["containerName"]
159+
(el) => el.ID === log['containerName']
160160
);
161161
newRows.push({
162162
container: currCont.Name,
163-
type: "stderr",
164-
time: log["timeStamp"],
165-
message: log["logMsg"],
163+
type: 'stderr',
164+
time: log['timeStamp'],
165+
message: log['logMsg'],
166166
id: parseInt(`stderr ${index}`),
167167
});
168-
newCSV.push([currCont.Name, "stderr", log["timeStamp"], log["logMsg"]]);
168+
newCSV.push([currCont.Name, 'stderr', log['timeStamp'], log['logMsg']]);
169169
});
170170

171171
setRows(newRows as keyof typeof setRows);
172-
setCsvData([["container", "type", "time", "message"], ...newCSV]);
172+
setCsvData([['container', 'type', 'time', 'message'], ...newCSV]);
173173
}
174174
};
175175

@@ -178,30 +178,54 @@ const ProcessLogsTable = () => {
178178
<div className="settings-container">
179179
<form>
180180
<h1 style={{ margin: 10 }}>Container Process Logs</h1>
181-
181+
<h3>
182+
<a
183+
style={{ margin: 5 }}
184+
target="_blank"
185+
rel="noreferrer"
186+
href="https://docs.docker.com/engine/reference/commandline/logs/"
187+
>
188+
Click here
189+
</a>{''}
190+
for more information on logs
191+
</h3>
192+
<br></br>
182193
<input
183194
style={{ margin: 5 }}
184195
type="radio"
185196
id="sinceInput"
186197
name="logOption"
187198
/>
188-
<label style={{ margin: 5 }} htmlFor="sinceInput">
199+
<label
200+
style={{ margin: 5 }}
201+
htmlFor="sinceInput"
202+
>
189203
Since
190204
</label>
191-
<input type="text" id="sinceText" />
205+
<input
206+
type="text"
207+
id="sinceText"
208+
/>
192209
<br></br>
193210
<input
194211
style={{ margin: 5 }}
195212
type="radio"
196213
id="tailInput"
197214
name="logOption"
198215
/>
199-
<label style={{ margin: 5 }} htmlFor="tailInput">
216+
<label
217+
style={{ margin: 5 }}
218+
htmlFor="tailInput"
219+
>
200220
Tail
201221
</label>
202-
<input style={{ marginLeft: 14 }} type="text" id="tailText" />
222+
<input
223+
style={{ marginLeft: 14 }}
224+
type="text"
225+
id="tailText"
226+
/>
203227

204-
<FormGroup style={{ display: "flex", flexDirection: "row" }}>
228+
<FormGroup style={{ display: 'flex', flexDirection: 'row' }}>
205229
{containerSelectors} {/** Checkboxes for running containers */}
206230
</FormGroup>
207231
<Button
@@ -230,9 +254,9 @@ const ProcessLogsTable = () => {
230254
>
231255
<CSVLink
232256
style={{
233-
textDecoration: "none",
234-
color: "white",
235-
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
257+
textDecoration: 'none',
258+
color: 'white',
259+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
236260
}}
237261
data={csvData}
238262
>
@@ -243,16 +267,16 @@ const ProcessLogsTable = () => {
243267

244268
<div
245269
className="process-logs-container"
246-
style={{ height: 660, width: "100%" }}
270+
style={{ height: 660, width: '100%' }}
247271
>
248272
<DataGrid
249273
key="DataGrid"
250274
rows={rows}
251275
columns={columns}
252-
getRowHeight={() => "auto"}
276+
getRowHeight={() => 'auto'}
253277
initialState={{
254278
sorting: {
255-
sortModel: [{ field: "time", sort: "desc" }], // default sorts table by time
279+
sortModel: [{ field: 'time', sort: 'desc' }], // default sorts table by time
256280
},
257281
}}
258282
/>

src/components/helper/commands.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ export const getLogs = async (optionsObj, getContainerLogsDispatcher) => {
675675
// build inputCommandString to get logs from command line
676676
let inputCommandString = 'docker logs --timestamps ';
677677
if (optionsObj.since) {
678-
inputCommandString += `--since ${optionsObj.since} `;
678+
inputCommandString += `--since ${optionsObj.since} `;
679679
}
680680
optionsObj.tail
681681
? (inputCommandString += `--tail ${optionsObj.tail} `)
@@ -684,6 +684,7 @@ export const getLogs = async (optionsObj, getContainerLogsDispatcher) => {
684684

685685
window.nodeMethod.runExec(inputCommandString, (error: child_process.ExecException | null, stdout: string, stderr: string) => {
686686
if (error) {
687+
alert(`Please enter a valid rfc3339 date, Unix timestamp, or Go duration string.`);
687688
console.error(`exec error: ${error}`);
688689
return;
689690
}

src/components/tabs/ProcessLogs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const ProcessLogs = (props) => {
3131
return (
3232
<div className='renderContainers'>
3333
<div className='header'>
34-
<h1 className='tabTitle'>Procsess Logs</h1>
34+
<h1 className='tabTitle'>Process Logs</h1>
3535
</div>
3636

3737
<h3>Running Containers: {props.runningList.length}</h3>

0 commit comments

Comments
 (0)