Merge branch 'dev'

# Conflicts:
#	src/Map/LastMLRun.jsx
#	src/Map/Layers/PendingPoints.jsx
#	src/Map/Layers/layers-config.js
#	src/api.js
#	src/icons/icons-config.js
#	src/modules/ImportMode/PointsFileUploadModal.jsx
#	src/modules/Table/PendingTable/PendingTable.jsx
#	src/modules/Table/PendingTable/usePendingTableFields.jsx
#	src/modules/Table/useColumns.jsx
#	src/utils.js
dev
RekHoto 3 years ago
commit 4117cd402d

@ -1,19 +1,30 @@
import { startML, useLastMLRun } from "../api.js"; import { startML, useLastMLRun } from "../api.js";
import { Button, Popover, Spin, Tooltip } from "antd"; import { Button, Popover, Spin, Tooltip } from "antd";
import { InfoCircleOutlined, LoadingOutlined } from "@ant-design/icons"; import { InfoCircleOutlined, LoadingOutlined } from "@ant-design/icons";
import { useMemo } from "react"; import { useEffect, useState } from "react";
const TASK_STATUSES = { const TASK_STATUSES = {
finished: "Перерасчет ML завершен" finished: "Перерасчет ML завершен"
} }
export function LastMLRun() { export function LastMLRun() {
const { data } = useLastMLRun(); const { data } = useLastMLRun();
const hasFinishedUpdate = useMemo(() => { const [isUpdating, setIsUpdating] = useState(false);
return data?.task_status === TASK_STATUSES.finished
useEffect(() => {
setIsUpdating(data?.task_status !== TASK_STATUSES.finished);
}, [data]); }, [data]);
const startUpdating = async () => {
setIsUpdating(true);
try {
await startML();
} catch (e) {
setIsUpdating(false);
}
}
const lastMLRunRender = () => { const lastMLRunRender = () => {
if (hasFinishedUpdate) return ( if (!isUpdating) return (
<> <>
<div className="text-xs text-grey z-10 bg-white-background rounded-xl px-2 py-0.5 space-y-3"> <div className="text-xs text-grey z-10 bg-white-background rounded-xl px-2 py-0.5 space-y-3">
Последнее обновление системы Последнее обновление системы
@ -21,7 +32,7 @@ export function LastMLRun() {
<div className="text-xs text-grey z-10 bg-white-background rounded-xl px-2 py-0.5 space-y-3"> <div className="text-xs text-grey z-10 bg-white-background rounded-xl px-2 py-0.5 space-y-3">
{new Date(data?.last_time).toLocaleString('ru-RU')} {new Date(data?.last_time).toLocaleString('ru-RU')}
</div> </div>
<Button type="text" className="flex items-center p-2 text-[#C50000] hover:text-[#C50000] text-xs" onClick={() => startML()}> <Button type="text" className="flex items-center p-2 text-[#C50000] hover:text-[#C50000] text-xs" onClick={() => startUpdating()}>
Обновить систему Обновить систему
</Button> </Button>
</> </>
@ -45,7 +56,7 @@ export function LastMLRun() {
> >
<Tooltip title="Инфо"> <Tooltip title="Инфо">
<Button className="absolute bottom-[64px] right-[20px] flex items-center justify-center p-3"> <Button className="absolute bottom-[64px] right-[20px] flex items-center justify-center p-3">
{hasFinishedUpdate {!isUpdating
? <InfoCircleOutlined className="w-4 h-4" /> ? <InfoCircleOutlined className="w-4 h-4" />
: <Spin indicator={<LoadingOutlined style={{ fontSize: 16, color: "#000000" }} spin />} /> : <Spin indicator={<LoadingOutlined style={{ fontSize: 16, color: "#000000" }} spin />} />
} }

@ -32,6 +32,9 @@ const useFilterExpression = () => {
]; ];
const staticKeyFiltersExpressions = RANGE_FILTERS_KEYS.map((key) => { const staticKeyFiltersExpressions = RANGE_FILTERS_KEYS.map((key) => {
if (/d[0-9]/.test(key) && filters[`${key}__lt`] === 4000) return [
[">=", ["get", key], filters[`${key}__gt`]]
];
return [ return [
[">=", ["get", key], filters[`${key}__gt`]], [">=", ["get", key], filters[`${key}__gt`]],
["<=", ["get", key], filters[`${key}__lt`]], ["<=", ["get", key], filters[`${key}__lt`]],

@ -103,7 +103,11 @@ export const getPointSymbolLayer = (image) => {
return { return {
type: "symbol", type: "symbol",
layout: { layout: {
"icon-image": image, "icon-image": [
'coalesce',
['image', image],
['image', 'defaultIcon']
],
"icon-size": ["interpolate", ["linear"], ["zoom"], 3, 0, 9, 0.1, 13, 0.5], "icon-size": ["interpolate", ["linear"], ["zoom"], 3, 0, 9, 0.1, 13, 0.5],
}, },
}; };

@ -101,6 +101,14 @@ export const importPoints = async (id) => {
return data; return data;
}; };
export const getImportStatus = async () => {
const { data } = await api.get(
`/api/pre_placement_points/import_status/`
);
return data;
};
export const useGetTotalInitialPointsCount = () => { export const useGetTotalInitialPointsCount = () => {
const dbTable = useDbTableName(); const dbTable = useDbTableName();
const { updateCounter } = useUpdateLayerCounter(); const { updateCounter } = useUpdateLayerCounter();

@ -0,0 +1,10 @@
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 2 2"
width="2"
height="2"
>
<g>
<circle cx="1" cy="1" r="0.5" fill="#26a2a2" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 176 B

@ -1,3 +1,7 @@
import logo from "../assets/logopng.png"; import logo from "../assets/logopng.png";
import defaultIcon from "../assets/circle.svg";
export const icons = [{ name: "logo", url: logo }]; export const icons = [
{ name: "logo", url: logo },
{ name: "defaultIcon", url: defaultIcon },
];

@ -1,6 +1,6 @@
import { Button, Modal, Spin } from "antd"; import { Button, Modal, Spin } from "antd";
import { useState } from "react"; import { useState } from "react";
import { importPoints } from "../../api.js"; import { getImportStatus, importPoints } from "../../api.js";
import { LoadingStage } from "./LoadingStage.jsx"; import { LoadingStage } from "./LoadingStage.jsx";
import { ReportStage } from "./ReportStage.jsx"; import { ReportStage } from "./ReportStage.jsx";
import { import {
@ -16,17 +16,25 @@ export const PointsFileUploadModal = ({onClose, isOpened}) => {
const [isImporting, setIsImporting] = useState(false); const [isImporting, setIsImporting] = useState(false);
const [isReportStage, setIsReportStage] = useState(false); const [isReportStage, setIsReportStage] = useState(false);
const [isError, setIsError] = useState(false); const [isError, setIsError] = useState(false);
const [importStatus, setImportStatus] = useState("Импортируем точки...")
const { toggleUpdateCounter } = useUpdateLayerCounter(); const { toggleUpdateCounter } = useUpdateLayerCounter();
const onImportPoints = async () => { const onImportPoints = async () => {
setIsImporting(true); setIsImporting(true);
try { try {
const { message } = await importPoints(fileId); await importPoints(fileId);
setReport(message); const myInterval = setInterval(async () => {
const response = await getImportStatus();
setImportStatus(response.task_status);
if (response.task_status === "Перерасчет ML завершен") {
setReport(response.data);
setIsImporting(false);
clearInterval(myInterval);
}
}, 2000);
toggleUpdateCounter(); toggleUpdateCounter();
} catch (e) { } catch (e) {
setIsError(true); setIsError(true);
} finally {
setIsImporting(false); setIsImporting(false);
} }
} }
@ -87,7 +95,7 @@ export const PointsFileUploadModal = ({onClose, isOpened}) => {
if (isImporting) return ( if (isImporting) return (
<div className="flex flex-col justify-center gap-2 items-center"> <div className="flex flex-col justify-center gap-2 items-center">
<Spin indicator={<LoadingOutlined style={{ fontSize: 64 }} spin />} /> <Spin indicator={<LoadingOutlined style={{ fontSize: 64 }} spin />} />
Импортируем точки... {importStatus}
</div> </div>
); );
if (isReportStage) return <ReportStage report={report} />; if (isReportStage) return <ReportStage report={report} />;

@ -18,8 +18,8 @@ export const PendingTable = ({ fullWidth }) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(PAGE_SIZE); const [pageSize, setPageSize] = useState(PAGE_SIZE);
const fields = usePendingTableFields(); const { fields, isDeleting } = usePendingTableFields();
const {columns, orderColumns, sort, setSort} = useColumns(fields, tableKey); const { columns, orderColumns, sort, setSort } = useColumns(fields, tableKey);
const { setPopup } = usePopup(); const { setPopup } = usePopup();
const onSort = (sortDirection, key) => { const onSort = (sortDirection, key) => {
@ -94,7 +94,7 @@ export const PendingTable = ({ fullWidth }) => {
onSort(sorter.order, sorter.columnKey); onSort(sorter.order, sorter.columnKey);
}} }}
header={<HeaderWrapper exportProvider={useExportPendingData} orderColumns={orderColumns} />} header={<HeaderWrapper exportProvider={useExportPendingData} orderColumns={orderColumns} />}
loading={isDataLoading} loading={isDataLoading || isDeleting}
/> />
); );
}; };

@ -1,5 +1,5 @@
import { useMode } from "../../../stores/useMode.js"; import { useMode } from "../../../stores/useMode.js";
import React, { useMemo } from "react"; import React, { useMemo, useState } from "react";
import { Button } from "antd"; import { Button } from "antd";
import { BiTrash } from "react-icons/all.js"; import { BiTrash } from "react-icons/all.js";
import { deletePoint } from "../../../api.js"; import { deletePoint } from "../../../api.js";
@ -24,13 +24,17 @@ const MATCHING_STATUS = {
export const usePendingTableFields = () => { export const usePendingTableFields = () => {
const { isImportMode } = useMode(); const { isImportMode } = useMode();
const { toggleUpdateCounter } = useUpdateLayerCounter(); const { toggleUpdateCounter } = useUpdateLayerCounter();
const [isDeleting, setIsDeleting] = useState(false);
const deleteRow = async (e, id) => { const deleteRow = async (e, id) => {
e.stopPropagation(); e.stopPropagation();
setIsDeleting(true);
try { try {
await deletePoint(id); await deletePoint(id);
toggleUpdateCounter(); toggleUpdateCounter();
} catch (e) { } catch (e) {
// //
} finally {
setIsDeleting(false);
} }
}; };
@ -71,5 +75,5 @@ export const usePendingTableFields = () => {
} }
] : []; ] : [];
}, [isImportMode]); }, [isImportMode]);
return fields; return { fields, isDeleting };
} }

@ -426,7 +426,7 @@ export const useColumns = (fields = [], key) => {
const columns = useMemo(() => { const columns = useMemo(() => {
return order.flatMap((item) => !item.show ? [] : defaultColumns[item.position]) return order.flatMap((item) => !item.show ? [] : defaultColumns[item.position])
.map((column) => { .map((column) => {
if (sort && sort.includes(column.key)) return { if (sort && sort.includes(column?.key)) return {
...column, ...column,
defaultSortOrder: sort.includes('-') ? 'descend' : 'ascend', defaultSortOrder: sort.includes('-') ? 'descend' : 'ascend',
}; };

@ -107,10 +107,12 @@ export const appendFiltersInUse = (params, filters, ranges) => {
filterKey.split('d')[1], filterKey.split('d')[1],
filters[`${filterKey}__gt`] - 1 filters[`${filterKey}__gt`] - 1
].join(',')); ].join(','));
if (filters[`${filterKey}__lt`] < 4000) {
params.append('dist_to_group__lt', [ params.append('dist_to_group__lt', [
filterKey.split('d')[1], filterKey.split('d')[1],
filters[`${filterKey}__lt`] + 1 filters[`${ filterKey }__lt`] + 1
].join(',')); ].join(','));
}
} else { } else {
params.append(`${filterKey}__gt`, filters[`${filterKey}__gt`] - 1); params.append(`${filterKey}__gt`, filters[`${filterKey}__gt`] - 1);
params.append(`${filterKey}__lt`, filters[`${filterKey}__lt`] + 1); params.append(`${filterKey}__lt`, filters[`${filterKey}__lt`] + 1);

Loading…
Cancel
Save