@danikokonn/yarik-frontend-lib 2.1.3 → 2.1.4
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":"
|
|
1
|
+
{"version":3,"file":"SubtaskItem.d.ts","sourceRoot":"","sources":["../../../src/components/SubtaskItem/SubtaskItem.tsx"],"names":[],"mappings":"AAiBA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AA2BlD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,uBAAuB,GACxB,EAAE,gBAAgB,2CAyHlB"}
|
|
@@ -11,9 +11,11 @@ import Accordion from "@mui/material/Accordion";
|
|
|
11
11
|
import AccordionDetails from "@mui/material/AccordionDetails";
|
|
12
12
|
import AccordionSummary from "@mui/material/AccordionSummary";
|
|
13
13
|
import CircularProgress from "@mui/material/CircularProgress";
|
|
14
|
-
import
|
|
14
|
+
import dayjs from "dayjs";
|
|
15
|
+
import duration from "dayjs/plugin/duration";
|
|
15
16
|
import { useEffect, useState } from "react";
|
|
16
|
-
import { taskStateText } from "../../utils";
|
|
17
|
+
import { formatDuration, prettyDatetime, taskStateText } from "../../utils";
|
|
18
|
+
dayjs.extend(duration);
|
|
17
19
|
const SubtaskState = ({ state }) => {
|
|
18
20
|
switch (state) {
|
|
19
21
|
case "success":
|
|
@@ -46,21 +48,10 @@ export default function SubtaskItem({ taskInstance, logs, expanded, onShowLogs,
|
|
|
46
48
|
setCopyText("Копировать");
|
|
47
49
|
}
|
|
48
50
|
}, [expanded]);
|
|
49
|
-
const formatEndDate =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
year: "numeric",
|
|
54
|
-
hour: "2-digit",
|
|
55
|
-
minute: "2-digit",
|
|
56
|
-
second: "2-digit",
|
|
57
|
-
});
|
|
58
|
-
const formatTaskDuration = moment
|
|
59
|
-
.duration(taskInstance.duration, "seconds")
|
|
60
|
-
.format({
|
|
61
|
-
precision: 1,
|
|
62
|
-
template: "h [ч], m [мин], s [сек]",
|
|
63
|
-
});
|
|
51
|
+
const formatEndDate = prettyDatetime(taskInstance.executionDate, true);
|
|
52
|
+
const formatTaskDuration = taskInstance.duration !== null
|
|
53
|
+
? formatDuration(taskInstance.duration)
|
|
54
|
+
: "н/д";
|
|
64
55
|
return (_jsxs(Accordion, { disableGutters: true, expanded: expanded, onChange: () => onShowLogs(taskInstance.taskId, taskInstance.tryNumber), disabled: !["running", "success", "failed"].includes(taskInstance.state || ""), sx: {
|
|
65
56
|
position: "relative",
|
|
66
57
|
}, 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"
|
|
@@ -17,7 +17,7 @@ import useSWR from "swr";
|
|
|
17
17
|
import { postRequest } from "../../http";
|
|
18
18
|
import { useAirflowContext } from "../../providers/AirflowProvider";
|
|
19
19
|
import { useDagRunStateContext } from "../../providers/DagStateProvider";
|
|
20
|
-
import {
|
|
20
|
+
import { formatDuration, getCSRFToken, prettyDatetime, taskStateText, useDebounce, } from "../../utils";
|
|
21
21
|
import ProcessingIcon from "../icons/ProcessingIcon";
|
|
22
22
|
import SubtaskItem from "../SubtaskItem/SubtaskItem";
|
|
23
23
|
const TaskStateIcon = ({ taskState, }) => {
|
|
@@ -228,7 +228,7 @@ const TaskLoader = ({ style, subTitle, onUnauthorized }) => {
|
|
|
228
228
|
},
|
|
229
229
|
});
|
|
230
230
|
}, 200);
|
|
231
|
-
const formatEndDate =
|
|
231
|
+
const formatEndDate = prettyDatetime(dagRun?.logicalDate, true);
|
|
232
232
|
const formatTaskDuration = formatDuration(taskInstances?.taskInstances.reduce((a, b) => a + (b.duration || 0), 0) ||
|
|
233
233
|
0);
|
|
234
234
|
const activeTaskElem = taskInstances?.taskInstances.find((ti) => {
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { PopoverOrigin } from "@mui/material";
|
|
2
|
-
import "
|
|
3
|
-
import "moment/locale/ru";
|
|
2
|
+
import "dayjs/locale/ru";
|
|
4
3
|
import { DagState, TaskState } from "./types";
|
|
5
4
|
export declare function getCSRFToken(): string;
|
|
6
5
|
export declare function setCSRFToken(newToken: string): void;
|
|
7
|
-
export declare function prettyDatetime(datetime?: string | null): string;
|
|
6
|
+
export declare function prettyDatetime(datetime?: string | null, utc?: boolean): string;
|
|
8
7
|
export declare const taskStateText: (taskState: DagState | TaskState | string | null | undefined) => "Завершена" | "Ошибка" | "В очереди" | "Запланирована" | "Выполняется" | "Недоступно" | "Нет состояния";
|
|
9
|
-
export declare const formatDate: (date: string) => string;
|
|
10
8
|
export declare const formatDuration: (duration: number) => string;
|
|
11
9
|
export declare const getSlugTableName: (name: string) => string;
|
|
12
10
|
export declare const getShiftedColor: (colorHex: string, shift: number) => string;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,iBAAiB,CAAC;AAKzB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAK9C,wBAAgB,YAAY,WAI3B;AAED,wBAAgB,YAAY,CAAC,QAAQ,E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U,MAAM,EAChB,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,MAMF,CAAC;AACF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAM7C,CAAC;AACF,eAAO,MAAM,aAAa,GACxB,KAAK,MAAM,EAEX,KAAK,GAAG,EACR,QAAQ,OAAO,KACd,MAKF,CAAC;AACF,eAAO,MAAM,WAAW,GAAI,YAAY,MAAM,KAAG,MAKhD,CAAC;AACF,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAK3C,CAAC"}
|
package/dist/utils.js
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import "dayjs/locale/ru";
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import utc from "dayjs/plugin/utc";
|
|
5
5
|
import { useCallback, useRef } from "react";
|
|
6
6
|
import { slugify } from "transliteration";
|
|
7
|
+
dayjs.extend(utc);
|
|
8
|
+
dayjs.extend(timezone);
|
|
7
9
|
export function getCSRFToken() {
|
|
8
10
|
return document.getElementsByName("csrfmiddlewaretoken")[0].value;
|
|
9
11
|
}
|
|
10
12
|
export function setCSRFToken(newToken) {
|
|
11
13
|
document.getElementsByName("csrfmiddlewaretoken")[0].value = newToken;
|
|
12
14
|
}
|
|
13
|
-
export function prettyDatetime(datetime) {
|
|
14
|
-
if (datetime
|
|
15
|
-
return moment_tz(datetime).locale("ru").format("dd DD MMM YYYY, HH:mm:ss");
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
15
|
+
export function prettyDatetime(datetime, utc) {
|
|
16
|
+
if (!datetime || datetime.length === 0)
|
|
18
17
|
return "";
|
|
18
|
+
const fmt = "dd DD MMM YYYY, HH:mm:ss";
|
|
19
|
+
const tz = dayjs.tz.guess();
|
|
20
|
+
try {
|
|
21
|
+
if (utc) {
|
|
22
|
+
return dayjs.utc(datetime).tz(tz).locale("ru").format(fmt);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return dayjs.tz(datetime, tz).locale("ru").format(fmt);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return datetime;
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
32
|
export const taskStateText = (taskState) => {
|
|
@@ -36,23 +47,17 @@ export const taskStateText = (taskState) => {
|
|
|
36
47
|
return "Нет состояния";
|
|
37
48
|
}
|
|
38
49
|
};
|
|
39
|
-
export const formatDate = (date) => {
|
|
40
|
-
return new Date(date).toLocaleString("ru", {
|
|
41
|
-
weekday: "short",
|
|
42
|
-
month: "short",
|
|
43
|
-
day: "numeric",
|
|
44
|
-
year: "numeric",
|
|
45
|
-
hour: "2-digit",
|
|
46
|
-
minute: "2-digit",
|
|
47
|
-
second: "2-digit",
|
|
48
|
-
timeZone: "Europe/Moscow",
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
50
|
export const formatDuration = (duration) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const d = dayjs.duration(duration, "seconds");
|
|
52
|
+
const totalSeconds = d.asSeconds();
|
|
53
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
54
|
+
if (hours > 0)
|
|
55
|
+
return `${hours} ч`;
|
|
56
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
57
|
+
if (minutes > 0)
|
|
58
|
+
return `${minutes} мин`;
|
|
59
|
+
const seconds = totalSeconds;
|
|
60
|
+
return `${Number(seconds.toFixed(1))} сек`;
|
|
56
61
|
};
|
|
57
62
|
export const getSlugTableName = (name) => {
|
|
58
63
|
const replaces = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danikokonn/yarik-frontend-lib",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@eslint/js": "^9.34.0",
|
|
17
|
+
"@tsconfig/strictest": "^2.0.8",
|
|
17
18
|
"@testing-library/jest-dom": "^6.9.1",
|
|
18
19
|
"@testing-library/react": "^16.3.2",
|
|
19
20
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -30,21 +31,13 @@
|
|
|
30
31
|
"prettier": "3.6.2",
|
|
31
32
|
"react": "^19.2.4",
|
|
32
33
|
"react-dom": "^19.2.4",
|
|
33
|
-
"ts-loader": "^9.5.4",
|
|
34
|
-
"tss-react": "^4.9.20",
|
|
35
34
|
"typescript": "^5.9.3",
|
|
36
35
|
"typescript-eslint": "^8.57.2",
|
|
37
36
|
"vitest": "^4.1.0"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@tsconfig/strictest": "^2.0.8",
|
|
41
|
-
"css-loader": "^7.1.4",
|
|
42
39
|
"dayjs": "^1.11.20",
|
|
43
|
-
"moment": "^2.30.1",
|
|
44
|
-
"moment-duration-format": "^2.3.2",
|
|
45
|
-
"moment-timezone": "^0.6.1",
|
|
46
40
|
"react-json-tree": "^0.20.0",
|
|
47
|
-
"style-loader": "^4.0.0",
|
|
48
41
|
"transliteration": "^2.6.1"
|
|
49
42
|
},
|
|
50
43
|
"peerDependencies": {
|