@danikokonn/yarik-frontend-lib 2.0.2-test3
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.
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/components/ActionDialog/ActionDialog.d.ts +23 -0
- package/dist/components/ActionDialog/ActionDialog.d.ts.map +1 -0
- package/dist/components/ActionDialog/ActionDialog.js +48 -0
- package/dist/components/ActionDialog/ActionDialogProps.d.ts +32 -0
- package/dist/components/ActionDialog/ActionDialogProps.d.ts.map +1 -0
- package/dist/components/ActionDialog/ActionDialogProps.js +1 -0
- package/dist/components/ActionDialog/index.d.ts +5 -0
- package/dist/components/ActionDialog/index.d.ts.map +1 -0
- package/dist/components/ActionDialog/index.js +3 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInput.d.ts +16 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInput.d.ts.map +1 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInput.js +30 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInputProps.d.ts +18 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInputProps.d.ts.map +1 -0
- package/dist/components/ColumnSearchInput/ColumnSearchInputProps.js +1 -0
- package/dist/components/ColumnSearchInput/index.d.ts +5 -0
- package/dist/components/ColumnSearchInput/index.d.ts.map +1 -0
- package/dist/components/ColumnSearchInput/index.js +3 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePicker.d.ts +5 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePicker.js +51 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePickerProps.d.ts +11 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePickerProps.d.ts.map +1 -0
- package/dist/components/DateTimeRangePicker/DateTimeRangePickerProps.js +1 -0
- package/dist/components/DateTimeRangePicker/index.d.ts +5 -0
- package/dist/components/DateTimeRangePicker/index.d.ts.map +1 -0
- package/dist/components/DateTimeRangePicker/index.js +3 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInput.d.ts +23 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInput.d.ts.map +1 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInput.js +80 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInputProps.d.ts +43 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInputProps.d.ts.map +1 -0
- package/dist/components/DatetimeRangeInput/DatetimeRangeInputProps.js +1 -0
- package/dist/components/DatetimeRangeInput/index.d.ts +5 -0
- package/dist/components/DatetimeRangeInput/index.d.ts.map +1 -0
- package/dist/components/DatetimeRangeInput/index.js +3 -0
- package/dist/components/Footer/Footer.d.ts +7 -0
- package/dist/components/Footer/Footer.d.ts.map +1 -0
- package/dist/components/Footer/Footer.js +22 -0
- package/dist/components/Footer/index.d.ts +3 -0
- package/dist/components/Footer/index.d.ts.map +1 -0
- package/dist/components/Footer/index.js +2 -0
- package/dist/components/IpAddressInput/IpAddressInput.d.ts +5 -0
- package/dist/components/IpAddressInput/IpAddressInput.d.ts.map +1 -0
- package/dist/components/IpAddressInput/IpAddressInput.js +21 -0
- package/dist/components/IpAddressInput/IpAddressInputProps.d.ts +13 -0
- package/dist/components/IpAddressInput/IpAddressInputProps.d.ts.map +1 -0
- package/dist/components/IpAddressInput/IpAddressInputProps.js +1 -0
- package/dist/components/IpAddressInput/index.d.ts +5 -0
- package/dist/components/IpAddressInput/index.d.ts.map +1 -0
- package/dist/components/IpAddressInput/index.js +3 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInput.d.ts +5 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInput.d.ts.map +1 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInput.js +11 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInputProps.d.ts +10 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInputProps.d.ts.map +1 -0
- package/dist/components/IpAddressSwitchableInput/IpAddressSwitchableInputProps.js +1 -0
- package/dist/components/IpAddressSwitchableInput/index.d.ts +5 -0
- package/dist/components/IpAddressSwitchableInput/index.d.ts.map +1 -0
- package/dist/components/IpAddressSwitchableInput/index.js +3 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePicker.d.ts +5 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePicker.d.ts.map +1 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePicker.js +29 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePickerProps.d.ts +10 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePickerProps.d.ts.map +1 -0
- package/dist/components/LocalizedDatetimePicker/LocalizedDatetimePickerProps.js +1 -0
- package/dist/components/LocalizedDatetimePicker/index.d.ts +5 -0
- package/dist/components/LocalizedDatetimePicker/index.d.ts.map +1 -0
- package/dist/components/LocalizedDatetimePicker/index.js +3 -0
- package/dist/components/Navigation/NavMenu.d.ts +19 -0
- package/dist/components/Navigation/NavMenu.d.ts.map +1 -0
- package/dist/components/Navigation/NavMenu.js +44 -0
- package/dist/components/Navigation/Navigation.d.ts +4 -0
- package/dist/components/Navigation/Navigation.d.ts.map +1 -0
- package/dist/components/Navigation/Navigation.js +188 -0
- package/dist/components/Navigation/NavigationProps.d.ts +30 -0
- package/dist/components/Navigation/NavigationProps.d.ts.map +1 -0
- package/dist/components/Navigation/NavigationProps.js +1 -0
- package/dist/components/Navigation/index.d.ts +5 -0
- package/dist/components/Navigation/index.d.ts.map +1 -0
- package/dist/components/Navigation/index.js +3 -0
- package/dist/components/NumberRangeInput/NumberRangeInput.d.ts +5 -0
- package/dist/components/NumberRangeInput/NumberRangeInput.d.ts.map +1 -0
- package/dist/components/NumberRangeInput/NumberRangeInput.js +51 -0
- package/dist/components/NumberRangeInput/NumberRangeInputProps.d.ts +11 -0
- package/dist/components/NumberRangeInput/NumberRangeInputProps.d.ts.map +1 -0
- package/dist/components/NumberRangeInput/NumberRangeInputProps.js +1 -0
- package/dist/components/NumberRangeInput/index.d.ts +5 -0
- package/dist/components/NumberRangeInput/index.d.ts.map +1 -0
- package/dist/components/NumberRangeInput/index.js +3 -0
- package/dist/components/PageWrapper/PageWrapper.d.ts +4 -0
- package/dist/components/PageWrapper/PageWrapper.d.ts.map +1 -0
- package/dist/components/PageWrapper/PageWrapper.js +16 -0
- package/dist/components/PageWrapper/PageWrapperProps.d.ts +10 -0
- package/dist/components/PageWrapper/PageWrapperProps.d.ts.map +1 -0
- package/dist/components/PageWrapper/PageWrapperProps.js +1 -0
- package/dist/components/PageWrapper/index.d.ts +5 -0
- package/dist/components/PageWrapper/index.d.ts.map +1 -0
- package/dist/components/PageWrapper/index.js +3 -0
- package/dist/components/RichFilterTextField/FilterHistoryMenu.d.ts +8 -0
- package/dist/components/RichFilterTextField/FilterHistoryMenu.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/FilterHistoryMenu.js +43 -0
- package/dist/components/RichFilterTextField/HintOptionsMenu.d.ts +12 -0
- package/dist/components/RichFilterTextField/HintOptionsMenu.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/HintOptionsMenu.js +50 -0
- package/dist/components/RichFilterTextField/RichFilterTextField.d.ts +5 -0
- package/dist/components/RichFilterTextField/RichFilterTextField.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/RichFilterTextField.js +177 -0
- package/dist/components/RichFilterTextField/RichFilterTextFieldProps.d.ts +71 -0
- package/dist/components/RichFilterTextField/RichFilterTextFieldProps.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/RichFilterTextFieldProps.js +1 -0
- package/dist/components/RichFilterTextField/index.d.ts +5 -0
- package/dist/components/RichFilterTextField/index.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/index.js +3 -0
- package/dist/components/RichFilterTextField/utils.d.ts +7 -0
- package/dist/components/RichFilterTextField/utils.d.ts.map +1 -0
- package/dist/components/RichFilterTextField/utils.js +131 -0
- package/dist/components/SmartTable/RowContent.d.ts +14 -0
- package/dist/components/SmartTable/RowContent.d.ts.map +1 -0
- package/dist/components/SmartTable/RowContent.js +29 -0
- package/dist/components/SmartTable/RuleRow.d.ts +22 -0
- package/dist/components/SmartTable/RuleRow.d.ts.map +1 -0
- package/dist/components/SmartTable/RuleRow.js +35 -0
- package/dist/components/SmartTable/SmartTable.d.ts +4 -0
- package/dist/components/SmartTable/SmartTable.d.ts.map +1 -0
- package/dist/components/SmartTable/SmartTable.js +175 -0
- package/dist/components/SmartTable/SmartTableProps.d.ts +40 -0
- package/dist/components/SmartTable/SmartTableProps.d.ts.map +1 -0
- package/dist/components/SmartTable/SmartTableProps.js +1 -0
- package/dist/components/SmartTable/TableHeader.d.ts +5 -0
- package/dist/components/SmartTable/TableHeader.d.ts.map +1 -0
- package/dist/components/SmartTable/TableHeader.js +13 -0
- package/dist/components/SmartTable/index.d.ts +5 -0
- package/dist/components/SmartTable/index.d.ts.map +1 -0
- package/dist/components/SmartTable/index.js +3 -0
- package/dist/components/SortBtn/SortBtn.d.ts +4 -0
- package/dist/components/SortBtn/SortBtn.d.ts.map +1 -0
- package/dist/components/SortBtn/SortBtn.js +23 -0
- package/dist/components/SortBtn/SortBtnProps.d.ts +7 -0
- package/dist/components/SortBtn/SortBtnProps.d.ts.map +1 -0
- package/dist/components/SortBtn/SortBtnProps.js +1 -0
- package/dist/components/SortBtn/index.d.ts +5 -0
- package/dist/components/SortBtn/index.d.ts.map +1 -0
- package/dist/components/SortBtn/index.js +3 -0
- package/dist/components/SubtaskItem/SubtaskItem.d.ts +4 -0
- package/dist/components/SubtaskItem/SubtaskItem.d.ts.map +1 -0
- package/dist/components/SubtaskItem/SubtaskItem.js +66 -0
- package/dist/components/SubtaskItem/SubtaskItemProps.d.ts +10 -0
- package/dist/components/SubtaskItem/SubtaskItemProps.d.ts.map +1 -0
- package/dist/components/SubtaskItem/SubtaskItemProps.js +1 -0
- package/dist/components/SubtaskItem/index.d.ts +5 -0
- package/dist/components/SubtaskItem/index.d.ts.map +1 -0
- package/dist/components/SubtaskItem/index.js +3 -0
- package/dist/components/TaskLoader/TaskLoader.d.ts +4 -0
- package/dist/components/TaskLoader/TaskLoader.d.ts.map +1 -0
- package/dist/components/TaskLoader/TaskLoader.js +333 -0
- package/dist/components/TaskLoader/TaskLoaderProps.d.ts +5 -0
- package/dist/components/TaskLoader/TaskLoaderProps.d.ts.map +1 -0
- package/dist/components/TaskLoader/TaskLoaderProps.js +1 -0
- package/dist/components/TaskLoader/index.d.ts +5 -0
- package/dist/components/TaskLoader/index.d.ts.map +1 -0
- package/dist/components/TaskLoader/index.js +3 -0
- package/dist/components/TaskStateDialog/TaskStateDialog.d.ts +4 -0
- package/dist/components/TaskStateDialog/TaskStateDialog.d.ts.map +1 -0
- package/dist/components/TaskStateDialog/TaskStateDialog.js +106 -0
- package/dist/components/TaskStateDialog/TaskStateDialogProps.d.ts +18 -0
- package/dist/components/TaskStateDialog/TaskStateDialogProps.d.ts.map +1 -0
- package/dist/components/TaskStateDialog/TaskStateDialogProps.js +1 -0
- package/dist/components/TaskStateDialog/index.d.ts +5 -0
- package/dist/components/TaskStateDialog/index.d.ts.map +1 -0
- package/dist/components/TaskStateDialog/index.js +3 -0
- package/dist/components/icons/GenerateAndRunIcon.d.ts +8 -0
- package/dist/components/icons/GenerateAndRunIcon.d.ts.map +1 -0
- package/dist/components/icons/GenerateAndRunIcon.js +29 -0
- package/dist/components/icons/GenerateIcon.d.ts +8 -0
- package/dist/components/icons/GenerateIcon.d.ts.map +1 -0
- package/dist/components/icons/GenerateIcon.js +27 -0
- package/dist/components/icons/IntegerIcon.d.ts +8 -0
- package/dist/components/icons/IntegerIcon.d.ts.map +1 -0
- package/dist/components/icons/IntegerIcon.js +15 -0
- package/dist/components/icons/ProcessingIcon.d.ts +3 -0
- package/dist/components/icons/ProcessingIcon.d.ts.map +1 -0
- package/dist/components/icons/ProcessingIcon.js +15 -0
- package/dist/components/icons/QueueIcon.d.ts +8 -0
- package/dist/components/icons/QueueIcon.d.ts.map +1 -0
- package/dist/components/icons/QueueIcon.js +15 -0
- package/dist/components/icons/RangeIcon.d.ts +8 -0
- package/dist/components/icons/RangeIcon.d.ts.map +1 -0
- package/dist/components/icons/RangeIcon.js +15 -0
- package/dist/components/icons/RunIcon.d.ts +8 -0
- package/dist/components/icons/RunIcon.d.ts.map +1 -0
- package/dist/components/icons/RunIcon.js +18 -0
- package/dist/components/icons/TextModeIcon.d.ts +5 -0
- package/dist/components/icons/TextModeIcon.d.ts.map +1 -0
- package/dist/components/icons/TextModeIcon.js +8 -0
- package/dist/components/icons/TreeModeIcon.d.ts +5 -0
- package/dist/components/icons/TreeModeIcon.d.ts.map +1 -0
- package/dist/components/icons/TreeModeIcon.js +8 -0
- package/dist/components/icons/index.d.ts +10 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/index.js +9 -0
- package/dist/components/index.d.ts +36 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +35 -0
- package/dist/http.d.ts +25 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +101 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/providers/AirflowProvider.d.ts +14 -0
- package/dist/providers/AirflowProvider.d.ts.map +1 -0
- package/dist/providers/AirflowProvider.js +80 -0
- package/dist/providers/DagStateProvider.d.ts +25 -0
- package/dist/providers/DagStateProvider.d.ts.map +1 -0
- package/dist/providers/DagStateProvider.js +115 -0
- package/dist/providers/SessionProvider.d.ts +11 -0
- package/dist/providers/SessionProvider.d.ts.map +1 -0
- package/dist/providers/SessionProvider.js +37 -0
- package/dist/providers/SnackBarProvider.d.ts +10 -0
- package/dist/providers/SnackBarProvider.d.ts.map +1 -0
- package/dist/providers/SnackBarProvider.js +35 -0
- package/dist/providers/index.d.ts +9 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +8 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +193 -0
- package/package.json +94 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useEffect, useState, } from "react";
|
|
2
|
+
import { getRequest } from "../http";
|
|
3
|
+
import { useAirflowContext } from "./AirflowProvider";
|
|
4
|
+
import { useSnackbarContext } from "./SnackBarProvider";
|
|
5
|
+
const DagRunStateContext = createContext({
|
|
6
|
+
isActive: true,
|
|
7
|
+
autorun: false,
|
|
8
|
+
dagRun: null,
|
|
9
|
+
taskInstances: null,
|
|
10
|
+
onUpdateState: () => { },
|
|
11
|
+
fetchState: () => { },
|
|
12
|
+
activate: () => { },
|
|
13
|
+
setAutorun: () => { },
|
|
14
|
+
scanInterval: 300,
|
|
15
|
+
});
|
|
16
|
+
export const DagRunStateProvider = ({ children, dagRun: _dagRun, autorun: _autorun, poolingByUser, taskInstances: _taskInstances, autorunHandler, scanInterval, }) => {
|
|
17
|
+
const { airflowAvailable, dagId, onLostConnection } = useAirflowContext();
|
|
18
|
+
const [isActive, setIsActive] = useState(_dagRun ? ["queued", "running"].includes(_dagRun.state) : dagId?.length > 0);
|
|
19
|
+
const [channelBusy, setChannelBusy] = useState(false);
|
|
20
|
+
const [autorun, setAutorun] = useState(_autorun || false);
|
|
21
|
+
const activate = useCallback(() => {
|
|
22
|
+
setIsActive(true);
|
|
23
|
+
}, [isActive, setIsActive]);
|
|
24
|
+
const [dagRun, setDagRun] = useState(_dagRun || null);
|
|
25
|
+
const [taskInstances, setTaskInstances] = useState(_taskInstances || null);
|
|
26
|
+
const { enqueueSnackbar } = useSnackbarContext();
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setDagRun(null);
|
|
29
|
+
setTaskInstances(null);
|
|
30
|
+
}, [dagId]);
|
|
31
|
+
const updateState = () => {
|
|
32
|
+
setChannelBusy(true);
|
|
33
|
+
getRequest({
|
|
34
|
+
url: "airflow/dag_run",
|
|
35
|
+
data: {
|
|
36
|
+
dag_id: dagId,
|
|
37
|
+
dag_run_id: dagRun && dagRun.dagRunId,
|
|
38
|
+
by_user: Boolean(poolingByUser),
|
|
39
|
+
},
|
|
40
|
+
successHandler: (resp) => {
|
|
41
|
+
if (resp?.dagRun) {
|
|
42
|
+
setDagRun(resp.dagRun);
|
|
43
|
+
setTaskInstances(resp.taskInstances);
|
|
44
|
+
setIsActive(["queued", "running"].includes(resp.dagRun.state));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setIsActive(false);
|
|
48
|
+
enqueueSnackbar(`Ошибка при обновлении состояния задачи${(dagId && " ") || ""}${dagId || ""}!`, "error");
|
|
49
|
+
}
|
|
50
|
+
setChannelBusy(false);
|
|
51
|
+
},
|
|
52
|
+
errorHandler: (resp) => {
|
|
53
|
+
if (resp?.status !== 404) {
|
|
54
|
+
enqueueSnackbar(`Ошибка при обновлении состояния задачи${(dagId && " ") || ""}${dagId || ""}!`, "error");
|
|
55
|
+
}
|
|
56
|
+
if (resp?.status === 503) {
|
|
57
|
+
onLostConnection();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setIsActive(false);
|
|
61
|
+
}
|
|
62
|
+
setChannelBusy(false);
|
|
63
|
+
},
|
|
64
|
+
}).catch((e) => {
|
|
65
|
+
console.log(e);
|
|
66
|
+
setChannelBusy(false);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const interval = setInterval(() => {
|
|
71
|
+
if (!airflowAvailable && !isActive)
|
|
72
|
+
setIsActive(true);
|
|
73
|
+
if (!airflowAvailable || !isActive || !dagId)
|
|
74
|
+
return;
|
|
75
|
+
if (channelBusy)
|
|
76
|
+
return;
|
|
77
|
+
updateState();
|
|
78
|
+
}, 1000);
|
|
79
|
+
return () => {
|
|
80
|
+
clearInterval(interval);
|
|
81
|
+
};
|
|
82
|
+
}, [airflowAvailable, isActive, dagRun, dagId, autorun, channelBusy]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (dagRun == null)
|
|
85
|
+
setIsActive(true);
|
|
86
|
+
}, [dagRun]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!airflowAvailable)
|
|
89
|
+
return;
|
|
90
|
+
if (isActive)
|
|
91
|
+
return;
|
|
92
|
+
if (autorunHandler)
|
|
93
|
+
autorunHandler(dagRun, autorun);
|
|
94
|
+
}, [airflowAvailable, isActive, dagRun, autorun]);
|
|
95
|
+
const onUpdateState = (isActive, dagRun, taskInstances) => {
|
|
96
|
+
setIsActive(isActive);
|
|
97
|
+
setDagRun(dagRun);
|
|
98
|
+
setTaskInstances(taskInstances);
|
|
99
|
+
};
|
|
100
|
+
return (React.createElement(DagRunStateContext.Provider, { value: {
|
|
101
|
+
isActive,
|
|
102
|
+
autorun,
|
|
103
|
+
dagRun,
|
|
104
|
+
taskInstances,
|
|
105
|
+
onUpdateState,
|
|
106
|
+
activate,
|
|
107
|
+
fetchState: updateState,
|
|
108
|
+
setAutorun: (autorun) => setAutorun(autorun),
|
|
109
|
+
scanInterval: scanInterval || 1,
|
|
110
|
+
} }, children));
|
|
111
|
+
};
|
|
112
|
+
export const useDagRunStateContext = () => {
|
|
113
|
+
return useContext(DagRunStateContext);
|
|
114
|
+
};
|
|
115
|
+
export default DagRunStateProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SessionProviderProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
pollingInterval: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const SessionProvider: ({ children, pollingInterval, }: SessionProviderProps) => React.JSX.Element;
|
|
7
|
+
export declare const useSessionContext: () => {
|
|
8
|
+
expiresIn: number;
|
|
9
|
+
};
|
|
10
|
+
export default SessionProvider;
|
|
11
|
+
//# sourceMappingURL=SessionProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SessionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAU9E,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,eAAe,GAAI,gCAG7B,oBAAoB,sBAwCtB,CAAC;AAEF,eAAO,MAAM,iBAAiB;eAvDjB,MAAM;CAyDlB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
+
import { useSnackbarContext } from "./SnackBarProvider";
|
|
3
|
+
import { getRequest } from "../http";
|
|
4
|
+
const SessionContext = createContext({
|
|
5
|
+
expiresIn: 0,
|
|
6
|
+
});
|
|
7
|
+
export const SessionProvider = ({ children, pollingInterval, }) => {
|
|
8
|
+
const { enqueueSnackbar } = useSnackbarContext();
|
|
9
|
+
const [expires, setExpires] = useState(false);
|
|
10
|
+
const alertExpire = () => enqueueSnackbar("Сессия завершилась, перезагрузите страницу!", "default");
|
|
11
|
+
const fetchSessionExpiryAge = () => getRequest({
|
|
12
|
+
url: "base/check_session",
|
|
13
|
+
successHandler: (_resp) => { },
|
|
14
|
+
errorHandler: (_resp) => {
|
|
15
|
+
setExpires(true);
|
|
16
|
+
alertExpire();
|
|
17
|
+
},
|
|
18
|
+
}).catch(() => {
|
|
19
|
+
setExpires(true);
|
|
20
|
+
alertExpire();
|
|
21
|
+
});
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const interval = setInterval(() => {
|
|
24
|
+
if (!expires) {
|
|
25
|
+
fetchSessionExpiryAge();
|
|
26
|
+
}
|
|
27
|
+
}, pollingInterval * 1000);
|
|
28
|
+
return () => clearInterval(interval);
|
|
29
|
+
}, [expires]);
|
|
30
|
+
return (React.createElement(SessionContext.Provider, { value: {
|
|
31
|
+
expiresIn: pollingInterval,
|
|
32
|
+
} }, children));
|
|
33
|
+
};
|
|
34
|
+
export const useSessionContext = () => {
|
|
35
|
+
return useContext(SessionContext);
|
|
36
|
+
};
|
|
37
|
+
export default SessionProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SnackBarProps {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare const SnackBarProvider: ({ children }: SnackBarProps) => React.JSX.Element;
|
|
6
|
+
export declare const useSnackbarContext: () => {
|
|
7
|
+
enqueueSnackbar(message: string, variant: "default" | "error" | "success" | "warning" | "info"): void;
|
|
8
|
+
};
|
|
9
|
+
export default SnackBarProvider;
|
|
10
|
+
//# sourceMappingURL=SnackBarProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SnackBarProvider.d.ts","sourceRoot":"","sources":["../../src/providers/SnackBarProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAezD,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA8CD,eAAO,MAAM,gBAAgB,GAAI,cAAc,aAAa,sBAM3D,CAAC;AAEF,eAAO,MAAM,kBAAkB;6BA/DlB,MAAM,WACN,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAC5D,IAAI;CA+DR,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { createContext, useContext } from "react";
|
|
2
|
+
import Button from "@mui/material/Button";
|
|
3
|
+
import { SnackbarProvider, useSnackbar } from "notistack";
|
|
4
|
+
const SnackBarContext = createContext({
|
|
5
|
+
enqueueSnackbar: () => { },
|
|
6
|
+
});
|
|
7
|
+
const SnackBarProviderUtilities = ({ children }) => {
|
|
8
|
+
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
|
9
|
+
const action = (snackbarId) => (React.createElement(React.Fragment, null,
|
|
10
|
+
React.createElement(Button, { size: "small", variant: "text", color: "inherit", onClick: () => {
|
|
11
|
+
closeSnackbar(snackbarId);
|
|
12
|
+
} }, "\u0417\u0430\u043A\u0440\u044B\u0442\u044C")));
|
|
13
|
+
function handleEnqueueSnackbar(message, variant) {
|
|
14
|
+
enqueueSnackbar(message, {
|
|
15
|
+
variant: variant,
|
|
16
|
+
preventDuplicate: true,
|
|
17
|
+
action: action,
|
|
18
|
+
anchorOrigin: {
|
|
19
|
+
horizontal: "left",
|
|
20
|
+
vertical: "bottom",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return (React.createElement(SnackBarContext.Provider, { value: {
|
|
25
|
+
enqueueSnackbar: handleEnqueueSnackbar,
|
|
26
|
+
} }, children));
|
|
27
|
+
};
|
|
28
|
+
export const SnackBarProvider = ({ children }) => {
|
|
29
|
+
return (React.createElement(SnackbarProvider, { maxSnack: 5, autoHideDuration: 5000, preventDuplicate: true },
|
|
30
|
+
React.createElement(SnackBarProviderUtilities, null, children)));
|
|
31
|
+
};
|
|
32
|
+
export const useSnackbarContext = () => {
|
|
33
|
+
return useContext(SnackBarContext);
|
|
34
|
+
};
|
|
35
|
+
export default SnackBarProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as DagStateProvider } from "./DagStateProvider";
|
|
2
|
+
export * from "./DagStateProvider";
|
|
3
|
+
export { default as SessionProvider } from "./SessionProvider";
|
|
4
|
+
export * from "./SessionProvider";
|
|
5
|
+
export { default as SnackBarProvider } from "./SnackBarProvider";
|
|
6
|
+
export * from "./SnackBarProvider";
|
|
7
|
+
export { default as AirflowProvider } from "./AirflowProvider";
|
|
8
|
+
export * from "./AirflowProvider";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as DagStateProvider } from "./DagStateProvider";
|
|
2
|
+
export * from "./DagStateProvider";
|
|
3
|
+
export { default as SessionProvider } from "./SessionProvider";
|
|
4
|
+
export * from "./SessionProvider";
|
|
5
|
+
export { default as SnackBarProvider } from "./SnackBarProvider";
|
|
6
|
+
export * from "./SnackBarProvider";
|
|
7
|
+
export { default as AirflowProvider } from "./AirflowProvider";
|
|
8
|
+
export * from "./AirflowProvider";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { SxProps } from "@mui/material";
|
|
3
|
+
export type DagState = "queued" | "running" | "success" | "failed";
|
|
4
|
+
export type TaskState = "success" | "running" | "failed" | "upstream_failed" | "skipped" | "up_for_retry" | "up_for_reschedule" | "queued" | "none" | "scheduled" | "deferred" | "removed" | "restarting";
|
|
5
|
+
export interface Dag {
|
|
6
|
+
dagId: string;
|
|
7
|
+
rootDagId: string | null;
|
|
8
|
+
isPaused: boolean | null;
|
|
9
|
+
isActive: boolean | null;
|
|
10
|
+
isSubdag: boolean;
|
|
11
|
+
lastParsedTime: string | null;
|
|
12
|
+
lastPickled: string | null;
|
|
13
|
+
lastExpired: string | null;
|
|
14
|
+
schedulerLock: boolean | null;
|
|
15
|
+
pickleId: string | null;
|
|
16
|
+
defaultView: string | null;
|
|
17
|
+
fileloc: string;
|
|
18
|
+
fileToken: string;
|
|
19
|
+
owners: string[];
|
|
20
|
+
description: string | null;
|
|
21
|
+
scheduleInterval: unknown | null;
|
|
22
|
+
timetableDescription: string | null;
|
|
23
|
+
tags: object[] | null;
|
|
24
|
+
maxActiveTasks: number | null;
|
|
25
|
+
maxActiveRuns: number | null;
|
|
26
|
+
hasTaskConcurrencyLimits: boolean | null;
|
|
27
|
+
hasImportErrors: boolean | null;
|
|
28
|
+
nextDagrun: string | null;
|
|
29
|
+
nextDagrunDataIntervalStart: string | null;
|
|
30
|
+
nextDagrunDataIntervalEnd: string | null;
|
|
31
|
+
nextDagrunCreateAfter: string | null;
|
|
32
|
+
maxConsecutiveFailedDagRuns: number | null;
|
|
33
|
+
}
|
|
34
|
+
export interface DagRun {
|
|
35
|
+
dagRunId: string | null;
|
|
36
|
+
dagId: string;
|
|
37
|
+
logicalDate: string | null;
|
|
38
|
+
endDate: string | null;
|
|
39
|
+
state: DagState;
|
|
40
|
+
conf?: {
|
|
41
|
+
rule_uuid: string;
|
|
42
|
+
table_name: string;
|
|
43
|
+
start_date: string;
|
|
44
|
+
end_date: string;
|
|
45
|
+
username: string;
|
|
46
|
+
filename?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface TaskInstance {
|
|
50
|
+
taskId: string;
|
|
51
|
+
dagId: string;
|
|
52
|
+
dagRunId: string;
|
|
53
|
+
executionDate: string;
|
|
54
|
+
duration: number | null;
|
|
55
|
+
state: TaskState | null;
|
|
56
|
+
tryNumber: number;
|
|
57
|
+
}
|
|
58
|
+
export interface TaskInstances {
|
|
59
|
+
taskInstances: TaskInstance[];
|
|
60
|
+
totalEntries: number;
|
|
61
|
+
}
|
|
62
|
+
export interface Logs {
|
|
63
|
+
continuationToken: string;
|
|
64
|
+
content: string;
|
|
65
|
+
}
|
|
66
|
+
export interface Column<T> {
|
|
67
|
+
name: string;
|
|
68
|
+
displayName: string;
|
|
69
|
+
fieldName: string;
|
|
70
|
+
defaultValue?: string;
|
|
71
|
+
sortable?: boolean;
|
|
72
|
+
searchable?: boolean;
|
|
73
|
+
order?: "asc" | "desc" | "none";
|
|
74
|
+
searchStr?: string | (() => string);
|
|
75
|
+
colSx?: SxProps;
|
|
76
|
+
resizable?: boolean;
|
|
77
|
+
searchComponent?(): ReactNode;
|
|
78
|
+
cellContentComponent?(row: T): ReactNode;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "moment-duration-format";
|
|
2
|
+
import "moment/locale/ru";
|
|
3
|
+
import { DagState, TaskState } from "./types";
|
|
4
|
+
import { PopoverOrigin } from "@mui/material";
|
|
5
|
+
export declare function getCSRFToken(): string;
|
|
6
|
+
export declare function setCSRFToken(newToken: string): void;
|
|
7
|
+
export declare function prettyDatetime(datetime: string): string;
|
|
8
|
+
export declare const taskStateText: (taskState: DagState | TaskState | string | null | undefined) => "Завершена" | "Ошибка" | "В очереди" | "Выполняется" | "Нет состояния";
|
|
9
|
+
export declare const formatDate: (date: string) => string;
|
|
10
|
+
export declare const formatDuration: (duration: number) => string;
|
|
11
|
+
export declare const getSlugTableName: (name: string) => string;
|
|
12
|
+
export declare const getShiftedColor: (colorHex: string, shift: number) => string;
|
|
13
|
+
export declare const getSQLLabHref: (supersetURL: string, tableName: string, schema: string, dbName: string, autorun?: boolean, queryLimit?: number) => string;
|
|
14
|
+
export declare const getDashboardHref: (supersetURL: string, tableName: string) => string;
|
|
15
|
+
export declare function useDebounce<Args extends unknown[]>(callback: (...args: Args) => void, delay: number): (...args: Args) => void;
|
|
16
|
+
export declare const getResponsiveAnchorOrigin: (anchorEl: HTMLElement, elementHeight: number) => PopoverOrigin;
|
|
17
|
+
export declare const getResponsiveTransformOrigin: (anchorEl: HTMLElement, elementHeight: number) => PopoverOrigin;
|
|
18
|
+
export declare const gettextTS: (msgid: string) => string;
|
|
19
|
+
export declare const ngettextTS: (singular: string, plural: string, count: number) => string;
|
|
20
|
+
export declare const pgettextTS: (context: string, msgid: string) => string;
|
|
21
|
+
export declare const npgettextTS: (context: string, singular: string, plural: string, count: number) => string;
|
|
22
|
+
export declare const gettextNoopTS: (msgid: string) => string;
|
|
23
|
+
export declare const interpolateTS: (fmt: string, obj: any, named?: boolean) => string;
|
|
24
|
+
export declare const getFormatTS: (formatType: string) => string;
|
|
25
|
+
export declare const pluralidxTS: (count: number) => number;
|
|
26
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;AAChC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,wBAAgB,YAAY,WAI3B;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,QAI5C;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,UAM9C;AAED,eAAO,MAAM,aAAa,GACxB,WAAW,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,2EAc5D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAWtC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,WAK9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,WAyC5C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,OAAO,MAAM,WAkB9D,CAAC;AACF,eAAO,MAAM,aAAa,GACxB,aAAa,MAAM,EACnB,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,UAAU,OAAO,EACjB,aAAa,MAAM,WAWpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,EAAE,WAAW,MAAM,WACR,CAAC;AAEhE,wBAAgB,WAAW,CAAC,IAAI,SAAS,OAAO,EAAE,EAChD,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,EACjC,KAAK,EAAE,MAAM,aAKD,IAAI,UAUjB;AAED,eAAO,MAAM,yBAAyB,GACpC,UAAU,WAAW,EACrB,eAAe,MAAM,KAOhB,aACN,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,UAAU,WAAW,EACrB,eAAe,MAAM,KAOhB,aACN,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAMzC,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,UAAU,MAAM,EAChB,QAAQ,MAAM,EACd,OAAO,MAAM,KACZ,MAMF,CAAC;AACF,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,OAAO,MAAM,KAAG,MAM3D,CAAC;AACF,eAAO,MAAM,WAAW,GACtB,SAAS,MAAM,EACf,UAAU,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
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import moment from "moment";
|
|
2
|
+
import moment_tz from "moment-timezone";
|
|
3
|
+
import "moment-duration-format";
|
|
4
|
+
import "moment/locale/ru";
|
|
5
|
+
import { slugify } from "transliteration";
|
|
6
|
+
import { useCallback, useRef } from "react";
|
|
7
|
+
export function getCSRFToken() {
|
|
8
|
+
return document.getElementsByName("csrfmiddlewaretoken")[0].value;
|
|
9
|
+
}
|
|
10
|
+
export function setCSRFToken(newToken) {
|
|
11
|
+
document.getElementsByName("csrfmiddlewaretoken")[0].value = newToken;
|
|
12
|
+
}
|
|
13
|
+
export function prettyDatetime(datetime) {
|
|
14
|
+
if (datetime && datetime.length > 0) {
|
|
15
|
+
return moment_tz(datetime).locale("ru").format("dd DD MMM YYYY, HH:mm:ss");
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const taskStateText = (taskState) => {
|
|
22
|
+
switch (taskState) {
|
|
23
|
+
case "success":
|
|
24
|
+
return "Завершена";
|
|
25
|
+
case "failed":
|
|
26
|
+
return "Ошибка";
|
|
27
|
+
case "queued":
|
|
28
|
+
return "В очереди";
|
|
29
|
+
case "running":
|
|
30
|
+
return "Выполняется";
|
|
31
|
+
default:
|
|
32
|
+
return "Нет состояния";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export const formatDate = (date) => {
|
|
36
|
+
return new Date(date).toLocaleString("ru", {
|
|
37
|
+
weekday: "short",
|
|
38
|
+
month: "short",
|
|
39
|
+
day: "numeric",
|
|
40
|
+
year: "numeric",
|
|
41
|
+
hour: "2-digit",
|
|
42
|
+
minute: "2-digit",
|
|
43
|
+
second: "2-digit",
|
|
44
|
+
timeZone: "Europe/Moscow",
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export const formatDuration = (duration) => {
|
|
48
|
+
return moment.duration(duration, "seconds").format({
|
|
49
|
+
precision: 1,
|
|
50
|
+
template: "h [ч], m [мин], s [сек]",
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export const getSlugTableName = (name) => {
|
|
54
|
+
const replaces = {
|
|
55
|
+
"(": " lparen ",
|
|
56
|
+
")": " rparen ",
|
|
57
|
+
"[": " lsqb ",
|
|
58
|
+
"]": " rsqb ",
|
|
59
|
+
"{": " lcub ",
|
|
60
|
+
"}": " rcub ",
|
|
61
|
+
"#": " num ",
|
|
62
|
+
"&": " amp ",
|
|
63
|
+
",": " com ",
|
|
64
|
+
".": " dot ",
|
|
65
|
+
";": " semi ",
|
|
66
|
+
":": " col ",
|
|
67
|
+
"/": " sol ",
|
|
68
|
+
"\\": " bsol ",
|
|
69
|
+
"?": " quest ",
|
|
70
|
+
"!": " excl ",
|
|
71
|
+
"-": " dash ",
|
|
72
|
+
"<": " lt ",
|
|
73
|
+
">": " gt ",
|
|
74
|
+
"=": " eq ",
|
|
75
|
+
"+": " plus ",
|
|
76
|
+
"*": " ast ",
|
|
77
|
+
"|": " bar ",
|
|
78
|
+
"'": " apos ",
|
|
79
|
+
'"': " quot ",
|
|
80
|
+
"`": " grave ",
|
|
81
|
+
"~": " tilde ",
|
|
82
|
+
"@": " at ",
|
|
83
|
+
$: " dol ",
|
|
84
|
+
"%": " percnt ",
|
|
85
|
+
"^": " hat ",
|
|
86
|
+
};
|
|
87
|
+
return `table_${slugify(name, {
|
|
88
|
+
separator: "_",
|
|
89
|
+
trim: true,
|
|
90
|
+
replaceAfter: replaces,
|
|
91
|
+
allowedChars: "a-zA-Z0-9_()\\[\\]{}#&,.;:\\/\\\\?!\\-<>=+*|'\"`~@$%^",
|
|
92
|
+
})}`;
|
|
93
|
+
};
|
|
94
|
+
export const getShiftedColor = (colorHex, shift) => {
|
|
95
|
+
let pureHex = colorHex.substring(1);
|
|
96
|
+
if (pureHex.length === 3) {
|
|
97
|
+
pureHex = `${pureHex[0]}${pureHex[0]}${pureHex[1]}${pureHex[1]}${pureHex[2]}${pureHex[2]}`;
|
|
98
|
+
}
|
|
99
|
+
const channels = [
|
|
100
|
+
parseInt(pureHex.substring(0, 2), 16),
|
|
101
|
+
parseInt(pureHex.substring(2, 4), 16),
|
|
102
|
+
parseInt(pureHex.substring(4, 6), 16),
|
|
103
|
+
];
|
|
104
|
+
const shifted = channels.map((ch) => {
|
|
105
|
+
return (ch + shift).toString(16);
|
|
106
|
+
});
|
|
107
|
+
return `#${shifted.join("")}`;
|
|
108
|
+
};
|
|
109
|
+
export const getSQLLabHref = (supersetURL, tableName, schema, dbName, autorun, queryLimit) => {
|
|
110
|
+
const url = new URL("sqllab/", supersetURL);
|
|
111
|
+
url.searchParams.append("name", tableName);
|
|
112
|
+
url.searchParams.append("schema", schema);
|
|
113
|
+
url.searchParams.append("dbname", dbName);
|
|
114
|
+
url.searchParams.append("sql", `select * from ${schema}.${tableName}`);
|
|
115
|
+
if (autorun != null)
|
|
116
|
+
url.searchParams.append("autorun", String(autorun));
|
|
117
|
+
if (queryLimit != null)
|
|
118
|
+
url.searchParams.append("queryLimit", String(queryLimit));
|
|
119
|
+
return url.href;
|
|
120
|
+
};
|
|
121
|
+
export const getDashboardHref = (supersetURL, tableName) => new URL(`superset/dashboard/${tableName}/`, supersetURL).href;
|
|
122
|
+
export function useDebounce(callback, delay) {
|
|
123
|
+
const timer = useRef(null);
|
|
124
|
+
const debouncedCallback = useCallback((...args) => {
|
|
125
|
+
if (timer.current) {
|
|
126
|
+
clearTimeout(timer.current);
|
|
127
|
+
}
|
|
128
|
+
timer.current = setTimeout(() => callback(...args), delay);
|
|
129
|
+
}, [callback, delay]);
|
|
130
|
+
return debouncedCallback;
|
|
131
|
+
}
|
|
132
|
+
export const getResponsiveAnchorOrigin = (anchorEl, elementHeight) => {
|
|
133
|
+
const rect = anchorEl?.getBoundingClientRect();
|
|
134
|
+
return (window.innerHeight - rect?.bottom > elementHeight
|
|
135
|
+
? { vertical: "bottom", horizontal: "left" }
|
|
136
|
+
: { vertical: "top", horizontal: "left" });
|
|
137
|
+
};
|
|
138
|
+
export const getResponsiveTransformOrigin = (anchorEl, elementHeight) => {
|
|
139
|
+
const rect = anchorEl?.getBoundingClientRect();
|
|
140
|
+
return (window.innerHeight - rect?.bottom > elementHeight
|
|
141
|
+
? { vertical: "top", horizontal: "left" }
|
|
142
|
+
: { vertical: "bottom", horizontal: "left" });
|
|
143
|
+
};
|
|
144
|
+
export const gettextTS = (msgid) => {
|
|
145
|
+
if (typeof gettext === "function") {
|
|
146
|
+
return gettext(msgid);
|
|
147
|
+
}
|
|
148
|
+
return msgid;
|
|
149
|
+
};
|
|
150
|
+
export const ngettextTS = (singular, plural, count) => {
|
|
151
|
+
if (typeof ngettext === "function") {
|
|
152
|
+
return ngettext(singular, plural, count);
|
|
153
|
+
}
|
|
154
|
+
return count === 1 ? singular : plural;
|
|
155
|
+
};
|
|
156
|
+
export const pgettextTS = (context, msgid) => {
|
|
157
|
+
if (typeof pgettext === "function") {
|
|
158
|
+
return pgettext(context, msgid);
|
|
159
|
+
}
|
|
160
|
+
return msgid;
|
|
161
|
+
};
|
|
162
|
+
export const npgettextTS = (context, singular, plural, count) => {
|
|
163
|
+
if (typeof npgettext === "function") {
|
|
164
|
+
return npgettext(context, singular, plural, count);
|
|
165
|
+
}
|
|
166
|
+
return count === 1 ? singular : plural;
|
|
167
|
+
};
|
|
168
|
+
export const gettextNoopTS = (msgid) => {
|
|
169
|
+
if (typeof gettext_noop === "function") {
|
|
170
|
+
return gettext_noop(msgid);
|
|
171
|
+
}
|
|
172
|
+
return msgid;
|
|
173
|
+
};
|
|
174
|
+
export const interpolateTS = (fmt,
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
|
+
obj, named) => {
|
|
177
|
+
if (typeof interpolate === "function") {
|
|
178
|
+
return interpolate(fmt, obj, named);
|
|
179
|
+
}
|
|
180
|
+
return fmt;
|
|
181
|
+
};
|
|
182
|
+
export const getFormatTS = (formatType) => {
|
|
183
|
+
if (typeof get_format === "function") {
|
|
184
|
+
return get_format(formatType);
|
|
185
|
+
}
|
|
186
|
+
return formatType;
|
|
187
|
+
};
|
|
188
|
+
export const pluralidxTS = (count) => {
|
|
189
|
+
if (typeof pluralidx === "function") {
|
|
190
|
+
return pluralidx(count);
|
|
191
|
+
}
|
|
192
|
+
return count;
|
|
193
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@danikokonn/yarik-frontend-lib",
|
|
3
|
+
"version": "2.0.2-test3",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"author": "",
|
|
7
|
+
"homepage": "https://github.com/YARIK-ML/YARIK-frontend-lib#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/YARIK-ML/YARIK-frontend-lib/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/YARIK-ML/YARIK-frontend-lib.git"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@eslint/js": "^9.16.0",
|
|
17
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
18
|
+
"@types/moment-duration-format": "^2.2.6",
|
|
19
|
+
"eslint": "^9.19.0",
|
|
20
|
+
"eslint-plugin-react": "^7.37.4",
|
|
21
|
+
"globals": "^15.14.0",
|
|
22
|
+
"prettier": "3.2.5",
|
|
23
|
+
"ts-loader": "^9.5.2",
|
|
24
|
+
"tss-react": "^4.9.15",
|
|
25
|
+
"typescript": "^5.7.3",
|
|
26
|
+
"typescript-eslint": "^8.23.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@emotion/react": "^11.14.0",
|
|
30
|
+
"@emotion/styled": "^11.14.0",
|
|
31
|
+
"@mui/icons-material": "^6.4.3",
|
|
32
|
+
"@mui/material": "^6.4.3",
|
|
33
|
+
"@mui/x-date-pickers": "^7.25.0",
|
|
34
|
+
"@types/react": "^18.3.18",
|
|
35
|
+
"@types/react-dom": "^18.3.5",
|
|
36
|
+
"css-loader": "^7.1.2",
|
|
37
|
+
"moment": "^2.30.1",
|
|
38
|
+
"moment-duration-format": "^2.3.2",
|
|
39
|
+
"moment-timezone": "^0.5.47",
|
|
40
|
+
"notistack": "^3.0.2",
|
|
41
|
+
"react": "^18.3.1",
|
|
42
|
+
"react-dom": "^18.3.1",
|
|
43
|
+
"react-imask": "^7.6.1",
|
|
44
|
+
"react-virtuoso": "^4.13.0",
|
|
45
|
+
"style-loader": "^4.0.0",
|
|
46
|
+
"transliteration": "^2.3.5"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"test": "echo \"Error: no test specified\"",
|
|
50
|
+
"build": "tsc"
|
|
51
|
+
},
|
|
52
|
+
"main": ".dist/index.js",
|
|
53
|
+
"types": ".dist/index.d.ts",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"import": "./dist/index.js",
|
|
57
|
+
"require": "./dist/index.js",
|
|
58
|
+
"types": "./dist/index.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./*": {
|
|
61
|
+
"import": "./dist/*/index.js",
|
|
62
|
+
"require": "./dist/*/index.js",
|
|
63
|
+
"types": "./dist/*/index.d.ts"
|
|
64
|
+
},
|
|
65
|
+
"./providers/*": {
|
|
66
|
+
"import": "./dist/providers/*.js",
|
|
67
|
+
"require": "./dist/providers/*.js",
|
|
68
|
+
"types": "./dist/providers/*.d.ts"
|
|
69
|
+
},
|
|
70
|
+
"./components/icons/*": {
|
|
71
|
+
"import": "./dist/components/icons/*.js",
|
|
72
|
+
"require": "./dist/components/icons/*.js",
|
|
73
|
+
"types": "./dist/components/icons/*.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./http": {
|
|
76
|
+
"import": "./dist/http.js",
|
|
77
|
+
"require": "./dist/http.js",
|
|
78
|
+
"types": "./dist/http.d.ts"
|
|
79
|
+
},
|
|
80
|
+
"./utils": {
|
|
81
|
+
"import": "./dist/utils.js",
|
|
82
|
+
"require": "./dist/utils.js",
|
|
83
|
+
"types": "./dist/utils.d.ts"
|
|
84
|
+
},
|
|
85
|
+
"./types": {
|
|
86
|
+
"import": "./dist/types.js",
|
|
87
|
+
"require": "./dist/types.js",
|
|
88
|
+
"types": "./dist/types.d.ts"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"files": [
|
|
92
|
+
"dist"
|
|
93
|
+
]
|
|
94
|
+
}
|