Skip to content

Commit 690b748

Browse files
Evgenii Grigorevblcham
authored andcommitted
[#195] Add more metadata to pipeline executions
1 parent acca1c7 commit 690b748

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/components/sform/SFormsFunctionModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SFormsFunctionModal extends React.Component {
3333
modalVisible: true,
3434
moduleTypeUri: newProps.scriptPath,
3535
moduleUri: newProps.functionUri,
36+
scriptPath: newProps.scriptPath,
3637
});
3738
});
3839
}
@@ -68,7 +69,7 @@ class SFormsFunctionModal extends React.Component {
6869
});
6970

7071
try {
71-
const response = await Rest.executeFunction(functionUri, params.join("&"));
72+
const response = await Rest.executeFunction(functionUri, params.join("&"), this.state.scriptPath);
7273
console.log(response);
7374
window.location.href = "/executions";
7475
} catch (error) {

src/pages/ExecutionsPage.tsx

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import DebugModal from "@components/modal/DebugModal";
44
import Rest from "@rest/Rest.tsx";
55
import { Table } from "react-bootstrap";
66
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7-
import { faSearch } from "@fortawesome/free-solid-svg-icons";
7+
import { faSearch, faEdit } from "@fortawesome/free-solid-svg-icons";
88
import { Link } from "react-router-dom";
99
import dayjs from "dayjs";
1010
import Loading from "@components/Loading";
@@ -33,25 +33,55 @@ const ExecutionsPage = () => {
3333
<tr>
3434
<th>ID</th>
3535
<th>Started</th>
36+
<th>Completed</th>
3637
<th>Modules Executed</th>
38+
<th>Status</th>
39+
<th>Function Name</th>
40+
<th>Script Name</th>
3741
<th>Action</th>
42+
<th>Edit</th>
3843
</tr>
3944
</thead>
4045
<tbody style={{ textAlign: "center" }}>
4146
{data
4247
.filter((v) => v !== null)
4348
.map((data, key) => {
44-
const executionId = data.id.split("/").pop();
49+
const executionId = data.id?.split("/").pop() ?? "—";
4550
return (
4651
<tr key={key}>
47-
<td>{executionId}</td>
48-
<td>{dayjs(data.has_pipepline_execution_date).format("YYYY-MM-DD HH:mm:ss.SSS")}</td>
49-
<td>{data.has_module_executions.length}</td>
52+
<td>
53+
<span
54+
style={{ cursor: "pointer", color: "#007bff", textDecoration: "underline" }}
55+
onClick={() => openJsonInNewTab(data)}
56+
title="Открыть JSON"
57+
>
58+
{executionId}
59+
</span>
60+
</td>
61+
<td>
62+
{data.has_pipepline_execution_date
63+
? dayjs(data.has_pipepline_execution_date).format("YYYY-MM-DD HH:mm:ss.SSS")
64+
: "—"}
65+
</td>
66+
<td>
67+
{data.has_pipeline_execution_finish_date
68+
? dayjs(data.has_pipeline_execution_finish_date).format("YYYY-MM-DD HH:mm:ss.SSS")
69+
: "—"}
70+
</td>
71+
<td>{data.has_module_executions?.length ?? 0}</td>
72+
<td>{data.has_pipeline_execution_status ?? "STARTED"}</td>
73+
<td>{data.has_executed_function_name ?? "—"}</td>
74+
<td>{data.has_pipeline_name ?? "—"}</td>
5075
<td>
5176
<Link to={`/execution?id=${executionId}`}>
5277
<FontAwesomeIcon icon={faSearch} />
5378
</Link>
5479
</td>
80+
<td>
81+
<Link to={`/script?file=${data.has_executed_function_script_path}`}>
82+
<FontAwesomeIcon icon={faEdit} />
83+
</Link>
84+
</td>
5585
</tr>
5686
);
5787
})}
@@ -61,4 +91,12 @@ const ExecutionsPage = () => {
6191
);
6292
};
6393

94+
const openJsonInNewTab = (jsonData) => {
95+
const jsonString = JSON.stringify(jsonData, null, 2);
96+
const newWindow = window.open();
97+
newWindow.document.open();
98+
newWindow.document.write("<html><body><pre>" + jsonString + "</pre></body></html>");
99+
newWindow.document.close();
100+
};
101+
64102
export default ExecutionsPage;

src/rest/Rest.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ export const Rest = {
184184
});
185185
},
186186

187-
executeFunction: function (functionUri, params) {
187+
executeFunction: function (functionUri, params, scriptPath) {
188188
const data = {
189189
"@type": Vocabulary.EXECUTION_FUNCTION_DTO,
190190
[Vocabulary.FUNCTION_URI]: functionUri,
191191
[Vocabulary.PARAMETER]: params,
192+
[Vocabulary.SCRIPT_PATH]: scriptPath,
192193
};
193194
return postFetcher(URLs.FUNCTION_EXECUTE, data);
194195
},

0 commit comments

Comments
 (0)