Исправлен зум карты на некоторых пользователях

This commit is contained in:
goodmice 2021-10-20 14:32:51 +05:00
parent c2647d1466
commit bdc9a4c285
8 changed files with 72 additions and 24 deletions

View File

@ -1,14 +1,14 @@
import { Map, Overlay } from "pigeon-maps"
import pointer from '../images/pointer.svg'
import {Link} from "react-router-dom";
import { PointerIcon } from '../components/PointerIcon'
import { Link } from "react-router-dom";
import LoaderPortal from '../components/LoaderPortal'
import { useState, useEffect } from "react";
import {ClusterService} from '../services/api'
import { ClusterService } from '../services/api'
import { invokeWebApiWrapperAsync } from "../components/factory"
const calcViewParams = (clusters) => {
if ((!clusters) || clusters.length === 0)
return {center:[60.81226, 70.0562], zoom: 5}
return { center: [60.81226, 70.0562], zoom: 5 }
const center = clusters.reduce((sum, cluster) => {
sum[0] += (cluster.latitude / clusters.length)
@ -27,18 +27,18 @@ const calcViewParams = (clusters) => {
// zoom min = 1 (mega far)
// 4 - full Russia (161.6 deg)
// 13.5 - Khanty-Mansiysk
let zoom = 5 + 5/maxDeg
zoom = zoom < 5 ? 5: zoom
zoom = zoom > 15 ? 15: zoom
let zoom = 5 + 5 / (maxDeg + 0.5)
zoom = zoom < 5 ? 5 : zoom
zoom = zoom > 15 ? 15 : zoom
return {center, zoom}
return { center, zoom }
}
export default function Deposit() {
const [clustersData, setClustersData] = useState([])
const [showLoader, setShowLoader] = useState(false)
useEffect(()=>invokeWebApiWrapperAsync(async()=>{
useEffect(() => invokeWebApiWrapperAsync(async () => {
const data = await ClusterService.getClusters()
setClustersData(data)
},
@ -47,24 +47,24 @@ export default function Deposit() {
[])
const viewParams = calcViewParams(clustersData)
const markers = clustersData.map(cluster =>
<Overlay
width={32}
anchor={[cluster.latitude, cluster.longitude]}
key={`${cluster.latitude} ${cluster.longitude}`}>
<Link to={`/cluster/${cluster.id}/all`}>
<img width={40} src={pointer} alt="+"/>
<span>{cluster.caption}</span>
</Link>
</Overlay >)
return (
<LoaderPortal show={showLoader}>
<div className={'h-100vh'}>
<Map {...viewParams}>
{markers}
{clustersData.map(cluster =>
<Overlay
width={32}
anchor={[cluster.latitude, cluster.longitude]}
key={`${cluster.latitude} ${cluster.longitude}`}>
<Link to={`/cluster/${cluster.id}/all`}>
<PointerIcon color={'black'} />
<span>{cluster.caption}</span>
</Link>
</Overlay >
)}
</Map>
</div>
</LoaderPortal>
);
)
}

View File

@ -42,6 +42,7 @@ export type { WellOperationCategoryDto } from './models/WellOperationCategoryDto
export type { WellOperationDto } from './models/WellOperationDto';
export type { WellOperationDtoPaginationContainer } from './models/WellOperationDtoPaginationContainer';
export type { WellOperationDtoPlanFactPredictBase } from './models/WellOperationDtoPlanFactPredictBase';
export type { WellParamsDto } from './models/WellParamsDto';
export { AdminClusterService } from './services/AdminClusterService';
export { AdminCompanyService } from './services/AdminCompanyService';

View File

@ -10,6 +10,8 @@ export type StatWellDto = {
id?: number;
caption?: string | null;
wellType?: string | null;
state?: string | null;
lastTelemetryDate?: string;
sections?: Array<StatSectionDto> | null;
total?: StatOperationsDtoPlanFactBase;
companies?: Array<CompanyDto> | null;

View File

@ -10,6 +10,9 @@ export type UserDto = {
name?: string | null;
surname?: string | null;
patronymic?: string | null;
email?: string | null;
phone?: string | null;
position?: string | null;
id?: number;
idCompany?: number | null;
idRole?: number | null;

View File

@ -8,6 +8,9 @@ export type UserTokenDto = {
name?: string | null;
surname?: string | null;
patronymic?: string | null;
email?: string | null;
phone?: string | null;
position?: string | null;
id?: number;
companyName?: string | null;
roleName?: string | null;

View File

@ -12,6 +12,7 @@ export type WellDto = {
latitude?: number | null;
longitude?: number | null;
wellType?: string | null;
idState?: number;
lastTelemetryDate?: string;
telemetry?: TelemetryDto;
}

View File

@ -0,0 +1,11 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type WellParamsDto = {
caption?: string | null;
latitude?: number | null;
longitude?: number | null;
idWellType?: number;
idState?: number;
}

View File

@ -2,11 +2,13 @@
/* tslint:disable */
/* eslint-disable */
import type { WellDto } from '../models/WellDto';
import type { WellParamsDto } from '../models/WellParamsDto';
import { request as __request } from '../core/request';
export class WellService {
/**
* Возвращает список доступных скважин
* @returns WellDto Success
* @throws ApiError
*/
@ -19,6 +21,31 @@ export class WellService {
}
/**
* Редактирует указанные поля скважины
* @param idWell Id скважины
* @param requestBody Объект параметров скважины.
* IdWellType: 1 - Наклонно-направленная, 2 - Горизонтальная.
* State: 0 - Неизвестно, 1 - В работе, 2 - Завершена.
* @returns number Success
* @throws ApiError
*/
public static async updateWell(
idWell?: number,
requestBody?: WellParamsDto,
): Promise<number> {
const result = await __request({
method: 'PUT',
path: `/api/well`,
query: {
'idWell': idWell,
},
body: requestBody,
});
return result.body;
}
/**
* Возвращает список скважин, передающих телеметрию в данный момент
* @returns WellDto Success
* @throws ApiError
*/