Skip to content

Commit 9333627

Browse files
authored
Merge pull request #25 from Feazom/dev
fix segment selector
2 parents 40ef52e + b073bf1 commit 9333627

File tree

6 files changed

+78
-77
lines changed

6 files changed

+78
-77
lines changed

UrfuMaps.Client/src/components/MapCanvas.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '../services/RequestService';
1919
import URLImage from './URLImage';
2020
import RouteSegmentDTO from '../types/RouteSegmentDTO';
21-
import { canvaPosition } from '../services/utils';
21+
import { canvaPosition, toFrontName } from '../services/utils';
2222
import { OrientationContext } from '../context';
2323
import MarkCanvas from './MarkCanvas';
2424
import { Floor } from '../types';
@@ -54,7 +54,6 @@ const MapCanvas = ({
5454
const [width, setWidth] = useState(window.innerWidth * 0.8);
5555
const [height, setHeight] = useState(window.innerHeight * 0.95);
5656
const forceUpdate = useForceUpdate();
57-
5857
const orientation = useContext(OrientationContext);
5958
const imageRef = useRef<Konva.Image>(null);
6059

@@ -83,6 +82,7 @@ const MapCanvas = ({
8382
}
8483
}
8584
);
85+
8686
const { data: sourceData } = useQuery(
8787
['position', source],
8888
() => {
@@ -155,7 +155,7 @@ const MapCanvas = ({
155155

156156
useEffect(() => {
157157
setRoute((r) => {
158-
return routeData || r;
158+
return routeData || [];
159159
});
160160
}, [routeData]);
161161

UrfuMaps.Client/src/components/SegmentSelector.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ const SegmentSelector = ({
4343
const previousSegmentCount = useRef(0);
4444
const orientation = useContext(OrientationContext);
4545

46-
// useEffect(() => {
47-
// setSelectedSegment((s) => {
48-
// const newSegment = segmentFind();
49-
// if (s !== newSegment) {
50-
// return newSegment;
51-
// }
52-
// return s;
53-
// });
54-
// }, [segmentFind]);
55-
5646
useEffect(() => {
5747
if (route.length > 0 && selectedSegment > 0) {
5848
setFloorNumber(route[selectedSegment - 1].floor);

UrfuMaps.Client/src/context.ts

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ i18next.init({
2929
u: 'У',
3030
f: 'Ф',
3131
h: 'Х',
32-
c: 'С',
32+
c: 'Ц',
3333
ch: 'Ч',
3434
sh: 'Ш',
35+
mt: 'МТ',
3536
wcw: 'СУ Ж',
3637
entryrtf: 'Вход',
3738
rtf: 'ИРИТ-РТФ',
@@ -49,3 +50,65 @@ i18next.init({
4950
});
5051

5152
export const t = i18next.t;
53+
54+
export const translation: Record<string, string> = {
55+
а: 'a',
56+
б: 'b',
57+
в: 'v',
58+
г: 'g',
59+
д: 'd',
60+
е: 'e',
61+
ж: 'j',
62+
з: 'z',
63+
и: 'i',
64+
к: 'k',
65+
л: 'l',
66+
м: 'm',
67+
н: 'n',
68+
о: 'o',
69+
п: 'p',
70+
р: 'r',
71+
с: 's',
72+
т: 't',
73+
у: 'u',
74+
ф: 'f',
75+
х: 'h',
76+
ц: 'c',
77+
ч: 'ch',
78+
ш: 'sh',
79+
мт: 'mt',
80+
гук: 'mab',
81+
э: 'e',
82+
сп: 'sp',
83+
вход: 'entry',
84+
правыйвход: 'entryr',
85+
левыйвход: 'entryl',
86+
a: 'a',
87+
b: 'b',
88+
v: 'v',
89+
g: 'g',
90+
d: 'd',
91+
e: 'e',
92+
j: 'j',
93+
z: 'z',
94+
i: 'i',
95+
k: 'k',
96+
l: 'l',
97+
m: 'm',
98+
n: 'n',
99+
o: 'o',
100+
p: 'p',
101+
r: 'r',
102+
s: 's',
103+
t: 't',
104+
u: 'u',
105+
f: 'f',
106+
h: 'h',
107+
c: 'c',
108+
ch: 'ch',
109+
sh: 'sh',
110+
mt: 'mt',
111+
mab: 'mab',
112+
sp: 'sp',
113+
entry: 'entry',
114+
};

UrfuMaps.Client/src/services/RequestService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TokenDTO from '../types/TokenDTO';
77
import UserDTO from '../types/UserDTO';
88
import axios, { AxiosResponse } from 'axios';
99
import PrefixDTO from '../types/PrefixDTO';
10+
import { DebugDto } from '../types';
1011

1112
const user: TokenDTO | undefined = JSON.parse(localStorage.getItem('user')!);
1213
const instance = axios.create({

UrfuMaps.Client/src/services/utils.ts

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Konva from 'konva';
22
import { Vector2d } from 'konva/lib/types';
3-
import { t } from '../context';
3+
import { t, translation } from '../context';
44

55
const special = /[\s`~!@#$%^&*()\-_=+[\]{};:'"\\|/,.<>?]/g;
66

@@ -10,68 +10,6 @@ const propertyHandler = {
1010
},
1111
};
1212

13-
const translation: Record<string, string> = {
14-
а: 'a',
15-
б: 'b',
16-
в: 'v',
17-
г: 'g',
18-
д: 'd',
19-
е: 'e',
20-
ж: 'j',
21-
з: 'z',
22-
и: 'i',
23-
к: 'k',
24-
л: 'l',
25-
м: 'm',
26-
н: 'n',
27-
о: 'o',
28-
п: 'p',
29-
р: 'r',
30-
с: 's',
31-
т: 't',
32-
у: 'u',
33-
ф: 'f',
34-
х: 'h',
35-
ц: 'c',
36-
ч: 'ch',
37-
ш: 'sh',
38-
мт: 'mt',
39-
гук: 'mab',
40-
э: 'e',
41-
сп: 'sp',
42-
вход: 'entry',
43-
правыйвход: 'entryr',
44-
левыйвход: 'entryl',
45-
a: 'a',
46-
b: 'b',
47-
v: 'v',
48-
g: 'g',
49-
d: 'd',
50-
e: 'e',
51-
j: 'j',
52-
z: 'z',
53-
i: 'i',
54-
k: 'k',
55-
l: 'l',
56-
m: 'm',
57-
n: 'n',
58-
o: 'o',
59-
p: 'p',
60-
r: 'r',
61-
s: 's',
62-
t: 't',
63-
u: 'u',
64-
f: 'f',
65-
h: 'h',
66-
c: 'c',
67-
ch: 'ch',
68-
sh: 'sh',
69-
mt: 'mt',
70-
mab: 'mab',
71-
sp: 'sp',
72-
entry: 'entry',
73-
};
74-
7513
const tr = new Proxy(translation, propertyHandler);
7614

7715
export function toFrontName(name: string) {

UrfuMaps.Client/src/types/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ import { Vector2d } from 'konva/lib/types';
22
import { EdgeDTO } from './EdgeDTO';
33
import PositionDTO from './PositionDTO';
44

5+
export type DebugDto = {
6+
fromId: number;
7+
fromX: number;
8+
fromY: number;
9+
toId: number;
10+
toX: number;
11+
toY: number;
12+
};
13+
514
export type TouchMoveResult = {
615
scale: number;
716
newPosition: Vector2d;

0 commit comments

Comments
 (0)