Merge branch 'feature/start_ml' into 'dev'

start ml button

See merge request spatial/postamates_frontend!41
dev
Anton Vlasov 2 years ago
commit f4611ffc34

@ -3,13 +3,18 @@ import {Button, Popover, Tooltip} from "antd";
import {InfoCircleOutlined} from "@ant-design/icons";
export function LastMLRun() {
const {data: time} = useLastMLRun();
const { data } = useLastMLRun();
const lastMLRunRender = () => {
return (
<div className="text-xs text-grey z-10 bg-white-background rounded-xl p-2 space-y-3">
Последний запуск: {time}
</div>
<>
<div className="text-xs text-grey z-10 bg-white-background rounded-xl p-2 space-y-3">
Последний запуск: {new Date(data?.last_time).toLocaleString('ru-RU')}
</div>
<div className="text-xs text-grey z-10 bg-white-background rounded-xl p-2 space-y-3">
{data?.task_status}
</div>
</>
);
};

@ -29,6 +29,7 @@ import {
RANGE_FILTERS_KEYS,
RANGE_FILTERS_MAP
} from "../stores/usePendingPointsFilters.js";
import { StartML } from "./StartML.jsx";
export const MapComponent = () => {
const mapRef = useRef(null);
@ -221,6 +222,7 @@ export const MapComponent = () => {
<Layers postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />
<Legend postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />
<StartML />
<LastMLRun />
<SignOut />
<LayersControl postGroups={filteredPostamatesGroups} otherGroups={filteredOtherGroups} />

@ -0,0 +1,14 @@
import { Button, Tooltip } from "antd";
import { RxUpdate } from "react-icons/all.js";
import { startML } from "../api.js";
export const StartML = () => {
return (
<Tooltip title="Обновить данные">
<Button className="absolute bottom-[108px] right-[20px] flex items-center justify-center p-3" onClick={() => startML()}>
<RxUpdate className="w-4 h-4" />
</Button>
</Tooltip>
);
}

@ -225,7 +225,15 @@ export const getLastMLRun = async () => {
`/api/placement_points/last_time_ml_run/`
);
return data?.last_time ? new Date(data?.last_time).toLocaleString('ru-RU') : '';
return data;
};
export const startML = async () => {
const { data } = await api.get(
`/api/placement_points/start/`
);
return data;
};
export const getPostamatesAndPvzGroups = async () => {
@ -268,6 +276,9 @@ export const useLastMLRun = () => {
async () => {
return await getLastMLRun();
},
{
refetchInterval: 5000,
}
);
}

Loading…
Cancel
Save