@danikokonn/yarik-frontend-lib 2.0.54 → 2.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"SubtaskItem.d.ts","sourceRoot":"","sources":["../../../src/components/SubtaskItem/SubtaskItem.tsx"],"names":[],"mappings":"AAgBA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,uBAAuB,GACxB,EAAE,gBAAgB,2CAuJlB"}
1
+ {"version":3,"file":"SubtaskItem.d.ts","sourceRoot":"","sources":["../../../src/components/SubtaskItem/SubtaskItem.tsx"],"names":[],"mappings":"AAgBA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAiBlD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,uBAAuB,GACxB,EAAE,gBAAgB,2CAwIlB"}
@@ -13,24 +13,24 @@ import CircularProgress from "@mui/material/CircularProgress";
13
13
  import { taskStateText } from "../../utils";
14
14
  import moment from "moment";
15
15
  import { useState } from "react";
16
+ const SubtaskState = ({ state }) => {
17
+ switch (state) {
18
+ case "success":
19
+ return _jsx(CheckCircleOutlineRoundedIcon, { color: "success" });
20
+ case "failed":
21
+ return _jsx(ErrorOutlineSharpIcon, { color: "error" });
22
+ case "queued":
23
+ return _jsx(AccessTimeSharpIcon, {});
24
+ case "running":
25
+ return _jsx(CircularProgress, { size: 20 });
26
+ default:
27
+ return _jsx(BlockSharpIcon, {});
28
+ }
29
+ };
16
30
  export default function SubtaskItem({ taskInstance, logs, expanded, onShowLogs, expandedLogContainerRef, }) {
17
31
  const [copyVisible, setCopyVisible] = useState(false);
18
32
  const [copyText, setCopyText] = useState("Копировать");
19
33
  const theme = useTheme();
20
- const subtaskState = (state) => {
21
- switch (state) {
22
- case "success":
23
- return _jsx(CheckCircleOutlineRoundedIcon, { color: "success" });
24
- case "failed":
25
- return _jsx(ErrorOutlineSharpIcon, { color: "error" });
26
- case "queued":
27
- return _jsx(AccessTimeSharpIcon, {});
28
- case "running":
29
- return _jsx(CircularProgress, { size: 20 });
30
- default:
31
- return _jsx(BlockSharpIcon, {});
32
- }
33
- };
34
34
  const formatEndDate = new Date(taskInstance.executionDate).toLocaleString("ru", {
35
35
  weekday: "short",
36
36
  month: "short",
@@ -59,7 +59,7 @@ export default function SubtaskItem({ taskInstance, logs, expanded, onShowLogs,
59
59
  setCopyText("Копировать");
60
60
  },
61
61
  },
62
- }, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ExpandMore, {}), children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [subtaskState(taskInstance.state), _jsxs("span", { children: [taskInstance.taskId, " - ", taskStateText(taskInstance.state), taskInstance.state === "success"
62
+ }, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ExpandMore, {}), children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [_jsx(SubtaskState, { state: taskInstance.state }), _jsxs("span", { children: [taskInstance.taskId, " - ", taskStateText(taskInstance.state), taskInstance.state === "success"
63
63
  ? (formatEndDate.startsWith("вт") ? " во " : " в ") +
64
64
  formatEndDate +
65
65
  " за " +
@@ -1,3 +1,4 @@
1
1
  import TaskLoaderProps from "./TaskLoaderProps";
2
- export default function TaskLoader({ style, subTitle, onUnauthorized, }: TaskLoaderProps): import("react/jsx-runtime").JSX.Element;
2
+ declare const TaskLoader: ({ style, subTitle, onUnauthorized }: TaskLoaderProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default TaskLoader;
3
4
  //# sourceMappingURL=TaskLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskLoader.d.ts","sourceRoot":"","sources":["../../../src/components/TaskLoader/TaskLoader.tsx"],"names":[],"mappings":"AA8BA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAiBhD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,cAAc,GACf,EAAE,eAAe,2CA4ZjB"}
1
+ {"version":3,"file":"TaskLoader.d.ts","sourceRoot":"","sources":["../../../src/components/TaskLoader/TaskLoader.tsx"],"names":[],"mappings":"AAgCA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAqBhD,QAAA,MAAM,UAAU,GAAI,qCAAqC,eAAe,4CA2avE,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -7,16 +7,18 @@ import RestartAltIcon from "@mui/icons-material/RestartAlt";
7
7
  import StopRoundedIcon from "@mui/icons-material/StopRounded";
8
8
  import SyncIcon from "@mui/icons-material/Sync";
9
9
  import CircularProgress from "@mui/material/CircularProgress";
10
+ import FormControlLabel from "@mui/material/FormControlLabel";
10
11
  import IconButton from "@mui/material/IconButton";
12
+ import Switch from "@mui/material/Switch";
11
13
  import Typography from "@mui/material/Typography";
12
- import React, { useState } from "react";
14
+ import { useEffect, useEffectEvent, useRef, useState } from "react";
13
15
  import { getRequest, postRequest } from "../../http";
14
16
  import { useAirflowContext } from "../../providers/AirflowProvider";
15
17
  import { useDagRunStateContext } from "../../providers/DagStateProvider";
16
18
  import { formatDate, formatDuration, getCSRFToken, taskStateText, useDebounce, } from "../../utils";
17
19
  import ProcessingIcon from "../icons/ProcessingIcon";
18
20
  import SubtaskItem from "../SubtaskItem/SubtaskItem";
19
- const taskStateIcon = (taskState) => {
21
+ const TaskStateIcon = ({ taskState, }) => {
20
22
  switch (taskState) {
21
23
  case "success":
22
24
  return _jsx(CheckCircleOutlineRoundedIcon, { fontSize: "large", color: "success" });
@@ -30,24 +32,26 @@ const taskStateIcon = (taskState) => {
30
32
  return _jsx(BlockSharpIcon, { fontSize: "large" });
31
33
  }
32
34
  };
33
- export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
35
+ const TaskLoader = ({ style, subTitle, onUnauthorized }) => {
34
36
  const { airflowAvailable, onLostConnection } = useAirflowContext();
35
37
  const { isActive, dagRun, taskInstances, onUpdateState, fetchState } = useDagRunStateContext();
36
- const [activeTask, setActiveTask] = React.useState(taskInstances?.taskInstances.find((ti) => {
38
+ const [activeTask, setActiveTask] = useState(taskInstances?.taskInstances.find((ti) => {
37
39
  return ti.state === "running";
38
40
  }) || null);
39
- const [logs, setLogs] = React.useState([null, null, null]);
41
+ const [logs, setLogs] = useState([null, null, null]);
40
42
  const [blockContols, setBlockControls] = useState(false);
41
- const logContainerRef = React.useRef(null);
42
- React.useEffect(() => {
43
- if (logContainerRef.current != null) {
43
+ const [followLogs, setFollowLogs] = useState(true);
44
+ const logContainerRef = useRef(null);
45
+ const scrollDown = useEffectEvent(() => {
46
+ if (logContainerRef.current != null && followLogs) {
44
47
  logContainerRef.current.scrollTo({
45
48
  left: 0,
46
49
  top: logContainerRef.current.scrollHeight,
47
50
  behavior: "smooth",
48
51
  });
49
52
  }
50
- }, [activeTask, logs]);
53
+ });
54
+ useEffect(() => scrollDown(), [activeTask, logs]);
51
55
  const updateActiveTask = () => {
52
56
  const newActiveTask = taskInstances?.taskInstances.find((ti) => {
53
57
  return ti.state === "running";
@@ -60,22 +64,24 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
60
64
  setActiveTask(newActiveTask);
61
65
  }
62
66
  };
63
- React.useEffect(() => {
67
+ useEffect(() => {
64
68
  if (isActive) {
69
+ setFollowLogs(true);
65
70
  setLogs([null, null, null]);
66
71
  }
67
72
  }, [isActive]);
68
- React.useEffect(() => {
73
+ useEffect(() => {
69
74
  const interval = setInterval(() => {
70
75
  if (!isActive)
71
76
  return;
72
- updateActiveTask();
77
+ if (followLogs)
78
+ updateActiveTask();
73
79
  }, 100);
74
80
  return () => {
75
81
  clearInterval(interval);
76
82
  };
77
83
  }, [isActive, taskInstances]);
78
- React.useEffect(() => {
84
+ useEffect(() => {
79
85
  const interval = setInterval(() => {
80
86
  if (!airflowAvailable)
81
87
  return;
@@ -130,7 +136,7 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
130
136
  clearInterval(interval);
131
137
  };
132
138
  }, [isActive, activeTask, dagRun, taskInstances, logs]);
133
- function handleShowLogs(taskId, tryNum) {
139
+ const handleShowLogs = (taskId, tryNum) => {
134
140
  if (!airflowAvailable)
135
141
  return;
136
142
  if (activeTask != null && taskId === activeTask.taskId) {
@@ -167,8 +173,8 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
167
173
  }
168
174
  },
169
175
  });
170
- }
171
- function handleRestartLoad() {
176
+ };
177
+ const handleRestartLoad = () => {
172
178
  if (!airflowAvailable)
173
179
  return;
174
180
  postRequest({
@@ -198,7 +204,7 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
198
204
  }
199
205
  },
200
206
  });
201
- }
207
+ };
202
208
  const handleStopLoad = useDebounce(() => {
203
209
  if (!airflowAvailable)
204
210
  return;
@@ -233,7 +239,8 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
233
239
  });
234
240
  }, 200);
235
241
  const formatEndDate = formatDate(dagRun?.logicalDate || "");
236
- const formatTaskDuration = formatDuration(taskInstances?.taskInstances.reduce((a, b) => a + (b.duration || 0), 0) || 0);
242
+ const formatTaskDuration = formatDuration(taskInstances?.taskInstances.reduce((a, b) => a + (b.duration || 0), 0) ||
243
+ 0);
237
244
  const activeTaskElem = taskInstances?.taskInstances.find((ti) => {
238
245
  return activeTask && ti.taskId === activeTask.taskId;
239
246
  });
@@ -268,7 +275,7 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
268
275
  width: "auto",
269
276
  whiteSpace: "nowrap",
270
277
  overflow: "hidden",
271
- }, children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [taskStateIcon(dagRun?.state), " ", _jsxs("span", { children: [taskStateText(dagRun?.state), dagRun?.state === "success"
278
+ }, children: _jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [_jsx(TaskStateIcon, { taskState: dagRun?.state }), _jsxs("span", { children: [taskStateText(dagRun?.state), dagRun?.state === "success"
272
279
  ? (formatEndDate.startsWith("вт") ? " во " : " в ") +
273
280
  formatEndDate +
274
281
  " за " +
@@ -279,7 +286,7 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
279
286
  width: "auto",
280
287
  flex: "0 0 auto",
281
288
  gap: "0.25rem",
282
- }, children: [_jsx(IconButton, { id: "updateTaskStateBtn", color: "default", title: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435", size: "small", onClick: (e) => {
289
+ }, children: [_jsx(FormControlLabel, { control: _jsx(Switch, { checked: followLogs, onChange: (_, c) => setFollowLogs(c) }), label: "\u0421\u043B\u0435\u0434\u043E\u0432\u0430\u0442\u044C" }), _jsx(IconButton, { id: "updateTaskStateBtn", color: "default", title: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435", size: "small", onClick: (e) => {
283
290
  setBlockControls(true);
284
291
  handleClick(e.currentTarget, () => {
285
292
  fetchState();
@@ -317,4 +324,5 @@ export default function TaskLoader({ style, subTitle, onUnauthorized, }) {
317
324
  }
318
325
  }
319
326
  ` })] }));
320
- }
327
+ };
328
+ export default TaskLoader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danikokonn/yarik-frontend-lib",
3
- "version": "2.0.54",
3
+ "version": "2.0.55",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "author": "",