From 34449e37108a091ee39d031cb11d9cd0373d378e Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 09:26:38 +0200 Subject: [PATCH 01/47] Version 1.0.1.1 release DB connection in /pages/api/talas_v5_DB/gisLines/readGisLines.js --- config/settings.js | 2 +- pages/api.zip | Bin 23173 -> 0 bytes pages/api/talas_v5_DB/gisLines/readGisLines.js | 10 ++++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) delete mode 100644 pages/api.zip diff --git a/config/settings.js b/config/settings.js index 36391cc2b..c1397dace 100644 --- a/config/settings.js +++ b/config/settings.js @@ -1,5 +1,5 @@ // /config/settings.js // Definieren der grundlegenden Umgebungseinstellungen und Konfigurationen der Karte -export const MAP_VERSION = "1.0.0"; +export const MAP_VERSION = "1.0.1"; //export const STANDARD_SIDE_MENU = true; //export const FULL_SIDE_MENU = false; diff --git a/pages/api.zip b/pages/api.zip deleted file mode 100644 index 345e83d412f38404ca22b3bbbb79bf9c15123ea4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23173 zcmb50V|1lk*0y8Ywq3Dp+qP{x729UTwkoz=F)J0bQmOFUIo+rG^k}@}%fFqm*Yjsx z^Pcy_vlV4P!O(z!fS`bYG@!H&nPg+pL4bgMf&u{{0sd>`XvL_*z`)>W zBImF!h}1)RLny9}7zx%jcOSw{sjP?=31(U#t^ni&1?BWU(Hu3Gb8|9jgB6lIB3?@Q7?4iOk($ zpO5uj&k9Szpvf*CL_1xw`&ZUTP2;9{+g&>`Oe4C9l!rRIUWMt z=35?oD;M=`eDCFpC*C!kC}m`l-(k?{Zn$TeRT%|cb=zL?v>IBkqKBF<#N*}!$p_mV z1DqjVnODr~EI}9pT zj+sFO4`u$`4Bu3YC)Mj&UyBX5gcETaWC%}h8aDN3=6-JXTpxIti2eNqbD4p%|MB+D zcm+{DqG`pyZh;r=gofj=`m+1Ss({DxMbEoID96vD!Bj=)xE9%x+aT9SwY6N4KpT2! zzw&K_z+YQ>(H482(>x40KS_QXl~ak=KiUeKh*mNiChF^rWKB7@8Me2r7{p4iNs z3a0^9exNH+KK{v;*4zh}v|9-FRP3^JRaK?Lr&3Ye%ea){qH;`mINlBE{i%YU5jwMM z!I*>>FVe4lL&V4YE3o1}5X#ni*9`s2pppj+1k?+_2<7hxS(v%fyBgUVxkxDjAhJuE zl|NuY8o5e+LLenfAZ?MtBu1#|gn}lkOjYmE;LGq_@N~j6Q2?U9rt1c0oWnH1n-}Ox zNH&Q-e)hZTpz5oF9})Iau}v5$sg8;^d!s~v90cb7&5mSQt!e>XIg@It4cX$nZkzyo zC4t0be$9&qga)o_6!^tyIa~sr^|Uz{S2e5cs`Y9HSvbV4FR)%Sj*-nE?gtS5@&rmJ zGLx7f1K3trW4M9cVtGcV4jEO=-a=S}*E;Y@@9bHxpKj#4>+lmv{5DRKF5G_1@9Z99`=XzA{0*6*QyUEQd_-k1ai(N+wPS`_?O5n~5wx`ZUC2 zqV^sM`h^|rbKg>%GLVkJ-mzF(yDy)lKjo^w$ca60@p3Y^8C=4hM{5YIG^xIJT0Cuq z1&Hk-!yB#b+TmCzvcP`>>eHx`GP(16(Ke8JBA>WEEph6l_+Wz?^iR$ zU=2An`%Z-f*8;O5_!Q_}zlsRUNW^&x#Fvyu-?}o7KN7df^Sc-?hCJGgu7Gm;llU!VJ;!O)Bn z=lTqtFD_^q;rIaE8bZ1oZ6g^nA~)HRgkd7CRlKqm0>s%eK5d()Td;d;m#vp>S>GgM zJrC}JmwU{moh=*VZmQ~BoAQkebpWI#S@@eJSR9UR@{7S0Zc^&fIhJ3Hu#28B&E)xY55|`WP0Dg%4~eLGM8Z}&w``dx@7%YHx3`Y=o@ZY-F0H9A zO$LkK_U+wUCUX=A@=Q_5J31K$BF_m3>Dz?9d(xk(t}VMf$gTf|m1)i5*)x4})D*J3 z^(dCnVjD6qE}RFKUBzSSNIEY|+%EB!j*Tl0_R@^uWVKqQ#hxmU-o}wd`cAR6d(iuU zY}*wz>UTssmM*M;g+}-+AKO<%!x+kdHZ!+UjUHEcs7`X80ky*dJhmV}&$i?D>$N_t^0 zBmm@~DM%ookL>i3hit9v&0ItrY#p419IXK84XbU)ZwMm!N$eAfU&;gvpX(|vtNKBa z>53ASep;F+QKSaxbu-y0TV+sX29sL)RHlP+JMm*0T@Q4IaT<9U2cF0v_mN== z0b?0c41lT0?ae|^ExA3mv;zrteEkk08>1*1oDy-!ZUzHOo6YQ>|9EL%+->6!&oU{| zp)fzhyu|l-X$$u&7lJc;@U6h}5`XPNKOn$vkzu5l4+~CW@U`%+SP3E_N<#O(Pm6?9 zjIc8Fh;k@%7Fjci2#;$2@^rL6Iq%sUOEIgRaeHCKzNA zrLmM;QVP)5TIUsa@tuVDzE8otg>NS4WEm}h2B{Qm4{G;V9i|C9RCI`{R_O%3vLus& zqb~Cxxj3bwc0yUG*@rFFrt}<5tE6;DB|FPh(x=XHZQrh2&V`^~sdR0%3$(;;gs2}` zCQMIk@MC$`9QfB#sutZnE=*Nygp=l(iJDDuR*2%qSDwm-X}!Nrf;8_6+3xCA7U^6` zbw+D@+wHu){ivafS8eL2WvRkO&`2gh3w<7Q5Owlo|5G&bLAvdXPp#-K2_^Td;z0WN zaudo+G)OOE#KkJu4^3biuAK<4*=K<%4PrjS-e>kZ`zp{Xx==amVQ30sTPB$yne*?D z?g1XK-Ucu)`l@wxUm=(457V-pCk$psDB)+yT2i&|ij3Cf z*6y|&&lbWP4eXgv5lZSq0Zp^M10=-<# z_2JYS^pKM<7guLQc-F~a_6fRDC;sf)$)Gq9~c7_M$z9pmlxgm}R7c%F%q$7!1$`CSWy3 z>$d%#FOP0(ULz0ZZ}B){Mw1oQGvVN2@h*2-nu~6QPKBzMw7j6tJ2|--Nk>xjlYQta)gVF+`HZwAn`1>;e+=V6eTjPF0 z3crH*Iw<?hH?r@yn*)0$>7CK1E@)4+-xB_-<{wAF;4S^?UwQS1}-xfBON|Qf}N3asa zN<8vd)ix;iGf{mlMX3}dw~?8n(#Cbo9Gs@+yhruKiwBaH$=j<<)*;w8O_Kmq7_%9KXnAKf)o%yK%f5CHM=>Q8o8Q%kRsyX;B0DT5BT({^Q3- z-8)6JZ=PQ0t)7vSdYgl9hs z$TK-|158e!$mapU{SQ;`o9CM|g>U`=JcJ1-!)92l!IlK@+Eu=Y;HT6#V5{l5?q6Zk zpv^A{JPwdKJc3iOez-lmuIOruxb?hkeX4x<+_*YwflDBIeNp1G{1apG1-O}!yJhk6 zE4r$03d|_=yhIgFv#7q8m7EayI}O7JhX4t>f*8{3k;g&ikt4i7>Ljq(LS6#}ZDXANCIz%2l3FZ%!cFrdi( z+he3mKg3mKOMZh1tEX*QFpJVmSa5KV)3*fg^B z%_C`eNABzBq)#dR+-;aLh;xlJ)IR68mz<*kvZG`#q&HEfV6q@uhIEjcB%ftf_yMKj z^IuPVFIqa2A+SS6xoLSc>}gsS1F!u;qHP+?z7R{=C&XaK@}RN( zTHqng3>i9WK>9_Aqh1x?tTSg_xg7SnXp!|L>oKo)6$N6om3S^P1FW&T7Z-q!hr+ov zxJiY0>08e#%B92|*?4mC^+9Llzc{-7K7w1h*;&rGzVLMC0zD}ly{5K2OzI+#GDcTw zvV?9-+`61c^D*s~rzy)p;LwrN9+gh;(IxQ}>)B;?afY74Zmb3)G>k=fJ0Hq?xo9ca zo~sQXCt0aL2^AlT6i?i<=qf%rrG zrVusE!x3uwaC(=$md>u5@)vMee+|`h$g4-tjMCTFRw8P__mv;?ihdyox~Wu(s#d^8 zZ0K&?9Hv&fHR1ip828?WLEU6unh7^4QsTgi1pr-!?$R3=^S%syX=SPg{djc0Ve?c>&F=P$_$T9lya2$IRB=8)9)M{h z08`HY8`FP9Uf#&gOxWuWVq^bFEaxFjq9%Y?k!87;6hde$kY+ui(9J`cv+0I@_dtXj zcAuE78{?*2)(arHu8p*$hWai6uv~E>{Z2$vjVg1?ozfIGyc@!*V&@ z5^V6DKqiR|f?uN$(AJF2s0OvnL(TU;GFv!dv`1toZTbD~eZ30@gEp|;FV|ki|JhqQvw-c+I|E0S`O;v<+yN90FS>7Gb;xBe7m|eZbohShV{VTA}`q%<8YN?fZ4B9bxXb){eOldo?vP znh8wz3=<=U2XfMoB?kUllIgMUR=O2>h{Zo!5%4WP!_B1mhI39)&>~|W`{KACSmv8w zTJ(i_hFwI~$|NxWg@k|Z*0gHH6A59~RjpL%_${CQ2J8BbK1G+AxD&&xD!qZM3fT%} z2(AU4dlwb$r4GbtmP{nzx@m>+>m8w8z}C}Wy$gU*>KHC$5CEei0E_ycyvx5r$@s4y z|EQ6YrtKF6(ZYTu-XdVuomZ{_BV)uiLfK`JD3!0nU_gnXK67JZ&63?Ev#a`L^NV|U zeY#vjr4+MGpp(hF$#J>#pqMmt{fXQj8bj}8o@r>_d8shVZz_B=7IPLOswpbz{ z*EU#Hx`6TBvMvP$0H#n%nbtGsWY~CRtQPdU1ZyB&2rk1hKuqh-RAQkdVjDM3+^>6A z=;}@7H4V*4U8r)WdbsE^=)g`j4^FXIv%m;C@ju8kIynmO;&i%YY-2m+NfA2$?~}RK zwhD7Egz;p<6K2KU5f{Q78|0?%QM0CNni;zCehn=HkO>43Q`FD=Jn*h?3^v#$ZvC56 z;@25)-7_W!D?_?mOSlu*TQLH$3J!ZvGj(5e2N15C%b^F`qHlg;c_Q;iTz~gt#9$m;{|K)DNf^dkU+c19#*d^6w1xjOXtl{}jD{PweRb zLG&CQto~Xii5H=0#Z0GoZUPwe1P1~l{clH%Oig9~?g;=%+)i~v9#A3q#is;d)p)L@ zw&JR$VirLaI;Sd2N=?8D$D+>KZ+c%C`UD{z{k_F?MPDcuMRemm!{zdQ>cP9-6nmXO zCyL;}xBPetx+ck>bp!dgGA<-`XW|Nqa2muBwKD!|+55oPyMwMnFi)P%Yy-yx5l!REj>q^x! zaatFQs9-2U!uvz^PAwq1h@3*%!pJei1ucFoh-DNZq`gO%+W(nFq>0s`j+*ASAL#pJ zN(CJHE5A|g{I;bJ)m-&w=Jsx!{B7CYTWjZwFyXQJnOIHlTM1qF&B2;$lV9e z#{*ZmJteq%Yz6IXMGSqBhb)1&da}fv)A9{IDSJ#Rf9p9=v#eI$_<6Z0V+_0 zYO^#Kz7aO-gOMRP-W{B03jFG)0}0-~M*q2RY_j;O^i1_lxx}F^nz^Tj;`AYIK?=C_ zS51A*N(r8p=3A_dLD5@Uo;2!N2CeO*SAal~UNOab9(BtLlJ%n~RrE+=WcAdZU~wq77*Co-4hmNps}3m!5e$FJcIb?i|Gc zoEX9vVXt=PIt(23vnIX5djZP}!wqe>XfRZyrM_TUQ!(jeR>@36cl0vhPt+dHyT3fo z9GcHsgd(Sm@q=AHJzEqJbz7@Z0O`Z5cm2M~8hzgYl8%N~p(fk{XV#u#;!IN(P)hb# zmO1EEYF|7`e+{83Bnn$}SmrTz=<(aL-IeB{Qc6&$vNk5)|N3V^tV1bUWo{I>xh zIMx6rg807$hpCyZnX8$i!$}hfQ)7QvDuL z07r_$G5flDwZ|B*WjKyw6qMOARcLE!-;t#FNegPJVdMztLyDjI{*dCmU3vY(p>h6J z$R*kov0ac|a?a{zah(bf1bKNP90dkS14<=Wcu^BvdVC##8plQ=Mo2(o7nr_4mA5R6 zBKg^~hDx>H8cNCpv$5dzt1vq&Dg?27_5;)JLmhX!pM?0iKG}l>Y6FLFFjzsyMh={c zqSpc0?WwkYEnu~H1{*OMiSAax8U&lC@$BYBUEcycV_#c0riHLGOUZ$XBDc4A`)r9; zHm1WtJrB9$-wZY{y;(Dlrt^uwS(>^uexsDV%7vSnC>?4?akiZfhs)ujynh&TuK$A1 zPPW6Vww$fMT8pXb`^wcea7GxRZOa_A!#G1_TE_;=x)q$%&>LT%j{YWjG3LS?xcYyBK7j1yE9J1+pD{bq8iaO%KgY3ZCODxXk zt@MPqR1ti*hgLTyimQFe&UwqHUrZr(8vHldXfOF?juDK0O1mD#9J9Y?Tet6D!2e07 z9e_@YFS<~w06IGWbdvlxIsx?;0L{OfSvwUug$+TpZi$HiPfflxl$K%`22mw&R-}?! zVnG0&YiqMNt=W1_T@-S~FD&*i4g6O)JZdCb{GL16nYq}2hN^8ig%P;|9qJTs4*|a) zkCgPV9J7c|@#FX{NpwJ_fBdXWDSdmLv|#NrUNEQp`j-Ao!5p;#5EhwCVg2zXXYxWrX4G<#SjOjqdC~gQUqH%$PDo=o zuHP7Rv7T*RIVKg$ETHNtZ`kKr7dETsz!7rf??uGXE$1>0aSx^=UEkG&YJqy#>zCsb zAB?Bgu{w#MZ%Tzmgosd*72Ufljd*K5^;~f*rQ@WV%HtbbhrQ*{0-hbS)Le8sZApju z>AWVj?J|l>(slxgELLLL4gzo+q)@zMl%7i+3$BFyizI z%cS>zyZA}&HNAIi>dRxF61QtJ2SwIqgBHoq_`R6CUEIz?T*tP*U4fx&Q+}hEq9+ms zYK(jUaY==tNqQzwEgWpR5MilUgwIDe^X0XsfMC8N{J^TVVw~xCMa~1L%r!a|qw@lk zOTvsLzNSFF_!qyc!^GCs%F!jTZ_uVYo#KowFe%M^!L+#tH>A$VrmjI?3GeAn#W+vg68#7Z#fFY2k%ESXNING_;2b@uk^25Xz6(Y|721^ z2UTlMt9Kq3z$DE7QcQpip|>(|u>Y{Ie#&w-fO%OD?h9cVx74m=8EZNg;lh%X3Jwoz zS-Nsk3u|Mm-o?ao;u8FCi;kmsH+S+$gwSB5bKmY?=G&&&thTWfCh)TWA~&}Qcl@6+ z*rIUXdGngywN)%Rs z16p$*^ZGaF4DhrmXxJ%RGlbIQjw5N|VN+toQ5+7^IZG5zJOrR_64=;?>`Q=H>e&7& zCsf3s#{^>RHz{RXmqx#~=MMW}+#18JON4ONe6L#3FvX1;fJI2j+LLrcTCgIWFUabF zQx0DX0;jCY)Ygd1OO6_Ux766e%z^MT&2_s4j-#orsfnDGnz0t05Lf}%yo%l9&CW^8 z#L05~SNibL=GXKM2prhx-?h__WoV}cb!Q=FeIlUCbJ3Mt=vU4{M_VPSQfIfyK-0h-|ao)pbdxtm~ET)d|+ld(Xz84iNN0TmM z5rSIqU#gTB$%Uuw%C|u?C|KRKElUN)2s<(EnlPJJGs68w_jWpgBiwrl<9T>^VrD*# zWlqz64jCTr{}E0hEy5Z%(@BYYB=`)&(`Zat3T{+AKlO`}PvCWixqJx4j)G<)Ct+ZQkl~oap-DP< z8ZOGX+GS6YHru~VDSjoD9U<)pg|-Y;tiFhVT$BBBT*>qbPgi1Zu>e?EMv}I)t9Fld z83T9 zYXoz)O6WmV_?t_X?z~=CGC+$PHy1zQ$}=o+>QShyI2S_i+FdvrB0A~8_%6fBBR)9P}fPNOo)Ho=I z2(Og1p35VqEw^_i3Dp+oYe(3yPb$7(KWm2Tq6ZYz&#xh5rOG#3Z9s44Jyp#?E@u59 zMoyT5?1iO$X7JrVf{1ErXcM+ma-KBSkcMF_i=vk2Z{JI4{BX=Pb@myMUsM1yLTVishU-S!kaHv?-jNlBGN;GGXHD-WZYA- z)u|mP?!>B{!waZ5n(_GHu^n<0`h^!)A3-V>*$%hQN!5iyftELtAM2-rOdnhB7EZ3Q z%!mlTvh?VvdBx0FCJL0Kbsypqs`1_-S_VtX0GDb5^bZ}7)e>a0yE5SIWof>SwH<1* zSa!R4&pj1XBoQFm_LNleAVa5$G{AJ~s}sa}S+`B5v2I@Rr--4AJ#`ypTtzJ3pZER& z?_s56?2^t^IERfBVKLg8+x!KEvld9tq*5}*A`_)=4tRb8*s&C{3A1~L+uRiGHzsn- z)=8h*eIy4_4YS6rI(a7YT3DU082BY7TxrsxE)I^JV<N9Tlx8K|-NMTC=pOmFysOPF7IM|!7Tq_aYdky+LFJO_ zraPlk=QFlRVA8Fk$@NK;A4q@2-rAaXlIo5BaCnHI zbCx84CgmRvZ=oOG;V3lG;yLCC*(^Mi>b=O_6^IuS5);!>gC->8zy!)1Q{%3nA7Z~D zH7$;TJ?+~>Xz`wrD83@I@82xi3@!X6f$zPbByO-8EN&kK4o`vHw1$lzNS+cdB-vz1 zR(frxP!GF7`sKwS7`tk0a;xGu@6AfS>(RVaju(mT^L@A(ioQr(w^~>6ThGq*y30c0 z9*Wzpti45BXXg9?cKAJcHLQWnS2(}Z9Zqjo{1 z_ag@YaU6hQB>V4&J`y_salrYHtPWTW$^KXkNqa$1Sprq1)>QM2JQB%Ti(D#;#i>fC zl3rozW1nQ$*4yt)+bN4r%r>YVyd727fhGoP+Tpl+4yOuEGP5L6za3-lpE{U)yty?| zrRiNuNfb}p>>Rz0z((*?qOl_u@u^A)RILK(W{P>L0#q{PYZpV{s}vcAae>#6dF zqR>mNX||05R5LdU5(h+NHt#28iT+)DkLSD5jl0cEUe==Saw5}ARWLup%Wf{s^DQu8 zJt6NL3>+-Q?Kw(0tfZ~dI(3VR7kissYwcdIV^h|$ZXlE;KQlZj(3jhgBPGaGC(?Jw z(qsZx!3ELo2Ev}M|9)dz4NW1Eb(JQrE*YG{r=b3oYDE(D; z!{T`ImP+9)5moz_WxkL7kZA5^7I*-70RTVwAGOul%E8&n)l0;|-rUOK4==f8{V}^l zJjCbsH48B*-EdBxi*B|unzJ>cJ~xgb*~qtRX*`s4UZ_3<3@>{oqvZrn#(oGwz54EO zNgRJh`e7NHH5Z30!nKUJF+R8-6}9}Wm;eC^n4%Bk1e$fkRYjO#Bop8L z2`h`zR4Q!PMhUC&2{ZWg65H9dsBp6&D2aG;5syp4(e`b3$>qgPQ7{rFZERA1$sKcN z4}(iLhM$~hOO4lkQUXjUx@-soL!%hnS{=5or35Dff%k6tc!_b_>E(3!rp2>T%RW40 zFR&$76~da8mYPddx)sR`8@iYy#%AI2XL#3{B}AIVwCMD_~)&tg0z^YSoU(!NR$Hla4@&l15=32$#2VGC42tcG1=mMR2-6;uoMG z?dx83RR=c3^6Cubevb0PsMEA&A~0@2HjBk}J)xFs^h}Eu%C4ITa6>jarOKHv( zyAKNK6{3YbQovs`A>&?irh+BwE_i5h22ZK0dwid3k!Ex=a#_w( zWXjv-GTE2zx!;%wC?7bak@Fve=?%QWr7u~}6;mx5jAJ`kAa{Yl*~CCU(U7a%nkS<& za+$xe#@RPCc(psM5AbUEx!unA7f^-Gar;nO-)bz$lxGfLD+590NjO5iM(p*){ez`{ zS3a!&AYv}Af6UYWB7HUh>9bnh?j&v5yeO@5R%ZmJ(R zqV)oBl%Hm>9Xn@Q$qt9>q_Bgu<49}FR@NTok8BxBq8*=ZOyKxdd|u1gO3Kx$(i+r1 z#?5{FoSY1nlte#IR(%+07MvMzd=N1{I;3gdku;8SQGwLtZDy|-MDb?-#HXJkty6Hp zC=IP?`H}IZo>kLelhJVR$aKX%2I&fKXcDmrg`wE#GC}I&ZM7vkXTPo^9J2Rh6}X68$(e%q*1kA_;;8+tJD`%#nPCfiSR9`R#t>h^yP z0kmHjg4Dv7s0tQ=bT3YHHDFO9p_Q>b-PwYq&HG&BWRAORkCWFthEm{|f6;$N(0EZT z+z#!x^=9Mi`dI@(Q~{b3@ahXMT*@zth|Pb87Gk+nP~LOxXA9a`h8;Q6-Otb3h+x!K<|2*1QrtjFdkU@3a!)=g?0Hi*7-w z9!|=s!F3s8iU>a^>$t3wlSF*wXOg_AY8o;)z<3Wd2IiNzp9`TspPLp1$?XhGbM9aMQPlr?;K2Sh1lax(D<5h-brD{h52*g50P*tY`x}2O0kSa~0lWbq9?TMV zKH_2I3f?~=q|R3IocYJ}fc8LEbx4YvT$_*tHRXd-wOSgAl>PVAUOB>I53dFSv1uqY zSK^uctLGCHr9PN+Q&`=|fkIKAUyiy3#8dBUoHQ^QiR9pj+Wo!on6EF-ww~c}OCZa9 za0-16eQXSp(jdyU-}q%9Ee;4duEVAtzA51iCt7N(b804aEolqexxz~2Vfu1Yme8+n z*Op$9lNw&-o3fYC1V+@f{!vxsN-Sw%bKEW8b7u{S_VRE1zW6gz$ETAI8LsD=J32=#rDi})0_}<%Z^3B z`c8}zU$8ksd0oe{k$%fBTOVML-#Jr87#GLm4nYLrynYCEn&eZ!d;cMh}KXd!|^~faSHx#6_5D{2<-y*I&-i_B^TGwuX zt-YIDHW*sKRjL47AO64I`=3*81JggYj{rBDsxoa2Xc6|}-Xo~wlGT&9k?{?MqUe5s zcC*??^M)$4JxpxAu-4et8~)Vqu*h)|?bb{?DeVBhH#jr(i{pSbtl1nqD`lCt1+agS z1(W(|GWDflgfh?Qb`gwJe_2|GYHpi~oM^Q&m`O_coeiLF>O4)zc3e3^SpzME9S4m_ zmZ>?-rG{uRzKl^oo$AzV5L$Q(B~SOijtyhp|)I$cj&`k_YB+IC5}|{ZK?I z3!3FRpN=85l+HgJuneG{(oe8Wq~QkAT-1v~3fSaVZ+j^^9<)u4+lAbVPbsoY(=?aI zI$U>~rdSSk4Lg5&hw$xr;Vd)AU&SJm>pMCE%AOv)yZ`%R3N$vm*# zI$1c%l@(+&#ogQ>J~qlKz7qGr%mnSGSL8RwT`pIoK2{L*mJ6tIl%5moNI|VNW_~&d z%Q1HC)~3jYDRv6(%)BAjT(Wm?MVr!DqL&z567b^p7Ya!51^oF_k+o61x#yq)^epZ9 zq_)kp89RwfTnO2#vc%8ON2Z5tKc1`U%e@YUb`$@|^&^u#90Dgj z4~HA!;wL(g^Sg!(r3;&vd)6`0i>r?oz+vQL4xy$;O zzabejb_{Lh&%?>qmAk>&mA*i~Bmgs^vYXv&t5&g$Sa(%%_HV!Cy+dwtlXrK<vXrD8TS?>$p zcmflI$)67|&`-DBZYCj%n}Zu3l{#*w`ZFzfaNWE%snTX$)knIc9vA9)Y~MZoYuh;e zgGU}*eBGV`Tud9P@(b!hcnyx<$2A^q=ilUZE*9PPex^GW!8tuR6?=n@mmfS41lle5f*`Gm6 zU?a&;%fw`eGDo2V#X((Zl?W2IFk_od$1A5beY6OI#6HYgeih5I$AfCf-}qY=;bJ4H z_5c}Tl_(swYe+s(SQTmuW5`!lSwxb0eLezO9I1d=SCWCnu?)!x@4%h(9ZRD4_4YC|bO%RB*I_x``0*A{6`oiV(nV{(p)P6(w1Ku7|1a zIBc*Z`6DL0@0C$vUzhN*G9u)Vl;^UB1eCa~z|)4OG|a$2MyX2D*ee|d?BH8bHzpf} z1E273`+0O8cz7Xr(M!8_l$%|Kp z2H77m2i#t?nAaAk=ljbwk!#^x83tj5;XM5A@eOicmh_z>%X~XM8Gd)_G4ut78*)=~ zP-DStiKOu~0dBKEV_;50#3qo%B+WfyS)jp)iDYeA+c*P@VuC~UcVlJ=J!{>k%R^Ve z+)v!E(3Uj~q>>o1;4mRx1wsRbh80jfl+|*xWFCR1N^oJWbZR|-fUTV+x5n+_sxDY`v`_IY(o+q z%gKf-3yE;Di|f-{0xt!EFKZw<=w^%N3}>UnnOezp5xa5(2KrAKdekV`o_sk36B^ez zQ#TFm#U(tARANe>tNhrGdC1)Ww(!UwuQm2ao1h5Lp8R-td6UC4*^pv|MxOIgP656- z{&~(E@1ZW7LD9p9u>-RQLBe`Z5w0GQ5H;_BmtgP?rd}`T^j%l1m$cWnABcV72cLbQ ztPSx~>!<;%@H8oHto zIFP!lbAK#m=1$%fTuk3-@!;oqW;pW{Z1I1GjJ-DaXZU?2s2Xwa>64$ zzrQ4?Kf=&N)XK%x*~-Kf5PcV!TlO2`7^7FP_xK3DMw6DJiD*(%2;Hze%BKB|q>@pK z)5c0MnyHEa7NIrf!!=5gE?_*;434H z;gOO0hC@J`^ZjrE;+L@@IIHH<9=w*FG8|B8Wr`~EDx}VE|CPVHF{9kqg zT0T9cY?Y_I@v=%XzrWQHCJ?S}y=J4u(>vrtjDEZJ&R?4~?tXBLd5f9Hm0u`t-?PMU zDb&t$pW#M4uD2ztstG?}y;{w4B(tIYLROA3LTpo-S+35}Z;+)Fn*u%Cz>2z438fvr zQQxxvb$ma~D68zu>fkZ6xYg^cqw5#ZLWtGwTkzKcJPwVpcU_J21pB+CuR{7D9Vcia z{N&JbWn<(U@1KR+S1X4h>RN`@UEd5eC0+o%gzDPDY8sou zY7W@$Y|p|k+Al>~-4LSEwHgh!_Sh5g|0C&VK zzfAmSjXI$TMvmP(Wz@$u(#q9obMB^W58&TK>7@7j8o;`>GI;bR`fGBYPlSM6Xo}Lz zmJO8rr19dV-}RfjdU*}yQoM+rAM@$uF!X%|Qd^3U*(P=@VsvJbBCygh&&DvI))s4I@!SxKA+D?8?|_YChC3K!Uwdjea--9VokV4s~igByIgHC91NXQj$0Cg4vdHLqPk zihXy`jYpENFhnpD+}o0CU2AvAq7o=`CdeVbI7Bd=-y?bm3UsuuH4fNKF667T{Xm>n z(|2cVYtU#7*8!{vk9k1!MhF)<$_0|X1k&D|rJ&C??zAzwr%3Ss_9Oyek z-%4KcT=M6&2UuOMzlyuF#xpQNI6ARWVFVwil6`*?+%X+QJ0)Y1XO>)SKxy8eR#J|4w$@Ax+2U{3 zD|gz8tGn(83Y#R}j89tnfR#Fo&7^Y$cRE#|pM$*K9vY35ciwO%B#f%te6WdI`)KRT zV@eaj)|Aqf$DxUily@4h>A91qma7DquX3kmLd z4xEl}T`^B@mjaNAs2bBOdK%ScI)6-mrk`$ez7od~U$i-ayhu0Cb@Go~`C+VU{FKOS0Y3v-Ot#DZ1nxE`i4 zewq9}eb!&Vf|swFTccfWqqN$5O_4im7I$M9Jx*(6R-p>*MxU-vUAS$Ff&Y@WH5Z?M z0r}PJg8LEE;H{89ZD;vi8=iY-_J}T!iD(@E&M1l5035dX8SaP3uU>m710x7cbr2f2F}7X9DRM^ zAk(~no}cS$6>I6NbIM#C%M}#F9QQ`eeTkSgnMG;VNsj2M7y{hB!rjrMvk=kPrR-6V z$Q^zL#`zU1Mt6KXRM1L+c{-z|V?eDs*JH^|+gdnz@<(j_}X?DVdC-b#*GV6Y()`0u*@vKl#(m zVurP>&~JwTpU&1 z=>QMfOUdzPt;}2LGO`cx)|E-=%=5TIT)EkJ0VxZf3rQz&m6|8Jf>TfaVvvi+X>1ttKuEliJ5-)baesS*6Y1p@riNdB-?Ja6PzV&eM&=vwXNyxr?6{ zKeyYV60e}e`*)^Ume3X!9F3ywP9H1j3qcv#^tFbOZ#L0gpC;SCsjMlj$va-SdhWgoa zFVefu{)9Sbn&*jXIeIBvq8X*$i!)cc-KDeQ)|sCutvPSlh(?y3%QQ(pYMz*k-sge% zz`Q~XH@ET5NG`>e(o8PvzFF`VB(Y*;J=rCiSa$oZJX$zatZZ=Uku!!TD_D~|X4f5Q zGv&+|);0*8152~_ANL@MNU!Hptrcu@QstA6&6b2%2GzyidC{sh9jLTS{oFYF;>ZEc zxVUTAhfWN*)A!}ySoDy0Fb#}Okv&2GwTVp^d3Z^s-D&jqEJj)%qky^Np{nGBtGV&v zhZ>~F9fj^J0=wK&6fdu)`#bz`U8TfR?DQ^ujw+sM4BMxqyo_-NcK@Fw!(^5G>aUJR z9J-Rkv;PDsTu5L3h3}k}1_7z19Y%OyAk4tGtbE$UrIIV((s5$HUgBWN{NxPl7a!l? zsh-bzDXvm%;$b0)^rcAiQ^Fn!%?S39rYYobGQ;#i69Sz|Z4ABATU45-KrL%y#AvyF zfCw8=t#aNFv&Y9s)v;3UUIF(&Qnu*9-*5l5yM2_!aCz+RaEQn|1+N=;9jx-`8zjMi zfrd`6L-7u2+UA@?KSR?M-@S7~?=3PtV!BRZ6Y|FCC6(??R>gW%*eEcaXQpf9$+Tv2 zjSMbwdiRCr%aXTC&wt)3^t)-OS`ecK!$^l2u1ySl`lv{HdXTNEj0RCc7kqem;GIQ^ zYAk-K@0IQ-QYXOm-N0+)wLJ6V?gnLfEm9d~Uk1OlhN=FgP~L1nXK8P$&Tudmz*$XYC_E|>UMK~{eRcfF#gi8HH-Wlw13`$$F`TsOZ-onYpe zM$Rof@)E${WZXfFoJ^5?(Q;G1aU|`2E2mAs$l#SOt1OPnNquz`(y&$)p{}q zVwKLUo<6-cZ0I8JR-tA3jaz@tGxID3#&Yn6+%3S}}P z>idpgdH&qh{xXe?Khqto$lYx zt6vg82+N3I9O)@JB9_Jy(quV0v7U%RBEX%2f@0?}Nnm9Y2hPaF|7~XwK=8r4Q}zYm zDQj8}xSrkru=@)W4evqvY0^!>3&IatqWt#K%oj$n(vlpRV=y)8$>?A66AVylpG;Rc z)T*TibDf`ccHxTdBF7jzdDrB*5c4d^;rk z=`D75F9rElUFJulzgF)w{#(M#LN$E2Ku9o(uNfI;^;*0uTw|B3X!!u^2kBpkL3U2| zs?}LFfipg_MplXyk4pO0ed&n7E;5sMX6-T;OUB*m4bF#Faa&pHtCSbkyqZzX$1MK( zs3hL4Vx>l5yn)k}$)(!nZ+tOI>{c}PRGQ=KyqYpbwo=6#ZG6b=S8*!*-fsHCrKDfxXW0b%oQd;0rC7lN-od~eHKW0(>C#39FL;TLvX zAis5FRZH>3!sY^wf`{0tx5wrp#>;lno(a`km=1DWqtl5CdED#NEo6}6v!kfxW=TTaa3NDNXYS6@hHinj z61j@RL*4tUMdXuDnj)%SZrFI-gyu2N-v`NTx{jRnhWQD{O5<;6u4dn zqp@7k9C_vks`17WPwx89pIXfCbyHDY-CyQeme6JW=J-zvX1l9Dhr6HbMVt*eA`w97 zG^{2j1f4gSsXkL@kr6t3sA}M--?Q!lXZCLEqc}wZ`dPDFY64N1fJU#R>+1=>l&Tks zt~tzzw_VwHLvx zj9IGRuOJo1pnAr4QkUu;+Rw?I&3pKODCIP3qx0LJF=>k&D<7e&J81X9#qqY+oHAny z_U&h`zAX(pUtyNuQvJlO_5O$VGIBl+yL0W5=oTyj7Mp4GbI%7R{~pPbCfrIMqSs!0 z*u)114;w? zZp^Y3{-3Pkx}*U#0&t=RAQ)u?i2n|@QQ`oK6TT1~g2n(EVw>;qrZ_kLq$*3_>}7K) zG314W`aivZtKV0rIZE^HX4|Bn>*n}DKmwJ7_QJ1grE$u^^YJnmYqT|!58O2 zfB`@MASUWkJ!&|(YAOhh9hhFQUEEMxMU4kn2?ODk0mrtmc)+-=*Tqo7!IeKiaJz(l z00;g*fBQ~$-*{8uIr9*tAV8sqjc^Nto;pl8#xjJt42UpogK7M&eiDM)I`2SADW!q) zt_XO&g@L0GOremu(jz@MQVkzzBzd4EcJ8LDmiw6dZ2{ zw4?+@gV|vCoy9|K4@VS%?4JN9H&l-QSt%jf2n4ltls7&sl>mVdDyWS~eh7xL#oEjc zfFknT4hDEo!ev4?thMmTRmefS>Nar#4^TJkV55|8tx diff --git a/pages/api/talas_v5_DB/gisLines/readGisLines.js b/pages/api/talas_v5_DB/gisLines/readGisLines.js index ce7ec97dd..5bb3ce7f7 100644 --- a/pages/api/talas_v5_DB/gisLines/readGisLines.js +++ b/pages/api/talas_v5_DB/gisLines/readGisLines.js @@ -1,7 +1,9 @@ +// /pages/api/talas_v5_DB/gisLines/readGisLines.js import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren export default async function handler(req, res) { const pool = getPool(); // Singleton-Pool verwenden + let connection; if (req.method !== "GET") { return res.status(405).json({ error: "Nur GET Methode erlaubt" }); @@ -10,8 +12,10 @@ export default async function handler(req, res) { const query = "SELECT * FROM talas_v5.gis_lines;"; try { - // Abrufen der Datenbankergebnisse - const [results] = await pool.query(query); + // Verbindung aus dem Pool holen + connection = await pool.getConnection(); + // Abfrage ausführen + const [results] = await connection.query(query); if (results.length > 0) { res.status(200).json(results); } else { @@ -20,5 +24,7 @@ export default async function handler(req, res) { } catch (error) { console.error("Fehler beim Abrufen der gis_lines:", error); res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" }); + } finally { + if (connection) connection.release(); // Verbindung freigeben } } From 2623da410e8afa0ed89a763facec955941f1021a Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 09:59:49 +0200 Subject: [PATCH 02/47] Version 1.0.1.2 connection.release() in folder talas_v5_DB in all files --- .../talas_v5_DB/gisLines/updateLineCoordinates.js | 1 + pages/api/talas_v5_DB/pois/addLocation.js | 2 +- pages/api/talas_v5_DB/priorityConfig.js | 13 ++++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js b/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js index 4be22f7e4..df5c425e8 100644 --- a/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js +++ b/pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js @@ -1,3 +1,4 @@ +// /pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren export default async function handler(req, res) { diff --git a/pages/api/talas_v5_DB/pois/addLocation.js b/pages/api/talas_v5_DB/pois/addLocation.js index 98494b342..7c66f7760 100644 --- a/pages/api/talas_v5_DB/pois/addLocation.js +++ b/pages/api/talas_v5_DB/pois/addLocation.js @@ -1,4 +1,4 @@ -// pages/api/addLocation.js +// pages/api/talas_v5_DB/pois/addLocation.js import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren export default async function handler(req, res) { diff --git a/pages/api/talas_v5_DB/priorityConfig.js b/pages/api/talas_v5_DB/priorityConfig.js index a2a24d1c6..beefcd091 100644 --- a/pages/api/talas_v5_DB/priorityConfig.js +++ b/pages/api/talas_v5_DB/priorityConfig.js @@ -6,16 +6,23 @@ import getPool from "../../../utils/mysqlPool"; // Singleton-Pool importieren export default async function handler(req, res) { const pool = getPool(); // Singleton-Pool verwenden + let connection; try { + // Verbindung abrufen + connection = await pool.getConnection(); + // Ausführen der Datenbankabfrage const query = "SELECT idprio, level, name, color FROM prio"; - const [results] = await pool.query(query); + const [results] = await connection.query(query); - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); // Nur rows werden zurückgegeben + // Senden Sie die Antwort zurück + res.status(200).json(results); } catch (error) { console.error("Fehler beim Abrufen der API", error); res.status(500).json({ error: "Fehler bei der Abfrage" }); + } finally { + // Verbindung freigeben + if (connection) connection.release(); } } From 7e100ff81b8c9830a9122fcd95fe4cabdaa86495 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 10:42:36 +0200 Subject: [PATCH 03/47] =?UTF-8?q?Version=201.0.1.3=20API=20aufruf=20statt?= =?UTF-8?q?=20direkte=20Anfrgen=20an=20die=20MySQL=20Datenbank=20und=20Web?= =?UTF-8?q?ServiceMap=20Mock=20Dateien=20und=20direkte=20MySQL=20Anfagen?= =?UTF-8?q?=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webserviceMap/GisStationsMeasurements.js | 116 -------- .../GisStationsStaticDistrict.js | 281 ------------------ .../GisStationsStatusDistrict.js | 81 ----- .../talas5/webserviceMap/GisSystemStatic.js | 273 ----------------- .../gisStationsMeasurementsSQL.js | 56 ---- services/apiService.js | 3 +- 6 files changed, 2 insertions(+), 808 deletions(-) delete mode 100644 pages/api/talas5/webserviceMap/GisStationsMeasurements.js delete mode 100644 pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js delete mode 100644 pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js delete mode 100644 pages/api/talas5/webserviceMap/GisSystemStatic.js delete mode 100644 pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js diff --git a/pages/api/talas5/webserviceMap/GisStationsMeasurements.js b/pages/api/talas5/webserviceMap/GisStationsMeasurements.js deleted file mode 100644 index 5aba69fc6..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsMeasurements.js +++ /dev/null @@ -1,116 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsMeasurements.js -const GisStationsMeasurements = { - "Name": "Liste aller Messungen der Geraete", - "Zeitstempel": "2024-05-31T15:25:32.5047629+02:00", - "IdMap": "10", - "Statis": [ - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 3, - "Na": "FBT", - "Val": "20.5", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 10, - "Na": "GT", - "Val": "nicht ermittelbar", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 2, - "Na": "LT", - "Val": "Datenlücke", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 6, - "Na": "RLF", - "Val": "100.0", - "Unit": "%", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 11, - "Na": "TPT", - "Val": "8.3", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 12, - "Na": "TT1", - "Val": "---", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 16, - "Na": "WFD", - "Val": "0.12", - "Unit": "mm", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 8, - "Na": "WGM", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 9, - "Na": "WGS", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10') { - // If the conditions are met, return the GisStationsMeasurements object with a 200 status code. - res.status(200).json(GisStationsMeasurements); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js b/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js deleted file mode 100644 index bf302f3d7..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js +++ /dev/null @@ -1,281 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js -const GisStationsStaticDistrict = { - "Name": "Liste aller Geraete einer bestimmten Karte", - "Zeitstempel": "2024-05-31T15:26:56.9235766+02:00", - "IdMap": "10", - "Points": [ - { - "LD_Name": "CPL Bentheim", - "IdLD": 50017, - "Device": "CPL V3.5 mit 16 Kü", - "Link": "cpl.aspx?ver=35&kue=16&id=50017", - "Location_Name": "Technikraum", - "Location_Short": "BEHE", - "IdLocation": 17448, - "Area_Name": "Bad-Bentheim", - "Area_Short": "BEHE--00", - "IdArea": 16418, - "X": 51.5728, - "Y": 9.00056, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Drucker", - "IdLD": 50084, - "Device": "Basisgerät", - "Link": "basis.aspx?ver=1&id=50084", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 14, - "System": 200, - "Active": 0 - }, - { - "LD_Name": "Türkontakt", - "IdLD": 50666, - "Device": "ECI", - "Link": "eci.aspx?ver=1&id=50666", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 17, - "System": 2, - "Active": 0 - }, - { - "LD_Name": "Triptis", - "IdLD": 50888, - "Device": "CPL 200", - "Link": "cpl.aspx?ver=30&kue=16&id=50888", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn I", - "IdLD": 50889, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50889", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn II", - "IdLD": 50900, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50900", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Hermsdorf", - "IdLD": 50901, - "Device": "CPL V3.5 mit 24 Kü", - "Link": "cpl.aspx?ver=35&kue=24&id=50901", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 1 - }, - { - "LD_Name": "GMA Littwin (TEST)", - "IdLD": 50004, - "Device": "Glättemeldeanlage", - "Link": "gma.aspx?ver=1&id=50004", - "Location_Name": "RG Relaisraum", - "Location_Short": "REZR", - "IdLocation": 18624, - "Area_Name": "Renzenhof (RG)", - "Area_Short": "REZHRG00", - "IdArea": 16570, - "X": 53.246036, - "Y": 8.163293, - "Icon": 1, - "System": 11, - "Active": 0 - }, - { - "LD_Name": "NRS Testserver", - "IdLD": 50005, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50005", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Gateway 2", - "IdLD": 50007, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50007", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Basisgerät mit SNMP MVP", - "IdLD": 50669, - "Device": "Basisgerät + SNMP", - "Link": "basisSNMP.aspx?&ver=1&id=50669", - "Location_Name": "Mylinghauserstraße Engelbert", - "Location_Short": "G-GEVELSBE-1", - "IdLocation": 24012, - "Area_Name": "Gevelsberg", - "Area_Short": "GMA-GEVELSBE", - "IdArea": 20919, - "X": 51.316799, - "Y": 7.33281, - "Icon": 14, - "System": 200, - "Active": 1 - }, - { - "LD_Name": "Server 3", - "IdLD": 50009, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50009", - "Location_Name": "Militärringstraße Militärringstraße", - "Location_Short": "G-KÖLN-1", - "IdLocation": 24015, - "Area_Name": "Köln", - "Area_Short": "GMA-KÖLN", - "IdArea": 20921, - "X": 50.898399, - "Y": 6.92278, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "ICL Test 5", - "IdLD": 50054, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50054", - "Location_Name": "Recheder Mühlenweg Dortmund-Ems-Kanal", - "Location_Short": "G-OLFEN-SE-1", - "IdLocation": 24022, - "Area_Name": "Olfen-Selm", - "Area_Short": "GMA-OLFEN-SE", - "IdArea": 20926, - "X": 51.702202, - "Y": 7.40822, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "ICL Test 3", - "IdLD": 50052, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50052", - "Location_Name": "Weidenstraße Hestenberg", - "Location_Short": "G-PLETTENB-1", - "IdLocation": 24024, - "Area_Name": "Plettenberg", - "Area_Short": "GMA-PLETTENB", - "IdArea": 20928, - "X": 51.224098, - "Y": 7.86969, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "Test Februar Kai", - "IdLD": 50912, - "Device": "Dauerzählstelle DZ", - "Link": "dauz.aspx?ver=1&id=50912", - "Location_Name": "In der Hoffnung Kiesberg - BG Ost", - "Location_Short": "G-WUPPERTA-4", - "IdLocation": 24039, - "Area_Name": "Wuppertal", - "Area_Short": "GMA-WUPPERTA", - "IdArea": 20937, - "X": 51.238899, - "Y": 7.12715, - "Icon": 14, - "System": 110, - "Active": 1 - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the GisStationsStaticDistrict object with a 200 status code. - res.status(200).json(GisStationsStaticDistrict); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js b/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js deleted file mode 100644 index 27b0b442b..000000000 --- a/pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js +++ /dev/null @@ -1,81 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsStatusDistrict.js -import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren - -export default async function handler(req, res) { - const pool = getPool(); // Singleton-Pool verwenden - let connection; // Verbindung deklarieren - - const { idMap, idUser } = req.query; - - if (!idMap || !idUser) { - return res.status(400).json({ error: "idMap and idUser are required" }); - } - - try { - // Verbindung aus dem Pool holen - connection = await pool.getConnection(); - - let onlySystem = -1; - let districtCounter = 0; - - // Get onlySystem - const [mapResult] = await connection.query("SELECT idsystem_typ FROM maps WHERE id = ?", [idMap]); - if (mapResult.length > 0) { - onlySystem = mapResult[0].idsystem_typ ?? -1; - } - - // Get districtCounter - if (idUser > 0) { - const [userLayerResult] = await connection.query("SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?", [idUser]); - districtCounter = userLayerResult[0].count; - } - - // Query erstellen - let query = ` - SELECT ld.idLD, dc.message, p.level, p.name, p.color, ld.idDevice, de.isService, dc.idIcon - FROM location as l - LEFT JOIN location_coordinates AS co ON l.idLocation = co.idLocation and co.idMaps = ? - LEFT JOIN location_device AS ld ON ld.idLocation = l.idLocation - LEFT JOIN datapoint as d ON d.idLD = ld.idLD - LEFT JOIN datapoint_conditions AS dc ON dc.idcondition = d.last_message_condition - LEFT JOIN prio AS p ON p.idPrio = dc.idprio - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN area as a on a.idArea = l.idArea - WHERE p.level < 100 AND co.X > 0 - `; - - const queryParams = [idMap]; - if (districtCounter > 0) { - query += ` AND a.iddistrict IN (SELECT iddistrict FROM user_user_layer1 WHERE iduser = ?)`; - queryParams.push(idUser); - } - if (onlySystem >= 0) { - query += ` AND de.idsystem_typ = ?`; - queryParams.push(onlySystem); - } - query += ` ORDER BY p.level desc`; - - const [results] = await connection.query(query, queryParams); - - const mpss = { - IdMap: idMap.toString(), - Statis: results.map((row) => ({ - IdLD: row.idLD ?? -1, - Le: row.level ?? -1, - Me: row.message ?? "?", - Na: row.name ?? "?", - Co: row.color ?? "#ffffff", - Feld: row.idDevice ?? -1, - Icon: row.idIcon ?? 0, - })), - }; - - res.status(200).json(mpss); - } catch (error) { - console.error("Fehler beim Laden der Daten:", error); - res.status(500).json({ error: "Interner Serverfehler" }); - } finally { - // Stelle sicher, dass die Verbindung zurück in den Pool gegeben wird - if (connection) connection.release(); - } -} diff --git a/pages/api/talas5/webserviceMap/GisSystemStatic.js b/pages/api/talas5/webserviceMap/GisSystemStatic.js deleted file mode 100644 index b2fb56635..000000000 --- a/pages/api/talas5/webserviceMap/GisSystemStatic.js +++ /dev/null @@ -1,273 +0,0 @@ -// /pages/api/webServiceMap.js -const gisSystemStatic = { - "Name": "Liste aller angezeigten Systeme", - "Zeitstempel": "2024-05-31T15:08:49.8599542+02:00", - "IdMap": "10", - "Systems": [ - { - "IdSystem": 1, - "Name": "TALAS", - "Longname": "Talas Meldestationen", - "Allow": 1, - "Icon": 1 - }, - { - "IdSystem": 2, - "Name": "ECI", - "Longname": "ECI Geräte", - "Allow": 1, - "Icon": 2 - }, - { - "IdSystem": 5, - "Name": "GSM Modem", - "Longname": "LR77 GSM Modems", - "Allow": 1, - "Icon": 5 - }, - { - "IdSystem": 6, - "Name": "Cisco Router", - "Longname": "Cisco Router", - "Allow": 1, - "Icon": 6 - }, - { - "IdSystem": 7, - "Name": "WAGO", - "Longname": "WAGO I/O Systeme", - "Allow": 1, - "Icon": 7 - }, - { - "IdSystem": 8, - "Name": "Siemens", - "Longname": "Siemens Notrufsystem", - "Allow": 0, - "Icon": 8 - }, - { - "IdSystem": 9, - "Name": "OTDR", - "Longname": "Glasfaserüberwachung OTU", - "Allow": 0, - "Icon": 9 - }, - { - "IdSystem": 10, - "Name": "WDM", - "Longname": " Wavelength Division Multiplexing", - "Allow": 0, - "Icon": 10 - }, - { - "IdSystem": 11, - "Name": "GMA", - "Longname": "Glättemeldeanlagen", - "Allow": 1, - "Icon": 11 - }, - { - "IdSystem": 13, - "Name": "Messstellen", - "Longname": "Messstellen", - "Allow": 0, - "Icon": 13 - }, - { - "IdSystem": 100, - "Name": "TALAS ICL", - "Longname": "Talas ICL Unterstationen", - "Allow": 1, - "Icon": 100 - }, - { - "IdSystem": 110, - "Name": "DAUZ", - "Longname": "Dauerzählstellen", - "Allow": 1, - "Icon": 110 - }, - { - "IdSystem": 111, - "Name": "SMS-Funkmodem", - "Longname": "SMS-Funkmodem", - "Allow": 0, - "Icon": 111 - }, - { - "IdSystem": 200, - "Name": "Sonstige", - "Longname": "Sonstige", - "Allow": 1, - "Icon": 200 - } - ], - "Rights": [ - { - "IdRight": 1 - }, - { - "IdRight": 2 - }, - { - "IdRight": 3 - }, - { - "IdRight": 5 - }, - { - "IdRight": 6 - }, - { - "IdRight": 7 - }, - { - "IdRight": 8 - }, - { - "IdRight": 10 - }, - { - "IdRight": 11 - }, - { - "IdRight": 12 - }, - { - "IdRight": 20 - }, - { - "IdRight": 22 - }, - { - "IdRight": 23 - }, - { - "IdRight": 25 - }, - { - "IdRight": 30 - }, - { - "IdRight": 40 - }, - { - "IdRight": 41 - }, - { - "IdRight": 42 - }, - { - "IdRight": 43 - }, - { - "IdRight": 44 - }, - { - "IdRight": 45 - }, - { - "IdRight": 46 - }, - { - "IdRight": 47 - }, - { - "IdRight": 48 - }, - { - "IdRight": 49 - }, - { - "IdRight": 50 - }, - { - "IdRight": 51 - }, - { - "IdRight": 52 - }, - { - "IdRight": 55 - }, - { - "IdRight": 56 - }, - { - "IdRight": 60 - }, - { - "IdRight": 61 - }, - { - "IdRight": 62 - }, - { - "IdRight": 63 - }, - { - "IdRight": 64 - }, - { - "IdRight": 65 - }, - { - "IdRight": 68 - }, - { - "IdRight": 69 - }, - { - "IdRight": 70 - }, - { - "IdRight": 71 - }, - { - "IdRight": 72 - }, - { - "IdRight": 73 - }, - { - "IdRight": 79 - }, - { - "IdRight": 80 - }, - { - "IdRight": 90 - }, - { - "IdRight": 93 - }, - { - "IdRight": 94 - }, - { - "IdRight": 95 - }, - { - "IdRight": 96 - } - ] -} - -// Export an async function handler for the API route. -export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the gisSystemStatic object with a 200 status code. - res.status(200).json(gisSystemStatic); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } -}; \ No newline at end of file diff --git a/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js b/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js deleted file mode 100644 index 7912816d4..000000000 --- a/pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js +++ /dev/null @@ -1,56 +0,0 @@ -// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js -import getPool from "../../../../utils/mysqlPool"; // Singleton-Pool importieren - -export default function handler(req, res) { - const pool = getPool(); // Singleton-Pool verwenden - - const idMap = req.query.idMap; - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const sqlQuery = ` - SELECT - ld.idLD, - dp.idDP, - dp.name AS Na, - dp.value AS Val, - dp.unit AS Unit, - mg.name AS Gr, - ld.idLocation, - area.Name AS Area_Name - FROM location_device as ld - LEFT JOIN location_coordinates AS co ON ld.idLocation = co.idLocation and co.idMaps = ? - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN datapoint AS dp ON ld.idLD = dp.idLD - LEFT JOIN message_group AS mg ON dp.idmessage_group = mg.idmessage_group - LEFT JOIN location AS loc ON ld.idLocation = loc.idLocation - LEFT JOIN area AS area ON loc.idArea = area.idArea - WHERE co.X > 0 AND dp.idmessage_group>0 AND length(dp.unit)> 0 AND length(dp.value)> 0 - `; - - pool.query(sqlQuery, [idMap], (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der gis_lines:", error); - return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" }); - } - - const response = { - Name: "Liste aller Messungen der Geraete", - Zeitstempel: new Date().toISOString(), - IdMap: idMap, - Statis: results.map((row) => ({ - IdLD: row.idLD, - IdDP: row.idDP, - Na: row.Na, - Val: row.Val, - Unit: row.Unit, - Gr: row.Gr, - IdLocation: row.idLocation, - Area_Name: row.Area_Name, - })), - }; - - res.json(response); - }); -} diff --git a/services/apiService.js b/services/apiService.js index 22fdc8841..a7370613c 100644 --- a/services/apiService.js +++ b/services/apiService.js @@ -3,8 +3,9 @@ import * as config from "../config/config"; import * as urls from "../config/urls"; export const fetchGisStatusStations = async (idMap, idUser) => { + const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; try { - const response = await fetch(`/api/talas5/webserviceMap/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`); + const response = await fetch(`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`); if (!response.ok) { throw new Error(`Error: ${response.statusText} MySQL Datenbankverbindung fehlgeschlagen! From 3d8ecb82874342c5cc7c6649ae8ec20c6c027ef4 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 11:14:03 +0200 Subject: [PATCH 04/47] Version 1.0.1.4 delete "api-Kopie" und "api back30" and delete link from device popup --- pages/api - Kopie/[...path].js | 20 -- pages/api - Kopie/get-talasIP.js | 20 -- pages/api - Kopie/gis-proxy.js | 34 --- pages/api - Kopie/linesColorApi.js | 64 ---- pages/api - Kopie/rights.js | 29 -- pages/api - Kopie/talas5/area.js | 40 --- pages/api - Kopie/talas5/location_device.js | 42 --- .../webserviceMap/GisStationsMeasurements.js | 116 -------- .../GisStationsStaticDistrict.js | 281 ------------------ .../GisStationsStatusDistrict.js | 84 ------ .../talas5/webserviceMap/GisSystemStatic.js | 273 ----------------- .../gisStationsMeasurementsSQL.js | 74 ----- .../talas_v5_DB/gisLines/readGisLines.js | 34 --- .../gisLines/updateLineCoordinates.js | 58 ---- .../talas_v5_DB/locationDevice/getDeviceId.js | 41 --- .../locationDevice/locationDeviceNameById.js | 40 --- .../locationDevice/locationDevices.js | 32 -- .../talas_v5_DB/poiTyp/readPoiTyp.js | 37 --- .../talas_v5_DB/pois/addLocation.js | 37 --- .../api - Kopie/talas_v5_DB/pois/deletePoi.js | 42 --- .../talas_v5_DB/pois/getPoiById.js | 43 --- .../api - Kopie/talas_v5_DB/pois/poi-icons.js | 36 --- .../talas_v5_DB/pois/readLocations.js | 32 -- .../talas_v5_DB/pois/updateLocation.js | 82 ----- .../api - Kopie/talas_v5_DB/pois/updatePoi.js | 45 --- .../api - Kopie/talas_v5_DB/priorityConfig.js | 31 -- .../station/getAllStationsNames.js | 43 --- pages/api back30/[...path].js | 20 -- pages/api back30/get-talasIP.js | 20 -- pages/api back30/gis-proxy.js | 34 --- pages/api back30/linesColorApi.js | 64 ---- pages/api back30/rights.js | 29 -- pages/api back30/talas5/area.js | 40 --- pages/api back30/talas5/location_device.js | 39 --- .../webserviceMap/GisStationsMeasurements.js | 116 -------- .../GisStationsStaticDistrict.js | 281 ------------------ .../GisStationsStatusDistrict.js | 100 ------- .../talas5/webserviceMap/GisSystemStatic.js | 273 ----------------- .../gisStationsMeasurementsSQL.js | 70 ----- .../talas_v5_DB/gisLines/readGisLines.js | 37 --- .../gisLines/updateLineCoordinates.js | 61 ---- .../talas_v5_DB/locationDevice/getDeviceId.js | 40 --- .../locationDevice/locationDeviceNameById.js | 46 --- .../locationDevice/locationDevices.js | 35 --- .../talas_v5_DB/poiTyp/readPoiTyp.js | 33 -- .../talas_v5_DB/pois/addLocation.js | 38 --- .../api back30/talas_v5_DB/pois/deletePoi.js | 45 --- .../api back30/talas_v5_DB/pois/getPoiById.js | 42 --- .../api back30/talas_v5_DB/pois/poi-icons.js | 42 --- .../talas_v5_DB/pois/readLocations.js | 42 --- .../talas_v5_DB/pois/updateLocation.js | 39 --- .../api back30/talas_v5_DB/pois/updatePoi.js | 46 --- .../api back30/talas_v5_DB/priorityConfig.js | 40 --- utils/createAndSetDevices.js | 12 +- 54 files changed, 11 insertions(+), 3383 deletions(-) delete mode 100644 pages/api - Kopie/[...path].js delete mode 100644 pages/api - Kopie/get-talasIP.js delete mode 100644 pages/api - Kopie/gis-proxy.js delete mode 100644 pages/api - Kopie/linesColorApi.js delete mode 100644 pages/api - Kopie/rights.js delete mode 100644 pages/api - Kopie/talas5/area.js delete mode 100644 pages/api - Kopie/talas5/location_device.js delete mode 100644 pages/api - Kopie/talas5/webserviceMap/GisStationsMeasurements.js delete mode 100644 pages/api - Kopie/talas5/webserviceMap/GisStationsStaticDistrict.js delete mode 100644 pages/api - Kopie/talas5/webserviceMap/GisStationsStatusDistrict.js delete mode 100644 pages/api - Kopie/talas5/webserviceMap/GisSystemStatic.js delete mode 100644 pages/api - Kopie/talas5/webserviceMap/gisStationsMeasurementsSQL.js delete mode 100644 pages/api - Kopie/talas_v5_DB/gisLines/readGisLines.js delete mode 100644 pages/api - Kopie/talas_v5_DB/gisLines/updateLineCoordinates.js delete mode 100644 pages/api - Kopie/talas_v5_DB/locationDevice/getDeviceId.js delete mode 100644 pages/api - Kopie/talas_v5_DB/locationDevice/locationDeviceNameById.js delete mode 100644 pages/api - Kopie/talas_v5_DB/locationDevice/locationDevices.js delete mode 100644 pages/api - Kopie/talas_v5_DB/poiTyp/readPoiTyp.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/addLocation.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/deletePoi.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/getPoiById.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/poi-icons.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/readLocations.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/updateLocation.js delete mode 100644 pages/api - Kopie/talas_v5_DB/pois/updatePoi.js delete mode 100644 pages/api - Kopie/talas_v5_DB/priorityConfig.js delete mode 100644 pages/api - Kopie/talas_v5_DB/station/getAllStationsNames.js delete mode 100644 pages/api back30/[...path].js delete mode 100644 pages/api back30/get-talasIP.js delete mode 100644 pages/api back30/gis-proxy.js delete mode 100644 pages/api back30/linesColorApi.js delete mode 100644 pages/api back30/rights.js delete mode 100644 pages/api back30/talas5/area.js delete mode 100644 pages/api back30/talas5/location_device.js delete mode 100644 pages/api back30/talas5/webserviceMap/GisStationsMeasurements.js delete mode 100644 pages/api back30/talas5/webserviceMap/GisStationsStaticDistrict.js delete mode 100644 pages/api back30/talas5/webserviceMap/GisStationsStatusDistrict.js delete mode 100644 pages/api back30/talas5/webserviceMap/GisSystemStatic.js delete mode 100644 pages/api back30/talas5/webserviceMap/gisStationsMeasurementsSQL.js delete mode 100644 pages/api back30/talas_v5_DB/gisLines/readGisLines.js delete mode 100644 pages/api back30/talas_v5_DB/gisLines/updateLineCoordinates.js delete mode 100644 pages/api back30/talas_v5_DB/locationDevice/getDeviceId.js delete mode 100644 pages/api back30/talas_v5_DB/locationDevice/locationDeviceNameById.js delete mode 100644 pages/api back30/talas_v5_DB/locationDevice/locationDevices.js delete mode 100644 pages/api back30/talas_v5_DB/poiTyp/readPoiTyp.js delete mode 100644 pages/api back30/talas_v5_DB/pois/addLocation.js delete mode 100644 pages/api back30/talas_v5_DB/pois/deletePoi.js delete mode 100644 pages/api back30/talas_v5_DB/pois/getPoiById.js delete mode 100644 pages/api back30/talas_v5_DB/pois/poi-icons.js delete mode 100644 pages/api back30/talas_v5_DB/pois/readLocations.js delete mode 100644 pages/api back30/talas_v5_DB/pois/updateLocation.js delete mode 100644 pages/api back30/talas_v5_DB/pois/updatePoi.js delete mode 100644 pages/api back30/talas_v5_DB/priorityConfig.js diff --git a/pages/api - Kopie/[...path].js b/pages/api - Kopie/[...path].js deleted file mode 100644 index b270661b1..000000000 --- a/pages/api - Kopie/[...path].js +++ /dev/null @@ -1,20 +0,0 @@ -// pages/api/[...path].js -import { createProxyMiddleware } from "http-proxy-middleware"; -//import { SERVER_URL } from "../config/urls.js"; -//console.log("SERVER_URL:", SERVER_URL); // Debug-Ausgabe - -export default createProxyMiddleware({ - //target: "http://192.168.10.58:3001", - // Stationen bekommen - //target: "http://10.10.0.13", // Ziel-URL des Proxys // API Aufruf zum mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl und mapDataIconUrl - target: `${process.env.NEXT_PUBLIC_SERVER_URL}`, // - //target: urls.PROXY_TARGET, - //target: "http://localhost:3000", // Ziel-URL des Proxys - //target: "http://192.168.10.187:3000", // Ziel-URL des Proxys - //target: "http://192.168.10.14", - changeOrigin: true, - pathRewrite: { - "^/api": "/", // Optional: Entfernt /api aus dem Pfad, wenn das Backend dies nicht erfordert - }, - logLevel: "debug", // Setzt das Logging-Level auf "debug" für detaillierte Ausgaben -}); diff --git a/pages/api - Kopie/get-talasIP.js b/pages/api - Kopie/get-talasIP.js deleted file mode 100644 index 1216fbbb7..000000000 --- a/pages/api - Kopie/get-talasIP.js +++ /dev/null @@ -1,20 +0,0 @@ -// pages/api/get-talasIP.js - -export default function handler(req, res) { - // Der x-forwarded-for Header könnte mehrere IP-Adressen enthalten, getrennt durch Kommas - let clientIp = - req.headers["x-forwarded-for"]?.split(",").map((ip) => ip.trim())[0] || - req.socket.remoteAddress; - - // Entfernen möglicher IPv6 "mapped" IPv4 Adressen - if (clientIp?.includes("::ffff:")) { - clientIp = clientIp.split("::ffff:")[1]; - } - - // Nur IPv4 Adressen weitergeben, IPv6 Adressen ausschließen - if (clientIp && clientIp.includes(":")) { - clientIp = ""; // Dies setzt die IP auf leer, wenn es sich um eine IPv6-Adresse handelt - } - - res.status(200).json({ ip: clientIp }); -} diff --git a/pages/api - Kopie/gis-proxy.js b/pages/api - Kopie/gis-proxy.js deleted file mode 100644 index b76883298..000000000 --- a/pages/api - Kopie/gis-proxy.js +++ /dev/null @@ -1,34 +0,0 @@ -// /pages/api/gis-proxy.js -// Importieren der erforderlichen Module -import httpProxy from "http-proxy"; -import Cookies from "cookies"; - -// Erstellen eines Proxy-Servers -const proxy = httpProxy.createProxyServer(); - -export default (req, res) => { - return new Promise((resolve) => { - // CORS-Headers einstellen - res.setHeader("Access-Control-Allow-Credentials", true); - res.setHeader("Access-Control-Allow-Origin", "*"); - - // Cookies initialisieren - const cookies = new Cookies(req, res); - const targetUrl = `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic`; - - // Proxy-Konfiguration und Event-Listener - req.on("data", () => {}); - req.on("end", () => { - proxy.web(req, res, { target: targetUrl, changeOrigin: true, selfHandleResponse: false }, (e) => { - if (e) { - console.error(e); - res.status(500).json({ error: "Proxy-Fehler", e }); - } - resolve(); - }); - }); - - // Weiterleitung der Headers - req.headers.cookie = cookies.get("cookie-name") || ""; - }); -}; diff --git a/pages/api - Kopie/linesColorApi.js b/pages/api - Kopie/linesColorApi.js deleted file mode 100644 index 57ee59262..000000000 --- a/pages/api - Kopie/linesColorApi.js +++ /dev/null @@ -1,64 +0,0 @@ -// /pages/api/linesColorApi.js -// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict -//In DB gis_lines idLD und idModul anpassen entsprechend - -// /pages/api/linesColorApi.js -import NextCors from "nextjs-cors"; - -export default async function handler(req, res) { - // Run the cors middleware - await NextCors(req, res, { - // Options - methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], - origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an - optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204 - }); - - const response = { - Name: "Liste aller Statis der Linien", - Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen - IdMap: "10", - Statis: [ - /* { - IdLD: 50922, - Modul: 1, - DpName: "KUE01_Ausfall", - ModulName: "42 Wippershain Sender", - // ModulTyp: "nicht vorhanden", - ModulTyp: "KÜ705-FO", - Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FFFF00", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 3, - DpName: "KUE03_Ausfall", - ModulName: "42 Solz Sender", - //ModulTyp: "nicht vorhanden", - ModulTyp: "KÜSS V2", - Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF0000", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 4, - DpName: "KUE04_Ausfall", - ModulName: "42/13 Bad Hersfeld Gaswerk", - ModulTyp: "Kue705-FO", - Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF00FF", - PrioName: "system", - Value: "10 MOhm", - }, */ - ], - }; - - res.status(200).json(response); -} diff --git a/pages/api - Kopie/rights.js b/pages/api - Kopie/rights.js deleted file mode 100644 index 507228147..000000000 --- a/pages/api - Kopie/rights.js +++ /dev/null @@ -1,29 +0,0 @@ -// pages/api/rights.js - -export default function handler(req, res) { - const { idMap, idUser } = req.query; - - // Beispielhafte Rechte, die je nach idMap und idUser variieren können - const rights = { - '10': [ - { IdRight: 1, Name: "Zugriff auf Dashboard" }, - { IdRight: 56, Name: "Erweiterte Berechtigungen" } - ], - '2': [ - { IdRight: 2, Name: "Zugriff auf Einstellungen" } - ], - '1': [ - { IdRight: 10, Name: "Admin-Zugriff" }, - { IdRight: 11, Name: "Zugriff auf alle Daten" } - ] - }; - - // Prüfung, ob eine gültige idMap und idUser vorhanden sind - if (rights[idMap] && idUser === '484') { - // Rückgabe der spezifischen Rechte basierend auf der idMap und idUser - res.status(200).json({ Rights: rights[idMap] }); - } else { - // Rückgabe leerer Rechte für ungültige idMap oder andere Benutzer - res.status(200).json({ Rights: [] }); - } -} diff --git a/pages/api - Kopie/talas5/area.js b/pages/api - Kopie/talas5/area.js deleted file mode 100644 index 9205aa5ca..000000000 --- a/pages/api - Kopie/talas5/area.js +++ /dev/null @@ -1,40 +0,0 @@ -// pages/api/talas_v5/area.js -// Lesen von talas_v5 MySQL-Datenbank -> area Tabelle enthält DAUZ Geräte -// Wenn gebraucht wird, dann nutzen ansonsten löschen - -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; -//console.log("my dbconfig: ", dbConfig); -export default function handler(req, res) { - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - res.status(500).json({ error: "Verbindungsfehler zur Datenbank" }); - return; - } - - //console.log("Verbunden als ID", connection.threadId); - //Fehler weil, existiertdie Tabelle auf localhost:3000 nicht - connection.query("SELECT ..., ..., ..., ... FROM ... WHERE ... = ...", (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - return; - } - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); - - connection.end(); - }); - }); -} diff --git a/pages/api - Kopie/talas5/location_device.js b/pages/api - Kopie/talas5/location_device.js deleted file mode 100644 index 9292690e0..000000000 --- a/pages/api - Kopie/talas5/location_device.js +++ /dev/null @@ -1,42 +0,0 @@ -// Importieren des mysql2 Pakets -import mysql from "mysql2"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -// Ein Hilfsfunktion, um Anfragen zu vereinfachen -function queryDatabase(query, params) { - return new Promise((resolve, reject) => { - pool.query(query, params, (error, results) => { - if (error) { - return reject(error); - } - resolve(results); - }); - }); -} - -// API-Handler -export default async function handler(req, res) { - try { - // Dein SQL-Query und die Parameter - const sql = "SELECT idLD, iddevice, name FROM location_device WHERE iddevice = ?"; - const params = [160]; // Beispielparameter - - // Ausführen der Datenbankabfrage - const results = await queryDatabase(sql, params); - res.status(200).json(results); - } catch (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - } -} diff --git a/pages/api - Kopie/talas5/webserviceMap/GisStationsMeasurements.js b/pages/api - Kopie/talas5/webserviceMap/GisStationsMeasurements.js deleted file mode 100644 index 5aba69fc6..000000000 --- a/pages/api - Kopie/talas5/webserviceMap/GisStationsMeasurements.js +++ /dev/null @@ -1,116 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsMeasurements.js -const GisStationsMeasurements = { - "Name": "Liste aller Messungen der Geraete", - "Zeitstempel": "2024-05-31T15:25:32.5047629+02:00", - "IdMap": "10", - "Statis": [ - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 3, - "Na": "FBT", - "Val": "20.5", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 10, - "Na": "GT", - "Val": "nicht ermittelbar", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 2, - "Na": "LT", - "Val": "Datenlücke", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 6, - "Na": "RLF", - "Val": "100.0", - "Unit": "%", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 11, - "Na": "TPT", - "Val": "8.3", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 12, - "Na": "TT1", - "Val": "---", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 16, - "Na": "WFD", - "Val": "0.12", - "Unit": "mm", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 8, - "Na": "WGM", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 9, - "Na": "WGS", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10') { - // If the conditions are met, return the GisStationsMeasurements object with a 200 status code. - res.status(200).json(GisStationsMeasurements); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api - Kopie/talas5/webserviceMap/GisStationsStaticDistrict.js b/pages/api - Kopie/talas5/webserviceMap/GisStationsStaticDistrict.js deleted file mode 100644 index bf302f3d7..000000000 --- a/pages/api - Kopie/talas5/webserviceMap/GisStationsStaticDistrict.js +++ /dev/null @@ -1,281 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js -const GisStationsStaticDistrict = { - "Name": "Liste aller Geraete einer bestimmten Karte", - "Zeitstempel": "2024-05-31T15:26:56.9235766+02:00", - "IdMap": "10", - "Points": [ - { - "LD_Name": "CPL Bentheim", - "IdLD": 50017, - "Device": "CPL V3.5 mit 16 Kü", - "Link": "cpl.aspx?ver=35&kue=16&id=50017", - "Location_Name": "Technikraum", - "Location_Short": "BEHE", - "IdLocation": 17448, - "Area_Name": "Bad-Bentheim", - "Area_Short": "BEHE--00", - "IdArea": 16418, - "X": 51.5728, - "Y": 9.00056, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Drucker", - "IdLD": 50084, - "Device": "Basisgerät", - "Link": "basis.aspx?ver=1&id=50084", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 14, - "System": 200, - "Active": 0 - }, - { - "LD_Name": "Türkontakt", - "IdLD": 50666, - "Device": "ECI", - "Link": "eci.aspx?ver=1&id=50666", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 17, - "System": 2, - "Active": 0 - }, - { - "LD_Name": "Triptis", - "IdLD": 50888, - "Device": "CPL 200", - "Link": "cpl.aspx?ver=30&kue=16&id=50888", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn I", - "IdLD": 50889, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50889", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn II", - "IdLD": 50900, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50900", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Hermsdorf", - "IdLD": 50901, - "Device": "CPL V3.5 mit 24 Kü", - "Link": "cpl.aspx?ver=35&kue=24&id=50901", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 1 - }, - { - "LD_Name": "GMA Littwin (TEST)", - "IdLD": 50004, - "Device": "Glättemeldeanlage", - "Link": "gma.aspx?ver=1&id=50004", - "Location_Name": "RG Relaisraum", - "Location_Short": "REZR", - "IdLocation": 18624, - "Area_Name": "Renzenhof (RG)", - "Area_Short": "REZHRG00", - "IdArea": 16570, - "X": 53.246036, - "Y": 8.163293, - "Icon": 1, - "System": 11, - "Active": 0 - }, - { - "LD_Name": "NRS Testserver", - "IdLD": 50005, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50005", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Gateway 2", - "IdLD": 50007, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50007", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Basisgerät mit SNMP MVP", - "IdLD": 50669, - "Device": "Basisgerät + SNMP", - "Link": "basisSNMP.aspx?&ver=1&id=50669", - "Location_Name": "Mylinghauserstraße Engelbert", - "Location_Short": "G-GEVELSBE-1", - "IdLocation": 24012, - "Area_Name": "Gevelsberg", - "Area_Short": "GMA-GEVELSBE", - "IdArea": 20919, - "X": 51.316799, - "Y": 7.33281, - "Icon": 14, - "System": 200, - "Active": 1 - }, - { - "LD_Name": "Server 3", - "IdLD": 50009, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50009", - "Location_Name": "Militärringstraße Militärringstraße", - "Location_Short": "G-KÖLN-1", - "IdLocation": 24015, - "Area_Name": "Köln", - "Area_Short": "GMA-KÖLN", - "IdArea": 20921, - "X": 50.898399, - "Y": 6.92278, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "ICL Test 5", - "IdLD": 50054, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50054", - "Location_Name": "Recheder Mühlenweg Dortmund-Ems-Kanal", - "Location_Short": "G-OLFEN-SE-1", - "IdLocation": 24022, - "Area_Name": "Olfen-Selm", - "Area_Short": "GMA-OLFEN-SE", - "IdArea": 20926, - "X": 51.702202, - "Y": 7.40822, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "ICL Test 3", - "IdLD": 50052, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50052", - "Location_Name": "Weidenstraße Hestenberg", - "Location_Short": "G-PLETTENB-1", - "IdLocation": 24024, - "Area_Name": "Plettenberg", - "Area_Short": "GMA-PLETTENB", - "IdArea": 20928, - "X": 51.224098, - "Y": 7.86969, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "Test Februar Kai", - "IdLD": 50912, - "Device": "Dauerzählstelle DZ", - "Link": "dauz.aspx?ver=1&id=50912", - "Location_Name": "In der Hoffnung Kiesberg - BG Ost", - "Location_Short": "G-WUPPERTA-4", - "IdLocation": 24039, - "Area_Name": "Wuppertal", - "Area_Short": "GMA-WUPPERTA", - "IdArea": 20937, - "X": 51.238899, - "Y": 7.12715, - "Icon": 14, - "System": 110, - "Active": 1 - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the GisStationsStaticDistrict object with a 200 status code. - res.status(200).json(GisStationsStaticDistrict); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api - Kopie/talas5/webserviceMap/GisStationsStatusDistrict.js b/pages/api - Kopie/talas5/webserviceMap/GisStationsStatusDistrict.js deleted file mode 100644 index ae7c25bde..000000000 --- a/pages/api - Kopie/talas5/webserviceMap/GisStationsStatusDistrict.js +++ /dev/null @@ -1,84 +0,0 @@ -// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js -import mysql from "mysql2/promise"; - -// Erstellen eines Verbindungspools anstelle einer einzelnen Verbindung -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - const { idMap, idUser } = req.query; - - if (!idMap || !idUser) { - return res.status(400).json({ error: "idMap and idUser are required" }); - } - - try { - let onlySystem = -1; - let districtCounter = 0; - - // Get onlySystem - const [mapResult] = await pool.query("SELECT idsystem_typ FROM maps WHERE id = ?", [idMap]); - if (mapResult.length > 0) { - onlySystem = mapResult[0].idsystem_typ ?? -1; - } - - // Get districtCounter - if (idUser > 0) { - const [userLayerResult] = await pool.query("SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?", [idUser]); - districtCounter = userLayerResult[0].count; - } - - // Building the query - let query = ` - SELECT ld.idLD, dc.message, p.level, p.name, p.color, ld.idDevice, de.isService, dc.idIcon - FROM location as l - LEFT JOIN location_coordinates AS co ON l.idLocation = co.idLocation and co.idMaps = ? - LEFT JOIN location_device AS ld ON ld.idLocation = l.idLocation - LEFT JOIN datapoint as d ON d.idLD = ld.idLD - LEFT JOIN datapoint_conditions AS dc ON dc.idcondition = d.last_message_condition - LEFT JOIN prio AS p ON p.idPrio = dc.idprio - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN area as a on a.idArea = l.idArea - WHERE p.level < 100 AND co.X > 0 - `; - - const queryParams = [idMap]; - if (districtCounter > 0) { - query += ` AND a.iddistrict IN (SELECT iddistrict FROM user_user_layer1 WHERE iduser = ?)`; - queryParams.push(idUser); - } - if (onlySystem >= 0) { - query += ` AND de.idsystem_typ = ?`; - queryParams.push(onlySystem); - } - query += ` ORDER BY p.level desc`; - - const [results] = await pool.query(query, queryParams); - - const mpss = { - IdMap: idMap.toString(), - Statis: results.map((row) => ({ - IdLD: row.idLD ?? -1, - Le: row.level ?? -1, - Me: row.message ?? "?", - Na: row.name ?? "?", - Co: row.color ?? "#ffffff", - Feld: row.idDevice ?? -1, - Icon: row.idIcon ?? 0, - })), - }; - - res.status(200).json(mpss); - } catch (error) { - console.error("Fehler beim Laden der Daten:", error); - res.status(500).json({ error: "Interner Serverfehler" }); - } -} diff --git a/pages/api - Kopie/talas5/webserviceMap/GisSystemStatic.js b/pages/api - Kopie/talas5/webserviceMap/GisSystemStatic.js deleted file mode 100644 index b2fb56635..000000000 --- a/pages/api - Kopie/talas5/webserviceMap/GisSystemStatic.js +++ /dev/null @@ -1,273 +0,0 @@ -// /pages/api/webServiceMap.js -const gisSystemStatic = { - "Name": "Liste aller angezeigten Systeme", - "Zeitstempel": "2024-05-31T15:08:49.8599542+02:00", - "IdMap": "10", - "Systems": [ - { - "IdSystem": 1, - "Name": "TALAS", - "Longname": "Talas Meldestationen", - "Allow": 1, - "Icon": 1 - }, - { - "IdSystem": 2, - "Name": "ECI", - "Longname": "ECI Geräte", - "Allow": 1, - "Icon": 2 - }, - { - "IdSystem": 5, - "Name": "GSM Modem", - "Longname": "LR77 GSM Modems", - "Allow": 1, - "Icon": 5 - }, - { - "IdSystem": 6, - "Name": "Cisco Router", - "Longname": "Cisco Router", - "Allow": 1, - "Icon": 6 - }, - { - "IdSystem": 7, - "Name": "WAGO", - "Longname": "WAGO I/O Systeme", - "Allow": 1, - "Icon": 7 - }, - { - "IdSystem": 8, - "Name": "Siemens", - "Longname": "Siemens Notrufsystem", - "Allow": 0, - "Icon": 8 - }, - { - "IdSystem": 9, - "Name": "OTDR", - "Longname": "Glasfaserüberwachung OTU", - "Allow": 0, - "Icon": 9 - }, - { - "IdSystem": 10, - "Name": "WDM", - "Longname": " Wavelength Division Multiplexing", - "Allow": 0, - "Icon": 10 - }, - { - "IdSystem": 11, - "Name": "GMA", - "Longname": "Glättemeldeanlagen", - "Allow": 1, - "Icon": 11 - }, - { - "IdSystem": 13, - "Name": "Messstellen", - "Longname": "Messstellen", - "Allow": 0, - "Icon": 13 - }, - { - "IdSystem": 100, - "Name": "TALAS ICL", - "Longname": "Talas ICL Unterstationen", - "Allow": 1, - "Icon": 100 - }, - { - "IdSystem": 110, - "Name": "DAUZ", - "Longname": "Dauerzählstellen", - "Allow": 1, - "Icon": 110 - }, - { - "IdSystem": 111, - "Name": "SMS-Funkmodem", - "Longname": "SMS-Funkmodem", - "Allow": 0, - "Icon": 111 - }, - { - "IdSystem": 200, - "Name": "Sonstige", - "Longname": "Sonstige", - "Allow": 1, - "Icon": 200 - } - ], - "Rights": [ - { - "IdRight": 1 - }, - { - "IdRight": 2 - }, - { - "IdRight": 3 - }, - { - "IdRight": 5 - }, - { - "IdRight": 6 - }, - { - "IdRight": 7 - }, - { - "IdRight": 8 - }, - { - "IdRight": 10 - }, - { - "IdRight": 11 - }, - { - "IdRight": 12 - }, - { - "IdRight": 20 - }, - { - "IdRight": 22 - }, - { - "IdRight": 23 - }, - { - "IdRight": 25 - }, - { - "IdRight": 30 - }, - { - "IdRight": 40 - }, - { - "IdRight": 41 - }, - { - "IdRight": 42 - }, - { - "IdRight": 43 - }, - { - "IdRight": 44 - }, - { - "IdRight": 45 - }, - { - "IdRight": 46 - }, - { - "IdRight": 47 - }, - { - "IdRight": 48 - }, - { - "IdRight": 49 - }, - { - "IdRight": 50 - }, - { - "IdRight": 51 - }, - { - "IdRight": 52 - }, - { - "IdRight": 55 - }, - { - "IdRight": 56 - }, - { - "IdRight": 60 - }, - { - "IdRight": 61 - }, - { - "IdRight": 62 - }, - { - "IdRight": 63 - }, - { - "IdRight": 64 - }, - { - "IdRight": 65 - }, - { - "IdRight": 68 - }, - { - "IdRight": 69 - }, - { - "IdRight": 70 - }, - { - "IdRight": 71 - }, - { - "IdRight": 72 - }, - { - "IdRight": 73 - }, - { - "IdRight": 79 - }, - { - "IdRight": 80 - }, - { - "IdRight": 90 - }, - { - "IdRight": 93 - }, - { - "IdRight": 94 - }, - { - "IdRight": 95 - }, - { - "IdRight": 96 - } - ] -} - -// Export an async function handler for the API route. -export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the gisSystemStatic object with a 200 status code. - res.status(200).json(gisSystemStatic); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } -}; \ No newline at end of file diff --git a/pages/api - Kopie/talas5/webserviceMap/gisStationsMeasurementsSQL.js b/pages/api - Kopie/talas5/webserviceMap/gisStationsMeasurementsSQL.js deleted file mode 100644 index 90c535086..000000000 --- a/pages/api - Kopie/talas5/webserviceMap/gisStationsMeasurementsSQL.js +++ /dev/null @@ -1,74 +0,0 @@ -// /pages/api/talas5/webserviceMap/gisStationsMeasurementsSQL.js -import mysql from "mysql2"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -pool.on("connection", function (connection) { - console.log("Database connected successfully."); -}); - -pool.on("error", function (err) { - console.error("Fehler beim Verbinden:", err); -}); - -export default function handler(req, res) { - const idMap = req.query.idMap; - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const sqlQuery = ` - SELECT - ld.idLD, - dp.idDP, - dp.name AS Na, - dp.value AS Val, - dp.unit AS Unit, - mg.name AS Gr, - ld.idLocation, - area.Name AS Area_Name - FROM location_device as ld - LEFT JOIN location_coordinates AS co ON ld.idLocation = co.idLocation and co.idMaps = ? - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN datapoint AS dp ON ld.idLD = dp.idLD - LEFT JOIN message_group AS mg ON dp.idmessage_group = mg.idmessage_group - LEFT JOIN location AS loc ON ld.idLocation = loc.idLocation - LEFT JOIN area AS area ON loc.idArea = area.idArea - WHERE co.X > 0 AND dp.idmessage_group>0 AND length(dp.unit)> 0 AND length(dp.value)> 0 - `; - - pool.query(sqlQuery, [idMap], (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der gis_lines:", error); - return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" }); - } - - const response = { - Name: "Liste aller Messungen der Geraete", - Zeitstempel: new Date().toISOString(), - IdMap: idMap, - Statis: results.map((row) => ({ - IdLD: row.idLD, - IdDP: row.idDP, - Na: row.Na, - Val: row.Val, - Unit: row.Unit, - Gr: row.Gr, - IdLocation: row.idLocation, - Area_Name: row.Area_Name, - })), - }; - - res.json(response); - }); -} diff --git a/pages/api - Kopie/talas_v5_DB/gisLines/readGisLines.js b/pages/api - Kopie/talas_v5_DB/gisLines/readGisLines.js deleted file mode 100644 index d734ed011..000000000 --- a/pages/api - Kopie/talas_v5_DB/gisLines/readGisLines.js +++ /dev/null @@ -1,34 +0,0 @@ -// /pages/api/talas_v5_DB/gisLines/readGisLines.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const query = "SELECT * FROM talas_v5.gis_lines;"; - - try { - const [results] = await pool.query(query); - if (results.length > 0) { - res.status(200).json(results); - } else { - res.status(404).json({ error: "Gerät nicht gefunden" }); - } - } catch (error) { - console.error("Fehler beim Abrufen der gis_lines:", error); - res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/gisLines/updateLineCoordinates.js b/pages/api - Kopie/talas_v5_DB/gisLines/updateLineCoordinates.js deleted file mode 100644 index 4271160a0..000000000 --- a/pages/api - Kopie/talas_v5_DB/gisLines/updateLineCoordinates.js +++ /dev/null @@ -1,58 +0,0 @@ -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "POST") { - return res.status(405).json({ error: "Nur POST Methode erlaubt" }); - } - - const { idLD, idModul, newCoordinates } = req.body; - if (!idLD || !idModul || !newCoordinates) { - return res.status(400).json({ error: "Fehlende Daten" }); - } - - const newLineString = `LINESTRING(${newCoordinates.map((coord) => `${coord[0]} ${coord[1]}`).join(",")})`; - - const query = "UPDATE talas_v5.gis_lines SET points = ST_GeomFromText(?) WHERE idLD = ? AND idModul = ?;"; - - let connection; - - try { - // Hole eine Verbindung aus dem Pool - connection = await pool.getConnection(); - - // Beginne eine Transaktion - await connection.beginTransaction(); - - // Führe die Abfrage aus - const [results] = await connection.query(query, [newLineString, idLD, idModul]); - - // Commit der Transaktion - await connection.commit(); - - console.log("Transaction Complete."); - res.status(200).json({ - success: "Updated successfully.", - affectedRows: results.affectedRows, - }); - } catch (error) { - // Rollback im Falle eines Fehlers - if (connection) await connection.rollback(); - console.error("Fehler beim Aktualisieren der gis_lines:", error); - res.status(500).json({ error: "Fehler beim Aktualisieren der gis_lines" }); - } finally { - // Stelle sicher, dass die Verbindung zurückgegeben wird - if (connection) connection.release(); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/locationDevice/getDeviceId.js b/pages/api - Kopie/talas_v5_DB/locationDevice/getDeviceId.js deleted file mode 100644 index 8b2326316..000000000 --- a/pages/api - Kopie/talas_v5_DB/locationDevice/getDeviceId.js +++ /dev/null @@ -1,41 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/getDeviceId.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const { deviceName } = req.query; - - if (!deviceName) { - return res.status(400).json({ error: "deviceName ist erforderlich" }); - } - - const query = "SELECT idLD FROM location_device WHERE name = ?"; - - try { - // Ausführen der Abfrage mit dem Pool - const [results] = await pool.query(query, [deviceName]); - if (results.length > 0) { - res.status(200).json({ idLD: results[0].idLD }); - } else { - res.status(404).json({ error: "Gerät nicht gefunden" }); - } - } catch (error) { - console.error("Fehler beim Abrufen der Geräte-ID:", error); - res.status(500).json({ error: "Fehler beim Abrufen der Geräte-ID" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/locationDevice/locationDeviceNameById.js b/pages/api - Kopie/talas_v5_DB/locationDevice/locationDeviceNameById.js deleted file mode 100644 index 575541547..000000000 --- a/pages/api - Kopie/talas_v5_DB/locationDevice/locationDeviceNameById.js +++ /dev/null @@ -1,40 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/locationDeviceNameById.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const { idLD } = req.query; - - if (!idLD) { - return res.status(400).json({ error: "idLD ist erforderlich" }); - } - - try { - const query = "SELECT name FROM location_device WHERE idLD = ?"; - const [results] = await pool.query(query, [idLD]); - - if (results.length > 0) { - res.status(200).json({ name: results[0].name }); - } else { - res.status(404).json({ error: "Gerät nicht gefunden", idLD }); - } - } catch (error) { - console.error("Fehler beim Abrufen des Gerätenamens:", error); - res.status(500).json({ error: "Fehler beim Abrufen des Gerätenamens" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/locationDevice/locationDevices.js b/pages/api - Kopie/talas_v5_DB/locationDevice/locationDevices.js deleted file mode 100644 index 082dc2929..000000000 --- a/pages/api - Kopie/talas_v5_DB/locationDevice/locationDevices.js +++ /dev/null @@ -1,32 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/locationDevices.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const query = "SELECT * FROM location_device WHERE iddevice = 160"; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query); - - res.status(200).json(results); - } catch (error) { - console.error("Fehler beim Abrufen der Geräteinformationen:", error); - res.status(500).json({ error: "Fehler beim Abrufen der Geräteinformationen" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/poiTyp/readPoiTyp.js b/pages/api - Kopie/talas_v5_DB/poiTyp/readPoiTyp.js deleted file mode 100644 index baff8f83d..000000000 --- a/pages/api - Kopie/talas_v5_DB/poiTyp/readPoiTyp.js +++ /dev/null @@ -1,37 +0,0 @@ -// pages/api/talas_v5_DB/poiTyp/readPoiTyp.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - res.setHeader("Allow", ["GET"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - const query = "SELECT * FROM poityp"; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query); - - if (results.length === 0) { - return res.status(404).json({ message: "Keine Einträge gefunden" }); - } - - res.status(200).json(results); - } catch (error) { - console.error("Fehler beim Abfragen der Datenbank:", error); - res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/addLocation.js b/pages/api - Kopie/talas_v5_DB/pois/addLocation.js deleted file mode 100644 index 864835647..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/addLocation.js +++ /dev/null @@ -1,37 +0,0 @@ -// pages/api/addLocation.js -import mysql from "mysql"; - -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - connectionLimit: 10, // Maximale Anzahl gleichzeitiger Verbindungen -}); - -export default function handler(req, res) { - if (req.method === "POST") { - const { name, poiTypeId, latitude, longitude, idLD } = req.body; - console.log("Received data:", req.body); // Überprüfen der empfangenen Daten - - const query = "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)"; - const point = `POINT(${longitude} ${latitude})`; - const values = [name, poiTypeId, point, idLD]; - - // Verwende den Pool, um eine Verbindung zu bekommen und die Query auszuführen - pool.query(query, values, (error, results) => { - if (error) { - console.error("Fehler beim Einfügen des Standorts:", error); - return res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } - res.status(200).json({ - id: results.insertId, - message: "Standort erfolgreich hinzugefügt", - }); - }); - } else { - res.setHeader("Allow", ["POST"]); - res.status(405).end(`Method ${req.method} Not Allowed`); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/deletePoi.js b/pages/api - Kopie/talas_v5_DB/pois/deletePoi.js deleted file mode 100644 index e9132bd6b..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/deletePoi.js +++ /dev/null @@ -1,42 +0,0 @@ -// pages/api/talas_v5_DB/pois/deletePoi.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "DELETE") { - return res.status(405).json({ error: "Nur DELETE Methode erlaubt" }); - } - - const { id } = req.query; // ID aus der Anfrage holen - - if (!id) { - return res.status(400).json({ error: "POI ID ist erforderlich" }); - } - - const query = "DELETE FROM poi WHERE idPoi = ?"; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query, [id]); - - if (results.affectedRows > 0) { - res.status(200).json({ message: "POI erfolgreich gelöscht" }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - } catch (error) { - console.error("Fehler beim Löschen des POI 3:", error); - res.status(500).json({ error: "Fehler beim Löschen des POI" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/getPoiById.js b/pages/api - Kopie/talas_v5_DB/pois/getPoiById.js deleted file mode 100644 index 3bd2f1023..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/getPoiById.js +++ /dev/null @@ -1,43 +0,0 @@ -// pages/api/talas_v5_DB/pois/getPoiById.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - res.setHeader("Allow", ["GET"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - const { idPoi } = req.query; - - if (!idPoi) { - return res.status(400).json({ error: "idPoi ist erforderlich" }); - } - - const query = "SELECT description FROM poi WHERE idPoi = ?"; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query, [idPoi]); - - if (results.length === 0) { - return res.status(404).json({ error: "POI nicht gefunden" }); - } - - res.status(200).json(results[0]); - } catch (error) { - console.error("Fehler bei der Abfrage:", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/poi-icons.js b/pages/api - Kopie/talas_v5_DB/pois/poi-icons.js deleted file mode 100644 index 407704538..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/poi-icons.js +++ /dev/null @@ -1,36 +0,0 @@ -// pages/api/talas_v5_DB/pois/poi-icons.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const query = ` - SELECT p.idPoi, i.path - FROM poi p - JOIN poiTyp pt ON p.idPoiTyp = pt.idPoiTyp - JOIN poiicons i ON pt.icon = i.idpoiicons; - `; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query); - res.status(200).json(results); - } catch (error) { - console.error("Fehler beim Abrufen der Icons:", error); - res.status(500).json({ error: "Fehler beim Abrufen der Icons" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/readLocations.js b/pages/api - Kopie/talas_v5_DB/pois/readLocations.js deleted file mode 100644 index 308de78af..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/readLocations.js +++ /dev/null @@ -1,32 +0,0 @@ -// pages/api/talas_v5_DB/pois/readLocations.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - const query = ` - SELECT idPoi, description, idPoiTyp, idLD, ST_AsText(position) AS position - FROM poi - `; - - try { - // Ausführen der Abfrage mit dem Verbindungspool - const [results] = await pool.query(query); - - // Senden der Antwort zurück - res.status(200).json(results); - } catch (error) { - console.error("Fehler beim Abrufen der API:", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/pois/updateLocation.js b/pages/api - Kopie/talas_v5_DB/pois/updateLocation.js deleted file mode 100644 index ee61070f2..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/updateLocation.js +++ /dev/null @@ -1,82 +0,0 @@ -// pages/api/talas_v5_DB/pois/updateLocation.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - charset: "utf8mb4", - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "POST") { - res.setHeader("Allow", ["POST"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - const { id, latitude, longitude } = req.body; - - if (!id || latitude === undefined || longitude === undefined) { - return res.status(400).json({ error: "id, latitude, und longitude sind erforderlich" }); - } - - const query = "UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?"; - - try { - const [result] = await pool.query(query, [longitude, latitude, id]); - - if (result.affectedRows > 0) { - res.status(200).json({ success: true }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - } catch (error) { - console.error("Fehler beim Aktualisieren der Position:", error); - res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } -} - -/* import mysql from "mysql"; -import util from "util"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - charset: "utf8mb4", -}; - -export default async function handler(req, res) { - if (req.method !== "POST") { - res.setHeader("Allow", ["POST"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - const { id, latitude, longitude } = req.body; - - const connection = mysql.createConnection(dbConfig); - // Promisify the query method - const query = util.promisify(connection.query).bind(connection); - - try { - await query("UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?", [ - longitude, - latitude, - id, - ]); - res.status(200).json({ success: true }); - } catch (error) { - console.error(error); - res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } finally { - connection.end(); - } -} */ diff --git a/pages/api - Kopie/talas_v5_DB/pois/updatePoi.js b/pages/api - Kopie/talas_v5_DB/pois/updatePoi.js deleted file mode 100644 index bc3356a2f..000000000 --- a/pages/api - Kopie/talas_v5_DB/pois/updatePoi.js +++ /dev/null @@ -1,45 +0,0 @@ -// pages/api/talas_v5_DB/pois/updatePoi.js -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "POST") { - return res.status(405).json({ error: "Nur POST Methode erlaubt" }); - } - - const { idPoi, description, idPoiTyp, idLD } = req.body; - - if (!idPoi) { - return res.status(400).json({ error: "POI ID ist erforderlich" }); - } - - const query = ` - UPDATE talas_v5.poi - SET description = ?, idPoiTyp = ?, idLD = ? - WHERE idPoi = ? - `; - - try { - const [results] = await pool.query(query, [description, idPoiTyp, idLD, idPoi]); - - if (results.affectedRows > 0) { - res.status(200).json({ message: "POI erfolgreich aktualisiert" }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - } catch (error) { - console.error("Fehler beim Aktualisieren des POI:", error); - res.status(500).json({ error: "Fehler beim Aktualisieren des POI" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/priorityConfig.js b/pages/api - Kopie/talas_v5_DB/priorityConfig.js deleted file mode 100644 index 719007020..000000000 --- a/pages/api - Kopie/talas_v5_DB/priorityConfig.js +++ /dev/null @@ -1,31 +0,0 @@ -// pages/api/talas_v5_DB/priorityConfig.js -// in tals5 http://10.10.0.13/talas5/Management/PriorityConfig.aspx beinhaltet die Tabelle prio die Prioritäten der Meldungen (Level 1-4) oder (0-4) je nachdem DB-Design -// das ist die API, die die Prioritäten zurückgibt - -import mysql from "mysql2/promise"; - -// Erstellen eines Pools von Datenbankverbindungen -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - try { - // Ausführen der Datenbankabfrage - const query = "SELECT idprio, level, name, color FROM prio"; - const results = await pool.query(query); - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results[0]); // Da mysql2 Tuple [rows, fields] zurückgibt, wählen wir nur rows mit [0] - } catch (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - } -} diff --git a/pages/api - Kopie/talas_v5_DB/station/getAllStationsNames.js b/pages/api - Kopie/talas_v5_DB/station/getAllStationsNames.js deleted file mode 100644 index 0d5d5ca05..000000000 --- a/pages/api - Kopie/talas_v5_DB/station/getAllStationsNames.js +++ /dev/null @@ -1,43 +0,0 @@ -// /pages/api/talas_v5_DB/station/getAllStationsNames.js -import mysql from "mysql2/promise"; - -// Verbindungspool-Konfiguration -const pool = mysql.createPool({ - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0, -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - res.setHeader("Allow", ["GET"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - try { - // Abrufen aller idLD und ihrer Namen - const [results] = await pool.query("SELECT idLD, name FROM location_device"); - - if (results.length === 0) { - return res.status(404).json({ error: "No data found" }); - } - - // Struktur der Antwort anpassen - const namesMap = results.reduce((map, { idLD, name }) => { - if (!map[idLD]) { - map[idLD] = name; // Stelle sicher, dass hier keine Duplikate oder Überschreibungen entstehen - } - return map; - }, {}); - - res.status(200).json(namesMap); - } catch (err) { - console.error("Fehler beim Abrufen der Daten:", err); - res.status(500).json({ error: "Error retrieving data from the database" }); - } -} diff --git a/pages/api back30/[...path].js b/pages/api back30/[...path].js deleted file mode 100644 index 0578e8448..000000000 --- a/pages/api back30/[...path].js +++ /dev/null @@ -1,20 +0,0 @@ -// pages/api/[...path].js -import { createProxyMiddleware } from "http-proxy-middleware"; -import { SERVER_URL } from "../config/urls.js"; -console.log("SERVER_URL:", SERVER_URL); // Debug-Ausgabe - -export default createProxyMiddleware({ - //target: "http://192.168.10.58:3001", - // Stationen bekommen - //target: "http://10.10.0.13", // Ziel-URL des Proxys // API Aufruf zum mapGisStationsStaticDistrictUrl, mapGisStationsStatusDistrictUrl, mapGisStationsMeasurementsUrl, mapGisSystemStaticUrl und mapDataIconUrl - target: `${SERVER_URL}`, // - //target: urls.PROXY_TARGET, - //target: "http://localhost:3000", // Ziel-URL des Proxys - //target: "http://192.168.10.187:3000", // Ziel-URL des Proxys - //target: "http://192.168.10.14", - changeOrigin: true, - pathRewrite: { - "^/api": "/", // Optional: Entfernt /api aus dem Pfad, wenn das Backend dies nicht erfordert - }, - logLevel: "debug", // Setzt das Logging-Level auf "debug" für detaillierte Ausgaben -}); diff --git a/pages/api back30/get-talasIP.js b/pages/api back30/get-talasIP.js deleted file mode 100644 index 1216fbbb7..000000000 --- a/pages/api back30/get-talasIP.js +++ /dev/null @@ -1,20 +0,0 @@ -// pages/api/get-talasIP.js - -export default function handler(req, res) { - // Der x-forwarded-for Header könnte mehrere IP-Adressen enthalten, getrennt durch Kommas - let clientIp = - req.headers["x-forwarded-for"]?.split(",").map((ip) => ip.trim())[0] || - req.socket.remoteAddress; - - // Entfernen möglicher IPv6 "mapped" IPv4 Adressen - if (clientIp?.includes("::ffff:")) { - clientIp = clientIp.split("::ffff:")[1]; - } - - // Nur IPv4 Adressen weitergeben, IPv6 Adressen ausschließen - if (clientIp && clientIp.includes(":")) { - clientIp = ""; // Dies setzt die IP auf leer, wenn es sich um eine IPv6-Adresse handelt - } - - res.status(200).json({ ip: clientIp }); -} diff --git a/pages/api back30/gis-proxy.js b/pages/api back30/gis-proxy.js deleted file mode 100644 index b76883298..000000000 --- a/pages/api back30/gis-proxy.js +++ /dev/null @@ -1,34 +0,0 @@ -// /pages/api/gis-proxy.js -// Importieren der erforderlichen Module -import httpProxy from "http-proxy"; -import Cookies from "cookies"; - -// Erstellen eines Proxy-Servers -const proxy = httpProxy.createProxyServer(); - -export default (req, res) => { - return new Promise((resolve) => { - // CORS-Headers einstellen - res.setHeader("Access-Control-Allow-Credentials", true); - res.setHeader("Access-Control-Allow-Origin", "*"); - - // Cookies initialisieren - const cookies = new Cookies(req, res); - const targetUrl = `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic`; - - // Proxy-Konfiguration und Event-Listener - req.on("data", () => {}); - req.on("end", () => { - proxy.web(req, res, { target: targetUrl, changeOrigin: true, selfHandleResponse: false }, (e) => { - if (e) { - console.error(e); - res.status(500).json({ error: "Proxy-Fehler", e }); - } - resolve(); - }); - }); - - // Weiterleitung der Headers - req.headers.cookie = cookies.get("cookie-name") || ""; - }); -}; diff --git a/pages/api back30/linesColorApi.js b/pages/api back30/linesColorApi.js deleted file mode 100644 index 57ee59262..000000000 --- a/pages/api back30/linesColorApi.js +++ /dev/null @@ -1,64 +0,0 @@ -// /pages/api/linesColorApi.js -// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict -//In DB gis_lines idLD und idModul anpassen entsprechend - -// /pages/api/linesColorApi.js -import NextCors from "nextjs-cors"; - -export default async function handler(req, res) { - // Run the cors middleware - await NextCors(req, res, { - // Options - methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], - origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an - optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204 - }); - - const response = { - Name: "Liste aller Statis der Linien", - Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen - IdMap: "10", - Statis: [ - /* { - IdLD: 50922, - Modul: 1, - DpName: "KUE01_Ausfall", - ModulName: "42 Wippershain Sender", - // ModulTyp: "nicht vorhanden", - ModulTyp: "KÜ705-FO", - Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FFFF00", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 3, - DpName: "KUE03_Ausfall", - ModulName: "42 Solz Sender", - //ModulTyp: "nicht vorhanden", - ModulTyp: "KÜSS V2", - Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF0000", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 4, - DpName: "KUE04_Ausfall", - ModulName: "42/13 Bad Hersfeld Gaswerk", - ModulTyp: "Kue705-FO", - Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF00FF", - PrioName: "system", - Value: "10 MOhm", - }, */ - ], - }; - - res.status(200).json(response); -} diff --git a/pages/api back30/rights.js b/pages/api back30/rights.js deleted file mode 100644 index 507228147..000000000 --- a/pages/api back30/rights.js +++ /dev/null @@ -1,29 +0,0 @@ -// pages/api/rights.js - -export default function handler(req, res) { - const { idMap, idUser } = req.query; - - // Beispielhafte Rechte, die je nach idMap und idUser variieren können - const rights = { - '10': [ - { IdRight: 1, Name: "Zugriff auf Dashboard" }, - { IdRight: 56, Name: "Erweiterte Berechtigungen" } - ], - '2': [ - { IdRight: 2, Name: "Zugriff auf Einstellungen" } - ], - '1': [ - { IdRight: 10, Name: "Admin-Zugriff" }, - { IdRight: 11, Name: "Zugriff auf alle Daten" } - ] - }; - - // Prüfung, ob eine gültige idMap und idUser vorhanden sind - if (rights[idMap] && idUser === '484') { - // Rückgabe der spezifischen Rechte basierend auf der idMap und idUser - res.status(200).json({ Rights: rights[idMap] }); - } else { - // Rückgabe leerer Rechte für ungültige idMap oder andere Benutzer - res.status(200).json({ Rights: [] }); - } -} diff --git a/pages/api back30/talas5/area.js b/pages/api back30/talas5/area.js deleted file mode 100644 index 9205aa5ca..000000000 --- a/pages/api back30/talas5/area.js +++ /dev/null @@ -1,40 +0,0 @@ -// pages/api/talas_v5/area.js -// Lesen von talas_v5 MySQL-Datenbank -> area Tabelle enthält DAUZ Geräte -// Wenn gebraucht wird, dann nutzen ansonsten löschen - -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; -//console.log("my dbconfig: ", dbConfig); -export default function handler(req, res) { - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - res.status(500).json({ error: "Verbindungsfehler zur Datenbank" }); - return; - } - - //console.log("Verbunden als ID", connection.threadId); - //Fehler weil, existiertdie Tabelle auf localhost:3000 nicht - connection.query("SELECT ..., ..., ..., ... FROM ... WHERE ... = ...", (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - return; - } - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); - - connection.end(); - }); - }); -} diff --git a/pages/api back30/talas5/location_device.js b/pages/api back30/talas5/location_device.js deleted file mode 100644 index 8c956f459..000000000 --- a/pages/api back30/talas5/location_device.js +++ /dev/null @@ -1,39 +0,0 @@ -// pages/api/talas_v5/location_device.js -// talas_v5 Datenbank -> location_device Tabelle enthält DAUZ Geräte - -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; -//console.log("my dbconfig: ", dbConfig); -export default function handler(req, res) { - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - res.status(500).json({ error: "Verbindungsfehler zur Datenbank" }); - return; - } - - //console.log("Verbunden als ID", connection.threadId); - //Fehler weil, existiertdie Tabelle auf localhost:3000 nicht - connection.query("SELECT idLD, iddevice, iddevice, name FROM location_device WHERE iddevice = 160", (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - return; - } - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); - - connection.end(); - }); - }); -} diff --git a/pages/api back30/talas5/webserviceMap/GisStationsMeasurements.js b/pages/api back30/talas5/webserviceMap/GisStationsMeasurements.js deleted file mode 100644 index 5aba69fc6..000000000 --- a/pages/api back30/talas5/webserviceMap/GisStationsMeasurements.js +++ /dev/null @@ -1,116 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsMeasurements.js -const GisStationsMeasurements = { - "Name": "Liste aller Messungen der Geraete", - "Zeitstempel": "2024-05-31T15:25:32.5047629+02:00", - "IdMap": "10", - "Statis": [ - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 3, - "Na": "FBT", - "Val": "20.5", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 10, - "Na": "GT", - "Val": "nicht ermittelbar", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 2, - "Na": "LT", - "Val": "Datenlücke", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 6, - "Na": "RLF", - "Val": "100.0", - "Unit": "%", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 11, - "Na": "TPT", - "Val": "8.3", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 12, - "Na": "TT1", - "Val": "---", - "Unit": "°C", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 16, - "Na": "WFD", - "Val": "0.12", - "Unit": "mm", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 8, - "Na": "WGM", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - }, - { - "IdLD": 50004, - "IdL": 18624, - "IdDP": 9, - "Na": "WGS", - "Val": "---", - "Unit": "m/s", - "Gr": "GMA", - "Area_Name": "Renzenhof (RG)" - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10') { - // If the conditions are met, return the GisStationsMeasurements object with a 200 status code. - res.status(200).json(GisStationsMeasurements); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api back30/talas5/webserviceMap/GisStationsStaticDistrict.js b/pages/api back30/talas5/webserviceMap/GisStationsStaticDistrict.js deleted file mode 100644 index bf302f3d7..000000000 --- a/pages/api back30/talas5/webserviceMap/GisStationsStaticDistrict.js +++ /dev/null @@ -1,281 +0,0 @@ -// /pages/api/talas5/webserviceMap/GisStationsStaticDistrict.js -const GisStationsStaticDistrict = { - "Name": "Liste aller Geraete einer bestimmten Karte", - "Zeitstempel": "2024-05-31T15:26:56.9235766+02:00", - "IdMap": "10", - "Points": [ - { - "LD_Name": "CPL Bentheim", - "IdLD": 50017, - "Device": "CPL V3.5 mit 16 Kü", - "Link": "cpl.aspx?ver=35&kue=16&id=50017", - "Location_Name": "Technikraum", - "Location_Short": "BEHE", - "IdLocation": 17448, - "Area_Name": "Bad-Bentheim", - "Area_Short": "BEHE--00", - "IdArea": 16418, - "X": 51.5728, - "Y": 9.00056, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Drucker", - "IdLD": 50084, - "Device": "Basisgerät", - "Link": "basis.aspx?ver=1&id=50084", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 14, - "System": 200, - "Active": 0 - }, - { - "LD_Name": "Türkontakt", - "IdLD": 50666, - "Device": "ECI", - "Link": "eci.aspx?ver=1&id=50666", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 17, - "System": 2, - "Active": 0 - }, - { - "LD_Name": "Triptis", - "IdLD": 50888, - "Device": "CPL 200", - "Link": "cpl.aspx?ver=30&kue=16&id=50888", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn I", - "IdLD": 50889, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50889", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Rodaborn II", - "IdLD": 50900, - "Device": "cpl.mio V>6", - "Link": "cplmio.aspx?ver=1&id=50900", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 0 - }, - { - "LD_Name": "Hermsdorf", - "IdLD": 50901, - "Device": "CPL V3.5 mit 24 Kü", - "Link": "cpl.aspx?ver=35&kue=24&id=50901", - "Location_Name": "Technikraum", - "Location_Short": "SLUE", - "IdLocation": 17776, - "Area_Name": "Schlüchtern II", - "Area_Short": "SLUE--00", - "IdArea": 14688, - "X": 53.2455, - "Y": 8.1614, - "Icon": 20, - "System": 1, - "Active": 1 - }, - { - "LD_Name": "GMA Littwin (TEST)", - "IdLD": 50004, - "Device": "Glättemeldeanlage", - "Link": "gma.aspx?ver=1&id=50004", - "Location_Name": "RG Relaisraum", - "Location_Short": "REZR", - "IdLocation": 18624, - "Area_Name": "Renzenhof (RG)", - "Area_Short": "REZHRG00", - "IdArea": 16570, - "X": 53.246036, - "Y": 8.163293, - "Icon": 1, - "System": 11, - "Active": 0 - }, - { - "LD_Name": "NRS Testserver", - "IdLD": 50005, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50005", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Gateway 2", - "IdLD": 50007, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50007", - "Location_Name": "(EV Ammersricht BZR REL)", - "Location_Short": "AMME", - "IdLocation": 21118, - "Area_Name": "Ammersricht BZR (FGN)", - "Area_Short": "AMMER--00", - "IdArea": 15958, - "X": 52.52726, - "Y": 12.165488, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "Basisgerät mit SNMP MVP", - "IdLD": 50669, - "Device": "Basisgerät + SNMP", - "Link": "basisSNMP.aspx?&ver=1&id=50669", - "Location_Name": "Mylinghauserstraße Engelbert", - "Location_Short": "G-GEVELSBE-1", - "IdLocation": 24012, - "Area_Name": "Gevelsberg", - "Area_Short": "GMA-GEVELSBE", - "IdArea": 20919, - "X": 51.316799, - "Y": 7.33281, - "Icon": 14, - "System": 200, - "Active": 1 - }, - { - "LD_Name": "Server 3", - "IdLD": 50009, - "Device": "Notruf Server", - "Link": "nrs_server.aspx?ver=1&id=50009", - "Location_Name": "Militärringstraße Militärringstraße", - "Location_Short": "G-KÖLN-1", - "IdLocation": 24015, - "Area_Name": "Köln", - "Area_Short": "GMA-KÖLN", - "IdArea": 20921, - "X": 50.898399, - "Y": 6.92278, - "Icon": 19, - "System": 8, - "Active": 0 - }, - { - "LD_Name": "ICL Test 5", - "IdLD": 50054, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50054", - "Location_Name": "Recheder Mühlenweg Dortmund-Ems-Kanal", - "Location_Short": "G-OLFEN-SE-1", - "IdLocation": 24022, - "Area_Name": "Olfen-Selm", - "Area_Short": "GMA-OLFEN-SE", - "IdArea": 20926, - "X": 51.702202, - "Y": 7.40822, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "ICL Test 3", - "IdLD": 50052, - "Device": "ICL", - "Link": "icl.aspx?ver=1&id=50052", - "Location_Name": "Weidenstraße Hestenberg", - "Location_Short": "G-PLETTENB-1", - "IdLocation": 24024, - "Area_Name": "Plettenberg", - "Area_Short": "GMA-PLETTENB", - "IdArea": 20928, - "X": 51.224098, - "Y": 7.86969, - "Icon": 23, - "System": 100, - "Active": 0 - }, - { - "LD_Name": "Test Februar Kai", - "IdLD": 50912, - "Device": "Dauerzählstelle DZ", - "Link": "dauz.aspx?ver=1&id=50912", - "Location_Name": "In der Hoffnung Kiesberg - BG Ost", - "Location_Short": "G-WUPPERTA-4", - "IdLocation": 24039, - "Area_Name": "Wuppertal", - "Area_Short": "GMA-WUPPERTA", - "IdArea": 20937, - "X": 51.238899, - "Y": 7.12715, - "Icon": 14, - "System": 110, - "Active": 1 - } - ] - } - - // Export an async function handler for the API route. - export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the GisStationsStaticDistrict object with a 200 status code. - res.status(200).json(GisStationsStaticDistrict); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } - }; \ No newline at end of file diff --git a/pages/api back30/talas5/webserviceMap/GisStationsStatusDistrict.js b/pages/api back30/talas5/webserviceMap/GisStationsStatusDistrict.js deleted file mode 100644 index 9d0f2024c..000000000 --- a/pages/api back30/talas5/webserviceMap/GisStationsStatusDistrict.js +++ /dev/null @@ -1,100 +0,0 @@ -import mysql from "mysql2/promise"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -export default async function handler(req, res) { - const { idMap, idUser } = req.query; - - if (!idMap || !idUser) { - res.status(400).json({ error: "idMap and idUser are required" }); - return; - } - - let connection; - try { - connection = await mysql.createConnection(dbConfig); - - let onlySystem = -1; - let districtCounter = 0; - - // Get onlySystem - const [mapResult] = await connection.execute( - "SELECT idsystem_typ FROM maps WHERE id = ?", - [idMap] - ); - if (mapResult.length > 0) { - onlySystem = mapResult[0].idsystem_typ ?? -1; - } - - // Get districtCounter - if (idUser > 0) { - const [userLayerResult] = await connection.execute( - "SELECT count(*) as count FROM user_User_layer1 WHERE iduser = ?", - [idUser] - ); - districtCounter = userLayerResult[0].count; - } - - // Get GisStatusStations - let query = ` - SELECT ld.idLD, dc.message, p.level, p.name, p.color, ld.idDevice, de.isService, dc.idIcon - FROM location as l - LEFT JOIN location_coordinates AS co ON l.idLocation = co.idLocation and co.idMaps = ? - LEFT JOIN location_device AS ld ON ld.idLocation = l.idLocation - LEFT JOIN datapoint as d ON d.idLD = ld.idLD - LEFT JOIN datapoint_conditions AS dc ON dc.idcondition = d.last_message_condition - LEFT JOIN prio AS p ON p.idPrio = dc.idprio - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN area as a on a.idArea = l.idArea - WHERE p.level < 100 AND co.X > 0 - `; - - if (districtCounter > 0) { - query += ` AND a.iddistrict IN (SELECT iddistrict FROM user_user_layer1 WHERE iduser = ?)`; - } - - if (onlySystem >= 0) { - query += ` AND de.idsystem_typ = ?`; - } - - query += ` ORDER BY p.level desc`; - - const queryParams = [idMap]; - if (districtCounter > 0) { - queryParams.push(idUser); - } - if (onlySystem >= 0) { - queryParams.push(onlySystem); - } - - const [results] = await connection.execute(query, queryParams); - - const mpss = { - IdMap: idMap.toString(), - Statis: results.map((row) => ({ - IdLD: row.idLD ?? -1, - Le: row.level ?? -1, - Me: row.message ?? "?", - Na: row.name ?? "?", - Co: row.color ?? "#ffffff", - Feld: row.idDevice ?? -1, - Icon: row.idIcon ?? 0, - })), - }; - - res.status(200).json(mpss); - } catch (error) { - console.error("Fehler beim Laden der Daten:", error); - res.status(500).json({ error: "Interner Serverfehler" }); - } finally { - if (connection) { - await connection.end(); - } - } -} diff --git a/pages/api back30/talas5/webserviceMap/GisSystemStatic.js b/pages/api back30/talas5/webserviceMap/GisSystemStatic.js deleted file mode 100644 index b2fb56635..000000000 --- a/pages/api back30/talas5/webserviceMap/GisSystemStatic.js +++ /dev/null @@ -1,273 +0,0 @@ -// /pages/api/webServiceMap.js -const gisSystemStatic = { - "Name": "Liste aller angezeigten Systeme", - "Zeitstempel": "2024-05-31T15:08:49.8599542+02:00", - "IdMap": "10", - "Systems": [ - { - "IdSystem": 1, - "Name": "TALAS", - "Longname": "Talas Meldestationen", - "Allow": 1, - "Icon": 1 - }, - { - "IdSystem": 2, - "Name": "ECI", - "Longname": "ECI Geräte", - "Allow": 1, - "Icon": 2 - }, - { - "IdSystem": 5, - "Name": "GSM Modem", - "Longname": "LR77 GSM Modems", - "Allow": 1, - "Icon": 5 - }, - { - "IdSystem": 6, - "Name": "Cisco Router", - "Longname": "Cisco Router", - "Allow": 1, - "Icon": 6 - }, - { - "IdSystem": 7, - "Name": "WAGO", - "Longname": "WAGO I/O Systeme", - "Allow": 1, - "Icon": 7 - }, - { - "IdSystem": 8, - "Name": "Siemens", - "Longname": "Siemens Notrufsystem", - "Allow": 0, - "Icon": 8 - }, - { - "IdSystem": 9, - "Name": "OTDR", - "Longname": "Glasfaserüberwachung OTU", - "Allow": 0, - "Icon": 9 - }, - { - "IdSystem": 10, - "Name": "WDM", - "Longname": " Wavelength Division Multiplexing", - "Allow": 0, - "Icon": 10 - }, - { - "IdSystem": 11, - "Name": "GMA", - "Longname": "Glättemeldeanlagen", - "Allow": 1, - "Icon": 11 - }, - { - "IdSystem": 13, - "Name": "Messstellen", - "Longname": "Messstellen", - "Allow": 0, - "Icon": 13 - }, - { - "IdSystem": 100, - "Name": "TALAS ICL", - "Longname": "Talas ICL Unterstationen", - "Allow": 1, - "Icon": 100 - }, - { - "IdSystem": 110, - "Name": "DAUZ", - "Longname": "Dauerzählstellen", - "Allow": 1, - "Icon": 110 - }, - { - "IdSystem": 111, - "Name": "SMS-Funkmodem", - "Longname": "SMS-Funkmodem", - "Allow": 0, - "Icon": 111 - }, - { - "IdSystem": 200, - "Name": "Sonstige", - "Longname": "Sonstige", - "Allow": 1, - "Icon": 200 - } - ], - "Rights": [ - { - "IdRight": 1 - }, - { - "IdRight": 2 - }, - { - "IdRight": 3 - }, - { - "IdRight": 5 - }, - { - "IdRight": 6 - }, - { - "IdRight": 7 - }, - { - "IdRight": 8 - }, - { - "IdRight": 10 - }, - { - "IdRight": 11 - }, - { - "IdRight": 12 - }, - { - "IdRight": 20 - }, - { - "IdRight": 22 - }, - { - "IdRight": 23 - }, - { - "IdRight": 25 - }, - { - "IdRight": 30 - }, - { - "IdRight": 40 - }, - { - "IdRight": 41 - }, - { - "IdRight": 42 - }, - { - "IdRight": 43 - }, - { - "IdRight": 44 - }, - { - "IdRight": 45 - }, - { - "IdRight": 46 - }, - { - "IdRight": 47 - }, - { - "IdRight": 48 - }, - { - "IdRight": 49 - }, - { - "IdRight": 50 - }, - { - "IdRight": 51 - }, - { - "IdRight": 52 - }, - { - "IdRight": 55 - }, - { - "IdRight": 56 - }, - { - "IdRight": 60 - }, - { - "IdRight": 61 - }, - { - "IdRight": 62 - }, - { - "IdRight": 63 - }, - { - "IdRight": 64 - }, - { - "IdRight": 65 - }, - { - "IdRight": 68 - }, - { - "IdRight": 69 - }, - { - "IdRight": 70 - }, - { - "IdRight": 71 - }, - { - "IdRight": 72 - }, - { - "IdRight": 73 - }, - { - "IdRight": 79 - }, - { - "IdRight": 80 - }, - { - "IdRight": 90 - }, - { - "IdRight": 93 - }, - { - "IdRight": 94 - }, - { - "IdRight": 95 - }, - { - "IdRight": 96 - } - ] -} - -// Export an async function handler for the API route. -export default async function handler(req, res) { - // Initialize an empty params object to store query parameters. - const params = { - idMap: req.query.idMap, - idUser: req.query.idUser - }; - - // Check if the requested ID map and user match certain conditions. - if (params.idMap === '10' && params.idUser === '484') { - // If the conditions are met, return the gisSystemStatic object with a 200 status code. - res.status(200).json(gisSystemStatic); - } else { - // If not, return a 404 error with the message "Not Found". - res.status(404).send('Not Found'); - } -}; \ No newline at end of file diff --git a/pages/api back30/talas5/webserviceMap/gisStationsMeasurementsSQL.js b/pages/api back30/talas5/webserviceMap/gisStationsMeasurementsSQL.js deleted file mode 100644 index de3670b6d..000000000 --- a/pages/api back30/talas5/webserviceMap/gisStationsMeasurementsSQL.js +++ /dev/null @@ -1,70 +0,0 @@ -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } - console.log("Database connected successfully."); -}); - -export default function handler(req, res) { - const idMap = req.query.idMap; - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - connection.query(` - SELECT - ld.idLD, - dp.idDP, - dp.name AS Na, - dp.value AS Val, - dp.unit AS Unit, - mg.name AS Gr, - ld.idLocation, - area.Name AS Area_Name - FROM location_device as ld - LEFT JOIN location_coordinates AS co ON ld.idLocation = co.idLocation and co.idMaps = ${idMap} - LEFT JOIN devices AS de ON de.idDevice = ld.idDevice - LEFT JOIN datapoint AS dp ON ld.idLD = dp.idLD - LEFT JOIN message_group AS mg ON dp.idmessage_group = mg.idmessage_group - LEFT JOIN location AS loc ON ld.idLocation = loc.idLocation - LEFT JOIN area AS area ON loc.idArea = area.idArea - WHERE co.X > 0 AND dp.idmessage_group>0 AND length(dp.unit)> 0 AND length(dp.value)> 0 - `, (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der gis_lines:", error); - return res - .status(500) - .json({ error: "Fehler beim Abrufen der gis_lines" }); - } - - const response = { - "Name": "Liste aller Messungen der Geraete", - "Zeitstempel": new Date().toISOString(), - "IdMap":idMap, - "Statis": results.map((row) => ({ - IdLD: row.idLD, - IdDP: row.idDP, - Na: row.Na, - Val: row.Val, - Unit: row.Unit, - Gr: row.Gr, - IdLocation: row.IdLocation, - Area_Name: row.Area_Name, - })), - }; - - res.json(response); - }); -} \ No newline at end of file diff --git a/pages/api back30/talas_v5_DB/gisLines/readGisLines.js b/pages/api back30/talas_v5_DB/gisLines/readGisLines.js deleted file mode 100644 index 7d8900a83..000000000 --- a/pages/api back30/talas_v5_DB/gisLines/readGisLines.js +++ /dev/null @@ -1,37 +0,0 @@ -// /pages/api/talas_v5_DB/gisLines/readGisLines.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } - //console.log("Database connected successfully."); -}); - -export default function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - const query = "SELECT * FROM talas_v5.gis_lines;"; - connection.query(query, (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der gis_lines:", error); - return res.status(500).json({ error: "Fehler beim Abrufen der gis_lines" }); - } - if (results.length > 0) { - res.json(results); - } else { - res.status(404).json({ error: "Gerät nicht gefunden" }); - } - }); -} diff --git a/pages/api back30/talas_v5_DB/gisLines/updateLineCoordinates.js b/pages/api back30/talas_v5_DB/gisLines/updateLineCoordinates.js deleted file mode 100644 index 48dfa36bc..000000000 --- a/pages/api back30/talas_v5_DB/gisLines/updateLineCoordinates.js +++ /dev/null @@ -1,61 +0,0 @@ -// /pages/api/talas_v5_DB/gisLines/updateLineCoordinates.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } - //console.log("Database connected successfully."); -}); - -export default function handler(req, res) { - if (req.method !== "POST") { - return res.status(405).json({ error: "Nur POST Methode erlaubt" }); - } - - const { idLD, idModul, newCoordinates } = req.body; - if (!idLD || !idModul || !newCoordinates) { - return res.status(400).json({ error: "Fehlende Daten" }); - } - - const newLineString = `LINESTRING(${newCoordinates.map((coord) => `${coord[0]} ${coord[1]}`).join(",")})`; - - const query = "UPDATE talas_v5.gis_lines SET points = ST_GeomFromText(?) WHERE idLD = ? AND idModul = ?;"; - - connection.beginTransaction((err) => { - if (err) { - throw err; - } - connection.query(query, [newLineString, idLD, idModul], (error, results, fields) => { - if (error) { - return connection.rollback(() => { - console.error("Fehler beim Aktualisieren der gis_lines:", error); - res.status(500).json({ error: "Fehler beim Aktualisieren der gis_lines" }); - }); - } - - connection.commit((err) => { - if (err) { - return connection.rollback(() => { - throw err; - }); - } - console.log("Transaction Complete."); - res.status(200).json({ - success: "Updated successfully.", - affectedRows: results.affectedRows, - }); - }); - }); - }); -} diff --git a/pages/api back30/talas_v5_DB/locationDevice/getDeviceId.js b/pages/api back30/talas_v5_DB/locationDevice/getDeviceId.js deleted file mode 100644 index fa373c80c..000000000 --- a/pages/api back30/talas_v5_DB/locationDevice/getDeviceId.js +++ /dev/null @@ -1,40 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/getDeviceId.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } -}); - -export default function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - const { deviceName } = req.query; - - const query = "SELECT idLD FROM location_device WHERE name = ?"; - connection.query(query, [deviceName], (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der Geräte-ID:", error); - return res - .status(500) - .json({ error: "Fehler beim Abrufen der Geräte-ID" }); - } - if (results.length > 0) { - res.json({ idLD: results[0].idLD }); - } else { - res.status(404).json({ error: "Gerät nicht gefunden" }); - } - }); -} diff --git a/pages/api back30/talas_v5_DB/locationDevice/locationDeviceNameById.js b/pages/api back30/talas_v5_DB/locationDevice/locationDeviceNameById.js deleted file mode 100644 index efccd89d9..000000000 --- a/pages/api back30/talas_v5_DB/locationDevice/locationDeviceNameById.js +++ /dev/null @@ -1,46 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/locationDeviceNameById.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } -}); - -export default async function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - const { idLD } = req.query; - - try { - const query = "SELECT name FROM location_device WHERE idLD = ?"; - const [results] = await new Promise((resolve, reject) => { - connection.query(query, [idLD], (error, results) => { - if (error) { - return reject(error); - } - resolve(results); - }); - }); - - if (results.length > 0) { - res.json({ name: results[0].name }); - } else { - res.status(404).json({ error: "Gerät nicht gefunden", idLD, results }); - } - } catch (error) { - console.error("Fehler beim Abrufen des Gerätenamens in locationDeviceNameById.js :", error); - res.status(500).json({ error: "Fehler beim Abrufen des Gerätenamens" }); - } -} diff --git a/pages/api back30/talas_v5_DB/locationDevice/locationDevices.js b/pages/api back30/talas_v5_DB/locationDevice/locationDevices.js deleted file mode 100644 index bfaf57654..000000000 --- a/pages/api back30/talas_v5_DB/locationDevice/locationDevices.js +++ /dev/null @@ -1,35 +0,0 @@ -// API in /api/talas_v5_DB/locationDevice/locationDevices.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } -}); - -export default function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const query = "SELECT * FROM location_device WHERE iddevice = 160"; - connection.query(query, (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der Geräteinformationen:", error); - return res - .status(500) - .json({ error: "Fehler beim Abrufen der Geräteinformationen" }); - } - res.json(results); - }); -} diff --git a/pages/api back30/talas_v5_DB/poiTyp/readPoiTyp.js b/pages/api back30/talas_v5_DB/poiTyp/readPoiTyp.js deleted file mode 100644 index 062c442cd..000000000 --- a/pages/api back30/talas_v5_DB/poiTyp/readPoiTyp.js +++ /dev/null @@ -1,33 +0,0 @@ -// pages/api/talas_v5_DB/poiTyp/readPoiTyp.js -import mysql from "mysql"; - -const pool = mysql.createPool({ - //connectionLimit: 10, - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}); - -export default function handler(req, res) { - if (req.method === "GET") { - const query = "SELECT * FROM poityp"; - - pool.query(query, (error, results) => { - if (error) { - console.error("Fehler beim Abfragen der Datenbank:", error); - return res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } - - if (results.length === 0) { - return res.status(404).json({ message: "Keine Einträge gefunden" }); - } - - res.status(200).json(results); - }); - } else { - res.setHeader("Allow", ["GET"]); - res.status(405).end(`Method ${req.method} Not Allowed`); - } -} diff --git a/pages/api back30/talas_v5_DB/pois/addLocation.js b/pages/api back30/talas_v5_DB/pois/addLocation.js deleted file mode 100644 index 118704d7d..000000000 --- a/pages/api back30/talas_v5_DB/pois/addLocation.js +++ /dev/null @@ -1,38 +0,0 @@ -// pages/api/talas_v5_DB/pois/addLocation.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -export default function handler(req, res) { - if (req.method === "POST") { - const { name, poiTypeId, latitude, longitude, idLD } = req.body; - console.log("Received data:", req.body); // Überprüfen der empfangenen Daten - const connection = mysql.createConnection(dbConfig); - - const query = - "INSERT INTO poi (description, idPoiTyp, position, idLD) VALUES (?, ?, ST_GeomFromText(?),?)"; - const point = `POINT(${longitude} ${latitude})`; - const values = [name, poiTypeId, point, idLD]; // Stellen Sie sicher, dass poiTypeId korrekt ist - - connection.query(query, values, (error, results) => { - connection.end(); - if (error) { - console.error("Fehler beim Einfügen des Standorts:", error); - return res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } - res.status(200).json({ - id: results.insertId, - message: "Standort erfolgreich hinzugefügt", - }); - }); - } else { - res.setHeader("Allow", ["POST"]); - res.status(405).end(`Method ${req.method} Not Allowed`); - } -} diff --git a/pages/api back30/talas_v5_DB/pois/deletePoi.js b/pages/api back30/talas_v5_DB/pois/deletePoi.js deleted file mode 100644 index 780a1b755..000000000 --- a/pages/api back30/talas_v5_DB/pois/deletePoi.js +++ /dev/null @@ -1,45 +0,0 @@ -// pages/api/talas_v5_DB/pois/deletePoi.js -import mysql from "mysql"; - -// Datenbankkonfiguration -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } - console.log("Verbunden als ID", connection.threadId); -}); - -export default function handler(req, res) { - if (req.method !== "DELETE") { - return res.status(405).json({ error: "Nur DELETE Methode erlaubt" }); - } - - const { id } = req.query; // ID aus der Anfrage holen - - if (!id) { - return res.status(400).json({ error: "POI ID ist erforderlich" }); - } - - const query = "DELETE FROM poi WHERE idPoi = ?"; - connection.query(query, [id], (error, results) => { - if (error) { - console.error("Fehler beim Löschen des POI 4:", error); - return res.status(500).json({ error: "Fehler beim Löschen des POI" }); - } - if (results.affectedRows > 0) { - res.json({ message: "POI erfolgreich gelöscht" }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - }); -} diff --git a/pages/api back30/talas_v5_DB/pois/getPoiById.js b/pages/api back30/talas_v5_DB/pois/getPoiById.js deleted file mode 100644 index 4ebf5b62c..000000000 --- a/pages/api back30/talas_v5_DB/pois/getPoiById.js +++ /dev/null @@ -1,42 +0,0 @@ -// pages/api/talas_v5_DB/pois/getPoiById.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -export default function handler(req, res) { - if (req.method === "GET") { - const { idPoi } = req.query; - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return res - .status(500) - .json({ error: "Verbindungsfehler zur Datenbank" }); - } - - const query = "SELECT description FROM poi WHERE idPoi = ?"; - connection.query(query, [idPoi], (error, results) => { - connection.end(); - if (error) { - console.error("Fehler bei der Abfrage:", error); - return res.status(500).json({ error: "Fehler bei der Abfrage" }); - } - if (results.length === 0) { - return res.status(404).json({ error: "POI nicht gefunden" }); - } - res.status(200).json(results[0]); - }); - }); - } else { - res.setHeader("Allow", ["GET"]); - res.status(405).end(`Method ${req.method} Not Allowed`); - } -} diff --git a/pages/api back30/talas_v5_DB/pois/poi-icons.js b/pages/api back30/talas_v5_DB/pois/poi-icons.js deleted file mode 100644 index ee092c226..000000000 --- a/pages/api back30/talas_v5_DB/pois/poi-icons.js +++ /dev/null @@ -1,42 +0,0 @@ -// pages/api/talas_v5_DB/pois/poi-icons.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); - -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } -}); - -export default function handler(req, res) { - if (req.method !== "GET") { - return res.status(405).json({ error: "Nur GET Methode erlaubt" }); - } - - const query = `SELECT p.idPoi, i.path - FROM poi p - JOIN poiTyp pt ON p.idPoiTyp = pt.idPoiTyp - JOIN poiicons i ON pt.icon = i.idpoiicons;`; - - connection.query(query, (error, results) => { - try { - if (error) { - throw error; - } - res.json(results); - } catch (err) { - console.error("Fehler beim Abrufen der icons:", err); - res.status(500).json({ error: "Fehler beim Abrufen der icons" }); - } - }); -} diff --git a/pages/api back30/talas_v5_DB/pois/readLocations.js b/pages/api back30/talas_v5_DB/pois/readLocations.js deleted file mode 100644 index 98a33cc88..000000000 --- a/pages/api back30/talas_v5_DB/pois/readLocations.js +++ /dev/null @@ -1,42 +0,0 @@ -// pages/api/talas_v5_DB/pois/readLocations.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; -//console.log("my dbconfig: ", dbConfig); -export default function handler(req, res) { - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - res.status(500).json({ error: "Verbindungsfehler zur Datenbank" }); - return; - } - - //console.log("Verbunden als ID", connection.threadId); - - connection.query("SELECT idPoi, description, idPoiTyp, idLD, ST_AsText(position) AS position FROM poi", (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - return; - } - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); - /* console.log( - "--------------- location.js ---------------", - "results in location.js : ", - results, - "---------------------- location.js end ---------------------------" - ); */ - connection.end(); - }); - }); -} diff --git a/pages/api back30/talas_v5_DB/pois/updateLocation.js b/pages/api back30/talas_v5_DB/pois/updateLocation.js deleted file mode 100644 index 625be5a75..000000000 --- a/pages/api back30/talas_v5_DB/pois/updateLocation.js +++ /dev/null @@ -1,39 +0,0 @@ -// pages/api/talas_v5_DB/pois/updateLocation.js -import mysql from "mysql"; -import util from "util"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, - charset: "utf8mb4", -}; - -export default async function handler(req, res) { - if (req.method !== "POST") { - res.setHeader("Allow", ["POST"]); - return res.status(405).end(`Method ${req.method} Not Allowed`); - } - - const { id, latitude, longitude } = req.body; - - const connection = mysql.createConnection(dbConfig); - // Promisify the query method - const query = util.promisify(connection.query).bind(connection); - - try { - await query("UPDATE poi SET position = POINT(?, ?) WHERE idPoi = ?", [ - longitude, - latitude, - id, - ]); - res.status(200).json({ success: true }); - } catch (error) { - console.error(error); - res.status(500).json({ error: "Ein Fehler ist aufgetreten" }); - } finally { - connection.end(); - } -} diff --git a/pages/api back30/talas_v5_DB/pois/updatePoi.js b/pages/api back30/talas_v5_DB/pois/updatePoi.js deleted file mode 100644 index 0eb9eeed3..000000000 --- a/pages/api back30/talas_v5_DB/pois/updatePoi.js +++ /dev/null @@ -1,46 +0,0 @@ -// pages/api/talas_v5_DB/pois/updatePoi.js -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; - -const connection = mysql.createConnection(dbConfig); -connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - return; - } - //console.log("Verbunden als ID", connection.threadId); -}); - -export default function handler(req, res) { - if (req.method !== "POST") { - return res.status(405).json({ error: "Nur POST Methode erlaubt" }); - } - - const { idPoi, description, idPoiTyp, idLD } = req.body; // Stellen Sie sicher, dass die Felder korrekt benannt sind - - //console.log("Empfangene Daten:", req.body); // Loggen der empfangenen Daten zur Überprüfung - - if (!idPoi) { - return res.status(400).json({ error: "POI ID ist erforderlich" }); - } - - const query = "UPDATE talas_v5.poi SET description = ?, idPoiTyp = ?, idLD = ? WHERE idPoi = ?"; - connection.query(query, [description, idPoiTyp, idLD, idPoi], (error, results) => { - if (error) { - console.error("Fehler beim Aktualisieren des POI:", error); - return res.status(500).json({ error: "Fehler beim Aktualisieren des POI" }); - } - if (results.affectedRows > 0) { - res.json({ message: "POI erfolgreich aktualisiert" }); - } else { - res.status(404).json({ error: "POI nicht gefunden" }); - } - }); -} diff --git a/pages/api back30/talas_v5_DB/priorityConfig.js b/pages/api back30/talas_v5_DB/priorityConfig.js deleted file mode 100644 index 06bfefe3d..000000000 --- a/pages/api back30/talas_v5_DB/priorityConfig.js +++ /dev/null @@ -1,40 +0,0 @@ -// pages/api/talas_v5_DB/priorityConfig.js -// in tals5 http://10.10.0.13/talas5/Management/PriorityConfig.aspx beinhaltet die Tabelle prio die Prioritäten der Meldungen (Level 1-4) oder (0-4) je nachdem DB-Design -// das ist die API, die die Prioritäten zurückgibt - -import mysql from "mysql"; - -const dbConfig = { - host: process.env.DB_HOST, - user: process.env.DB_USER, - password: process.env.DB_PASSWORD, - database: process.env.DB_NAME, - port: process.env.DB_PORT, -}; -//console.log("my dbconfig: ", dbConfig); -export default function handler(req, res) { - const connection = mysql.createConnection(dbConfig); - - connection.connect((err) => { - if (err) { - console.error("Fehler beim Verbinden:", err.stack); - res.status(500).json({ error: "Verbindungsfehler zur Datenbank" }); - return; - } - - //console.log("Verbunden als ID", connection.threadId); - //Fehler weil, existiertdie Tabelle auf localhost:3000 nicht - connection.query("SELECT idprio, level, name, color FROM prio ", (error, results) => { - if (error) { - console.error("Fehler beim Abrufen der API", error); - res.status(500).json({ error: "Fehler bei der Abfrage" }); - return; - } - - // Wichtig: Senden Sie die Antwort zurück - res.status(200).json(results); - - connection.end(); - }); - }); -} diff --git a/utils/createAndSetDevices.js b/utils/createAndSetDevices.js index 89b34f82d..e7e4236f3 100644 --- a/utils/createAndSetDevices.js +++ b/utils/createAndSetDevices.js @@ -1,3 +1,4 @@ +// /utils/createAndSetDevices.js import circleIcon from "../components/gisPolylines/icons/CircleIcon"; import { saveLineData, redrawPolyline } from "./mapUtils"; import L from "leaflet"; @@ -106,9 +107,18 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste ${station.Area_Short} (${station.Area_Name})
${station.Location_Short} (${station.Location_Name})
${statusInfo}
- ${BASE_URL}${station.Link} `); + /* marker.bindPopup(` +
+ ${station.LD_Name} + ${station.Device}
+ ${station.Area_Short} (${station.Area_Name})
+ ${station.Location_Short} (${station.Location_Name}) +
${statusInfo}
+ ${BASE_URL}${station.Link} +
+ `); */ return marker; }); From 094e27e1474b4574f022dace4ea783fcaff0bc7e Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 11:53:21 +0200 Subject: [PATCH 05/47] Version 1.0.1.5 delete linsColorApi.js because was mock file --- pages/api/linesColorApi.js | 64 -------------------------------------- pages/api/talas5/area.js | 7 ++++- 2 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 pages/api/linesColorApi.js diff --git a/pages/api/linesColorApi.js b/pages/api/linesColorApi.js deleted file mode 100644 index 57ee59262..000000000 --- a/pages/api/linesColorApi.js +++ /dev/null @@ -1,64 +0,0 @@ -// /pages/api/linesColorApi.js -// http://10.10.0.13/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict -//In DB gis_lines idLD und idModul anpassen entsprechend - -// /pages/api/linesColorApi.js -import NextCors from "nextjs-cors"; - -export default async function handler(req, res) { - // Run the cors middleware - await NextCors(req, res, { - // Options - methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], - origin: "*", // Erlauben Sie alle Ursprünge, oder geben Sie spezifische Ursprünge an - optionsSuccessStatus: 200, // Legacy-Browser-Unterstützung für 204 - }); - - const response = { - Name: "Liste aller Statis der Linien", - Zeitstempel: new Date().toISOString(), // Aktuellen Zeitstempel hinzufügen - IdMap: "10", - Statis: [ - /* { - IdLD: 50922, - Modul: 1, - DpName: "KUE01_Ausfall", - ModulName: "42 Wippershain Sender", - // ModulTyp: "nicht vorhanden", - ModulTyp: "KÜ705-FO", - Message: "KUEG 01: 42 Wippershain Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FFFF00", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 3, - DpName: "KUE03_Ausfall", - ModulName: "42 Solz Sender", - //ModulTyp: "nicht vorhanden", - ModulTyp: "KÜSS V2", - Message: "KUEG 03: 42 Solz Sender Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF0000", - PrioName: "system", - Value: "10 MOhm", - }, - { - IdLD: 25440, - Modul: 4, - DpName: "KUE04_Ausfall", - ModulName: "42/13 Bad Hersfeld Gaswerk", - ModulTyp: "Kue705-FO", - Message: "KUEG 04: 42/13 Bad Hersfeld Gaswerk Messwerkausfall kommend", - Level: 4, - PrioColor: "#FF00FF", - PrioName: "system", - Value: "10 MOhm", - }, */ - ], - }; - - res.status(200).json(response); -} diff --git a/pages/api/talas5/area.js b/pages/api/talas5/area.js index a9c399a52..69f571c97 100644 --- a/pages/api/talas5/area.js +++ b/pages/api/talas5/area.js @@ -4,16 +4,21 @@ import getPool from "../../utils/mysqlPool"; // Verwende den Singleton-Pool export default async function handler(req, res) { + let connection; + try { const pool = getPool(); // Hole den Pool + connection = await pool.getConnection(); // Hole die Verbindung // Führe die Abfrage aus - const [results] = await pool.query("SELECT id, name FROM area WHERE id = ?", [req.query.id]); + const [results] = await connection.query("SELECT id, name FROM area WHERE id = ?", [req.query.id]); // Sende die Antwort zurück res.status(200).json(results); } catch (error) { console.error("Fehler beim Abrufen der API", error); res.status(500).json({ error: "Fehler bei der Abfrage" }); + } finally { + if (connection) connection.release(); // Gib die Verbindung zurück in den Pool } } From 98e8bdf96e6181e5cb15431d90d313a744016d88 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 5 Sep 2024 15:26:42 +0200 Subject: [PATCH 06/47] Version 1.0.1.6 mysqlPool.js configuration is better, but can be better, check MySQL Workbench Connections --- utils/mysqlPool.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/utils/mysqlPool.js b/utils/mysqlPool.js index 266a6ecdf..80b5f98ef 100644 --- a/utils/mysqlPool.js +++ b/utils/mysqlPool.js @@ -1,5 +1,4 @@ import mysql from "mysql2/promise"; - // Variablen für den Singleton-Pool let cachedPool; let connectionCount = 0; // Zähler für die aktiven Verbindungen @@ -13,28 +12,41 @@ function getPool() { password: process.env.DB_PASSWORD, database: process.env.DB_NAME, port: process.env.DB_PORT, - connectionLimit: 10, // Setze ein Limit für gleichzeitige Verbindungen + connectionLimit: 20, // Setze ein Limit für gleichzeitige Verbindungen waitForConnections: true, - queueLimit: 0, // Unbegrenzte Warteschlange für Verbindungen + queueLimit: 10, // Warteschlangenlimit für Verbindungen + connectTimeout: 5000, // Timeout für Verbindungsversuche (5 Sekunden) + acquireTimeout: 10000, // Timeout für Verbindungsanforderungen aus dem Pool (10 Sekunden) + idleTimeout: 60000, // 1 Minute }); // Ereignisse für das Protokollieren der Verbindungsstatistiken cachedPool.on("acquire", () => { connectionCount++; - console.log("Connection acquired. Active connections: ", connectionCount); + console.log(`[ACQUIRE] Active connections: ${connectionCount}`); }); cachedPool.on("release", () => { connectionCount--; - console.log("Connection released. Active connections: ", connectionCount); + console.log(`[RELEASE] Active connections: ${connectionCount}`); }); cachedPool.on("enqueue", () => { - console.log("Waiting for available connection slot."); + console.log(`[ENQUEUE] Waiting for available connection slot.`); }); } return cachedPool; } +// Optionale Funktion zum Schließen aller Verbindungen im Pool (manuell aufzurufen) +export function closePool() { + if (cachedPool) { + cachedPool.end(() => { + console.log("All pool connections closed."); + }); + cachedPool = null; // Setze den Pool auf null, um sicherzustellen, dass er neu erstellt wird, falls benötigt. + } +} + export default getPool; From 6850fee16ae1905099ca0ffb94481f3a6609736f Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 6 Sep 2024 10:41:47 +0200 Subject: [PATCH 07/47] WIP: Add basic structure for edit mode to DataSheet.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Bearbeitungsmodus ist noch nicht vollständig, und es fehlen einige Funktionalitäten. Reduzierung der Datenbankanfragen noch in Arbeit. --- components/DataSheet.js | 20 +--- components/EditModeToggle.js | 26 +++++ components/MapComponent.js | 13 ++- components/imports.js | 162 -------------------------------- components/useMapContextMenu.js | 6 ++ pages/api/rights.js | 29 ------ services/apiService.js | 21 +++-- utils/createAndSetDevices.js | 6 ++ 8 files changed, 66 insertions(+), 217 deletions(-) create mode 100644 components/EditModeToggle.js delete mode 100644 components/imports.js delete mode 100644 pages/api/rights.js diff --git a/components/DataSheet.js b/components/DataSheet.js index baa9cf9cf..a7ce0cf92 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -1,4 +1,3 @@ -// components/DataSheet.js import React, { useEffect, useState } from "react"; import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil"; import { gisStationsStaticDistrictState } from "../store/atoms/gisStationState"; @@ -7,6 +6,7 @@ import { mapLayersState } from "../store/atoms/mapLayersState"; import { selectedAreaState } from "../store/atoms/selectedAreaState"; import { zoomTriggerState } from "../store/atoms/zoomTriggerState"; import { poiLayerVisibleState } from "../store/atoms/poiLayerVisibleState"; +import EditModeToggle from "./EditModeToggle"; function DataSheet() { const [poiVisible, setPoiVisible] = useRecoilState(poiLayerVisibleState); @@ -25,10 +25,7 @@ function DataSheet() { }; useEffect(() => { - console.log("GisStationsStaticDistrict:", GisStationsStaticDistrict); - console.log("GisSystemStatic:", GisSystemStatic); const allowedSystems = new Set(GisSystemStatic.filter((system) => system.Allow === 1).map((system) => system.IdSystem)); - console.log("allowedSystems:", allowedSystems); const seenNames = new Set(); const filteredAreas = GisStationsStaticDistrict.filter((item) => { @@ -45,7 +42,6 @@ function DataSheet() { name: area.Area_Name, })) ); - //console.log("filteredAreas:", filteredAreas); const seenSystemNames = new Set(); const filteredSystems = GisSystemStatic.filter((item) => { @@ -64,9 +60,6 @@ function DataSheet() { })) ); }, [GisStationsStaticDistrict, GisSystemStatic]); - //}, []); - //----------------------------------------- - //----------------------------------------- const handleCheckboxChange = (name, event) => { const { checked } = event.target; @@ -78,7 +71,6 @@ function DataSheet() { }; return newState; }); - console.log("mapLayersVisibility:", mapLayersVisibility); }; const handleIconClick = () => { @@ -90,12 +82,7 @@ function DataSheet() {
- {stationListing.map((station) => (
+
{systemListing.map((system) => ( @@ -128,6 +116,8 @@ function DataSheet() { POIs
+ +
); diff --git a/components/EditModeToggle.js b/components/EditModeToggle.js new file mode 100644 index 000000000..13c6860fd --- /dev/null +++ b/components/EditModeToggle.js @@ -0,0 +1,26 @@ +import React, { useState, useEffect } from "react"; + +function EditModeToggle() { + const [editMode, setEditMode] = useState(() => localStorage.getItem("editMode") === "true"); + + const toggleEditMode = () => { + const newEditMode = !editMode; + setEditMode(newEditMode); + localStorage.setItem("editMode", newEditMode); + //Browser neu laden, um die Änderungen anzuwenden + window.location.reload(); + }; + + useEffect(() => { + const storedMode = localStorage.getItem("editMode") === "true"; + setEditMode(storedMode); + }, []); + + return ( + + ); +} + +export default EditModeToggle; diff --git a/components/MapComponent.js b/components/MapComponent.js index 2f71d5c81..1989fc706 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -226,7 +226,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const rights = await fetchUserRights(); setUserRights(rights); setIsRightsLoaded(true); - setHasRights(rights && rights.includes(56)); // Prüfen, ob Benutzer die Rechte hat + + setHasRights(localStorage.getItem("editMode") && rights.includes(56)); // Prüfen, ob Benutzer die Rechte hat }; fetchAndSetUserRights(); @@ -235,8 +236,14 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { useGmaMarkersLayer(map, gmaMarkers, GisStationsMeasurements, layers.MAP_LAYERS.GMA, oms); // Verwende den ausgelagerten Hook useEffect(() => { - const fetchAllData = async () => { + const fetchWebServiceMap = async () => { try { + // Zähler für externe API-Aufrufe in localStorage speichern + let requestCount = localStorage.getItem("fetchWebServiceMap") || 0; + requestCount++; + localStorage.setItem("fetchWebServiceMap", requestCount); + console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + // Fetch GIS Stations Static District await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict); @@ -253,7 +260,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } }; - fetchAllData(); + fetchWebServiceMap(); }, []); //-------------------------------------------------------- useEffect(() => { diff --git a/components/imports.js b/components/imports.js deleted file mode 100644 index a81e36edb..000000000 --- a/components/imports.js +++ /dev/null @@ -1,162 +0,0 @@ -// imports.js -import React, { useEffect, useRef, useState, useCallback } from "react"; -import L, { marker } from "leaflet"; -import "leaflet/dist/leaflet.css"; -import "leaflet-contextmenu/dist/leaflet.contextmenu.css"; -import "leaflet-contextmenu"; -import * as config from "../config/config.js"; -import * as urls from "../config/urls.js"; -import "leaflet.smooth_marker_bouncing"; -import OverlappingMarkerSpiderfier from "overlapping-marker-spiderfier-leaflet"; -import DataSheet from "./DataSheet.js"; -import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil"; -import { gisStationsStaticDistrictState } from "../store/atoms/gisStationState.js"; -import { gisSystemStaticState } from "../store/atoms/gisSystemState.js"; -import { mapLayersState } from "../store/atoms/mapLayersState.js"; -import { selectedAreaState } from "../store/atoms/selectedAreaState.js"; -import { zoomTriggerState } from "../store/atoms/zoomTriggerState.js"; -import { poiTypState } from "../store/atoms/poiTypState.js"; -import AddPoiModalWindow from "./pois/AddPoiModalWindow.js"; -import { poiReadFromDbTriggerAtom } from "../store/atoms/poiReadFromDbTriggerAtom.js"; -import { InformationCircleIcon } from "@heroicons/react/20/solid"; // oder 'outline' -import PoiUpdateModal from "./pois/PoiUpdateModal.js"; -import { selectedPoiState } from "../store/atoms/poiState.js"; -import { currentPoiState } from "../store/atoms/currentPoiState.js"; -import { ToastContainer, toast } from "react-toastify"; -import "react-toastify/dist/ReactToastify.css"; -import { mapIdState, userIdState } from "../store/atoms/urlParameterState.js"; -import { poiLayerVisibleState } from "../store/atoms/poiLayerVisibleState.js"; -import plusRoundIcon from "./PlusRoundIcon.js"; -import { parsePoint, findClosestPoints } from "../utils/geometryUtils.js"; -import { insertNewPOI, removePOI, handleEditPoi } from "../utils/poiUtils.js"; -import { createAndSetDevices } from "../utils/createAndSetDevices.js"; -import { redrawPolyline, restoreMapSettings, checkOverlappingMarkers } from "../utils/mapUtils.js"; -import circleIcon from "./gisPolylines/icons/CircleIcon.js"; -import startIcon from "./gisPolylines/icons/StartIcon.js"; -import endIcon from "./gisPolylines/icons/EndIcon.js"; -import { fetchGisStatusStations, fetchPriorityConfig, fetchPoiData, updateLocationInDatabase, fetchUserRights, fetchDeviceNameById } from "../services/apiService.js"; -import { addContextMenuToMarker } from "../utils/addContextMenuToMarker.js"; -import { MAP_VERSION } from "../config/settings.js"; -import * as layers from "../config/layers.js"; -import { zoomIn, zoomOut, centerHere } from "../utils/zoomAndCenterUtils.js"; -import { initializeMap } from "../utils/initializeMap.js"; -import { addItemsToMapContextMenu } from "./useMapContextMenu.js"; -import useGmaMarkersLayer from "../hooks/layers/useGmaMarkersLayer.js"; // Import the custom hook -import useTalasMarkersLayer from "../hooks/layers/useTalasMarkersLayer.js"; // Import the custom hook -import useEciMarkersLayer from "../hooks/layers/useEciMarkersLayer.js"; -import useGsmModemMarkersLayer from "../hooks/layers/useGsmModemMarkersLayer.js"; -import useCiscoRouterMarkersLayer from "../hooks/layers/useCiscoRouterMarkersLayer.js"; -import useWagoMarkersLayer from "../hooks/layers/useWagoMarkersLayer.js"; -import useSiemensMarkersLayer from "../hooks/layers/useSiemensMarkersLayer.js"; -import useOtdrMarkersLayer from "../hooks/layers/useOtdrMarkersLayer.js"; -import useWdmMarkersLayer from "../hooks/layers/useWdmMarkersLayer.js"; -import useMessstellenMarkersLayer from "../hooks/layers/useMessstellenMarkersLayer.js"; -import useTalasiclMarkersLayer from "../hooks/layers/useTalasiclMarkersLayer.js"; -import useDauzMarkersLayer from "../hooks/layers/useDauzMarkersLayer.js"; -import useSmsfunkmodemMarkersLayer from "../hooks/layers/useSmsfunkmodemMarkersLayer.js"; -import useUlafMarkersLayer from "../hooks/layers/useUlafMarkersLayer.js"; -import useSonstigeMarkersLayer from "../hooks/layers/useSonstigeMarkersLayer.js"; -import handlePoiSelect from "../utils/handlePoiSelect.js"; -import { fetchGisStationsStaticDistrict, fetchGisStationsStatusDistrict, fetchGisStationsMeasurements, fetchGisSystemStatic } from "../services/fetchData.js"; -import { setupPolylines } from "../utils/setupPolylines.js"; -import { setupPOIs } from "../utils/setupPOIs.js"; -import VersionInfoModal from "./VersionInfoModal.js"; -//-------------------------------------------- -import PoiUpdateModalWrapper from "./pois/PoiUpdateModalWrapper"; -import AddPoiModalWindowWrapper from "./pois/AddPoiModalWindowWrapper"; -import useFetchPoiData from "../hooks/useFetchPoiData"; -import usePoiTypData from "../hooks/usePoiTypData"; -import useMarkerLayers from "../hooks/useMarkerLayers"; -import useLayerVisibility from "../hooks/useLayerVisibility"; -import useLineData from "../hooks/useLineData.js"; - -export { - React, - useEffect, - useRef, - useState, - useCallback, - L, - marker, - config, - urls, - OverlappingMarkerSpiderfier, - DataSheet, - useRecoilState, - useRecoilValue, - useSetRecoilState, - gisStationsStaticDistrictState, - gisSystemStaticState, - mapLayersState, - selectedAreaState, - zoomTriggerState, - poiTypState, - AddPoiModalWindow, - poiReadFromDbTriggerAtom, - InformationCircleIcon, - PoiUpdateModal, - selectedPoiState, - currentPoiState, - ToastContainer, - toast, - mapIdState, - userIdState, - poiLayerVisibleState, - plusRoundIcon, - parsePoint, - findClosestPoints, - insertNewPOI, - removePOI, - createAndSetDevices, - handleEditPoi, - redrawPolyline, - restoreMapSettings, - checkOverlappingMarkers, - circleIcon, - startIcon, - endIcon, - fetchGisStatusStations, - fetchPriorityConfig, - fetchPoiData, - updateLocationInDatabase, - fetchUserRights, - fetchDeviceNameById, - addContextMenuToMarker, - MAP_VERSION, - layers, - zoomIn, - zoomOut, - centerHere, - initializeMap, - addItemsToMapContextMenu, - useGmaMarkersLayer, - useTalasMarkersLayer, - useEciMarkersLayer, - useGsmModemMarkersLayer, - useCiscoRouterMarkersLayer, - useWagoMarkersLayer, - useSiemensMarkersLayer, - useOtdrMarkersLayer, - useWdmMarkersLayer, - useMessstellenMarkersLayer, - useTalasiclMarkersLayer, - useDauzMarkersLayer, - useSmsfunkmodemMarkersLayer, - useUlafMarkersLayer, - useSonstigeMarkersLayer, - handlePoiSelect, - fetchGisStationsStaticDistrict, - fetchGisStationsStatusDistrict, - fetchGisStationsMeasurements, - fetchGisSystemStatic, - setupPolylines, - setupPOIs, - VersionInfoModal, - PoiUpdateModalWrapper, - AddPoiModalWindowWrapper, - useFetchPoiData, - usePoiTypData, - useMarkerLayers, - useLayerVisibility, - useLineData, -}; diff --git a/components/useMapContextMenu.js b/components/useMapContextMenu.js index 13fe8a6a9..5af55fdb1 100644 --- a/components/useMapContextMenu.js +++ b/components/useMapContextMenu.js @@ -19,6 +19,8 @@ const showCoordinates = (e) => { }; // Kontextmenü Callback für "POI hinzufügen" const addStationCallback = (event, hasRights, setShowPopup, setPopupCoordinates) => { + const editMode = localStorage.getItem("editMode") === "true"; + hasRights = editMode ? hasRights : undefined; if (hasRights) { setPopupCoordinates(event.latlng); setShowPopup(true); @@ -36,6 +38,10 @@ const addStationCallback = (event, hasRights, setShowPopup, setPopupCoordinates) }; export const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, hasRights, setShowPopup, setPopupCoordinates) => { + // Überprüfe den Bearbeitungsmodus in localStorage + const editMode = localStorage.getItem("editMode") === "true"; + hasRights = editMode ? hasRights : undefined; + if (!menuItemAdded && map && map.contextmenu) { map.contextmenu.addItem({ text: "Koordinaten anzeigen", diff --git a/pages/api/rights.js b/pages/api/rights.js deleted file mode 100644 index 507228147..000000000 --- a/pages/api/rights.js +++ /dev/null @@ -1,29 +0,0 @@ -// pages/api/rights.js - -export default function handler(req, res) { - const { idMap, idUser } = req.query; - - // Beispielhafte Rechte, die je nach idMap und idUser variieren können - const rights = { - '10': [ - { IdRight: 1, Name: "Zugriff auf Dashboard" }, - { IdRight: 56, Name: "Erweiterte Berechtigungen" } - ], - '2': [ - { IdRight: 2, Name: "Zugriff auf Einstellungen" } - ], - '1': [ - { IdRight: 10, Name: "Admin-Zugriff" }, - { IdRight: 11, Name: "Zugriff auf alle Daten" } - ] - }; - - // Prüfung, ob eine gültige idMap und idUser vorhanden sind - if (rights[idMap] && idUser === '484') { - // Rückgabe der spezifischen Rechte basierend auf der idMap und idUser - res.status(200).json({ Rights: rights[idMap] }); - } else { - // Rückgabe leerer Rechte für ungültige idMap oder andere Benutzer - res.status(200).json({ Rights: [] }); - } -} diff --git a/services/apiService.js b/services/apiService.js index a7370613c..67c771f28 100644 --- a/services/apiService.js +++ b/services/apiService.js @@ -4,6 +4,13 @@ import * as urls from "../config/urls"; export const fetchGisStatusStations = async (idMap, idUser) => { const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; + + // Zähler für API-Aufrufe in localStorage speichern + let requestCount = localStorage.getItem("gisStatusStationsCount") || 0; + requestCount++; + localStorage.setItem("gisStatusStationsCount", requestCount); + console.log(`fetchGisStatusStations wurde ${requestCount} Mal aufgerufen.`); + try { const response = await fetch(`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`); if (!response.ok) { @@ -13,7 +20,6 @@ export const fetchGisStatusStations = async (idMap, idUser) => { prüfen oder nodeMap Dienst neu starten`); } const data = await response.json(); - //console.log("GisStatusStations:", data); return data; } catch (error) { console.error("Fehler beim Abrufen der Daten:", error); @@ -100,15 +106,19 @@ export const fetchDeviceNameById = async (idLD) => { // ---------------------------------------------- // services/apiService.js export const fetchUserRights = async () => { + // Zähler für API-Aufrufe in localStorage speichern + let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0; + userRightsRequestCount++; + localStorage.setItem("userRightsRequestCount", userRightsRequestCount); + console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); + try { - // const response = await fetch(`${urls.SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`); const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); - // console.log("Benutzerrechte in fetchRights:", data); // Überprüfen der Struktur der Antwort if (!data || !data.Rights || !Array.isArray(data.Rights)) { @@ -116,13 +126,8 @@ export const fetchUserRights = async () => { } const rightsArray = data.Rights; // Nehmen an, dass 'Rights' das Array von Rechten ist - //console.log("rightsArray in apiService:", rightsArray); - - // Speichert die IDs der Rechte in einem Array const userRightsIds = rightsArray.map((right) => right.IdRight); - // Wenn alles gut geht, logge die erfolgreichen Abschluss - // console.log("Benutzerrechte erfolgreich abgerufen:", userRightsIds); return userRightsIds; } catch (error) { console.error("Fehler beim Abrufen der Benutzerrechte", error); diff --git a/utils/createAndSetDevices.js b/utils/createAndSetDevices.js index e7e4236f3..268072ab9 100644 --- a/utils/createAndSetDevices.js +++ b/utils/createAndSetDevices.js @@ -21,6 +21,12 @@ const determinePriority = (iconPath, priorityConfig) => { // Funktion zum Erstellen und Setzen von Markern export const createAndSetDevices = async (systemId, setMarkersFunction, GisSystemStatic, priorityConfig) => { try { + // Zähler für externe API-Aufrufe in localStorage speichern + let requestCount = localStorage.getItem("gisStationsStaticRequestCount") || 0; + requestCount++; + localStorage.setItem("gisStationsStaticRequestCount", requestCount); + console.log(`config.mapGisStationsStaticDistrictUrl in createAndSetDevice wurde ${requestCount} Mal aufgerufen.`); + const response1 = await fetch(config.mapGisStationsStaticDistrictUrl); const jsonResponse = await response1.json(); const response2 = await fetch(config.mapGisStationsStatusDistrictUrl); From 861c9ead3d19ba8c7b9b8f6d36ebb1cdbfc0fefc Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 6 Sep 2024 10:55:14 +0200 Subject: [PATCH 08/47] Add counter for fetchWebServiceMap in MapComponent.js --- components/MapComponent.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 1989fc706..d51ded68f 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -240,21 +240,31 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { try { // Zähler für externe API-Aufrufe in localStorage speichern let requestCount = localStorage.getItem("fetchWebServiceMap") || 0; - requestCount++; - localStorage.setItem("fetchWebServiceMap", requestCount); - console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + requestCount = parseInt(requestCount, 10); // Fetch GIS Stations Static District await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict); + requestCount++; // Zähler erhöhen + localStorage.setItem("fetchWebServiceMap", requestCount); + console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Status District await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict); + requestCount++; // Zähler erhöhen + localStorage.setItem("fetchWebServiceMap", requestCount); + console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Measurements await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements); + requestCount++; // Zähler erhöhen + localStorage.setItem("fetchWebServiceMap", requestCount); + console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS System Static await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded); + requestCount++; // Zähler erhöhen + localStorage.setItem("fetchWebServiceMap", requestCount); + console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); } catch (error) { console.error("Error fetching data:", error); } @@ -262,6 +272,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { fetchWebServiceMap(); }, []); + //-------------------------------------------------------- useEffect(() => { const endpoint = "/api/talas_v5_DB/gisLines/readGisLines"; From af458ac27002c93ddbf461025b8d0deb6b365bfc Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 6 Sep 2024 11:25:32 +0200 Subject: [PATCH 09/47] Add editMode to poiUtils.js, setupPOIs.js and useMapContextMenu.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit editMode von localStorage lesen und Rechte vergeben oder entnehmen wenn die Schaltfläche "Bearbeitungsmodus aktivieren" --- utils/createAndSetDevices.js | 4 ++-- utils/poiUtils.js | 2 ++ utils/setupPOIs.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/createAndSetDevices.js b/utils/createAndSetDevices.js index 268072ab9..4849b8739 100644 --- a/utils/createAndSetDevices.js +++ b/utils/createAndSetDevices.js @@ -22,9 +22,9 @@ const determinePriority = (iconPath, priorityConfig) => { export const createAndSetDevices = async (systemId, setMarkersFunction, GisSystemStatic, priorityConfig) => { try { // Zähler für externe API-Aufrufe in localStorage speichern - let requestCount = localStorage.getItem("gisStationsStaticRequestCount") || 0; + let requestCount = localStorage.getItem("gisStationsStaticRequestCount-createDevice") || 0; requestCount++; - localStorage.setItem("gisStationsStaticRequestCount", requestCount); + localStorage.setItem("gisStationsStaticRequestCount-createDevice", requestCount); console.log(`config.mapGisStationsStaticDistrictUrl in createAndSetDevice wurde ${requestCount} Mal aufgerufen.`); const response1 = await fetch(config.mapGisStationsStaticDistrictUrl); diff --git a/utils/poiUtils.js b/utils/poiUtils.js index b3e23fd78..cd0ebca01 100644 --- a/utils/poiUtils.js +++ b/utils/poiUtils.js @@ -66,6 +66,8 @@ export const handleEditPoi = ( fetchPoiData, toast // Hier toast als Parameter erhalten ) => { + const editMode = localStorage.getItem("editMode") === "true"; + userRights = editMode ? userRights : undefined; //console.log("Selected Marker ID (idPoi):", marker.options.id); //console.log("Selected Marker Description:", marker.options.description); //console.log("User Rights:", userRights); diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 104b114c3..558941719 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -29,6 +29,8 @@ export const setupPOIs = async ( setCurrentPoiData, deviceName ) => { + const editMode = localStorage.getItem("editMode") === "true"; + userRights = editMode ? userRights : undefined; if (map && poiLayerRef.current) { map.removeLayer(poiLayerRef.current); poiLayerRef.current = new L.LayerGroup().addTo(map); From 04e50c30f8ac26f50598fdbe788f2e29fdfc1124 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 6 Sep 2024 14:08:39 +0200 Subject: [PATCH 10/47] feat: Implementierung des Bearbeitungsmodus --- components/PoiUtils.js | 7 +- components/pois/PoiUtils.js | 1 + utils/poiUtils.js | 1 + utils/setupPOIs.js | 1 + utils/setupPolylines.js | 184 +++++++++++++++++++++--------------- 5 files changed, 112 insertions(+), 82 deletions(-) diff --git a/components/PoiUtils.js b/components/PoiUtils.js index a66985054..065b52a65 100644 --- a/components/PoiUtils.js +++ b/components/PoiUtils.js @@ -23,6 +23,7 @@ export const addMarkersToMap = (markers, map, layerGroup) => { marker.on("mouseover", () => marker.openPopup()); marker.on("mouseout", () => marker.closePopup()); marker.on("dragend", (e) => { + console.log("Marker wurde verschoben in addMarkersToMap"); const newLat = e.target.getLatLng().lat; const newLng = e.target.getLatLng().lng; const markerId = e.target.options.id; @@ -32,11 +33,7 @@ export const addMarkersToMap = (markers, map, layerGroup) => { }; // Funktion zum Aktualisieren der Standorte in der Datenbank -export const updateLocationInDatabase = async ( - id, - newLatitude, - newLongitude -) => { +export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => { const response = await fetch("/api/talas_v5_DB/pois/updateLocation", { method: "POST", headers: { "Content-Type": "application/json" }, diff --git a/components/pois/PoiUtils.js b/components/pois/PoiUtils.js index 003145249..9275f95f1 100644 --- a/components/pois/PoiUtils.js +++ b/components/pois/PoiUtils.js @@ -24,6 +24,7 @@ export const addMarkersToMap = (markers, map, layerGroup) => { marker.on("mouseover", () => marker.openPopup()); marker.on("mouseout", () => marker.closePopup()); marker.on("dragend", (e) => { + console.log("Marker wurde verschoben in addMarkersToMap"); const newLat = e.target.getLatLng().lat; const newLng = e.target.getLatLng().lng; const markerId = e.target.options.id; diff --git a/utils/poiUtils.js b/utils/poiUtils.js index cd0ebca01..8348cbde6 100644 --- a/utils/poiUtils.js +++ b/utils/poiUtils.js @@ -20,6 +20,7 @@ export const insertNewPOI = (closestPoints, newPoint, lineData, map) => { // Event-Listener für das Verschieben des Markers hinzufügen newMarker.on("dragend", () => { + console.log("Marker wurde verschoben in insertNewPOI"); const newCoords = newMarker.getLatLng(); setNewCoords(newCoords); const newCoordinates = [...lineData.coordinates]; diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 558941719..0ecc86906 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -105,6 +105,7 @@ export const setupPOIs = async ( }); marker.on("dragend", (e) => { + console.log("Marker wurde verschoben in setupPOIs"); if (canDrag) { const newLat = e.target.getLatLng().lat; const newLng = e.target.getLatLng().lng; diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index dffd60b42..5981cef75 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -9,6 +9,7 @@ import startIcon from "../components/gisPolylines/icons/StartIcon"; import endIcon from "../components/gisPolylines/icons/EndIcon"; import { redrawPolyline } from "./mapUtils"; import { openInNewTab } from "./openInNewTab"; +import { toast } from "react-toastify"; // Funktion zum Deaktivieren der Polyline-Ereignisse export function disablePolylineEvents(polylines) { @@ -39,6 +40,7 @@ export function enablePolylineEvents(polylines, lineColors) { export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter) => { const markers = []; const polylines = []; + const editMode = localStorage.getItem("editMode") === "true"; // Prüfen, ob der Bearbeitungsmodus aktiv ist linePositions.forEach((lineData, lineIndex) => { const lineMarkers = []; @@ -51,96 +53,124 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, icon = endIcon; } - const marker = L.marker(coord, { - icon: icon, - draggable: true, - contextmenu: true, - contextmenuInheritItems: false, - contextmenuItems: [], - }).addTo(map); - - marker.on("dragend", () => { - const newCoords = marker.getLatLng(); - setNewCoords(newCoords); - const newCoordinates = [...lineData.coordinates]; - newCoordinates[index] = [newCoords.lat, newCoords.lng]; - - const updatedPolyline = L.polyline(newCoordinates, { - color: lineColors[`${lineData.idLD}-${lineData.idModul}`] || "#000000", + // Nur Marker mit circleIcon ausblenden, wenn Bearbeitungsmodus deaktiviert ist + if (icon !== circleIcon || editMode) { + const marker = L.marker(coord, { + icon: icon, + draggable: editMode, // Nur verschiebbar, wenn Bearbeitungsmodus aktiv ist + contextmenu: true, + contextmenuInheritItems: false, + contextmenuItems: [], }).addTo(map); - updatedPolyline.bindTooltip(tooltipContents[`${lineData.idLD}-${lineData.idModul}`] || "Standard-Tooltip-Inhalt", { - permanent: false, - direction: "auto", - }); + marker.on("dragend", () => { + console.log("Marker wurde verschoben in setupPolylines.js"); + if (editMode) { + const newCoords = marker.getLatLng(); + setNewCoords(newCoords); + const newCoordinates = [...lineData.coordinates]; + newCoordinates[index] = [newCoords.lat, newCoords.lng]; - updatedPolyline.on("mouseover", () => { - updatedPolyline.setStyle({ weight: 20 }); - updatedPolyline.bringToFront(); - }); + const updatedPolyline = L.polyline(newCoordinates, { + color: lineColors[`${lineData.idLD}-${lineData.idModul}`] || "#000000", + }).addTo(map); - updatedPolyline.on("mouseout", () => { - updatedPolyline.setStyle({ weight: 3 }); - }); + updatedPolyline.bindTooltip(tooltipContents[`${lineData.idLD}-${lineData.idModul}`] || "Standard-Tooltip-Inhalt", { + permanent: false, + direction: "auto", + }); - polylines[lineIndex].remove(); - polylines[lineIndex] = updatedPolyline; - lineData.coordinates = newCoordinates; + updatedPolyline.on("mouseover", () => { + updatedPolyline.setStyle({ weight: 20 }); + updatedPolyline.bringToFront(); + }); - const requestData = { - idModul: lineData.idModul, - idLD: lineData.idLD, - newCoordinates, - }; + updatedPolyline.on("mouseout", () => { + updatedPolyline.setStyle({ weight: 3 }); + }); - fetch("/api/talas_v5_DB/gisLines/updateLineCoordinates", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(requestData), - }) - .then((response) => { - if (!response.ok) { - return response.json().then((data) => { - throw new Error(data.error || "Unbekannter Fehler"); - }); - } - return response.json(); - }) - .then((data) => { - console.log("Koordinaten erfolgreich aktualisiert:", data); - }) - .catch((error) => { - console.error("Fehler beim Aktualisieren der Koordinaten:", error.message); - }); - }); + polylines[lineIndex].remove(); + polylines[lineIndex] = updatedPolyline; + lineData.coordinates = newCoordinates; - marker.on("mouseover", function () { - this.bindContextMenu({ - contextmenuItems: [ - { - text: "Stützpunkt entfernen", - icon: "/img/icons/gisLines/remove-support-point.svg", - callback: () => { - const newCoords = marker.getLatLng(); - const newCoordinates = [...lineData.coordinates]; - newCoordinates[index] = [newCoords.lat, newCoords.lng]; + const requestData = { + idModul: lineData.idModul, + idLD: lineData.idLD, + newCoordinates, + }; - removePOI(marker, lineData, currentZoom, currentCenter); - polylines[lineIndex].remove(); - lineData.coordinates = newCoordinates; + fetch("/api/talas_v5_DB/gisLines/updateLineCoordinates", { + method: "POST", + headers: { + "Content-Type": "application/json", }, - }, - ], + body: JSON.stringify(requestData), + }) + .then((response) => { + if (!response.ok) { + return response.json().then((data) => { + throw new Error(data.error || "Unbekannter Fehler"); + }); + } + return response.json(); + }) + .then((data) => { + console.log("Koordinaten erfolgreich aktualisiert:", data); + }) + .catch((error) => { + console.error("Fehler beim Aktualisieren der Koordinaten:", error.message); + }); + } else { + toast.error("Benutzer hat keine Berechtigung zum Bearbeiten.", { + position: "top-center", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + }); + } }); - }); - marker.on("mouseout", function () { - this.unbindContextMenu(); - }); + marker.on("mouseover", function () { + this.bindContextMenu({ + contextmenuItems: [ + { + text: "Stützpunkt entfernen", + icon: "/img/icons/gisLines/remove-support-point.svg", + callback: () => { + if (editMode) { + const newCoords = marker.getLatLng(); + const newCoordinates = [...lineData.coordinates]; + newCoordinates[index] = [newCoords.lat, newCoords.lng]; - lineMarkers.push(marker); + removePOI(marker, lineData, currentZoom, currentCenter); + polylines[lineIndex].remove(); + lineData.coordinates = newCoordinates; + } else { + toast.error("Benutzer hat keine Berechtigung zum Bearbeiten.", { + position: "top-center", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + }); + } + }, + }, + ], + }); + }); + + marker.on("mouseout", function () { + this.unbindContextMenu(); + }); + + lineMarkers.push(marker); + } }); const polyline = L.polyline(lineData.coordinates, { From e1b51f68021fad1ea82734d7ae0b70d3f73e6bc6 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 11:48:43 +0200 Subject: [PATCH 11/47] =?UTF-8?q?Kontextmen=C3=BC=20Item=20"POI=20Bearbeit?= =?UTF-8?q?en",=20"POI=20hinzuf=C3=BCgen"=20und=20"St=C3=BCtzpunkt=20hinzu?= =?UTF-8?q?f=C3=BCgen"=20ausblenden=20wenn=20localStorage=20Variable=20"ed?= =?UTF-8?q?itMode"=20false=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponent.js | 18 +- components/useMapContextMenu.js | 18 +- package-lock.json | 626 ++++++++++++++++++++++++++++++-- package.json | 7 +- services/apiService copy.js | 172 +++++++++ services/apiService.js | 68 +++- utils/setupPOIs.js | 45 +-- utils/setupPolylines.js | 35 +- 8 files changed, 886 insertions(+), 103 deletions(-) create mode 100644 services/apiService copy.js diff --git a/components/MapComponent.js b/components/MapComponent.js index d51ded68f..0d3db4781 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -227,7 +227,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { setUserRights(rights); setIsRightsLoaded(true); - setHasRights(localStorage.getItem("editMode") && rights.includes(56)); // Prüfen, ob Benutzer die Rechte hat + // Sicherstellen, dass `rights` ein Array ist, bevor `.includes()` aufgerufen wird + setHasRights(localStorage.getItem("editMode") && Array.isArray(rights) && rights.includes(56)); }; fetchAndSetUserRights(); @@ -242,26 +243,33 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { let requestCount = localStorage.getItem("fetchWebServiceMap") || 0; requestCount = parseInt(requestCount, 10); + const fetchOptions = { + method: "GET", + headers: { + Connection: "keep-alive", // Keep-Alive-Header hinzufügen + }, + }; + // Fetch GIS Stations Static District - await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict); + await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Status District - await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict); + await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Measurements - await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements); + await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS System Static - await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded); + await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); diff --git a/components/useMapContextMenu.js b/components/useMapContextMenu.js index 5af55fdb1..6a59bbf8e 100644 --- a/components/useMapContextMenu.js +++ b/components/useMapContextMenu.js @@ -69,14 +69,16 @@ export const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, h callback: (e) => centerHereCallback(e, map), }); - map.contextmenu.addItem({ separator: true }); - - map.contextmenu.addItem({ - text: "POI hinzufügen", - icon: "img/add_station.png", - className: "background-red", - callback: (event) => addStationCallback(event, hasRights, setShowPopup, setPopupCoordinates), - }); + // wenn localStorage Variable editMode true ist, dann wird der Button "POI hinzufügen" angezeigt + if (editMode) { + map.contextmenu.addItem({ separator: true }); + map.contextmenu.addItem({ + text: "POI hinzufügen", + icon: "img/add_station.png", + className: "background-red", + callback: (event) => addStationCallback(event, hasRights, setShowPopup, setPopupCoordinates), + }); + } setMenuItemAdded(true); } diff --git a/package-lock.json b/package-lock.json index 263df0364..2c403330d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,14 @@ { - "name": "04.09.2024 NodeMap", + "name": "09.09.2024 NodeMap", "lockfileVersion": 3, "requires": true, "packages": { "": { "dependencies": { + "@emotion/react": "^11.13.3", + "@emotion/styled": "^11.13.0", "@heroicons/react": "^2.1.5", + "@mui/icons-material": "^6.0.2", "autoprefixer": "^10.4.19", "dotenv": "^16.4.5", "http-proxy-middleware": "^3.0.0", @@ -75,7 +78,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", - "dev": true, "dependencies": { "@babel/highlight": "^7.24.7", "picocolors": "^1.0.0" @@ -127,7 +129,6 @@ "version": "7.25.0", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", - "dev": true, "dependencies": { "@babel/types": "^7.25.0", "@jridgewell/gen-mapping": "^0.3.5", @@ -250,7 +251,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", - "dev": true, "dependencies": { "@babel/traverse": "^7.24.7", "@babel/types": "^7.24.7" @@ -362,7 +362,6 @@ "version": "7.24.8", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -371,7 +370,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -416,7 +414,6 @@ "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", - "dev": true, "dependencies": { "@babel/helper-validator-identifier": "^7.24.7", "chalk": "^2.4.2", @@ -431,7 +428,6 @@ "version": "7.25.3", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.3.tgz", "integrity": "sha512-iLTJKDbJ4hMvFPgQwwsVoxtHyWpKKPBrxkANrSYewDPaPpT5py5yeVkgPIJ7XYXhndxJpaA3PyALSXQ7u8e/Dw==", - "dev": true, "dependencies": { "@babel/types": "^7.25.2" }, @@ -1801,7 +1797,6 @@ "version": "7.25.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", - "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -1813,7 +1808,6 @@ "version": "7.25.0", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.0.tgz", "integrity": "sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", "@babel/parser": "^7.25.0", @@ -1827,7 +1821,6 @@ "version": "7.25.3", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.3.tgz", "integrity": "sha512-HefgyP1x754oGCsKmV5reSmtV7IXj/kpaE1XYY+D9G5PvKKoFfSbiS4M77MdjuwlZKDIKFCffq9rPU+H/s3ZdQ==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", "@babel/generator": "^7.25.0", @@ -1845,7 +1838,6 @@ "version": "7.25.2", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.2.tgz", "integrity": "sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==", - "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", "@babel/helper-validator-identifier": "^7.24.7", @@ -1933,6 +1925,163 @@ "ms": "^2.1.1" } }, + "node_modules/@emotion/babel-plugin": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.12.0.tgz", + "integrity": "sha512-y2WQb+oP8Jqvvclh8Q55gLUyb7UFvgv7eJfsj7td5TToBrIUtPay2kMrZi4xjq9qw2vD0ZR5fSho0yqoFgX7Rw==", + "dependencies": { + "@babel/helper-module-imports": "^7.16.7", + "@babel/runtime": "^7.18.3", + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/serialize": "^1.2.0", + "babel-plugin-macros": "^3.1.0", + "convert-source-map": "^1.5.0", + "escape-string-regexp": "^4.0.0", + "find-root": "^1.1.0", + "source-map": "^0.5.7", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/babel-plugin/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" + }, + "node_modules/@emotion/babel-plugin/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@emotion/babel-plugin/node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@emotion/cache": { + "version": "11.13.1", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.13.1.tgz", + "integrity": "sha512-iqouYkuEblRcXmylXIwwOodiEK5Ifl7JcX7o6V4jI3iW4mLXX3dmt5xwBtIkJiQEXFAI+pC8X0i67yiPkH9Ucw==", + "dependencies": { + "@emotion/memoize": "^0.9.0", + "@emotion/sheet": "^1.4.0", + "@emotion/utils": "^1.4.0", + "@emotion/weak-memoize": "^0.4.0", + "stylis": "4.2.0" + } + }, + "node_modules/@emotion/hash": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.2.tgz", + "integrity": "sha512-MyqliTZGuOm3+5ZRSaaBGP3USLw6+EGykkwZns2EPC5g8jJ4z9OrdZY9apkl3+UP9+sdz76YYkwCKP5gh8iY3g==" + }, + "node_modules/@emotion/is-prop-valid": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.3.0.tgz", + "integrity": "sha512-SHetuSLvJDzuNbOdtPVbq6yMMMlLoW5Q94uDqJZqy50gcmAjxFkVqmzqSGEFq9gT2iMuIeKV1PXVWmvUhuZLlQ==", + "dependencies": { + "@emotion/memoize": "^0.9.0" + } + }, + "node_modules/@emotion/memoize": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.9.0.tgz", + "integrity": "sha512-30FAj7/EoJ5mwVPOWhAyCX+FPfMDrVecJAM+Iw9NRoSl4BBAQeqj4cApHHUXOVvIPgLVDsCFoz/hGD+5QQD1GQ==" + }, + "node_modules/@emotion/react": { + "version": "11.13.3", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.13.3.tgz", + "integrity": "sha512-lIsdU6JNrmYfJ5EbUCf4xW1ovy5wKQ2CkPRM4xogziOxH1nXxBSjpC9YqbFAP7circxMfYp+6x676BqWcEiixg==", + "dependencies": { + "@babel/runtime": "^7.18.3", + "@emotion/babel-plugin": "^11.12.0", + "@emotion/cache": "^11.13.0", + "@emotion/serialize": "^1.3.1", + "@emotion/use-insertion-effect-with-fallbacks": "^1.1.0", + "@emotion/utils": "^1.4.0", + "@emotion/weak-memoize": "^0.4.0", + "hoist-non-react-statics": "^3.3.1" + }, + "peerDependencies": { + "react": ">=16.8.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@emotion/serialize": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.3.1.tgz", + "integrity": "sha512-dEPNKzBPU+vFPGa+z3axPRn8XVDetYORmDC0wAiej+TNcOZE70ZMJa0X7JdeoM6q/nWTMZeLpN/fTnD9o8MQBA==", + "dependencies": { + "@emotion/hash": "^0.9.2", + "@emotion/memoize": "^0.9.0", + "@emotion/unitless": "^0.10.0", + "@emotion/utils": "^1.4.0", + "csstype": "^3.0.2" + } + }, + "node_modules/@emotion/sheet": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.4.0.tgz", + "integrity": "sha512-fTBW9/8r2w3dXWYM4HCB1Rdp8NLibOw2+XELH5m5+AkWiL/KqYX6dc0kKYlaYyKjrQ6ds33MCdMPEwgs2z1rqg==" + }, + "node_modules/@emotion/styled": { + "version": "11.13.0", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.13.0.tgz", + "integrity": "sha512-tkzkY7nQhW/zC4hztlwucpT8QEZ6eUzpXDRhww/Eej4tFfO0FxQYWRyg/c5CCXa4d/f174kqeXYjuQRnhzf6dA==", + "dependencies": { + "@babel/runtime": "^7.18.3", + "@emotion/babel-plugin": "^11.12.0", + "@emotion/is-prop-valid": "^1.3.0", + "@emotion/serialize": "^1.3.0", + "@emotion/use-insertion-effect-with-fallbacks": "^1.1.0", + "@emotion/utils": "^1.4.0" + }, + "peerDependencies": { + "@emotion/react": "^11.0.0-rc.0", + "react": ">=16.8.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@emotion/unitless": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.10.0.tgz", + "integrity": "sha512-dFoMUuQA20zvtVTuxZww6OHoJYgrzfKM1t52mVySDJnMSEa08ruEvdYQbhvyu6soU+NeLVd3yKfTfT0NeV6qGg==" + }, + "node_modules/@emotion/use-insertion-effect-with-fallbacks": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.1.0.tgz", + "integrity": "sha512-+wBOcIV5snwGgI2ya3u99D7/FJquOIniQT1IKyDsBmEgwvpxMNeS65Oib7OnE2d2aY+3BU4OiH+0Wchf8yk3Hw==", + "peerDependencies": { + "react": ">=16.8.0" + } + }, + "node_modules/@emotion/utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.4.0.tgz", + "integrity": "sha512-spEnrA1b6hDR/C68lC2M7m6ALPUHZC0lIY7jAS/B/9DuuO1ZP04eov8SMv/6fwRd8pzmsn2AuJEznRREWlQrlQ==" + }, + "node_modules/@emotion/weak-memoize": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", + "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==" + }, "node_modules/@heroicons/react": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.5.tgz", @@ -2797,6 +2946,245 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mui/core-downloads-tracker": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-6.0.2.tgz", + "integrity": "sha512-Cg68oOlAfbJgMgvbCwcX3Y3HdygCl6X1nREYTdEWcEKUQhNarrC45Cc35mP+zA7p3ZXE/7FLiaTCCgwuSoef/Q==", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + } + }, + "node_modules/@mui/icons-material": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-6.0.2.tgz", + "integrity": "sha512-WaTPSvKcx8X7NdWAHzJWDZv+YXvK0MUY8+JI/r4/q2GgIa5RW+n4+08CGX6jB7sWhU1R3zy28NfsDUwwQjOThw==", + "dependencies": { + "@babel/runtime": "^7.25.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@mui/material": "^6.0.2", + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/material": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-6.0.2.tgz", + "integrity": "sha512-KrnkJFSyhsAh8V30DNUbWyRyxMi4ZHjFg1ikQGx+mUAIffFTYIEx9Q+Kxd3vCT0FUFGOmbsuh6F6yRhpybsjkg==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.25.0", + "@mui/core-downloads-tracker": "^6.0.2", + "@mui/system": "^6.0.2", + "@mui/types": "^7.2.16", + "@mui/utils": "^6.0.2", + "@popperjs/core": "^2.11.8", + "@types/react-transition-group": "^4.4.11", + "clsx": "^2.1.1", + "csstype": "^3.1.3", + "prop-types": "^15.8.1", + "react-is": "^18.3.1", + "react-transition-group": "^4.4.5" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@mui/material-pigment-css": "^6.0.2", + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@mui/material-pigment-css": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/material/node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "peer": true + }, + "node_modules/@mui/private-theming": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-6.0.2.tgz", + "integrity": "sha512-emddFcRhA0hPGVIwIbW5g0V8vtCgw2g/H/A7jTdGe7dpCWEPpp6jPIXRRKcEUWgmg91R6rBNfV+LFHxBxmZXOQ==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.25.0", + "@mui/utils": "^6.0.2", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/styled-engine": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-6.0.2.tgz", + "integrity": "sha512-qd3Vlhted0SYVGotnCfVNcxff7vW2WN0fclbAexff60NeNS1qs/H/CImHEHUBiUGeNWMPRochbN6VF1arQ7/jA==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.25.0", + "@emotion/cache": "^11.13.1", + "csstype": "^3.1.3", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.4.1", + "@emotion/styled": "^11.3.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + } + } + }, + "node_modules/@mui/system": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-6.0.2.tgz", + "integrity": "sha512-AZv1/C4PuHgWFTA8YraIzl3FTVLdRz0RIMRwEADWZBdIhnuTHS/4+r8qE9+3CcpTHg1WsEu8btaO3AhQahSM9A==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.25.0", + "@mui/private-theming": "^6.0.2", + "@mui/styled-engine": "^6.0.2", + "@mui/types": "^7.2.16", + "@mui/utils": "^6.0.2", + "clsx": "^2.1.1", + "csstype": "^3.1.3", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/types": { + "version": "7.2.16", + "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.16.tgz", + "integrity": "sha512-qI8TV3M7ShITEEc8Ih15A2vLzZGLhD+/UPNwck/hcls2gwg7dyRjNGXcQYHKLB5Q7PuTRfrTkAoPa2VV1s67Ag==", + "peer": true, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/utils": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-6.0.2.tgz", + "integrity": "sha512-TeFrYsxcmeoDSlkoPhX+LjIuuqC5Pyj+xz2kRceKCkUpwMNTEeVOfowXDPe+mboZwmpJ5ZxP4eiAgQMdeEasjg==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.25.0", + "@mui/types": "^7.2.16", + "@types/prop-types": "^15.7.12", + "clsx": "^2.1.1", + "prop-types": "^15.8.1", + "react-is": "^18.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/utils/node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "peer": true + }, "node_modules/@next/env": { "version": "14.2.5", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.5.tgz", @@ -2978,6 +3366,16 @@ "node": ">=14" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3376,6 +3774,36 @@ "undici-types": "~6.11.1" } }, + "node_modules/@types/parse-json": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", + "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==" + }, + "node_modules/@types/prop-types": { + "version": "15.7.12", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", + "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==", + "peer": true + }, + "node_modules/@types/react": { + "version": "18.3.5", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.5.tgz", + "integrity": "sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==", + "peer": true, + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-transition-group": { + "version": "4.4.11", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.11.tgz", + "integrity": "sha512-RM05tAniPZ5DZPzzNFP+DmrcOdD0efDUxMy3145oljWSl3x9ZV5vhme98gTxFrj2lhXvmGNnUiuDyJgY9IKkNA==", + "peer": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/sinonjs__fake-timers": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.1.tgz", @@ -3737,7 +4165,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -4034,6 +4461,20 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/babel-plugin-macros": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", + "integrity": "sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==", + "dependencies": { + "@babel/runtime": "^7.12.5", + "cosmiconfig": "^7.0.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">=10", + "npm": ">=6" + } + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.11", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz", @@ -4329,7 +4770,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, "engines": { "node": ">=6" } @@ -4380,7 +4820,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -4572,7 +5011,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -4580,8 +5018,7 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, "node_modules/colorette": { "version": "2.0.20", @@ -4660,6 +5097,29 @@ "node": ">= 0.10" } }, + "node_modules/cosmiconfig": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", + "integrity": "sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==", + "dependencies": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.2.1", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.10.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "engines": { + "node": ">= 6" + } + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -4856,6 +5316,11 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", "dev": true }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, "node_modules/cypress": { "version": "13.14.2", "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.14.2.tgz", @@ -5230,6 +5695,16 @@ "dev": true, "peer": true }, + "node_modules/dom-helpers": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", + "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.8.7", + "csstype": "^3.0.2" + } + }, "node_modules/domexception": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", @@ -5352,7 +5827,6 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, "dependencies": { "is-arrayish": "^0.2.1" } @@ -5397,7 +5871,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, "engines": { "node": ">=0.8.0" } @@ -5735,6 +6208,11 @@ "node": ">=8" } }, + "node_modules/find-root": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==" + }, "node_modules/find-up": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", @@ -6033,7 +6511,6 @@ "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, "engines": { "node": ">=4" } @@ -6070,7 +6547,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, "engines": { "node": ">=4" } @@ -6122,6 +6598,19 @@ "node": ">= 0.4" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/hoist-non-react-statics/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -6262,6 +6751,29 @@ } ] }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-fresh/node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "engines": { + "node": ">=4" + } + }, "node_modules/import-local": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", @@ -6327,8 +6839,7 @@ "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, "node_modules/is-binary-path": { "version": "2.1.0", @@ -8567,7 +9078,6 @@ "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, "bin": { "jsesc": "bin/jsesc" }, @@ -8578,8 +9088,7 @@ "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", - "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", - "dev": true + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" }, "node_modules/json-schema": { "version": "0.4.0", @@ -9532,11 +10041,21 @@ "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==" }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", @@ -9613,6 +10132,14 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "engines": { + "node": ">=8" + } + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -9889,6 +10416,23 @@ "node": ">= 6" } }, + "node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "peer": true, + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/prop-types/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "peer": true + }, "node_modules/proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", @@ -10048,6 +10592,22 @@ "react-dom": ">=18" } }, + "node_modules/react-transition-group": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", + "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", + "peer": true, + "dependencies": { + "@babel/runtime": "^7.5.5", + "dom-helpers": "^5.0.1", + "loose-envify": "^1.4.0", + "prop-types": "^15.6.2" + }, + "peerDependencies": { + "react": ">=16.6.0", + "react-dom": ">=16.6.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -10134,8 +10694,7 @@ "node_modules/regenerator-runtime": { "version": "0.14.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "dev": true + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, "node_modules/regenerator-transform": { "version": "0.15.2", @@ -10736,6 +11295,11 @@ } } }, + "node_modules/stylis": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" + }, "node_modules/sucrase": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", @@ -10802,7 +11366,6 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "dependencies": { "has-flag": "^3.0.0" }, @@ -11053,7 +11616,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, "engines": { "node": ">=4" } diff --git a/package.json b/package.json index 8fd52eb51..971c1fc6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "dependencies": { + "@emotion/react": "^11.13.3", + "@emotion/styled": "^11.13.0", "@heroicons/react": "^2.1.5", + "@mui/icons-material": "^6.0.2", "autoprefixer": "^10.4.19", "dotenv": "^16.4.5", "http-proxy-middleware": "^3.0.0", @@ -25,8 +28,8 @@ "start": "next start", "export": "next export", "test": "jest", - "cypress": "cypress open", - "cypress:run": "cypress run" + "cypress": "cypress open", + "cypress:run": "cypress run" }, "devDependencies": { "@babel/core": "^7.25.2", diff --git a/services/apiService copy.js b/services/apiService copy.js new file mode 100644 index 000000000..aef459476 --- /dev/null +++ b/services/apiService copy.js @@ -0,0 +1,172 @@ +// services/apiService.js +import * as config from "../config/config"; +import * as urls from "../config/urls"; + +let timeoutId; + +const fetchWithTimeout = async (url, options, timeout = 5000) => { + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); + + try { + const response = await fetch(url, { + ...options, + signal: controller.signal, + }); + clearTimeout(id); + return response; + } catch (error) { + clearTimeout(id); // Im Falle eines Fehlers den Timeout abbrechen + throw error; + } +}; + +export const fetchGisStatusStations = async (idMap, idUser) => { + // Verhindere wiederholte schnelle API-Aufrufe durch Debouncing + if (timeoutId) { + clearTimeout(timeoutId); + } + + timeoutId = setTimeout(async () => { + const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; + + try { + // Verwende das Timeout für die API-Anfrage + const response = await fetchWithTimeout( + `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, + null, + 5000 // Timeout auf 5 Sekunden gesetzt + ); + + if (!response.ok) { + throw new Error(`Error: ${response.statusText}`); + } + + const data = await response.json(); + return data; + } catch (error) { + console.error("Fehler beim Abrufen der Daten:", error); + throw error; + } + }, 500); // Debounce-Zeit auf 500ms gesetzt +}; + +// ---------------------------------------------- +/* export const fetchPriorityConfig = async () => { + try { + const response = await fetch("/api/talas_v5_DB/priorityConfig"); + const data = await response.json(); + console.log("Prioritätskonfiguration:", data); + setPriorityConfig(data); + } catch (error) { + console.error("Fehler beim Laden der Prioritätskonfiguration:", error); + } +}; */ + +// ---------------------------------------------- +export const fetchPoiData = async (idPoi) => { + try { + const response = await fetch(`/api/talas_v5_DB/pois/getPoiById?idPoi=${idPoi}`); + if (!response.ok) { + throw new Error("Fehler beim Abrufen der POI-Daten"); + } + const data = await response.json(); + return { + idPoi, + name: data.name, + description: data.description, + }; + } catch (error) { + console.error("Fehler beim Abrufen der POI-Daten", error); + return null; + } +}; +// ---------------------------------------------- +// Funktion zum Aktualisieren der Position in der Datenbank +export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => { + const response = await fetch("/api/talas_v5_DB/pois/updateLocation", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id, + latitude: newLatitude, + longitude: newLongitude, + }), + }); + + if (response.ok) { + //schreib die neue Kooridnaten in die Console + //akuellisiere die Position in der Datenbank mit den neuen Koordinaten mit updateLocation mit SQL Anweisung UPDATE + } else { + console.error("Fehler beim Aktualisieren der Position"); + } +}; + +// ---------------------------------------------- +// Funktionen zur Überwachung der Internetverbindung +export const checkInternet = () => { + fetch("https://tile.openstreetmap.org/1/1/1.png", { method: "HEAD" }) + .then((response) => setOnline(response.ok)) + .catch(() => setOnline(false)); +}; + +// ---------------------------------------------- +export const fetchDeviceNameById = async (idLD) => { + try { + const response = await fetch(`/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`); + const data = await response.json(); + if (response.ok) { + return data.name; + } else { + //throw new Error(data.error || "Gerät nicht gefunden"); + throw new Error("Gerät nicht gefunden in apiService.js"); + } + } catch (error) { + console.error("Fehler beim Abrufen des Gerätenamens in apiService.js:", error); + return "Unbekannt"; + } +}; + +// ---------------------------------------------- +// services/apiService.js +export const fetchUserRights = async () => { + // Zähler für API-Aufrufe in localStorage speichern + let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0; + userRightsRequestCount++; + localStorage.setItem("userRightsRequestCount", userRightsRequestCount); + console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); + + // Debouncing, um wiederholte schnelle API-Aufrufe zu verhindern + if (timeoutId) { + clearTimeout(timeoutId); // Falls innerhalb der Debounce-Zeit wieder ein Aufruf erfolgt, wird der alte abgebrochen + } + + timeoutId = setTimeout(async () => { + try { + const response = await fetchWithTimeout( + `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, + null, + 5000 // Timeout für die API-Anfrage auf 5 Sekunden gesetzt + ); + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const data = await response.json(); + + // Überprüfen der Struktur der Antwort + if (!data || !data.Rights || !Array.isArray(data.Rights)) { + throw new Error("Invalid response structure"); + } + + const rightsArray = data.Rights; // Nehmen an, dass 'Rights' das Array von Rechten ist + const userRightsIds = rightsArray.map((right) => right.IdRight); + + return userRightsIds; + } catch (error) { + console.error("Fehler beim Abrufen der Benutzerrechte", error); + return []; + } + }, 500); // Debounce-Zeit auf 500 ms gesetzt +}; diff --git a/services/apiService.js b/services/apiService.js index 67c771f28..db8bc9f15 100644 --- a/services/apiService.js +++ b/services/apiService.js @@ -2,31 +2,55 @@ import * as config from "../config/config"; import * as urls from "../config/urls"; -export const fetchGisStatusStations = async (idMap, idUser) => { - const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; +let timeoutId; - // Zähler für API-Aufrufe in localStorage speichern - let requestCount = localStorage.getItem("gisStatusStationsCount") || 0; - requestCount++; - localStorage.setItem("gisStatusStationsCount", requestCount); - console.log(`fetchGisStatusStations wurde ${requestCount} Mal aufgerufen.`); +const fetchWithTimeout = async (url, options, timeout = 5000) => { + const controller = new AbortController(); + const id = setTimeout(() => controller.abort(), timeout); try { - const response = await fetch(`${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`); - if (!response.ok) { - throw new Error(`Error: ${response.statusText} - MySQL Datenbankverbindung fehlgeschlagen! - MySQL-Mode: SET GLOBAL sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'; - prüfen oder nodeMap Dienst neu starten`); - } - const data = await response.json(); - return data; + const response = await fetch(url, { + ...options, + signal: controller.signal, + }); + clearTimeout(id); + return response; } catch (error) { - console.error("Fehler beim Abrufen der Daten:", error); - throw error; // Fehler weiter werfen, um ihn in der Komponente behandeln zu können + clearTimeout(id); // Im Falle eines Fehlers den Timeout abbrechen + throw error; } }; +export const fetchGisStatusStations = async (idMap, idUser) => { + // Verhindere wiederholte schnelle API-Aufrufe durch Debouncing + if (timeoutId) { + clearTimeout(timeoutId); + } + + timeoutId = setTimeout(async () => { + const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; + + try { + // Verwende das Timeout für die API-Anfrage + const response = await fetchWithTimeout( + `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, + null, + 5000 // Timeout auf 5 Sekunden gesetzt + ); + + if (!response.ok) { + throw new Error(`Error: ${response.statusText}`); + } + + const data = await response.json(); + return data; + } catch (error) { + console.error("Fehler beim Abrufen der Daten:", error); + throw error; + } + }, 500); // Debounce-Zeit auf 500ms gesetzt +}; + // ---------------------------------------------- /* export const fetchPriorityConfig = async () => { try { @@ -113,7 +137,13 @@ export const fetchUserRights = async () => { console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); try { - const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`); + const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, { + method: "GET", + headers: { + Connection: "keep-alive", // Keep-Alive Header hinzufügen + }, + }); + if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 0ecc86906..8d153cd3b 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -29,8 +29,9 @@ export const setupPOIs = async ( setCurrentPoiData, deviceName ) => { - const editMode = localStorage.getItem("editMode") === "true"; - userRights = editMode ? userRights : undefined; + const editMode = localStorage.getItem("editMode") === "true"; // Prüfen, ob der Bearbeitungsmodus aktiv ist + userRights = editMode ? userRights : undefined; // Nur Berechtigungen anwenden, wenn editMode true ist + if (map && poiLayerRef.current) { map.removeLayer(poiLayerRef.current); poiLayerRef.current = new L.LayerGroup().addTo(map); @@ -55,25 +56,30 @@ export const setupPOIs = async ( name: location.name, description: location.description, link: location.link, - }).bindContextMenu({ - contextmenu: true, - contextmenuWidth: 140, - contextmenuItems: [ - { - text: "POI Bearbeiten", - icon: "/img/poi-edit.png", - callback: () => handleEditPoi(marker, userRights, setCurrentPoiData, setShowPoiUpdateModal, fetchPoiData, toast), - }, - ], }); + // Nur das Kontextmenü "POI Bearbeiten" hinzufügen, wenn editMode true ist + if (editMode) { + marker.bindContextMenu({ + contextmenu: true, + contextmenuWidth: 140, + contextmenuItems: [ + { + text: "POI Bearbeiten", + icon: "/img/poi-edit.png", + callback: () => handleEditPoi(marker, userRights, setCurrentPoiData, setShowPoiUpdateModal, fetchPoiData, toast), + }, + ], + }); + } + marker.bindPopup(` -
- ${location.description || "Unbekannt"}
- ${deviceName}
- ${poiTypName}
-
- `); +
+ ${location.description || "Unbekannt"}
+ ${deviceName}
+ ${poiTypName}
+
+ `); marker.on("mouseover", function () { handlePoiSelect( @@ -93,9 +99,6 @@ export const setupPOIs = async ( setCurrentPoi(location); this.openPopup(); - // Deaktiviere Polyline-Ereignisse beim Öffnen des Kontextmenüs des Markers - //disablePolylineEvents(window.polylines); - localStorage.setItem("lastElementType", "marker"); localStorage.setItem("markerLink", this.options.link); }); diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index 5981cef75..d3a7cce18 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -177,24 +177,27 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, color: lineColors[`${lineData.idLD}-${lineData.idModul}`] || "#000000", weight: 3, contextmenu: true, - contextmenuItems: [ - { - text: "Stützpunkt hinzufügen", - icon: "/img/icons/gisLines/add-support-point.svg", - callback: (e) => { - if (tempMarker) { - tempMarker.remove(); - } - const newPoint = e.latlng; - const closestPoints = findClosestPoints(lineData.coordinates, newPoint, map); - insertNewPOI(closestPoints, newPoint, lineData, map); - redrawPolyline(lineData, lineColors, tooltipContents, map); - window.location.reload(); - }, - }, - ], + contextmenuItems: [], }).addTo(map); + // Füge "Stützpunkt hinzufügen" nur hinzu, wenn editMode aktiv ist + if (editMode) { + polyline.options.contextmenuItems.push({ + text: "Stützpunkt hinzufügen", + icon: "/img/icons/gisLines/add-support-point.svg", + callback: (e) => { + if (tempMarker) { + tempMarker.remove(); + } + const newPoint = e.latlng; + const closestPoints = findClosestPoints(lineData.coordinates, newPoint, map); + insertNewPOI(closestPoints, newPoint, lineData, map); + redrawPolyline(lineData, lineColors, tooltipContents, map); + window.location.reload(); + }, + }); + } + // Hier wird der Tooltip hinzugefügt polyline.bindTooltip(tooltipContents[`${lineData.idLD}-${lineData.idModul}`] || "Standard-Tooltip-Inhalt", { permanent: false, From ae803bdc50a05f4cec11f5b6612aa5e0f5aaf008 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 12:09:03 +0200 Subject: [PATCH 12/47] Added tooltips to EditModeToggle icons and adjusted tooltip positioning using Material-UI --- components/DataSheet.js | 3 +-- components/EditModeToggle.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/DataSheet.js b/components/DataSheet.js index a7ce0cf92..cc9ab003a 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -90,6 +90,7 @@ function DataSheet() { ))} + Expand @@ -116,8 +117,6 @@ function DataSheet() { POIs - - ); diff --git a/components/EditModeToggle.js b/components/EditModeToggle.js index 13c6860fd..3c6053bf1 100644 --- a/components/EditModeToggle.js +++ b/components/EditModeToggle.js @@ -1,4 +1,7 @@ import React, { useState, useEffect } from "react"; +import DesignServicesIcon from "@mui/icons-material/DesignServices"; +import EditOffIcon from "@mui/icons-material/EditOff"; +import Tooltip from "@mui/material/Tooltip"; // Importiere Tooltip von Material-UI function EditModeToggle() { const [editMode, setEditMode] = useState(() => localStorage.getItem("editMode") === "true"); @@ -17,9 +20,17 @@ function EditModeToggle() { }, []); return ( - +
+ {editMode ? ( + + + + ) : ( + + + + )} +
); } From e94ecd7279e50cedd54b827db94feb9fb2886222 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 13:56:28 +0200 Subject: [PATCH 13/47] feat(api): Add mock API routes for testing GIS lines and station names - Created mock API route for fetching GIS lines data (/api/talas_v5_DB/gisLines/readGisLinesMock) - Created mock API route for fetching station names data (/api/talas_v5_DB/station/getAllStationsNamesMock) - Replaced original API calls in useLineData hook with mock routes for development and testing --- components/EditModeToggle.js | 3 +- hooks/useLineData.js | 12 +- .../talas_v5_DB/gisLines/readGisLinesMock.js | 303 +++++++ .../webserviceGisLinesStatusUrlMock.js | 758 ++++++++++++++++++ .../station/getAllStationsNamesMock.js | 46 ++ .../station/getAllStationsNamesMock.json | 751 +++++++++++++++++ 6 files changed, 1869 insertions(+), 4 deletions(-) create mode 100644 pages/api/talas_v5_DB/gisLines/readGisLinesMock.js create mode 100644 pages/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock.js create mode 100644 pages/api/talas_v5_DB/station/getAllStationsNamesMock.js create mode 100644 pages/api/talas_v5_DB/station/getAllStationsNamesMock.json diff --git a/components/EditModeToggle.js b/components/EditModeToggle.js index 3c6053bf1..051fac5d0 100644 --- a/components/EditModeToggle.js +++ b/components/EditModeToggle.js @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import DesignServicesIcon from "@mui/icons-material/DesignServices"; import EditOffIcon from "@mui/icons-material/EditOff"; +import ModeEditIcon from "@mui/icons-material/ModeEdit"; import Tooltip from "@mui/material/Tooltip"; // Importiere Tooltip von Material-UI function EditModeToggle() { @@ -27,7 +28,7 @@ function EditModeToggle() { ) : ( - + )} diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 129e32ae9..47907e603 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -9,12 +9,18 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const fetchData = async () => { try { console.log("Daten werden abgerufen..."); - const response1 = await fetch(webserviceGisLinesStatusUrl); + //const response1 = await fetch(webserviceGisLinesStatusUrl); // original + const response1 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock`); //von original kopiert const data1 = await response1.json(); - const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); + console.log("Daten empfangen data1:", data1); + //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); + const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); const data2 = await response2.json(); - const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNames`); + console.log("Daten empfangen data2:", data2); + //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNames`); + const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNamesMock`); const namesData = await response3.json(); + console.log("Daten empfangen namesData:", namesData); const colorsByModule = {}; const newTooltipContents = {}; diff --git a/pages/api/talas_v5_DB/gisLines/readGisLinesMock.js b/pages/api/talas_v5_DB/gisLines/readGisLinesMock.js new file mode 100644 index 000000000..bad20059e --- /dev/null +++ b/pages/api/talas_v5_DB/gisLines/readGisLinesMock.js @@ -0,0 +1,303 @@ +// /pages/api/talas_v5_DB/gisLines/readGisLines.js + +export default function handler(req, res) { + // JSON-Daten hier + const data = [ + { + idLD: 50035, + idModul: 1, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.264596890603144, + y: 8.176574707031252, + }, + ], + }, + { + idLD: 50035, + idModul: 2, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.258949437816085, + y: 8.157176971435549, + }, + { + x: 53.27568426437073, + y: 8.163356781005861, + }, + ], + }, + { + idLD: 50035, + idModul: 3, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.25735774823773, + y: 8.213653564453127, + }, + ], + }, + { + idLD: 50035, + idModul: 4, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.241488959365725, + y: 8.184814453125002, + }, + { + x: 53.232550546124244, + y: 8.200263977050783, + }, + { + x: 53.23049547461783, + y: 8.230476379394533, + }, + { + x: 53.23666039320915, + y: 8.264122009277346, + }, + { + x: 53.242413516276585, + y: 8.217430114746096, + }, + { + x: 53.247138717452785, + y: 8.21880340576172, + }, + { + x: 53.253917442602265, + y: 8.233737945556642, + }, + ], + }, + { + idLD: 50035, + idModul: 5, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.257922548093866, + y: 8.179321289062502, + }, + { + x: 53.27075689767353, + y: 8.199234008789064, + }, + { + x: 53.269730291457705, + y: 8.237171173095705, + }, + { + x: 53.26665032490112, + y: 8.288583755493166, + }, + ], + }, + { + idLD: 50035, + idModul: 6, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.243594865485605, + y: 8.169021606445314, + }, + { + x: 53.24015345301049, + y: 8.171596527099611, + }, + { + x: 53.236352168364164, + y: 8.18035125732422, + }, + { + x: 53.23049547461783, + y: 8.185672760009767, + }, + { + x: 53.229159625240165, + y: 8.192882537841799, + }, + { + x: 53.22576843579022, + y: 8.19957733154297, + }, + { + x: 53.21898525115505, + y: 8.201808929443361, + }, + { + x: 53.20891126768285, + y: 8.205413818359377, + }, + { + x: 53.19739524287978, + y: 8.217945098876955, + }, + ], + }, + { + idLD: 50035, + idModul: 7, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.25063092211432, + y: 8.205242156982424, + }, + { + x: 53.255149822694534, + y: 8.223438262939455, + }, + ], + }, + { + idLD: 50035, + idModul: 8, + points: [ + { + x: 53.246185, + y: 8.162953, + }, + { + x: 53.26048972617302, + y: 8.199234008789064, + }, + { + x: 53.2577171671909, + y: 8.203182220458986, + }, + ], + }, + { + idLD: 50036, + idModul: 1, + points: [ + { + x: 53.39605, + y: 8.10297, + }, + { + x: 53.40605, + y: 8.11297, + }, + ], + }, + { + idLD: 50036, + idModul: 2, + points: [ + { + x: 53.39605, + y: 8.10297, + }, + { + x: 53.40605, + y: 8.12297, + }, + ], + }, + { + idLD: 50036, + idModul: 8, + points: [ + { + x: 53.39605, + y: 8.10297, + }, + { + x: 53.405233950076024, + y: 8.136577606201174, + }, + ], + }, + { + idLD: 50071, + idModul: 1, + points: [ + { + x: 53.45257, + y: 7.91525, + }, + { + x: 53.46257, + y: 7.92525, + }, + ], + }, + { + idLD: 50071, + idModul: 2, + points: [ + { + x: 53.45257, + y: 7.91525, + }, + { + x: 53.46257, + y: 7.93525, + }, + ], + }, + { + idLD: 50071, + idModul: 3, + points: [ + { + x: 53.45257, + y: 7.91525, + }, + { + x: 53.46257, + y: 7.94525, + }, + ], + }, + { + idLD: 50071, + idModul: 4, + points: [ + { + x: 53.45257, + y: 7.91525, + }, + { + x: 53.4516692168179, + y: 7.936935424804688, + }, + { + x: 53.45718897904939, + y: 7.958908081054688, + }, + ], + }, + ]; + // Sende die JSON-Daten als Antwort + res.status(200).json(data); +} diff --git a/pages/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock.js b/pages/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock.js new file mode 100644 index 000000000..b4f9edcfd --- /dev/null +++ b/pages/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock.js @@ -0,0 +1,758 @@ +// /pages/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock.js + +export default function handler(req, res) { + // Deine JSON-Daten hier + const data = { + Name: "Liste aller Statis der Linien", + Zeitstempel: "2024-09-09T12:29:42.5075786+02:00", + IdMap: "12", + Statis: [ + { + IdLD: 50035, + Modul: 4, + DpName: "KUE04_Messwertalarm", + ModulName: "Ost LWL", + ModulTyp: "Kü605µF", + Message: "KÜG 04: Isolationsminderung kommend", + Level: 2, + PrioColor: "#FF9900", + PrioName: "major", + Value: "True", + }, + { + IdLD: 50035, + Modul: 3, + DpName: "KUE03_Aderbruch", + ModulName: "Ost", + ModulTyp: "Kü705-FO", + Message: "KÜG 03: Aderbruch kommend", + Level: 1, + PrioColor: "#FF0000", + PrioName: "critical", + Value: "?", + }, + { + IdLD: 50035, + Modul: 4, + DpName: "KUE04_Aderbruch", + ModulName: "Ost LWL", + ModulTyp: "Kü605µF", + Message: "KÜG 04: Aderbruch kommend", + Level: 1, + PrioColor: "#FF0000", + PrioName: "critical", + Value: "?", + }, + { + IdLD: 50035, + Modul: 5, + DpName: "KUE05_Aderbruch", + ModulName: " West", + ModulTyp: "Kü605µC", + Message: "KÜG 05: Aderbruch kommend", + Level: 1, + PrioColor: "#FF0000", + PrioName: "critical", + Value: "?", + }, + { + IdLD: 50035, + Modul: 6, + DpName: "KUE06_Aderbruch", + ModulName: "K54 AP12", + ModulTyp: "Kü705-FO", + Message: "KÜG 06: Aderbruch kommend", + Level: 1, + PrioColor: "#FF0000", + PrioName: "critical", + Value: "?", + }, + { + IdLD: 50035, + Modul: 1, + DpName: "KUE01_Messwert", + ModulName: "Nord", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "51.5 MOhm", + }, + { + IdLD: 50035, + Modul: 2, + DpName: "KUE02_Messwert", + ModulName: "Süd", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "30 MOhm", + }, + { + IdLD: 50035, + Modul: 6, + DpName: "KUE06_Messwert", + ModulName: "K54 AP12", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 MOhm", + }, + { + IdLD: 50035, + Modul: 7, + DpName: "KUE07_Messwert", + ModulName: "Kreuzung 50Hz", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 MOhm", + }, + { + IdLD: 50035, + Modul: 8, + DpName: "KUE08_Messwert", + ModulName: "Querung EWE", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 MOhm", + }, + { + IdLD: 50035, + Modul: 21, + DpName: "KUE21_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.61 MOhm", + }, + { + IdLD: 50035, + Modul: 22, + DpName: "KUE22_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.72 MOhm", + }, + { + IdLD: 50035, + Modul: 1, + DpName: "KUE01_Schleifenwert", + ModulName: "Nord", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.61 kOhm", + }, + { + IdLD: 50035, + Modul: 2, + DpName: "KUE02_Schleifenwert", + ModulName: "Süd", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.79 kOhm", + }, + { + IdLD: 50035, + Modul: 4, + DpName: "KUE04_Schleifenwert", + ModulName: "Ost LWL", + ModulTyp: "Kü605µF", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "64.01 kOhm", + }, + { + IdLD: 50035, + Modul: 5, + DpName: "KUE05_Schleifenwert", + ModulName: " West", + ModulTyp: "Kü605µC", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "64.01 kOhm", + }, + { + IdLD: 50035, + Modul: 6, + DpName: "KUE06_Schleifenwert", + ModulName: "K54 AP12", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50035, + Modul: 7, + DpName: "KUE07_Schleifenwert", + ModulName: "Kreuzung 50Hz", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50035, + Modul: 8, + DpName: "KUE08_Schleifenwert", + ModulName: "Querung EWE", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50036, + Modul: 1, + DpName: "KUE01_Messwert", + ModulName: "Friedrichsfehn", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "10.5 MOhm", + }, + { + IdLD: 50036, + Modul: 2, + DpName: "KUE02_Messwert", + ModulName: "Köln", + ModulTyp: "Kü605µC", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "10 MOhm", + }, + { + IdLD: 50036, + Modul: 3, + DpName: "KUE03_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "200 MOhm", + }, + { + IdLD: 50036, + Modul: 4, + DpName: "KUE04_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 MOhm", + }, + { + IdLD: 50036, + Modul: 5, + DpName: "KUE05_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "11.5 MOhm", + }, + { + IdLD: 50036, + Modul: 8, + DpName: "KUE08_Messwert", + ModulName: "Köln", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 Events", + }, + { + IdLD: 50036, + Modul: 9, + DpName: "KUE09_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "11 MOhm", + }, + { + IdLD: 50036, + Modul: 10, + DpName: "KUE10_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "11 MOhm", + }, + { + IdLD: 50036, + Modul: 11, + DpName: "KUE11_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "11 MOhm", + }, + { + IdLD: 50036, + Modul: 12, + DpName: "KUE12_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "11 MOhm", + }, + { + IdLD: 50036, + Modul: 1, + DpName: "KUE01_Schleifenwert", + ModulName: "Friedrichsfehn", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "2.32 kOhm", + }, + { + IdLD: 50036, + Modul: 2, + DpName: "KUE02_Schleifenwert", + ModulName: "Köln", + ModulTyp: "Kü605µC", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "2.15 kOhm", + }, + { + IdLD: 50036, + Modul: 6, + DpName: "KUE06_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "64.01 kOhm", + }, + { + IdLD: 50036, + Modul: 7, + DpName: "KUE07_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "64.01 kOhm", + }, + { + IdLD: 50036, + Modul: 8, + DpName: "KUE08_Schleifenwert", + ModulName: "Köln", + ModulTyp: "KÜSS V2", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50071, + Modul: 1, + DpName: "KUE01_Messwert", + ModulName: "Test 1", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 2, + DpName: "KUE02_Messwert", + ModulName: "Test 2", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 3, + DpName: "KUE03_Messwert", + ModulName: "Test 3", + ModulTyp: "Kü705-FO", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 4, + DpName: "KUE04_Messwert", + ModulName: "Test 4", + ModulTyp: "Kü605µF", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 5, + DpName: "KUE05_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 6, + DpName: "KUE06_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 MOhm", + }, + { + IdLD: 50071, + Modul: 7, + DpName: "KUE07_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.1 Events", + }, + { + IdLD: 50071, + Modul: 8, + DpName: "KUE08_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "51 Events", + }, + { + IdLD: 50071, + Modul: 11, + DpName: "KUE11_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.59 kOhm", + }, + { + IdLD: 50071, + Modul: 12, + DpName: "KUE12_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.61 kOhm", + }, + { + IdLD: 50071, + Modul: 13, + DpName: "KUE13_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.58 kOhm", + }, + { + IdLD: 50071, + Modul: 14, + DpName: "KUE14_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.6 kOhm", + }, + { + IdLD: 50071, + Modul: 15, + DpName: "KUE15_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.6 kOhm", + }, + { + IdLD: 50071, + Modul: 16, + DpName: "KUE16_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0.57 kOhm", + }, + { + IdLD: 50082, + Modul: 6, + DpName: "KUE06_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 MOhm", + }, + { + IdLD: 50082, + Modul: 7, + DpName: "KUE07_Messwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "10 MOhm", + }, + { + IdLD: 50082, + Modul: 6, + DpName: "KUE06_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50082, + Modul: 7, + DpName: "KUE07_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "2.74 kOhm", + }, + { + IdLD: 50086, + Modul: 1, + DpName: "KUE01_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "201 kOhm", + }, + { + IdLD: 50086, + Modul: 2, + DpName: "KUE02_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "201 kOhm", + }, + { + IdLD: 50086, + Modul: 3, + DpName: "KUE03_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "201 kOhm", + }, + { + IdLD: 50086, + Modul: 4, + DpName: "KUE04_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "0 kOhm", + }, + { + IdLD: 50086, + Modul: 11, + DpName: "KUE11_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + { + IdLD: 50086, + Modul: 12, + DpName: "KUE12_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + { + IdLD: 50086, + Modul: 13, + DpName: "KUE13_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + { + IdLD: 50086, + Modul: 14, + DpName: "KUE14_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + { + IdLD: 50086, + Modul: 15, + DpName: "KUE15_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + { + IdLD: 50086, + Modul: 16, + DpName: "KUE16_Schleifenwert", + ModulName: "?", + ModulTyp: "?", + Message: "?", + Level: -1, + PrioColor: "#ffffff", + PrioName: "?", + Value: "4.01 kOhm", + }, + ], + }; + // Sende die JSON-Daten als Antwort + res.status(200).json(data); +} diff --git a/pages/api/talas_v5_DB/station/getAllStationsNamesMock.js b/pages/api/talas_v5_DB/station/getAllStationsNamesMock.js new file mode 100644 index 000000000..f82692502 --- /dev/null +++ b/pages/api/talas_v5_DB/station/getAllStationsNamesMock.js @@ -0,0 +1,46 @@ +// /pages/api/talas_v5_DB/station/getAllStationsNamesMock.js + +export default function handler(req, res) { + // JSON-Daten hier + const stationNames = { + 50035: "CPL Schulungssystem", + 50036: "CPL Varel", + 50039: "MIO Schulungssystem", + 50040: "LTE-Modem Belecke", + 50041: "LTE-Modem Halver", + 50042: "LTE-Modem Lipperbruch", + 50043: "GMA Bunde", + 50044: "GMA Albrechtsplatz", + 50045: "Cisco Router Engelbert", + 50046: "Cisco-Router Schmallenberg", + 50050: "GMA Testgerät", + 50051: "GMA Beleke", + 50052: "Router 1", + 50055: "Testgerät 2", + 50063: "Testgerät 1", + 50064: "CPL Meldestation A", + 50066: "CPL USV Raum", + 50067: "Kontrollmodul 1", + 50068: "Kontrollmodul 2", + 50071: "Testgerät MIK-245", + 50076: "SMS Funkmodem", + 50077: "Notrufserver", + 50078: "OGETest", + 50079: "OGETest", + 50080: "Insel", + 50081: "CPL Test", + 50082: "Buchhaim", + 50083: "Zählstelle B35", + 50084: "TEST JOL", + 50085: "KH Westerstede (Master CPL 232)", + 50086: "KH Oldenburg CPL 2 (Master CPL 233)", + 50087: "PWC Gebäude A (LON, Slave von 232)", + 50088: "PWC Gebäude B (CPL 231, Slave von 232)", + 50089: "LR 77", + 50091: "DC Server", + 50092: "DZ WIS 1", + }; + + // Sende die JSON-Daten als Antwort + res.status(200).json(stationNames); +} diff --git a/pages/api/talas_v5_DB/station/getAllStationsNamesMock.json b/pages/api/talas_v5_DB/station/getAllStationsNamesMock.json new file mode 100644 index 000000000..ad867d096 --- /dev/null +++ b/pages/api/talas_v5_DB/station/getAllStationsNamesMock.json @@ -0,0 +1,751 @@ +{ + "Name": "Liste aller Statis der Linien", + "Zeitstempel": "2024-09-09T12:29:42.5075786+02:00", + "IdMap": "12", + "Statis": [ + { + "IdLD": 50035, + "Modul": 4, + "DpName": "KUE04_Messwertalarm", + "ModulName": "Ost LWL", + "ModulTyp": "Kü605µF", + "Message": "KÜG 04: Isolationsminderung kommend", + "Level": 2, + "PrioColor": "#FF9900", + "PrioName": "major", + "Value": "True" + }, + { + "IdLD": 50035, + "Modul": 3, + "DpName": "KUE03_Aderbruch", + "ModulName": "Ost", + "ModulTyp": "Kü705-FO", + "Message": "KÜG 03: Aderbruch kommend", + "Level": 1, + "PrioColor": "#FF0000", + "PrioName": "critical", + "Value": "?" + }, + { + "IdLD": 50035, + "Modul": 4, + "DpName": "KUE04_Aderbruch", + "ModulName": "Ost LWL", + "ModulTyp": "Kü605µF", + "Message": "KÜG 04: Aderbruch kommend", + "Level": 1, + "PrioColor": "#FF0000", + "PrioName": "critical", + "Value": "?" + }, + { + "IdLD": 50035, + "Modul": 5, + "DpName": "KUE05_Aderbruch", + "ModulName": " West", + "ModulTyp": "Kü605µC", + "Message": "KÜG 05: Aderbruch kommend", + "Level": 1, + "PrioColor": "#FF0000", + "PrioName": "critical", + "Value": "?" + }, + { + "IdLD": 50035, + "Modul": 6, + "DpName": "KUE06_Aderbruch", + "ModulName": "K54 AP12", + "ModulTyp": "Kü705-FO", + "Message": "KÜG 06: Aderbruch kommend", + "Level": 1, + "PrioColor": "#FF0000", + "PrioName": "critical", + "Value": "?" + }, + { + "IdLD": 50035, + "Modul": 1, + "DpName": "KUE01_Messwert", + "ModulName": "Nord", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "51.5 MOhm" + }, + { + "IdLD": 50035, + "Modul": 2, + "DpName": "KUE02_Messwert", + "ModulName": "Süd", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "30 MOhm" + }, + { + "IdLD": 50035, + "Modul": 6, + "DpName": "KUE06_Messwert", + "ModulName": "K54 AP12", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 MOhm" + }, + { + "IdLD": 50035, + "Modul": 7, + "DpName": "KUE07_Messwert", + "ModulName": "Kreuzung 50Hz", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 MOhm" + }, + { + "IdLD": 50035, + "Modul": 8, + "DpName": "KUE08_Messwert", + "ModulName": "Querung EWE", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 MOhm" + }, + { + "IdLD": 50035, + "Modul": 21, + "DpName": "KUE21_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.61 MOhm" + }, + { + "IdLD": 50035, + "Modul": 22, + "DpName": "KUE22_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.72 MOhm" + }, + { + "IdLD": 50035, + "Modul": 1, + "DpName": "KUE01_Schleifenwert", + "ModulName": "Nord", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.61 kOhm" + }, + { + "IdLD": 50035, + "Modul": 2, + "DpName": "KUE02_Schleifenwert", + "ModulName": "Süd", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.79 kOhm" + }, + { + "IdLD": 50035, + "Modul": 4, + "DpName": "KUE04_Schleifenwert", + "ModulName": "Ost LWL", + "ModulTyp": "Kü605µF", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "64.01 kOhm" + }, + { + "IdLD": 50035, + "Modul": 5, + "DpName": "KUE05_Schleifenwert", + "ModulName": " West", + "ModulTyp": "Kü605µC", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "64.01 kOhm" + }, + { + "IdLD": 50035, + "Modul": 6, + "DpName": "KUE06_Schleifenwert", + "ModulName": "K54 AP12", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50035, + "Modul": 7, + "DpName": "KUE07_Schleifenwert", + "ModulName": "Kreuzung 50Hz", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50035, + "Modul": 8, + "DpName": "KUE08_Schleifenwert", + "ModulName": "Querung EWE", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50036, + "Modul": 1, + "DpName": "KUE01_Messwert", + "ModulName": "Friedrichsfehn", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "10.5 MOhm" + }, + { + "IdLD": 50036, + "Modul": 2, + "DpName": "KUE02_Messwert", + "ModulName": "Köln", + "ModulTyp": "Kü605µC", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "10 MOhm" + }, + { + "IdLD": 50036, + "Modul": 3, + "DpName": "KUE03_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "200 MOhm" + }, + { + "IdLD": 50036, + "Modul": 4, + "DpName": "KUE04_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 MOhm" + }, + { + "IdLD": 50036, + "Modul": 5, + "DpName": "KUE05_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "11.5 MOhm" + }, + { + "IdLD": 50036, + "Modul": 8, + "DpName": "KUE08_Messwert", + "ModulName": "Köln", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 Events" + }, + { + "IdLD": 50036, + "Modul": 9, + "DpName": "KUE09_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "11 MOhm" + }, + { + "IdLD": 50036, + "Modul": 10, + "DpName": "KUE10_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "11 MOhm" + }, + { + "IdLD": 50036, + "Modul": 11, + "DpName": "KUE11_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "11 MOhm" + }, + { + "IdLD": 50036, + "Modul": 12, + "DpName": "KUE12_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "11 MOhm" + }, + { + "IdLD": 50036, + "Modul": 1, + "DpName": "KUE01_Schleifenwert", + "ModulName": "Friedrichsfehn", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "2.32 kOhm" + }, + { + "IdLD": 50036, + "Modul": 2, + "DpName": "KUE02_Schleifenwert", + "ModulName": "Köln", + "ModulTyp": "Kü605µC", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "2.15 kOhm" + }, + { + "IdLD": 50036, + "Modul": 6, + "DpName": "KUE06_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "64.01 kOhm" + }, + { + "IdLD": 50036, + "Modul": 7, + "DpName": "KUE07_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "64.01 kOhm" + }, + { + "IdLD": 50036, + "Modul": 8, + "DpName": "KUE08_Schleifenwert", + "ModulName": "Köln", + "ModulTyp": "KÜSS V2", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50071, + "Modul": 1, + "DpName": "KUE01_Messwert", + "ModulName": "Test 1", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 2, + "DpName": "KUE02_Messwert", + "ModulName": "Test 2", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 3, + "DpName": "KUE03_Messwert", + "ModulName": "Test 3", + "ModulTyp": "Kü705-FO", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 4, + "DpName": "KUE04_Messwert", + "ModulName": "Test 4", + "ModulTyp": "Kü605µF", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 5, + "DpName": "KUE05_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 6, + "DpName": "KUE06_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 MOhm" + }, + { + "IdLD": 50071, + "Modul": 7, + "DpName": "KUE07_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.1 Events" + }, + { + "IdLD": 50071, + "Modul": 8, + "DpName": "KUE08_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "51 Events" + }, + { + "IdLD": 50071, + "Modul": 11, + "DpName": "KUE11_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.59 kOhm" + }, + { + "IdLD": 50071, + "Modul": 12, + "DpName": "KUE12_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.61 kOhm" + }, + { + "IdLD": 50071, + "Modul": 13, + "DpName": "KUE13_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.58 kOhm" + }, + { + "IdLD": 50071, + "Modul": 14, + "DpName": "KUE14_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.6 kOhm" + }, + { + "IdLD": 50071, + "Modul": 15, + "DpName": "KUE15_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.6 kOhm" + }, + { + "IdLD": 50071, + "Modul": 16, + "DpName": "KUE16_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0.57 kOhm" + }, + { + "IdLD": 50082, + "Modul": 6, + "DpName": "KUE06_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 MOhm" + }, + { + "IdLD": 50082, + "Modul": 7, + "DpName": "KUE07_Messwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "10 MOhm" + }, + { + "IdLD": 50082, + "Modul": 6, + "DpName": "KUE06_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50082, + "Modul": 7, + "DpName": "KUE07_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "2.74 kOhm" + }, + { + "IdLD": 50086, + "Modul": 1, + "DpName": "KUE01_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "201 kOhm" + }, + { + "IdLD": 50086, + "Modul": 2, + "DpName": "KUE02_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "201 kOhm" + }, + { + "IdLD": 50086, + "Modul": 3, + "DpName": "KUE03_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "201 kOhm" + }, + { + "IdLD": 50086, + "Modul": 4, + "DpName": "KUE04_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "0 kOhm" + }, + { + "IdLD": 50086, + "Modul": 11, + "DpName": "KUE11_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + }, + { + "IdLD": 50086, + "Modul": 12, + "DpName": "KUE12_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + }, + { + "IdLD": 50086, + "Modul": 13, + "DpName": "KUE13_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + }, + { + "IdLD": 50086, + "Modul": 14, + "DpName": "KUE14_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + }, + { + "IdLD": 50086, + "Modul": 15, + "DpName": "KUE15_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + }, + { + "IdLD": 50086, + "Modul": 16, + "DpName": "KUE16_Schleifenwert", + "ModulName": "?", + "ModulTyp": "?", + "Message": "?", + "Level": -1, + "PrioColor": "#ffffff", + "PrioName": "?", + "Value": "4.01 kOhm" + } + ] +} \ No newline at end of file From f0c61570a04af5bf2ae36dbef684114270361174 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 14:50:02 +0200 Subject: [PATCH 14/47] =?UTF-8?q?setInterval=20in=20useLineData=20um=20neu?= =?UTF-8?q?e=20=C3=84nderungen=20zu=20zeichnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useLineData.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 47907e603..b5c7267d7 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -1,3 +1,4 @@ +// /hooks/useLineData.js import { useEffect, useState } from "react"; import { SERVER_URL } from "../config/urls"; @@ -153,10 +154,10 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { fetchData(); // Setze ein Intervall, um die Daten alle 20 Sekunden erneut abzurufen - //const intervalId = setInterval(fetchData, 20000); + const intervalId = setInterval(fetchData, 20000); // Räumt das Intervall auf, wenn die Komponente entladen wird - //return () => clearInterval(intervalId); + return () => clearInterval(intervalId); }, [webserviceGisLinesStatusUrl, setLineStatusData]); return { lineColors, tooltipContents }; From aa38493f03bee4c5bb42c71cfb1293fdad321e93 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 15:20:00 +0200 Subject: [PATCH 15/47] prepair redux --- hooks/useLineData.js | 4 +++ package-lock.json | 55 ++++++++++++++++++++++++++++++++++-- package.json | 6 +++- pages/_app.js | 10 +++++-- pages/api/websocket.js | 27 ++++++++++++++++++ redux/actions.js | 9 ++++++ redux/reducer.js | 18 ++++++++++++ redux/store.js | 8 ++++++ redux/websocketMiddleware.js | 29 +++++++++++++++++++ 9 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 pages/api/websocket.js create mode 100644 redux/actions.js create mode 100644 redux/reducer.js create mode 100644 redux/store.js create mode 100644 redux/websocketMiddleware.js diff --git a/hooks/useLineData.js b/hooks/useLineData.js index b5c7267d7..e89ca06a7 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -1,8 +1,12 @@ // /hooks/useLineData.js import { useEffect, useState } from "react"; import { SERVER_URL } from "../config/urls"; +import { useDispatch, useSelector } from "react-redux"; +import { connectWebSocket, disconnectWebSocket } from "../redux/actions"; const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { + const dispatch = useDispatch(); + const messages = useSelector((state) => state.messages); const [lineColors, setLineColors] = useState({}); const [tooltipContents, setTooltipContents] = useState({}); diff --git a/package-lock.json b/package-lock.json index 2c403330d..691d7655d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,9 +23,13 @@ "postcss": "^8.4.40", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-redux": "^9.1.2", "react-toastify": "^10.0.5", "recoil": "^0.7.7", - "tailwindcss": "^3.4.7" + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "tailwindcss": "^3.4.7", + "ws": "^8.18.0" }, "devDependencies": { "@babel/core": "^7.25.2", @@ -3828,6 +3832,11 @@ "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", "dev": true }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "node_modules/@types/yargs": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", @@ -10580,6 +10589,28 @@ "dev": true, "peer": true }, + "node_modules/react-redux": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.1.2.tgz", + "integrity": "sha512-0OA4dhM1W48l3uzmv6B7TXPCGmokUU4p1M44DGN2/D9a1FjVPukVjER1PcPX97jIg6aUeLq1XJo1IpfbgULn0w==", + "dependencies": { + "@types/use-sync-external-store": "^0.0.3", + "use-sync-external-store": "^1.0.0" + }, + "peerDependencies": { + "@types/react": "^18.2.25", + "react": "^18.0", + "redux": "^5.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "redux": { + "optional": true + } + } + }, "node_modules/react-toastify": { "version": "10.0.5", "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz", @@ -10673,6 +10704,19 @@ "node": ">=8" } }, + "node_modules/redux": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz", + "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==" + }, + "node_modules/redux-thunk": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz", + "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==", + "peerDependencies": { + "redux": "^5.0.0" + } + }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -11818,6 +11862,14 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz", + "integrity": "sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -12152,7 +12204,6 @@ "version": "8.18.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "dev": true, "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 971c1fc6d..90097e17d 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,13 @@ "postcss": "^8.4.40", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-redux": "^9.1.2", "react-toastify": "^10.0.5", "recoil": "^0.7.7", - "tailwindcss": "^3.4.7" + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "tailwindcss": "^3.4.7", + "ws": "^8.18.0" }, "scripts": { "dev": "next dev", diff --git a/pages/_app.js b/pages/_app.js index fc74da978..1a2213940 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -1,13 +1,17 @@ // Pfad: pages/_app.js import React from "react"; import { RecoilRoot } from "recoil"; +import { Provider } from "react-redux"; +import store from "../redux/store"; import "../styles/global.css"; function MyApp({ Component, pageProps }) { return ( - - - + + + + + ); } diff --git a/pages/api/websocket.js b/pages/api/websocket.js new file mode 100644 index 000000000..20b4c6716 --- /dev/null +++ b/pages/api/websocket.js @@ -0,0 +1,27 @@ +// /pages/api/websocket.js +import { Server } from "ws"; + +export default function handler(req, res) { + if (!res.socket.server.ws) { + console.log("Starting WebSocket server"); + const wss = new Server({ server: res.socket.server }); + + wss.on("connection", (ws) => { + console.log("New WebSocket connection"); + + ws.on("message", (message) => { + console.log("Received:", message); + // Beispielnachricht an den Client senden + ws.send(JSON.stringify({ message: "Hallo von WebSocket-Server" })); + }); + + // Schließe die Verbindung + ws.on("close", () => { + console.log("WebSocket connection closed"); + }); + }); + + res.socket.server.ws = wss; + } + res.end(); +} diff --git a/redux/actions.js b/redux/actions.js new file mode 100644 index 000000000..d147d7d35 --- /dev/null +++ b/redux/actions.js @@ -0,0 +1,9 @@ +// /redux/actions.js +export const connectWebSocket = (url) => ({ + type: "WS_CONNECT", + payload: { url }, +}); + +export const disconnectWebSocket = () => ({ + type: "WS_DISCONNECT", +}); diff --git a/redux/reducer.js b/redux/reducer.js new file mode 100644 index 000000000..008b8d138 --- /dev/null +++ b/redux/reducer.js @@ -0,0 +1,18 @@ +// /redux/reducer.js +const initialState = { + messages: [], +}; + +const websocketReducer = (state = initialState, action) => { + switch (action.type) { + case "WS_MESSAGE_RECEIVED": + return { + ...state, + messages: [...state.messages, action.payload], + }; + default: + return state; + } +}; + +export default websocketReducer; diff --git a/redux/store.js b/redux/store.js new file mode 100644 index 000000000..cf3e43428 --- /dev/null +++ b/redux/store.js @@ -0,0 +1,8 @@ +// /redux/store.js +import { createStore, applyMiddleware } from "redux"; +import websocketMiddleware from "./websocketMiddleware"; +import websocketReducer from "./reducer"; + +const store = createStore(websocketReducer, applyMiddleware(websocketMiddleware)); + +export default store; diff --git a/redux/websocketMiddleware.js b/redux/websocketMiddleware.js new file mode 100644 index 000000000..75c39637d --- /dev/null +++ b/redux/websocketMiddleware.js @@ -0,0 +1,29 @@ +// /redux/websocketMiddleware.js +const websocketMiddleware = () => { + let socket; + + return ({ dispatch }) => + (next) => + (action) => { + if (action.type === "WS_CONNECT") { + socket = new WebSocket(action.payload.url); + + socket.onmessage = (event) => { + const data = JSON.parse(event.data); + dispatch({ type: "WS_MESSAGE_RECEIVED", payload: data }); + }; + + socket.onclose = () => { + dispatch({ type: "WS_DISCONNECTED" }); + }; + } + + if (action.type === "WS_DISCONNECT" && socket) { + socket.close(); + } + + return next(action); + }; +}; + +export default websocketMiddleware; From 3f6760a783ecbf41e22e2e3e9954031638116a8b Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 9 Sep 2024 15:26:29 +0200 Subject: [PATCH 16/47] npm install @reduxjs/toolkit weil 'createStore' is deprecated. in redux --- components/TestScript.js | 2 +- package-lock.json | 38 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + redux/store.js | 8 ++++++-- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/components/TestScript.js b/components/TestScript.js index 668e98486..c34b9f7dc 100644 --- a/components/TestScript.js +++ b/components/TestScript.js @@ -26,7 +26,7 @@ export default function TestScript() { if (addRegex.test(setupPolylinesCode)) { console.log("%c✔ Test bestanden: Der Text für 'Stützpunkt hinzufügen' wurde gefunden.", successStyle); } else { - console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt hinzufügen' wurde nicht gefunden.", failStyle); + //console.log("%c✘ Test fehlgeschlagen: Der Text für 'Stützpunkt hinzufügen' wurde nicht gefunden.", failStyle); } // Beispiel einer neutralen Nachricht (falls benötigt) diff --git a/package-lock.json b/package-lock.json index 691d7655d..65982e38b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "@emotion/styled": "^11.13.0", "@heroicons/react": "^2.1.5", "@mui/icons-material": "^6.0.2", + "@reduxjs/toolkit": "^2.2.7", "autoprefixer": "^10.4.19", "dotenv": "^16.4.5", "http-proxy-middleware": "^3.0.0", @@ -3380,6 +3381,29 @@ "url": "https://opencollective.com/popperjs" } }, + "node_modules/@reduxjs/toolkit": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.2.7.tgz", + "integrity": "sha512-faI3cZbSdFb8yv9dhDTmGwclW0vk0z5o1cia+kf7gCbaCwHI5e+7tP57mJUv22pNcNbeA62GSrPpfrUfdXcQ6g==", + "dependencies": { + "immer": "^10.0.3", + "redux": "^5.0.1", + "redux-thunk": "^3.1.0", + "reselect": "^5.1.0" + }, + "peerDependencies": { + "react": "^16.9.0 || ^17.0.0 || ^18", + "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-redux": { + "optional": true + } + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -6760,6 +6784,15 @@ } ] }, + "node_modules/immer": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz", + "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/immer" + } + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -10810,6 +10843,11 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, + "node_modules/reselect": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz", + "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==" + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/package.json b/package.json index 90097e17d..5083e77ca 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "@emotion/styled": "^11.13.0", "@heroicons/react": "^2.1.5", "@mui/icons-material": "^6.0.2", + "@reduxjs/toolkit": "^2.2.7", "autoprefixer": "^10.4.19", "dotenv": "^16.4.5", "http-proxy-middleware": "^3.0.0", diff --git a/redux/store.js b/redux/store.js index cf3e43428..a12ad9d77 100644 --- a/redux/store.js +++ b/redux/store.js @@ -1,8 +1,12 @@ // /redux/store.js -import { createStore, applyMiddleware } from "redux"; +import { configureStore } from "@reduxjs/toolkit"; import websocketMiddleware from "./websocketMiddleware"; import websocketReducer from "./reducer"; -const store = createStore(websocketReducer, applyMiddleware(websocketMiddleware)); +// Erstelle den Store mit configureStore +const store = configureStore({ + reducer: websocketReducer, + middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(websocketMiddleware), +}); export default store; From 3c78e387faa3c2b479394331d39df52c7c4bbc1d Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 07:33:02 +0200 Subject: [PATCH 17/47] =?UTF-8?q?.env.local=20f=C3=BCr=2010.10.0.30=20vorb?= =?UTF-8?q?ereitet=20ohne=20Mock=20Dateien=20von=20useLineData.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 40 ++++++++++++++++++++-------------------- hooks/useLineData.js | 12 ++++++------ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.env.local b/.env.local index 426f51759..14b8e8c52 100644 --- a/.env.local +++ b/.env.local @@ -1,24 +1,7 @@ #.env.local #je nach dem Mysql Server, ob localhost freigegeben ist oder die IP Adresse des Servers, manchmal die beide und manchmal nur eine -#DB_HOST=10.10.0.30 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 - - -######################### - -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" -######################### - - -DB_HOST=10.10.0.70 +DB_HOST=10.10.0.30 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 @@ -29,8 +12,25 @@ DB_PORT=3306 NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" +######################### + + +#DB_HOST=10.10.0.70 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 + + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" ######################### diff --git a/hooks/useLineData.js b/hooks/useLineData.js index e89ca06a7..60abd1d17 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -14,16 +14,16 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const fetchData = async () => { try { console.log("Daten werden abgerufen..."); - //const response1 = await fetch(webserviceGisLinesStatusUrl); // original - const response1 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock`); //von original kopiert + const response1 = await fetch(webserviceGisLinesStatusUrl); // original + //const response1 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock`); //von original kopiert const data1 = await response1.json(); console.log("Daten empfangen data1:", data1); - //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); - const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); + const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); + //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); const data2 = await response2.json(); console.log("Daten empfangen data2:", data2); - //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNames`); - const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNamesMock`); + const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNames`); + //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNamesMock`); const namesData = await response3.json(); console.log("Daten empfangen namesData:", namesData); From 56762082651dd29fab200c686d7a7999c35570eb Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 08:21:37 +0200 Subject: [PATCH 18/47] =?UTF-8?q?.env.local=20f=C3=BCr=2030?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- hooks/useLineData.js | 4 ++-- .../talas_v5_DB/{station => device}/getAllStationsNames.js | 2 +- .../{station => device}/getAllStationsNamesMock.js | 2 +- .../{station => device}/getAllStationsNamesMock.json | 0 5 files changed, 5 insertions(+), 5 deletions(-) rename pages/api/talas_v5_DB/{station => device}/getAllStationsNames.js (95%) rename pages/api/talas_v5_DB/{station => device}/getAllStationsNamesMock.js (95%) rename pages/api/talas_v5_DB/{station => device}/getAllStationsNamesMock.json (100%) diff --git a/.env.local b/.env.local index 14b8e8c52..905d3f37a 100644 --- a/.env.local +++ b/.env.local @@ -14,7 +14,7 @@ NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" +NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" ######################### diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 60abd1d17..4832193d7 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -22,8 +22,8 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); const data2 = await response2.json(); console.log("Daten empfangen data2:", data2); - const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNames`); - //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/station/getAllStationsNamesMock`); + const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNames`); + //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNamesMock`); const namesData = await response3.json(); console.log("Daten empfangen namesData:", namesData); diff --git a/pages/api/talas_v5_DB/station/getAllStationsNames.js b/pages/api/talas_v5_DB/device/getAllStationsNames.js similarity index 95% rename from pages/api/talas_v5_DB/station/getAllStationsNames.js rename to pages/api/talas_v5_DB/device/getAllStationsNames.js index 1bf158cb2..68299296c 100644 --- a/pages/api/talas_v5_DB/station/getAllStationsNames.js +++ b/pages/api/talas_v5_DB/device/getAllStationsNames.js @@ -1,4 +1,4 @@ -// /pages/api/talas_v5_DB/station/getAllStationsNames.js +// /pages/api/talas_v5_DB/device/getAllStationsNames.js import getPool from "../../../../utils/mysqlPool"; // Importiere den Singleton-Pool export default async function handler(req, res) { diff --git a/pages/api/talas_v5_DB/station/getAllStationsNamesMock.js b/pages/api/talas_v5_DB/device/getAllStationsNamesMock.js similarity index 95% rename from pages/api/talas_v5_DB/station/getAllStationsNamesMock.js rename to pages/api/talas_v5_DB/device/getAllStationsNamesMock.js index f82692502..34b80f812 100644 --- a/pages/api/talas_v5_DB/station/getAllStationsNamesMock.js +++ b/pages/api/talas_v5_DB/device/getAllStationsNamesMock.js @@ -1,4 +1,4 @@ -// /pages/api/talas_v5_DB/station/getAllStationsNamesMock.js +// /pages/api/talas_v5_DB/device/getAllStationsNamesMock.js export default function handler(req, res) { // JSON-Daten hier diff --git a/pages/api/talas_v5_DB/station/getAllStationsNamesMock.json b/pages/api/talas_v5_DB/device/getAllStationsNamesMock.json similarity index 100% rename from pages/api/talas_v5_DB/station/getAllStationsNamesMock.json rename to pages/api/talas_v5_DB/device/getAllStationsNamesMock.json From d57d86cf6c4c6728007de19be9f2d6b78f54fd57 Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 13:06:03 +0200 Subject: [PATCH 19/47] =?UTF-8?q?Tooltip=20f=C3=BCr=20die=20Linien=20an=20?= =?UTF-8?q?Maus-Koordinaten=20positionieren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 42 ++++++++++++++---------------- components/MapComponent.js | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/.env.local b/.env.local index 905d3f37a..9f1fbbc78 100644 --- a/.env.local +++ b/.env.local @@ -1,37 +1,32 @@ #.env.local #je nach dem Mysql Server, ob localhost freigegeben ist oder die IP Adresse des Servers, manchmal die beide und manchmal nur eine -DB_HOST=10.10.0.30 +#DB_HOST=10.10.0.30 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.30" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" +######################### + + +DB_HOST=10.10.0.70 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 DB_PORT=3306 - ######################### NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" -NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" -######################### - - -#DB_HOST=10.10.0.70 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 - - -######################### - -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" ######################### #DB_HOST=192.168.10.167 @@ -45,3 +40,6 @@ NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.pn #NEXT_PUBLIC_SERVER_URL="http://192.168.10.167" #NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.167" #NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" + +######################### online +#NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/components/MapComponent.js b/components/MapComponent.js index 0d3db4781..d55855bd6 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -499,17 +499,70 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { fetchData(); }, []); + //Tooltip an mouse position anzeigen für die Linien useEffect(() => { if (!map) return; + // Entferne alte Marker und Polylinien markers.forEach((marker) => marker.remove()); polylines.forEach((polyline) => polyline.remove()); + // Setze neue Marker und Polylinien mit den aktuellen Daten const { markers: newMarkers, polylines: newPolylines } = setupPolylines(map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker); + newPolylines.forEach((polyline, index) => { + const tooltipContent = tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] || "Standard-Tooltip-Inhalt"; + + polyline.bindTooltip(tooltipContent, { + permanent: false, + direction: "auto", + sticky: true, + offset: [0, 10], + pane: "tooltipPane", + }); + + // Mausbewegung tracken + polyline.on("mouseover", (e) => { + const tooltip = polyline.getTooltip(); + if (tooltip) { + const mousePos = e.containerPoint; // Mausposition relativ zur Karte + const mapSize = map.getSize(); // Größe der Karte + + // Berechne die Tooltip-Position, um sicherzustellen, dass sie innerhalb des sichtbaren Bereichs bleibt + let direction = "right"; // Standard-Richtung + + if (mousePos.x > mapSize.x - 100) { + direction = "left"; // Bewege den Tooltip nach links, wenn der Mauszeiger nahe dem rechten Rand ist + } else if (mousePos.x < 100) { + direction = "right"; // Bewege den Tooltip nach rechts, wenn der Mauszeiger nahe dem linken Rand ist + } + + if (mousePos.y > mapSize.y - 100) { + direction = "top"; // Bewege den Tooltip nach oben, wenn der Mauszeiger nahe dem unteren Rand ist + } else if (mousePos.y < 100) { + direction = "bottom"; // Bewege den Tooltip nach unten, wenn der Mauszeiger nahe dem oberen Rand ist + } + + // Setze die neue Richtung und öffne den Tooltip + tooltip.options.direction = direction; + polyline.openTooltip(e.latlng); + } + }); + + /* polyline.on("mouseover", () => { + polyline.openTooltip(); + }); */ + + polyline.on("mouseout", () => { + polyline.closeTooltip(); + }); + }); + setMarkers(newMarkers); setPolylines(newPolylines); }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker]); + // }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker]); + //-------------------------------------------- useEffect(() => { if (map) { From 77bc63f22e2ccb65f3be737c2c9897a411ddcd0d Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 14:04:39 +0200 Subject: [PATCH 20/47] Connection: "close" in HTTP headers in fetchWebServiceMap in MapComponent.js --- components/MapComponent.js | 6 +++--- hooks/useLineData.js | 12 ++++++------ services/apiService.js | 9 +++++++-- utils/createAndSetDevices.js | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index d55855bd6..449f4f12b 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -197,9 +197,9 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { //--------------------------------------------------------------- - useEffect(() => { + /* useEffect(() => { fetchGisStatusStations(12, 484); // Beispielaufruf mit idMap = 10 und idUser = 484 - }, []); + }, []); */ useEffect(() => { const params = new URL(window.location.href).searchParams; @@ -246,7 +246,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { const fetchOptions = { method: "GET", headers: { - Connection: "keep-alive", // Keep-Alive-Header hinzufügen + Connection: "close", // Keep-Alive-Header hinzufügen }, }; diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 4832193d7..0d95b4919 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -17,15 +17,15 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const response1 = await fetch(webserviceGisLinesStatusUrl); // original //const response1 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock`); //von original kopiert const data1 = await response1.json(); - console.log("Daten empfangen data1:", data1); + //console.log("Daten empfangen data1:", data1); const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); const data2 = await response2.json(); - console.log("Daten empfangen data2:", data2); + //console.log("Daten empfangen data2:", data2); const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNames`); //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNamesMock`); const namesData = await response3.json(); - console.log("Daten empfangen namesData:", namesData); + //console.log("Daten empfangen namesData:", namesData); const colorsByModule = {}; const newTooltipContents = {}; @@ -36,7 +36,7 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { // Sortiere die Meldungen nach Level, damit die höchste Priorität (kleinster Level) zuerst kommt const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level); - console.log("Sortierte Daten:", sortedStatis); + //console.log("Sortierte Daten:", sortedStatis); // Filtere Objekte mit gleichem IdLD und Modul, und Level > 0, und entferne die Objekte mit dem höchsten Level const filteredStatis = []; @@ -56,7 +56,7 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { } }); - console.log("Gefilterte Daten (Objekte mit höchstem Level entfernt):", filteredStatis); + //console.log("Gefilterte Daten (Objekte mit höchstem Level entfernt):", filteredStatis); filteredStatis.forEach((statis) => { const key = `${statis.IdLD}-${statis.Modul}`; @@ -227,7 +227,7 @@ function logGroupedData(statisList) { } }); - console.log("Aggregierte und gruppierte Daten (gefiltert):", formattedData); + //console.log("Aggregierte und gruppierte Daten (gefiltert):", formattedData); } export default useLineData; diff --git a/services/apiService.js b/services/apiService.js index db8bc9f15..733ab3100 100644 --- a/services/apiService.js +++ b/services/apiService.js @@ -34,7 +34,12 @@ export const fetchGisStatusStations = async (idMap, idUser) => { // Verwende das Timeout für die API-Anfrage const response = await fetchWithTimeout( `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, - null, + { + method: "GET", + headers: { + Connection: "close", // Dieser Header stellt sicher, dass die Verbindung nach dem Abruf geschlossen wird + }, + }, 5000 // Timeout auf 5 Sekunden gesetzt ); @@ -140,7 +145,7 @@ export const fetchUserRights = async () => { const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, { method: "GET", headers: { - Connection: "keep-alive", // Keep-Alive Header hinzufügen + Connection: "close", }, }); diff --git a/utils/createAndSetDevices.js b/utils/createAndSetDevices.js index 4849b8739..5cb2b3dff 100644 --- a/utils/createAndSetDevices.js +++ b/utils/createAndSetDevices.js @@ -25,7 +25,7 @@ export const createAndSetDevices = async (systemId, setMarkersFunction, GisSyste let requestCount = localStorage.getItem("gisStationsStaticRequestCount-createDevice") || 0; requestCount++; localStorage.setItem("gisStationsStaticRequestCount-createDevice", requestCount); - console.log(`config.mapGisStationsStaticDistrictUrl in createAndSetDevice wurde ${requestCount} Mal aufgerufen.`); + //console.log(`config.mapGisStationsStaticDistrictUrl in createAndSetDevice wurde ${requestCount} Mal aufgerufen.`); const response1 = await fetch(config.mapGisStationsStaticDistrictUrl); const jsonResponse = await response1.json(); From d132ac000afda30e6aa612baa215aa73622e996f Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 14:29:26 +0200 Subject: [PATCH 21/47] Replace setInterval with recursive setTimeout for better control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In diesem Code wird setTimeout verwendet, um die Funktion fetchData rekursiv nach 20 Sekunden erneut aufzurufen. Dies ersetzt setInterval und bietet eine bessere Kontrolle über das Timing und das Cleanup, um sicherzustellen, dass der Code sauber bleibt, wenn die Komponente unmounted wird --- hooks/useLineData.js | 189 +++++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 105 deletions(-) diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 0d95b4919..daf3edaca 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -11,97 +11,84 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const [tooltipContents, setTooltipContents] = useState({}); useEffect(() => { + let isCancelled = false; // Flag to cancel ongoing operations if component unmounts + const fetchData = async () => { try { - console.log("Daten werden abgerufen..."); - const response1 = await fetch(webserviceGisLinesStatusUrl); // original - //const response1 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/webserviceGisLinesStatusUrlMock`); //von original kopiert + console.log("Fetching data..."); + const response1 = await fetch(webserviceGisLinesStatusUrl); const data1 = await response1.json(); - //console.log("Daten empfangen data1:", data1); + const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLines`); - //const response2 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/gisLines/readGisLinesMock`); const data2 = await response2.json(); - //console.log("Daten empfangen data2:", data2); + const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNames`); - //const response3 = await fetch(`${SERVER_URL}:3000/api/talas_v5_DB/device/getAllStationsNamesMock`); const namesData = await response3.json(); - //console.log("Daten empfangen namesData:", namesData); - const colorsByModule = {}; - const newTooltipContents = {}; - const valueMap = {}; + if (!isCancelled) { + const colorsByModule = {}; + const newTooltipContents = {}; + const valueMap = {}; - // Logik zur Gruppierung der Daten - logGroupedData(data1.Statis); + logGroupedData(data1.Statis); - // Sortiere die Meldungen nach Level, damit die höchste Priorität (kleinster Level) zuerst kommt - const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level); - //console.log("Sortierte Daten:", sortedStatis); + const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level); - // Filtere Objekte mit gleichem IdLD und Modul, und Level > 0, und entferne die Objekte mit dem höchsten Level - const filteredStatis = []; - const seenKeys = new Set(); + const filteredStatis = []; + const seenKeys = new Set(); - sortedStatis.forEach((statis) => { - const key = `${statis.IdLD}-${statis.Modul}`; + sortedStatis.forEach((statis) => { + const key = `${statis.IdLD}-${statis.Modul}`; - if (statis.Level > 0) { - if (!seenKeys.has(key)) { - seenKeys.add(key); - filteredStatis.push(statis); // Behalte das Objekt mit dem niedrigsten Level (höchste Priorität) + if (statis.Level > 0) { + if (!seenKeys.has(key)) { + seenKeys.add(key); + filteredStatis.push(statis); + } + } else { + filteredStatis.push(statis); } - } else { - // Für Level -1 oder nicht relevante Meldungen einfach hinzufügen - filteredStatis.push(statis); - } - }); + }); - //console.log("Gefilterte Daten (Objekte mit höchstem Level entfernt):", filteredStatis); - - filteredStatis.forEach((statis) => { - const key = `${statis.IdLD}-${statis.Modul}`; - if (!valueMap[key]) { - valueMap[key] = { - messages: [], - messwert: undefined, - schleifenwert: undefined, - }; - } - - // Sammle Messwert und Schleifenwert - if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) { - valueMap[key].messwert = statis.Value; - } - if (statis.DpName.endsWith("_Schleifenwert") && !valueMap[key].schleifenwert) { - valueMap[key].schleifenwert = statis.Value; - } - if (statis.Message && statis.Message !== "?") { - valueMap[key].messages.push(statis.Message); - } - }); - - // Jetzt durch alle Prioritätslevel gehen und die Farben sowie Meldungen korrekt setzen - filteredStatis.forEach((statis) => { - const key = `${statis.IdLD}-${statis.Modul}`; - const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul); - - if (matchingLine) { - const prioColor = statis.PrioColor === "#ffffff" ? "green" : statis.PrioColor; - const values = valueMap[key]; - - if (!values) { - console.error(`Keine Werte gefunden für Key: ${key}`); - return; + filteredStatis.forEach((statis) => { + const key = `${statis.IdLD}-${statis.Modul}`; + if (!valueMap[key]) { + valueMap[key] = { + messages: [], + messwert: undefined, + schleifenwert: undefined, + }; } - // Nachrichtenanzeige - const messageDisplay = values.messages.map((msg) => (msg ? `${msg}
` : "")).join(""); - const prioNameDisplay = statis.PrioName && statis.PrioName !== "?" ? `(${statis.PrioName})` : ""; + if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) { + valueMap[key].messwert = statis.Value; + } + if (statis.DpName.endsWith("_Schleifenwert") && !valueMap[key].schleifenwert) { + valueMap[key].schleifenwert = statis.Value; + } + if (statis.Message && statis.Message !== "?") { + valueMap[key].messages.push(statis.Message); + } + }); + + filteredStatis.forEach((statis) => { + const key = `${statis.IdLD}-${statis.Modul}`; + const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul); + + if (matchingLine) { + const prioColor = statis.PrioColor === "#ffffff" ? "green" : statis.PrioColor; + const values = valueMap[key]; + + if (!values) { + console.error(`Keine Werte gefunden für Key: ${key}`); + return; + } + + const messageDisplay = values.messages.map((msg) => (msg ? `${msg}
` : "")).join(""); + const prioNameDisplay = statis.PrioName && statis.PrioName !== "?" ? `(${statis.PrioName})` : ""; + + colorsByModule[key] = prioColor; - // Setze die Farbe und Tooltip für jede Linie (für alle Prioritätslevel) - colorsByModule[key] = prioColor; - // Überprüfe, ob ModulTyp den Text "705-FO" enthält - if (statis.ModulTyp && statis.ModulTyp.includes("705-FO")) { newTooltipContents[key] = `
${statis.ModulName || "Unknown"} @@ -122,46 +109,38 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""}
`; - } else { - newTooltipContents[key] = ` -
- ${statis.ModulName || "Unknown"} -
- ${statis.ModulTyp || "N/A"} -
- Slot: ${statis.Modul || "N/A"} -
- Station: ${namesData[matchingLine.idLD] || "N/A"} -
-
- - ${messageDisplay} -
- ${prioNameDisplay} -
- -
- `; } - } - }); + }); - // Setze die Farben und Tooltip-Inhalte - setLineColors(colorsByModule); - setTooltipContents(newTooltipContents); - setLineStatusData(data1.Statis); + setLineColors(colorsByModule); + setTooltipContents(newTooltipContents); + setLineStatusData(data1.Statis); + } } catch (error) { - console.error("Fehler beim Abrufen der Daten:", error); + if (!isCancelled) { + console.error("Fehler beim Abrufen der Daten:", error); + } } }; + // Funktion für rekursiven Aufruf mit Timeout + const scheduleNextFetch = () => { + if (!isCancelled) { + setTimeout(async () => { + await fetchData(); + scheduleNextFetch(); + }, 20000); + } + }; + + // Starte den ersten Aufruf fetchData(); + scheduleNextFetch(); - // Setze ein Intervall, um die Daten alle 20 Sekunden erneut abzurufen - const intervalId = setInterval(fetchData, 20000); - - // Räumt das Intervall auf, wenn die Komponente entladen wird - return () => clearInterval(intervalId); + // Cleanup-Funktion, um sicherzustellen, dass keine weiteren Daten nach dem Unmount gesetzt werden + return () => { + isCancelled = true; + }; }, [webserviceGisLinesStatusUrl, setLineStatusData]); return { lineColors, tooltipContents }; From 6167cbe5b233ae357d2c6c772abf4f8663fd5bf9 Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 20:46:12 +0200 Subject: [PATCH 22/47] feat: Display multiple messages with individual prioColor in line tooltips - Added support for displaying multiple messages per module in tooltips - Each message now correctly displays its respective prioColor - Enhanced message rendering for better visual clarity, including colored indicators for each message - Fixed sorting and filtering of messages based on level and status --- .env.local | 38 ++++++++++----------- hooks/useLineData.js | 78 ++++++++++++++++++++------------------------ 2 files changed, 55 insertions(+), 61 deletions(-) diff --git a/.env.local b/.env.local index 9f1fbbc78..06b79e736 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -DB_HOST=10.10.0.70 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 - -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -#DB_HOST=192.168.10.167 +#DB_HOST=10.10.0.70 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +DB_HOST=192.168.10.168 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -#NEXT_PUBLIC_BASE_URL="http://192.168.10.167/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://192.168.10.167" -#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.167" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/hooks/useLineData.js b/hooks/useLineData.js index daf3edaca..cadac5532 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -30,28 +30,12 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const newTooltipContents = {}; const valueMap = {}; - logGroupedData(data1.Statis); - + // Sortiere Statis nach Level const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level); - const filteredStatis = []; - const seenKeys = new Set(); - sortedStatis.forEach((statis) => { const key = `${statis.IdLD}-${statis.Modul}`; - if (statis.Level > 0) { - if (!seenKeys.has(key)) { - seenKeys.add(key); - filteredStatis.push(statis); - } - } else { - filteredStatis.push(statis); - } - }); - - filteredStatis.forEach((statis) => { - const key = `${statis.IdLD}-${statis.Modul}`; if (!valueMap[key]) { valueMap[key] = { messages: [], @@ -60,23 +44,28 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { }; } + // Sammle Messwert und Schleifenwert if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) { valueMap[key].messwert = statis.Value; } if (statis.DpName.endsWith("_Schleifenwert") && !valueMap[key].schleifenwert) { valueMap[key].schleifenwert = statis.Value; } + + // Füge die Meldung zusammen mit der entsprechenden PrioColor hinzu if (statis.Message && statis.Message !== "?") { - valueMap[key].messages.push(statis.Message); + valueMap[key].messages.push({ + message: statis.Message, + prioColor: statis.PrioColor && statis.PrioColor !== "#ffffff" ? statis.PrioColor : "green", + }); } }); - filteredStatis.forEach((statis) => { + sortedStatis.forEach((statis) => { const key = `${statis.IdLD}-${statis.Modul}`; const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul); if (matchingLine) { - const prioColor = statis.PrioColor === "#ffffff" ? "green" : statis.PrioColor; const values = valueMap[key]; if (!values) { @@ -84,31 +73,36 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { return; } - const messageDisplay = values.messages.map((msg) => (msg ? `${msg}
` : "")).join(""); + // Generiere das HTML für jede Meldung mit der jeweiligen PrioColor + const messageDisplay = + values.messages.length > 0 + ? values.messages.map((msg) => `${msg.message}
`).join("") + : ""; + const prioNameDisplay = statis.PrioName && statis.PrioName !== "?" ? `(${statis.PrioName})` : ""; - colorsByModule[key] = prioColor; + // Setze die Hauptfarbe für das Modul basierend auf der PrioColor der ersten Meldung + colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green"; newTooltipContents[key] = ` -
- ${statis.ModulName || "Unknown"} -
- ${statis.ModulTyp || "N/A"} -
- Slot: ${statis.Modul || "N/A"} -
- Station: ${namesData[matchingLine.idLD] || "N/A"} -
-
- - ${messageDisplay} -
- ${prioNameDisplay} -
- ${values.messwert ? `Messwert: ${values.messwert}
` : ""} - ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""} -
- `; +
+ ${statis.ModulName || "Unknown"} +
+ ${statis.ModulTyp || "N/A"} +
+ Slot: ${statis.Modul || "N/A"} +
+ Station: ${namesData[matchingLine.idLD] || "N/A"} +
+
+ ${messageDisplay} +
+ ${prioNameDisplay} +
+ ${values.messwert ? `Messwert: ${values.messwert}
` : ""} + ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""} +
+ `; } }); @@ -206,7 +200,7 @@ function logGroupedData(statisList) { } }); - //console.log("Aggregierte und gruppierte Daten (gefiltert):", formattedData); + console.log("Aggregierte und gruppierte Daten (gefiltert):", formattedData); } export default useLineData; From 2da00799dd89965738692e098ee928beea2c1f17 Mon Sep 17 00:00:00 2001 From: ISA Date: Tue, 10 Sep 2024 20:55:42 +0200 Subject: [PATCH 23/47] =?UTF-8?q?Linien=20Tooltip=20offset=20auf=2020,=20d?= =?UTF-8?q?amit=20der=20Cursor=20nicht=20dr=C3=BCber=20steht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/MapComponent.js | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 449f4f12b..1e46307ec 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -498,7 +498,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }; fetchData(); }, []); - + //-------------------------------------------- //Tooltip an mouse position anzeigen für die Linien useEffect(() => { if (!map) return; @@ -517,7 +517,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { permanent: false, direction: "auto", sticky: true, - offset: [0, 10], + offset: [20, 0], pane: "tooltipPane", }); @@ -561,7 +561,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { setMarkers(newMarkers); setPolylines(newPolylines); }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker]); - // }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker]); + //-------------------------------------------- useEffect(() => { @@ -592,6 +592,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { }; } }, [map]); + //-------------------------------------------- useEffect(() => { if (selectedArea && map) { @@ -608,12 +609,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } }, [zoomTrigger, map]); - /* useEffect(() => { - if (mapRef.current && !map) { - initializeMap(mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights); - } - }, [mapRef, map, hasRights, addItemsToMapContextMenu]); */ - useEffect(() => { if (map && poiLayerRef.current && isPoiTypLoaded && !menuItemAdded && isRightsLoaded) { addItemsToMapContextMenu(map, menuItemAdded, setMenuItemAdded, hasRights, setShowPopup, setPopupCoordinates); @@ -638,18 +633,6 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { fetchPriorityConfig(); }, []); //-------------------------------------------- - /* useEffect(() => { - if (!map) return; - - markers.forEach((marker) => marker.remove()); - polylines.forEach((polyline) => polyline.remove()); - - const { markers: newMarkers, polylines: newPolylines } = setupPolylines(map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter); - - setMarkers(newMarkers); - setPolylines(newPolylines); - }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker, currentZoom, currentCenter]); // Ensure currentZoom and currentCenter are included in the dependency array */ - //-------------------------------------------- useEffect(() => { if (mapRef.current && !map) { initializeMap(mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled); From fb0e8b817d8d982d2004a82b81b7dcb4eef88113 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 06:47:52 +0200 Subject: [PATCH 24/47] delete prioNameDisplay in Tooltip for polyline --- .env.local | 38 +++++++++++++++++++------------------- hooks/useLineData.js | 1 - 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.env.local b/.env.local index 06b79e736..f808f5136 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -#DB_HOST=10.10.0.70 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 - -######################### - -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -DB_HOST=192.168.10.168 +DB_HOST=10.10.0.70 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 DB_PORT=3306 + +######################### + +NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +#DB_HOST=192.168.10.168 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/hooks/useLineData.js b/hooks/useLineData.js index cadac5532..cb19e99a4 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -97,7 +97,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => {
${messageDisplay}
- ${prioNameDisplay}
${values.messwert ? `Messwert: ${values.messwert}
` : ""} ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""} From f5e9de16f672062d9500cc931b598c7a1b4141a7 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 08:58:01 +0200 Subject: [PATCH 25/47] Ein einfacher externer WebSocket-Server und in useLineData.js testen --- hooks/useLineData.js | 79 +++++++++++++++++++++++++----------------- pages/api/websocket.js | 27 --------------- websocket-server.js | 19 ++++++++++ 3 files changed, 66 insertions(+), 59 deletions(-) delete mode 100644 pages/api/websocket.js create mode 100644 websocket-server.js diff --git a/hooks/useLineData.js b/hooks/useLineData.js index cb19e99a4..2a3e79b09 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -9,6 +9,29 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const messages = useSelector((state) => state.messages); const [lineColors, setLineColors] = useState({}); const [tooltipContents, setTooltipContents] = useState({}); + const [webSocketMessages, setWebSocketMessages] = useState([]); + + useEffect(() => { + const ws = new WebSocket("ws://localhost:3001"); // Verwende den externen WebSocket-Server + + ws.onopen = () => { + console.log("WebSocket-Verbindung hergestellt"); + }; + + ws.onmessage = (event) => { + const message = JSON.parse(event.data); + setWebSocketMessages((prev) => [...prev, message]); + console.log("WebSocket-Nachricht erhalten:", message); + }; + + ws.onclose = () => { + console.log("WebSocket-Verbindung geschlossen"); + }; + + return () => { + ws.close(); + }; + }, []); useEffect(() => { let isCancelled = false; // Flag to cancel ongoing operations if component unmounts @@ -30,7 +53,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const newTooltipContents = {}; const valueMap = {}; - // Sortiere Statis nach Level const sortedStatis = [...data1.Statis].sort((a, b) => a.Level - b.Level); sortedStatis.forEach((statis) => { @@ -44,7 +66,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { }; } - // Sammle Messwert und Schleifenwert if (statis.DpName.endsWith("_Messwert") && statis.Value !== "True" && !valueMap[key].messwert) { valueMap[key].messwert = statis.Value; } @@ -52,7 +73,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { valueMap[key].schleifenwert = statis.Value; } - // Füge die Meldung zusammen mit der entsprechenden PrioColor hinzu if (statis.Message && statis.Message !== "?") { valueMap[key].messages.push({ message: statis.Message, @@ -73,33 +93,28 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { return; } - // Generiere das HTML für jede Meldung mit der jeweiligen PrioColor - const messageDisplay = - values.messages.length > 0 - ? values.messages.map((msg) => `${msg.message}
`).join("") - : ""; + const messageDisplay = values.messages.map((msg) => `${msg.message}
`).join(""); const prioNameDisplay = statis.PrioName && statis.PrioName !== "?" ? `(${statis.PrioName})` : ""; - // Setze die Hauptfarbe für das Modul basierend auf der PrioColor der ersten Meldung colorsByModule[key] = values.messages.length > 0 ? values.messages[0].prioColor : "green"; newTooltipContents[key] = `
- ${statis.ModulName || "Unknown"} -
- ${statis.ModulTyp || "N/A"} -
- Slot: ${statis.Modul || "N/A"} -
- Station: ${namesData[matchingLine.idLD] || "N/A"} -
-
- ${messageDisplay} -
-
- ${values.messwert ? `Messwert: ${values.messwert}
` : ""} - ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""} + ${statis.ModulName || "Unknown"} +
+ ${statis.ModulTyp || "N/A"} +
+ Slot: ${statis.Modul || "N/A"} +
+ Station: ${namesData[matchingLine.idLD] || "N/A"} +
+
+ ${messageDisplay} +
+
+ ${values.messwert ? `Messwert: ${values.messwert}
` : ""} + ${values.schleifenwert ? `Schleifenwert: ${values.schleifenwert}` : ""}
`; } @@ -110,27 +125,27 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { setLineStatusData(data1.Statis); } } catch (error) { - if (!isCancelled) { - console.error("Fehler beim Abrufen der Daten:", error); + console.error("Fehler beim Abrufen der Daten:", error); + + // Füge einen try-catch Block für den Reload hinzu + try { + window.location.reload(); + } catch (reloadError) { + console.error("Fehler beim Neuladen der Seite:", reloadError); } } }; - // Funktion für rekursiven Aufruf mit Timeout const scheduleNextFetch = () => { if (!isCancelled) { - setTimeout(async () => { - await fetchData(); - scheduleNextFetch(); - }, 20000); + fetchData(); + setTimeout(scheduleNextFetch, 20000); } }; - // Starte den ersten Aufruf fetchData(); scheduleNextFetch(); - // Cleanup-Funktion, um sicherzustellen, dass keine weiteren Daten nach dem Unmount gesetzt werden return () => { isCancelled = true; }; diff --git a/pages/api/websocket.js b/pages/api/websocket.js deleted file mode 100644 index 20b4c6716..000000000 --- a/pages/api/websocket.js +++ /dev/null @@ -1,27 +0,0 @@ -// /pages/api/websocket.js -import { Server } from "ws"; - -export default function handler(req, res) { - if (!res.socket.server.ws) { - console.log("Starting WebSocket server"); - const wss = new Server({ server: res.socket.server }); - - wss.on("connection", (ws) => { - console.log("New WebSocket connection"); - - ws.on("message", (message) => { - console.log("Received:", message); - // Beispielnachricht an den Client senden - ws.send(JSON.stringify({ message: "Hallo von WebSocket-Server" })); - }); - - // Schließe die Verbindung - ws.on("close", () => { - console.log("WebSocket connection closed"); - }); - }); - - res.socket.server.ws = wss; - } - res.end(); -} diff --git a/websocket-server.js b/websocket-server.js new file mode 100644 index 000000000..63ada340e --- /dev/null +++ b/websocket-server.js @@ -0,0 +1,19 @@ +const WebSocket = require("ws"); + +// Starte den WebSocket-Server auf Port 3001 +const wss = new WebSocket.Server({ port: 3001 }); + +wss.on("connection", (ws) => { + console.log("New WebSocket connection"); + + ws.on("message", (message) => { + console.log("Received:", message); + ws.send(JSON.stringify({ message: "Hallo vom WebSocket-Server" })); + }); + + ws.on("close", () => { + console.log("WebSocket connection closed"); + }); +}); + +console.log("WebSocket-Server läuft auf ws://localhost:3001"); From f16d389dfdbb0700e9e678a380d9a3693de83562 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 09:38:51 +0200 Subject: [PATCH 26/47] feat: Persist checkbox states in localStorage to retain settings after page reload - Implemented logic to save the visibility states of POI and map layers in localStorage. - Loaded saved checkbox states on component mount to retain user preferences. - Updated `handleCheckboxChange` and `handlePoiCheckboxChange` to store changes in localStorage. - Ensured that settings persist across page reloads for a better user experience. --- components/DataSheet.js | 29 ++++++++++++++++++++--------- hooks/useLineData.js | 2 ++ websocket-server.js | 18 ++++++++++++++++-- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/components/DataSheet.js b/components/DataSheet.js index cc9ab003a..80d875dd8 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -18,6 +18,18 @@ function DataSheet() { const GisSystemStatic = useRecoilValue(gisSystemStaticState); const setZoomTrigger = useSetRecoilState(zoomTriggerState); + useEffect(() => { + const storedPoiVisible = localStorage.getItem("poiVisible"); + if (storedPoiVisible !== null) { + setPoiVisible(storedPoiVisible === "true"); + } + + const storedMapLayersVisibility = localStorage.getItem("mapLayersVisibility"); + if (storedMapLayersVisibility) { + setMapLayersVisibility(JSON.parse(storedMapLayersVisibility)); + } + }, [setPoiVisible, setMapLayersVisibility]); + const handleAreaChange = (event) => { const selectedIndex = event.target.options.selectedIndex; const areaName = event.target.options[selectedIndex].text; @@ -69,10 +81,17 @@ function DataSheet() { ...prev, [name]: checked, }; + localStorage.setItem("mapLayersVisibility", JSON.stringify(newState)); // Store in localStorage return newState; }); }; + const handlePoiCheckboxChange = (event) => { + const { checked } = event.target; + setPoiVisible(checked); + localStorage.setItem("poiVisible", checked); // Store POI visibility in localStorage + }; + const handleIconClick = () => { setSelectedArea("Station wählen"); setZoomTrigger((current) => current + 1); @@ -104,15 +123,7 @@ function DataSheet() {
))} - { - const checked = e.target.checked; - setPoiVisible(checked); - }} - id="poi-checkbox" - /> + diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 2a3e79b09..1140e7c47 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -16,6 +16,8 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { ws.onopen = () => { console.log("WebSocket-Verbindung hergestellt"); + // Testnachricht an den Server senden + ws.send(JSON.stringify({ type: "test", message: "Hallo vom Client" })); }; ws.onmessage = (event) => { diff --git a/websocket-server.js b/websocket-server.js index 63ada340e..fae14eb4d 100644 --- a/websocket-server.js +++ b/websocket-server.js @@ -7,8 +7,22 @@ wss.on("connection", (ws) => { console.log("New WebSocket connection"); ws.on("message", (message) => { - console.log("Received:", message); - ws.send(JSON.stringify({ message: "Hallo vom WebSocket-Server" })); + // Konvertiere den Buffer in einen String + const messageString = message.toString(); + + console.log("Received:", messageString); + + // Versuche die Nachricht in JSON zu parsen + try { + const parsedMessage = JSON.parse(messageString); + + // Beispielnachricht an den Client zurücksenden + if (parsedMessage.type === "test") { + ws.send(JSON.stringify({ message: `Hallo zurück, ${parsedMessage.message}` })); + } + } catch (error) { + console.error("Fehler beim Parsen der Nachricht:", error); + } }); ws.on("close", () => { From fdd8f13a3aba4af6e0216698b1eca1e359e8adfa Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 10:15:00 +0200 Subject: [PATCH 27/47] WebSocket client and server communication --- websocket-server.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/websocket-server.js b/websocket-server.js index fae14eb4d..d233ed4cb 100644 --- a/websocket-server.js +++ b/websocket-server.js @@ -7,21 +7,12 @@ wss.on("connection", (ws) => { console.log("New WebSocket connection"); ws.on("message", (message) => { - // Konvertiere den Buffer in einen String - const messageString = message.toString(); + console.log("Received:", message); + const parsedMessage = JSON.parse(message); - console.log("Received:", messageString); - - // Versuche die Nachricht in JSON zu parsen - try { - const parsedMessage = JSON.parse(messageString); - - // Beispielnachricht an den Client zurücksenden - if (parsedMessage.type === "test") { - ws.send(JSON.stringify({ message: `Hallo zurück, ${parsedMessage.message}` })); - } - } catch (error) { - console.error("Fehler beim Parsen der Nachricht:", error); + // Beispielnachricht an den Client zurücksenden + if (parsedMessage.type === "test") { + ws.send(JSON.stringify({ message: `Hallo zurück, ${parsedMessage.message}` })); } }); From a43fbff4f846a33e8a83a2194f8eb218c55b1419 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 10:35:38 +0200 Subject: [PATCH 28/47] contexmenu handle in MapComponent wegen error contextmenu nicht vorhanden --- components/MapComponent.js | 14 ++++++++++++++ hooks/useLineData.js | 26 ------------------------- utils/initializeMap.js | 39 +++++++++++++++++++++++++------------- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index 1e46307ec..f9d35753f 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -655,6 +655,20 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { // Setze die Karteninstanz in den Recoil-Atom } }, [map]); + //-------------------------------------------- + // contextmenü Error "Contextmenu ist nicht vorhanden" + useEffect(() => { + if (map) { + // Überprüfe, ob die Karte und das Contextmenu existieren + if (map.contextmenu) { + console.log("Contextmenu ist vorhanden"); + // Hier kannst du deine Logik für das Contextmenu hinzufügen + map.contextmenu.hide(); // Beispiel: Contextmenu verstecken + } else { + console.warn("Contextmenu ist nicht vorhanden"); + } + } + }, [map]); return ( <> diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 1140e7c47..1856d1716 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -2,38 +2,12 @@ import { useEffect, useState } from "react"; import { SERVER_URL } from "../config/urls"; import { useDispatch, useSelector } from "react-redux"; -import { connectWebSocket, disconnectWebSocket } from "../redux/actions"; const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const dispatch = useDispatch(); const messages = useSelector((state) => state.messages); const [lineColors, setLineColors] = useState({}); const [tooltipContents, setTooltipContents] = useState({}); - const [webSocketMessages, setWebSocketMessages] = useState([]); - - useEffect(() => { - const ws = new WebSocket("ws://localhost:3001"); // Verwende den externen WebSocket-Server - - ws.onopen = () => { - console.log("WebSocket-Verbindung hergestellt"); - // Testnachricht an den Server senden - ws.send(JSON.stringify({ type: "test", message: "Hallo vom Client" })); - }; - - ws.onmessage = (event) => { - const message = JSON.parse(event.data); - setWebSocketMessages((prev) => [...prev, message]); - console.log("WebSocket-Nachricht erhalten:", message); - }; - - ws.onclose = () => { - console.log("WebSocket-Verbindung geschlossen"); - }; - - return () => { - ws.close(); - }; - }, []); useEffect(() => { let isCancelled = false; // Flag to cancel ongoing operations if component unmounts diff --git a/utils/initializeMap.js b/utils/initializeMap.js index 4e4b561a4..582210a83 100644 --- a/utils/initializeMap.js +++ b/utils/initializeMap.js @@ -5,9 +5,9 @@ import "leaflet/dist/leaflet.css"; import "leaflet-contextmenu/dist/leaflet.contextmenu.css"; import * as urls from "../config/urls.js"; import * as layers from "../config/layers.js"; -import { openInNewTab } from "./openInNewTab.js"; // Korrigiert +import { openInNewTab } from "./openInNewTab.js"; -export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights) => { +export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItemsToMapContextMenu, hasRights, setPolylineEventsDisabled) => { if (mapRef.current) { const initMap = L.map(mapRef.current, { center: [53.111111, 8.4625], @@ -25,20 +25,25 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems const link = localStorage.getItem("polylineLink"); const clickedElement = e.relatedTarget; - // Überprüfe, ob der Kontextklick auf eine Polyline oder einen Marker erfolgt ist - if (link) { - const newTab = window.open(link, "_blank"); - if (newTab) { - // Wenn der Tab geöffnet wird, lösche die `localStorage`-Einträge - localStorage.removeItem("polylineLink"); - localStorage.removeItem("lastElementType"); + // Überprüfe, ob Karte und contextmenu existieren + if (initMap && initMap.contextmenu) { + // Verarbeite Kontextmenü-Callback + if (link) { + const newTab = window.open(link, "_blank"); + if (newTab) { + // Lösche Einträge im localStorage + localStorage.removeItem("polylineLink"); + localStorage.removeItem("lastElementType"); + } else { + console.error("Fehler: Das neue Tab konnte nicht geöffnet werden."); + } + } else if (clickedElement instanceof L.Marker || clickedElement instanceof L.Polyline) { + openInNewTab(e, clickedElement); } else { - console.error("Fehler: Das neue Tab konnte nicht geöffnet werden."); + console.error("Kein gültiges Ziel für den Kontextmenüeintrag"); } - } else if (clickedElement instanceof L.Marker || clickedElement instanceof L.Polyline) { - openInNewTab(e, clickedElement); // Verwende openInNewTab für beide Fälle } else { - console.error("Kein gültiges Ziel für den Kontextmenüeintrag"); + console.error("Karte oder Kontextmenü nicht verfügbar."); } }, }, @@ -46,15 +51,23 @@ export const initializeMap = (mapRef, setMap, setOms, setMenuItemAdded, addItems ], }); + // Füge die Tile-Layer hinzu L.tileLayer(urls.ONLINE_TILE_LAYER, { attribution: '© OpenStreetMap contributors', }).addTo(initMap); + // Initialisiere OverlappingMarkerSpiderfier const overlappingMarkerSpiderfier = new OverlappingMarkerSpiderfier(initMap, { nearbyDistance: 20, }); + // Setze die Map und OMS in den State setMap(initMap); setOms(overlappingMarkerSpiderfier); + + // Wenn Rechte geladen sind und es noch nicht hinzugefügt wurde, füge das Kontextmenü hinzu + if (hasRights && !setMenuItemAdded) { + addItemsToMapContextMenu(initMap, setMenuItemAdded, setPolylineEventsDisabled); + } } }; From 30f671e1c108ca82986d5f6bd9e57e319d2c273f Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 10:57:36 +0200 Subject: [PATCH 29/47] fix: adjust dropdown menu width and layout for better responsiveness - Set fixed min-width (150px) and max-width (200px) for the dropdown menu to ensure it does not expand too much on smaller screens. - Removed flex-grow from dropdown to prevent it from taking excess space. - Improved flex layout between dropdown, EditModeToggle, and expand icon to ensure proper spacing and alignment. --- components/DataSheet.js | 17 ++++++++++++----- components/EditModeToggle.js | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/DataSheet.js b/components/DataSheet.js index 80d875dd8..2bdee6ec0 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -98,10 +98,15 @@ function DataSheet() { }; return ( -
+
-
- {stationListing.map((station) => ( ))} - - Expand +
+ + Expand +
diff --git a/components/EditModeToggle.js b/components/EditModeToggle.js index 051fac5d0..289a5e8fc 100644 --- a/components/EditModeToggle.js +++ b/components/EditModeToggle.js @@ -1,5 +1,5 @@ +// /components/EditModeToggle.js import React, { useState, useEffect } from "react"; -import DesignServicesIcon from "@mui/icons-material/DesignServices"; import EditOffIcon from "@mui/icons-material/EditOff"; import ModeEditIcon from "@mui/icons-material/ModeEdit"; import Tooltip from "@mui/material/Tooltip"; // Importiere Tooltip von Material-UI From 8a01ca88149868effffa15aac33ff78ddb0b7be6 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 14:53:13 +0200 Subject: [PATCH 30/47] fix: close context menu 2 seconds before API call to prevent errors - Implemented logic to monitor the context menu state and ensure it closes 2 seconds before the 20-second interval API call - Added functionality to log remaining time while the context menu is open for better debugging - Refactored interval handling to reset remaining time and close the context menu properly - Addressed runtime error related to null context menu handling --- components/MapComponent.js | 26 ++++++++------ hooks/useLineData.js | 74 +------------------------------------- utils/setupPolylines.js | 26 ++++++++++++++ 3 files changed, 42 insertions(+), 84 deletions(-) diff --git a/components/MapComponent.js b/components/MapComponent.js index f9d35753f..e705f9ff9 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -76,6 +76,7 @@ import { polylineEventsDisabledState } from "../store/atoms/polylineEventsDisabl import { disablePolylineEvents, enablePolylineEvents } from "../utils/setupPolylines"; const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { + const [editMode, setEditMode] = useState(false); // editMode Zustand const { deviceName, setDeviceName } = useMapComponentState(); const { poiTypData, isPoiTypLoaded } = usePoiTypData("/api/talas_v5_DB/poiTyp/readPoiTyp"); //const [deviceName, setDeviceName] = useState(""); @@ -656,20 +657,23 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { } }, [map]); //-------------------------------------------- - // contextmenü Error "Contextmenu ist nicht vorhanden" useEffect(() => { - if (map) { - // Überprüfe, ob die Karte und das Contextmenu existieren - if (map.contextmenu) { - console.log("Contextmenu ist vorhanden"); - // Hier kannst du deine Logik für das Contextmenu hinzufügen - map.contextmenu.hide(); // Beispiel: Contextmenu verstecken - } else { - console.warn("Contextmenu ist nicht vorhanden"); + const initializeContextMenu = () => { + if (map) { + map.whenReady(() => { + setTimeout(() => { + if (map.contextmenu) { + console.log("Contextmenu ist vorhanden"); + } else { + console.warn("Contextmenu ist nicht verfügbar."); + } + }, 500); + }); } - } - }, [map]); + }; + initializeContextMenu(); + }, [map]); return ( <> diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 1856d1716..3798f3fbe 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -1,4 +1,3 @@ -// /hooks/useLineData.js import { useEffect, useState } from "react"; import { SERVER_URL } from "../config/urls"; import { useDispatch, useSelector } from "react-redux"; @@ -10,11 +9,10 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { const [tooltipContents, setTooltipContents] = useState({}); useEffect(() => { - let isCancelled = false; // Flag to cancel ongoing operations if component unmounts + let isCancelled = false; const fetchData = async () => { try { - console.log("Fetching data..."); const response1 = await fetch(webserviceGisLinesStatusUrl); const data1 = await response1.json(); @@ -64,11 +62,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { if (matchingLine) { const values = valueMap[key]; - if (!values) { - console.error(`Keine Werte gefunden für Key: ${key}`); - return; - } - const messageDisplay = values.messages.map((msg) => `${msg.message}
`).join(""); const prioNameDisplay = statis.PrioName && statis.PrioName !== "?" ? `(${statis.PrioName})` : ""; @@ -102,8 +95,6 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { } } catch (error) { console.error("Fehler beim Abrufen der Daten:", error); - - // Füge einen try-catch Block für den Reload hinzu try { window.location.reload(); } catch (reloadError) { @@ -130,67 +121,4 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { return { lineColors, tooltipContents }; }; -// Funktion zur Gruppierung der Daten -function logGroupedData(statisList) { - const grouped = statisList.reduce((acc, item) => { - const { IdLD, Modul, Level, PrioColor, PrioName, ModulName, ModulTyp, Message, DpName, Value } = item; - - if (!acc[IdLD]) { - acc[IdLD] = {}; - } - - if (!acc[IdLD][Modul]) { - acc[IdLD][Modul] = { - ModulName: ModulName || "Unknown", - ModulTyp: ModulTyp || "N/A", - TotalLevel: Level, - PrioColors: new Set(), - PrioNames: new Set(), - Messages: [], - Messwert: undefined, - Schleifenwert: undefined, - }; - } - - acc[IdLD][Modul].PrioColors.add(PrioColor); - acc[IdLD][Modul].PrioNames.add(PrioName); - if (Message && Message !== "?") { - acc[IdLD][Modul].Messages.push(Message); - } - - if (DpName.endsWith("_Messwert") && !acc[IdLD][Modul].Messwert) { - acc[IdLD][Modul].Messwert = Value; - } - - if (DpName.endsWith("_Schleifenwert") && !acc[IdLD][Modul].Schleifenwert) { - acc[IdLD][Modul].Schleifenwert = Value; - } - - return acc; - }, {}); - - const formattedData = {}; - Object.entries(grouped).forEach(([stationId, modules]) => { - const filteredModules = Object.entries(modules) - .filter(([modulId, data]) => data.ModulName !== "?") - .map(([modulId, data]) => ({ - Modul: modulId, - ModulName: data.ModulName, - ModulTyp: data.ModulTyp, - TotalLevel: data.TotalLevel, - PrioColors: Array.from(data.PrioColors).join(", "), - PrioNames: Array.from(data.PrioNames).join(", "), - Messages: data.Messages.join(" | "), - Messwert: data.Messwert, - Schleifenwert: data.Schleifenwert, - })); - - if (filteredModules.length > 0) { - formattedData[stationId] = filteredModules; - } - }); - - console.log("Aggregierte und gruppierte Daten (gefiltert):", formattedData); -} - export default useLineData; diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index d3a7cce18..795e4aa4f 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -37,6 +37,31 @@ export function enablePolylineEvents(polylines, lineColors) { }); } +// Funktion zum Schließen des Kontextmenüs vor dem Intervall +const closeContextMenuBeforeInterval = (map) => { + if (map && map.contextmenu && map.contextmenu.isVisible && map.contextmenu.isVisible()) { + console.log("Schließe Kontextmenü 2 Sekunden vor dem Intervall"); + map.contextmenu.hide(); + } +}; + +// Zeitintervall mit Schließen des Kontextmenüs 2 Sekunden vorher +export const startIntervalWithContextMenuHandling = (map) => { + setInterval(() => { + remainingTime = 20; // Zeit zurücksetzen für den neuen Durchlauf + // Kontextmenü überwachen + monitorContextMenu(map); + + // Schließe das Kontextmenü 2 Sekunden vor dem API-Aufruf + setTimeout(() => { + closeContextMenuBeforeInterval(map); + }, 18000); // 18 Sekunden warten, dann schließen + + // API-Aufruf oder Logik, die alle 20 Sekunden ausgeführt wird + fetchData(); + }, 20000); // 20-Sekunden-Intervall +}; + export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter) => { const markers = []; const polylines = []; @@ -223,6 +248,7 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, console.log("Link der Linie (via Rechtsklick):", link); localStorage.setItem("lastElementType", "polyline"); localStorage.setItem("polylineLink", link); + closeContextMenuBeforeInterval(map); }); polylines.push(polyline); From 633886b4664f8f982b033851f5dadb106103c016 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 15:35:13 +0200 Subject: [PATCH 31/47] =?UTF-8?q?delete=20doppelte=20Best=C3=A4tigung=20PO?= =?UTF-8?q?I=20wurde=20erfolgreich=20gel=C3=B6scht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/PoiUpdateModal.js | 2 +- components/pois/PoiUpdateModal.js | 2 +- store/atoms/polylineLayerVisibleState.js | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 store/atoms/polylineLayerVisibleState.js diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal.js index 09940017b..07d80b8e6 100644 --- a/components/PoiUpdateModal.js +++ b/components/PoiUpdateModal.js @@ -83,7 +83,7 @@ const PoiUpdateModal = ({ onClose, poiData }) => { method: "DELETE", }); if (response.ok) { - alert("POI wurde erfolgreich gelöscht."); + // alert("POI wurde erfolgreich gelöscht."); onClose(); // Close the modal //Browser neu laden, um die aktualisierte Liste anzuzeigen window.location.reload(); diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index a4ad1e579..c2795c80e 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -54,7 +54,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { method: "DELETE", }); if (response.ok) { - alert("POI wurde erfolgreich gelöscht."); + //alert("POI wurde erfolgreich gelöscht."); onClose(); window.location.reload(); } else { diff --git a/store/atoms/polylineLayerVisibleState.js b/store/atoms/polylineLayerVisibleState.js new file mode 100644 index 000000000..6988d96af --- /dev/null +++ b/store/atoms/polylineLayerVisibleState.js @@ -0,0 +1,7 @@ +// /sttore/atoms/polylineLayerVisibleState.js +import { atom } from "recoil"; + +export const polylineLayerVisibleState = atom({ + key: "polylineLayerVisibleState", + default: true, // Standardmäßig auf sichtbar setzen +}); From f8a4b1f86b02dfc6f2840077ec6504f85b402e4c Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 22:19:04 +0200 Subject: [PATCH 32/47] Kabelstrecken einblenden und ausblenden --- .env.local | 38 ++++++++++++++-------------- .vscode/settings.json | 1 - components/DataSheet.js | 51 +++++++++++++++++++++++++------------- components/MapComponent.js | 37 +++++++++++++++------------ utils/setupPolylines.js | 27 ++++++++++++++++---- 5 files changed, 96 insertions(+), 58 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.env.local b/.env.local index f808f5136..06b79e736 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -DB_HOST=10.10.0.70 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 - -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -#DB_HOST=192.168.10.168 +#DB_HOST=10.10.0.70 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +DB_HOST=192.168.10.168 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 0967ef424..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/components/DataSheet.js b/components/DataSheet.js index 2bdee6ec0..952e4d2e5 100644 --- a/components/DataSheet.js +++ b/components/DataSheet.js @@ -7,6 +7,7 @@ import { selectedAreaState } from "../store/atoms/selectedAreaState"; import { zoomTriggerState } from "../store/atoms/zoomTriggerState"; import { poiLayerVisibleState } from "../store/atoms/poiLayerVisibleState"; import EditModeToggle from "./EditModeToggle"; +import { polylineLayerVisibleState } from "../store/atoms/polylineLayerVisibleState"; // Import für Polyline-Visibility function DataSheet() { const [poiVisible, setPoiVisible] = useRecoilState(poiLayerVisibleState); @@ -17,12 +18,16 @@ function DataSheet() { const GisStationsStaticDistrict = useRecoilValue(gisStationsStaticDistrictState); const GisSystemStatic = useRecoilValue(gisSystemStaticState); const setZoomTrigger = useSetRecoilState(zoomTriggerState); - + const [polylineVisible, setPolylineVisible] = useRecoilState(polylineLayerVisibleState); // Zustand für Polylines useEffect(() => { const storedPoiVisible = localStorage.getItem("poiVisible"); if (storedPoiVisible !== null) { setPoiVisible(storedPoiVisible === "true"); } + const storedPolylineVisible = localStorage.getItem("polylineVisible"); + if (storedPolylineVisible !== null) { + setPolylineVisible(storedPolylineVisible === "true"); + } const storedMapLayersVisibility = localStorage.getItem("mapLayersVisibility"); if (storedMapLayersVisibility) { @@ -96,17 +101,17 @@ function DataSheet() { setSelectedArea("Station wählen"); setZoomTrigger((current) => current + 1); }; + const handlePolylineCheckboxChange = (event) => { + const { checked } = event.target; + setPolylineVisible(checked); + localStorage.setItem("polylineVisible", checked); // Store Polyline visibility in localStorage + }; return (
- {stationListing.map((station) => (
-
+ {/* Checkboxen in einem gemeinsamen Container */} +
{systemListing.map((system) => ( - handleCheckboxChange(system.name, e)} id={`system-${system.id}`} /> - -
+
+ handleCheckboxChange(system.name, e)} id={`system-${system.id}`} /> + +
))} - - + +
+ + +
+ +
+ + +
diff --git a/components/MapComponent.js b/components/MapComponent.js index e705f9ff9..cf6e06960 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -74,8 +74,10 @@ import useCreateAndSetDevices from "../hooks/useCreateAndSetDevices"; import { useMapComponentState } from "../hooks/useMapComponentState"; import { polylineEventsDisabledState } from "../store/atoms/polylineEventsDisabledState"; import { disablePolylineEvents, enablePolylineEvents } from "../utils/setupPolylines"; +import { polylineLayerVisibleState } from "../store/atoms/polylineLayerVisibleState"; const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { + const polylineVisible = useRecoilValue(polylineLayerVisibleState); const [editMode, setEditMode] = useState(false); // editMode Zustand const { deviceName, setDeviceName } = useMapComponentState(); const { poiTypData, isPoiTypLoaded } = usePoiTypData("/api/talas_v5_DB/poiTyp/readPoiTyp"); @@ -509,7 +511,15 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { polylines.forEach((polyline) => polyline.remove()); // Setze neue Marker und Polylinien mit den aktuellen Daten - const { markers: newMarkers, polylines: newPolylines } = setupPolylines(map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker); + const { markers: newMarkers, polylines: newPolylines } = setupPolylines( + map, + linePositions, + lineColors, + tooltipContents, + setNewCoords, + tempMarker, + polylineVisible // polylineVisible wird jetzt korrekt übergeben + ); newPolylines.forEach((polyline, index) => { const tooltipContent = tooltipContents[`${linePositions[index].idLD}-${linePositions[index].idModul}`] || "Standard-Tooltip-Inhalt"; @@ -522,38 +532,31 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { pane: "tooltipPane", }); - // Mausbewegung tracken polyline.on("mouseover", (e) => { const tooltip = polyline.getTooltip(); if (tooltip) { - const mousePos = e.containerPoint; // Mausposition relativ zur Karte - const mapSize = map.getSize(); // Größe der Karte + const mousePos = e.containerPoint; + const mapSize = map.getSize(); - // Berechne die Tooltip-Position, um sicherzustellen, dass sie innerhalb des sichtbaren Bereichs bleibt - let direction = "right"; // Standard-Richtung + let direction = "right"; if (mousePos.x > mapSize.x - 100) { - direction = "left"; // Bewege den Tooltip nach links, wenn der Mauszeiger nahe dem rechten Rand ist + direction = "left"; } else if (mousePos.x < 100) { - direction = "right"; // Bewege den Tooltip nach rechts, wenn der Mauszeiger nahe dem linken Rand ist + direction = "right"; } if (mousePos.y > mapSize.y - 100) { - direction = "top"; // Bewege den Tooltip nach oben, wenn der Mauszeiger nahe dem unteren Rand ist + direction = "top"; } else if (mousePos.y < 100) { - direction = "bottom"; // Bewege den Tooltip nach unten, wenn der Mauszeiger nahe dem oberen Rand ist + direction = "bottom"; } - // Setze die neue Richtung und öffne den Tooltip tooltip.options.direction = direction; polyline.openTooltip(e.latlng); } }); - /* polyline.on("mouseover", () => { - polyline.openTooltip(); - }); */ - polyline.on("mouseout", () => { polyline.closeTooltip(); }); @@ -561,7 +564,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { setMarkers(newMarkers); setPolylines(newPolylines); - }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker]); + }, [map, linePositions, lineColors, tooltipContents, newPoint, newCoords, tempMarker, polylineVisible]); //-------------------------------------------- @@ -674,6 +677,8 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { initializeContextMenu(); }, [map]); + //-------------------------------------------- + return ( <> diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index 795e4aa4f..e7ff84279 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -10,6 +10,8 @@ import endIcon from "../components/gisPolylines/icons/EndIcon"; import { redrawPolyline } from "./mapUtils"; import { openInNewTab } from "./openInNewTab"; import { toast } from "react-toastify"; +import { polylineLayerVisibleState } from "../store/atoms/polylineLayerVisibleState"; +import { useRecoilValue } from "recoil"; // Funktion zum Deaktivieren der Polyline-Ereignisse export function disablePolylineEvents(polylines) { @@ -21,17 +23,21 @@ export function disablePolylineEvents(polylines) { // Funktion zum Aktivieren der Polyline-Ereignisse export function enablePolylineEvents(polylines, lineColors) { + // Überprüfe, ob polylines definiert ist und ob es Elemente enthält + if (!polylines || polylines.length === 0) { + console.warn("Keine Polylinien vorhanden oder polylines ist undefined."); + return; + } + + // Falls Polylinien vorhanden sind, wende die Events an polylines.forEach((polyline) => { polyline.on("mouseover", (e) => { - //console.log("Mouseover on polyline", polyline.options); polyline.setStyle({ weight: 14 }); const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?id=${polyline.options.idLD}`; - //localStorage.setItem("lastElementType", "polyline"); - //localStorage.setItem("polylineLink", link); + // Verwende den Link oder speichere ihn, falls nötig }); polyline.on("mouseout", (e) => { - //console.log("Mouseout from polyline", polyline.options); polyline.setStyle({ weight: 3 }); }); }); @@ -62,7 +68,18 @@ export const startIntervalWithContextMenuHandling = (map) => { }, 20000); // 20-Sekunden-Intervall }; -export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter) => { +export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, polylineVisible) => { + if (!polylineVisible) { + // Entferne alle Polylinien, wenn sie ausgeblendet werden sollen + if (window.polylines) { + window.polylines.forEach((polyline) => { + if (map.hasLayer(polyline)) { + map.removeLayer(polyline); + } + }); + } + return { markers: [], polylines: [] }; + } const markers = []; const polylines = []; const editMode = localStorage.getItem("editMode") === "true"; // Prüfen, ob der Bearbeitungsmodus aktiv ist From 0230600da916a006c052120576992fd79b7f3232 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 11 Sep 2024 22:42:48 +0200 Subject: [PATCH 33/47] =?UTF-8?q?St=C3=BCtzpunkte=20in=20Kontextmen=C3=BC?= =?UTF-8?q?=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/setupPolylines.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index e7ff84279..86e73dc4c 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -265,6 +265,11 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, console.log("Link der Linie (via Rechtsklick):", link); localStorage.setItem("lastElementType", "polyline"); localStorage.setItem("polylineLink", link); + if (editMode) { + polyline.bindContextMenu({ + contextmenuItems: polyline.options.contextmenuItems, + }); + } closeContextMenuBeforeInterval(map); }); From da5e5a8b6536153b13053cbd416150f0bc48f545 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 12 Sep 2024 09:14:05 +0200 Subject: [PATCH 34/47] =?UTF-8?q?Kombination=20f=C3=BCr=2030,=20Linien=20a?= =?UTF-8?q?usblenden,=20und=20checkbox=20in=20localStorage=20mergen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 36 ++++++++++++++++++------------------ utils/setupPolylines.js | 39 ++++++--------------------------------- 2 files changed, 24 insertions(+), 51 deletions(-) diff --git a/.env.local b/.env.local index 06b79e736..dcf3201e4 100644 --- a/.env.local +++ b/.env.local @@ -1,17 +1,17 @@ #.env.local #je nach dem Mysql Server, ob localhost freigegeben ist oder die IP Adresse des Servers, manchmal die beide und manchmal nur eine -#DB_HOST=10.10.0.30 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 +DB_HOST=10.10.0.30 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.30" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://10.10.0.30" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" ######################### @@ -29,17 +29,17 @@ #NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" ######################### -DB_HOST=192.168.10.168 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 +#DB_HOST=192.168.10.168 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index 86e73dc4c..3d242c33c 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -32,43 +32,22 @@ export function enablePolylineEvents(polylines, lineColors) { // Falls Polylinien vorhanden sind, wende die Events an polylines.forEach((polyline) => { polyline.on("mouseover", (e) => { + //console.log("Mouseover on polyline", polyline.options); polyline.setStyle({ weight: 14 }); const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?id=${polyline.options.idLD}`; - // Verwende den Link oder speichere ihn, falls nötig + //localStorage.setItem("lastElementType", "polyline"); + //localStorage.setItem("polylineLink", link); }); polyline.on("mouseout", (e) => { + //console.log("Mouseout from polyline", polyline.options); polyline.setStyle({ weight: 3 }); }); }); } -// Funktion zum Schließen des Kontextmenüs vor dem Intervall -const closeContextMenuBeforeInterval = (map) => { - if (map && map.contextmenu && map.contextmenu.isVisible && map.contextmenu.isVisible()) { - console.log("Schließe Kontextmenü 2 Sekunden vor dem Intervall"); - map.contextmenu.hide(); - } -}; - -// Zeitintervall mit Schließen des Kontextmenüs 2 Sekunden vorher -export const startIntervalWithContextMenuHandling = (map) => { - setInterval(() => { - remainingTime = 20; // Zeit zurücksetzen für den neuen Durchlauf - // Kontextmenü überwachen - monitorContextMenu(map); - - // Schließe das Kontextmenü 2 Sekunden vor dem API-Aufruf - setTimeout(() => { - closeContextMenuBeforeInterval(map); - }, 18000); // 18 Sekunden warten, dann schließen - - // API-Aufruf oder Logik, die alle 20 Sekunden ausgeführt wird - fetchData(); - }, 20000); // 20-Sekunden-Intervall -}; - -export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, polylineVisible) => { +export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter, polylineVisible) => { + polylineVisible = localStorage.getItem("polylineVisible") === "true"; if (!polylineVisible) { // Entferne alle Polylinien, wenn sie ausgeblendet werden sollen if (window.polylines) { @@ -265,12 +244,6 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, console.log("Link der Linie (via Rechtsklick):", link); localStorage.setItem("lastElementType", "polyline"); localStorage.setItem("polylineLink", link); - if (editMode) { - polyline.bindContextMenu({ - contextmenuItems: polyline.options.contextmenuItems, - }); - } - closeContextMenuBeforeInterval(map); }); polylines.push(polyline); From b364d056f1ace82d132775ce3f2aa1c743b8f8d6 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 12 Sep 2024 13:24:50 +0200 Subject: [PATCH 35/47] feat: Set default polyline visibility to true if not defined in localStorage - Added logic to check if 'polylineVisible' exists in localStorage on page load. - If not present, set the default value to 'true' to ensure polylines are displayed by default. - Updated `setupPolylines` function to handle polyline visibility based on localStorage value. --- .env.local | 38 +++++++++++++++++++------------------- utils/setupPolylines.js | 8 +++++++- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.env.local b/.env.local index dcf3201e4..ee43d9cb9 100644 --- a/.env.local +++ b/.env.local @@ -1,32 +1,32 @@ #.env.local #je nach dem Mysql Server, ob localhost freigegeben ist oder die IP Adresse des Servers, manchmal die beide und manchmal nur eine -DB_HOST=10.10.0.30 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.30" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.30" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.30:3000/mapTiles/{z}/{x}/{y}.png" -######################### - - -#DB_HOST=10.10.0.70 +#DB_HOST=10.10.0.13 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.13/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.13" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.13" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + + +DB_HOST=10.10.0.70 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" ######################### #DB_HOST=192.168.10.168 diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index 3d242c33c..050b5711d 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -47,7 +47,13 @@ export function enablePolylineEvents(polylines, lineColors) { } export const setupPolylines = (map, linePositions, lineColors, tooltipContents, setNewCoords, tempMarker, currentZoom, currentCenter, polylineVisible) => { - polylineVisible = localStorage.getItem("polylineVisible") === "true"; + if (localStorage.getItem("polylineVisible") === null) { + localStorage.setItem("polylineVisible", "true"); // Standardwert setzen + polylineVisible = true; // Wert in der Funktion initialisieren + } else { + polylineVisible = localStorage.getItem("polylineVisible") === "true"; + } + if (!polylineVisible) { // Entferne alle Polylinien, wenn sie ausgeblendet werden sollen if (window.polylines) { From 5295dfec6207f5fdd32dc69d47e731358e1adf66 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 12 Sep 2024 22:56:59 +0200 Subject: [PATCH 36/47] WIP: POI Update --- .env.local | 38 +++--- components/MapComponent.js | 12 +- ...iUpdateModal.js => PoiUpdateModal copy.js} | 0 .../gisPolylines/PolylineContextMenu.js | 26 ++++ components/pois/PoiUpdateModal.js | 127 ++++++++---------- hooks/useMapComponentState.js | 22 ++- pages/api/talas5/location_device.js | 7 +- .../locationDevice/locationDevices.js | 3 +- utils/setupPOIs.js | 7 +- 9 files changed, 135 insertions(+), 107 deletions(-) rename components/{PoiUpdateModal.js => PoiUpdateModal copy.js} (100%) create mode 100644 components/gisPolylines/PolylineContextMenu.js diff --git a/.env.local b/.env.local index ee43d9cb9..6ea9a3240 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -DB_HOST=10.10.0.70 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 - -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -#DB_HOST=192.168.10.168 +#DB_HOST=10.10.0.70 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +DB_HOST=192.168.10.168 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/components/MapComponent.js b/components/MapComponent.js index cf6e06960..53d4b47f8 100644 --- a/components/MapComponent.js +++ b/components/MapComponent.js @@ -257,25 +257,25 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { await fetchGisStationsStaticDistrict(mapGisStationsStaticDistrictUrl, setGisStationsStaticDistrict, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); - console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + //console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Status District await fetchGisStationsStatusDistrict(mapGisStationsStatusDistrictUrl, setGisStationsStatusDistrict, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); - console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + //console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS Stations Measurements await fetchGisStationsMeasurements(mapGisStationsMeasurementsUrl, setGisStationsMeasurements, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); - console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + //console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); // Fetch GIS System Static await fetchGisSystemStatic(mapGisSystemStaticUrl, setGisSystemStatic, setGisSystemStaticLoaded, fetchOptions); requestCount++; // Zähler erhöhen localStorage.setItem("fetchWebServiceMap", requestCount); - console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); + //console.log(`fetchWebServiceMap in MapComponent wurde ${requestCount} Mal aufgerufen.`); } catch (error) { console.error("Error fetching data:", error); } @@ -376,7 +376,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { useEffect(() => { if (poiData.length === 0) return; - setupPOIs(map, locations, poiData, poiTypMap, userRights, poiLayerRef, setSelectedPoi, setLocationDeviceData, setDeviceName, setCurrentPoi, poiLayerVisible, fetchPoiData, toast, setShowPoiUpdateModal, setCurrentPoiData); + setupPOIs(map, locations, poiData, poiTypMap, userRights, poiLayerRef, setSelectedPoi, setLocationDeviceData, setDeviceName, setCurrentPoi, poiLayerVisible, fetchPoiData, toast, setShowPoiUpdateModal, setCurrentPoiData, deviceName); }, [map, locations, onLocationUpdate, poiReadTrigger, isPoiTypLoaded, userRights, poiLayerVisible, poiData, poiTypMap]); //--------------------------------------------- @@ -666,7 +666,7 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => { map.whenReady(() => { setTimeout(() => { if (map.contextmenu) { - console.log("Contextmenu ist vorhanden"); + //console.log("Contextmenu ist vorhanden"); } else { console.warn("Contextmenu ist nicht verfügbar."); } diff --git a/components/PoiUpdateModal.js b/components/PoiUpdateModal copy.js similarity index 100% rename from components/PoiUpdateModal.js rename to components/PoiUpdateModal copy.js diff --git a/components/gisPolylines/PolylineContextMenu.js b/components/gisPolylines/PolylineContextMenu.js new file mode 100644 index 000000000..a07de670b --- /dev/null +++ b/components/gisPolylines/PolylineContextMenu.js @@ -0,0 +1,26 @@ +// /components/gisPolylines/PolylineContextMenu.js +import React from "react"; + +const PolylineContextMenu = ({ position, onAddPoint, onRemovePoint, onClose }) => { + return ( +
+
    +
  • Stützpunkt hinzufügen
  • +
  • Stützpunkt entfernen
  • +
  • Schließen
  • +
+
+ ); +}; + +export default PolylineContextMenu; diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index c2795c80e..8d1b61ee7 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -1,5 +1,3 @@ -// components/pois/poiUpdateModal.js - import React, { useState, useEffect } from "react"; import { useRecoilValue } from "recoil"; import { selectedPoiState } from "../../store/atoms/poiState"; @@ -8,6 +6,7 @@ import { currentPoiState } from "../../store/atoms/currentPoiState"; const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const currentPoi = useRecoilValue(currentPoiState); const selectedPoi = useRecoilValue(selectedPoiState); + const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : ""); const [name, setName] = useState(poiData ? poiData.name : ""); const [poiTypData, setPoiTypData] = useState([]); @@ -15,36 +14,73 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const [locationDeviceData, setLocationDeviceData] = useState([]); const [deviceName, setDeviceName] = useState(""); const [idLD, setIdLD] = useState(poiData ? poiData.idLD : ""); - const [description, setDescription] = useState(poiData ? poiData.description : ""); + // Fetch and set POI data useEffect(() => { if (poiData) { - //console.log("Initial poiData:", poiData); setPoiId(poiData.idPoi); setName(poiData.name); setPoiTypeId(poiData.idPoiTyp); setIdLD(poiData.idLD); setDescription(poiData.description); - setDeviceName(poiData.idLD); - //console.log("Loaded POI Data for editing:", poiData); } }, [poiData]); + // Fetch POI types and pre-select the current POI type useEffect(() => { - const fetchDeviceId = async () => { - if (poiData && poiData.idLD) { + const fetchPoiTypData = async () => { + const cachedPoiTypData = localStorage.getItem("poiTypData"); + if (cachedPoiTypData) { + const data = JSON.parse(cachedPoiTypData); + setPoiTypData(data); + if (poiData) { + setPoiTypeId(poiData.idPoiTyp); // Set the selected POI type ID + } + } else { try { - const response = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceIdById?idLD=${poiData.idLD}`); + const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp"); const data = await response.json(); - if (data) setDeviceName(data.name); + setPoiTypData(data); + localStorage.setItem("poiTypData", JSON.stringify(data)); + if (poiData) { + setPoiTypeId(poiData.idPoiTyp); // Set the selected POI type ID + } } catch (error) { - console.error("Fehler beim Abrufen der Geräteinformation in PoiUpdateModel.js: ", error); + console.error("Fehler beim Abrufen der poiTyp Daten:", error); } } }; + fetchPoiTypData(); + }, [poiData]); - fetchDeviceId(); + // Fetch location devices and pre-select the current device + useEffect(() => { + const fetchLocationDevices = async () => { + const cachedDeviceData = localStorage.getItem("locationDeviceData"); + if (cachedDeviceData) { + const data = JSON.parse(cachedDeviceData); + setLocationDeviceData(data); + if (poiData) { + const selectedDevice = data.find((device) => device.idLD === poiData.idLD); + setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device + } + } else { + try { + const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); + const data = await response.json(); + setLocationDeviceData(data); + localStorage.setItem("locationDeviceData", JSON.stringify(data)); + if (poiData) { + const selectedDevice = data.find((device) => device.idLD === poiData.idLD); + setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device + } + } catch (error) { + console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error); + } + } + }; + fetchLocationDevices(); }, [poiData]); const handleDeletePoi = async () => { @@ -54,79 +90,24 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { method: "DELETE", }); if (response.ok) { - //alert("POI wurde erfolgreich gelöscht."); onClose(); window.location.reload(); } else { throw new Error("Fehler beim Löschen des POI."); } } catch (error) { - console.error("Fehler beim Löschen des POI 2:", error); + console.error("Fehler beim Löschen des POI:", error); alert("Fehler beim Löschen des POI."); } } }; - useEffect(() => { - const fetchPoiTypData = async () => { - try { - const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp"); - const data = await response.json(); - setPoiTypData(data); - if (selectedPoi && data) { - const matchingType = data.find((pt) => pt.name === selectedPoi.typ); - if (matchingType) { - setPoiTypeId(matchingType.idPoiTyp); - } - } - } catch (error) { - console.error("Fehler beim Abrufen der poiTyp Daten:", error); - } - }; - fetchPoiTypData(); - }, [selectedPoi]); - - useEffect(() => { - const fetchData = async () => { - try { - // const response = await fetch("/api/talas_v5/location_device"); //"/api/talas_v5_DB/locationDevice/location_device" - const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); - const data = await response.json(); - setLocationDeviceData(data); - if (poiData && poiData.idLD) { - const selectedDevice = data.find((device) => device.id === poiData.idLD); - setDeviceName(selectedDevice ? selectedDevice.id : data[0].id); - //console.log("Selected Device in poiUpdate:", selectedDevice); - } - } catch (error) { - console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error); - } - }; - fetchData(); - }, []); - - useEffect(() => { - fetch("/api/talas_v5_DB/locationDevice/locationDevices") - .then((response) => response.json()) - .then((data) => { - setLocationDeviceData(data); - const currentDevice = data.find((device) => device.idLD === currentPoi.idLD); - if (currentDevice) { - setDeviceName(currentDevice.name); - //console.log("Current Device name in poiUpdate:", currentDevice.name); - } - }) - .catch((error) => { - console.error("Fehler beim Abrufen der Gerätedaten:", error); - setLocationDeviceData([]); - }); - }, [poiData?.idLD, currentPoi]); - const handleSubmit = async (event) => { event.preventDefault(); const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`); const idLDData = await idLDResponse.json(); const idLD = idLDData.idLD; + try { const response = await fetch("/api/talas_v5_DB/pois/updatePoi", { method: "POST", @@ -176,8 +157,8 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { Gerät: setPoiTypeId(e.target.value)} className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm"> - {poiTypData.map((poiTyp, index) => ( - ))} diff --git a/hooks/useMapComponentState.js b/hooks/useMapComponentState.js index 2ebc06a04..7d248a4b7 100644 --- a/hooks/useMapComponentState.js +++ b/hooks/useMapComponentState.js @@ -1,5 +1,5 @@ // hooks/useMapComponentState.js -import { useState, useRef } from "react"; +import { useState, useEffect } from "react"; import usePoiTypData from "./usePoiTypData"; import { useRecoilValue } from "recoil"; import { poiLayerVisibleState } from "../store/atoms/poiLayerVisibleState"; @@ -12,6 +12,26 @@ export const useMapComponentState = () => { const [menuItemAdded, setMenuItemAdded] = useState(false); const poiLayerVisible = useRecoilValue(poiLayerVisibleState); + // Fetch devices when the component is mounted + useEffect(() => { + const fetchDeviceData = async () => { + try { + const response = await fetch("/api/talas5/location_device"); // API call to get devices + const data = await response.json(); + setLocationDeviceData(data); // Set the device data + + // Optional: set a default deviceName if needed + if (data.length > 0) { + setDeviceName(data[0].name); // Set the first device's name + } + } catch (error) { + console.error("Error fetching device data:", error); + } + }; + + fetchDeviceData(); + }, []); // Runs only once when the component is mounted + return { poiTypData, isPoiTypLoaded, diff --git a/pages/api/talas5/location_device.js b/pages/api/talas5/location_device.js index 498db9424..38d50c465 100644 --- a/pages/api/talas5/location_device.js +++ b/pages/api/talas5/location_device.js @@ -8,14 +8,15 @@ export default async function handler(req, res) { let connection; try { // SQL-Query and parameters - const sql = "SELECT idLD, iddevice, name FROM location_device WHERE iddevice = ?"; - const params = [160]; // Example parameter + const sql = "SELECT idLD, iddevice, name FROM location_device ORDER BY name"; + //const params = [160]; // Example parameter // Get a connection from the pool connection = await pool.getConnection(); // Execute the query - const [results] = await connection.query(sql, params); + //const [results] = await connection.query(sql, params); + const [results] = await connection.query(sql); // Check if results are empty if (!results.length) { diff --git a/pages/api/talas_v5_DB/locationDevice/locationDevices.js b/pages/api/talas_v5_DB/locationDevice/locationDevices.js index 4b1e7bc2b..df6d4abea 100644 --- a/pages/api/talas_v5_DB/locationDevice/locationDevices.js +++ b/pages/api/talas_v5_DB/locationDevice/locationDevices.js @@ -8,7 +8,8 @@ export default async function handler(req, res) { return res.status(405).json({ error: "Nur GET Methode erlaubt" }); } - const query = "SELECT * FROM location_device WHERE iddevice = 160"; + //const query = "SELECT * FROM location_device WHERE iddevice = 160"; + const query = "SELECT * FROM location_device ORDER BY name"; let connection; diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 8d153cd3b..435742bf0 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -76,12 +76,13 @@ export const setupPOIs = async ( marker.bindPopup(`
${location.description || "Unbekannt"}
- ${deviceName}
+ ${deviceName || "unbekannt"}
${poiTypName}
`); marker.on("mouseover", function () { + console.log("Device Name:", deviceName); // Debugging handlePoiSelect( { id: location.idPoi, @@ -92,12 +93,10 @@ export const setupPOIs = async ( }, setSelectedPoi, setLocationDeviceData, - setDeviceName, + setDeviceName, // Stelle sicher, dass dies korrekt funktioniert poiLayerRef, poiTypMap ); - setCurrentPoi(location); - this.openPopup(); localStorage.setItem("lastElementType", "marker"); localStorage.setItem("markerLink", this.options.link); From 56f4a585aeb38092a92d9f7c5adf2ffd6037a89b Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 13 Sep 2024 08:50:10 +0200 Subject: [PATCH 37/47] =?UTF-8?q?WIP:=20POI=20Update=20Modal,=20Beschreibu?= =?UTF-8?q?ng=20und=20Ger=C3=A4t=20funktioniert=20wie=20erweitet,=20Typ=20?= =?UTF-8?q?soll=20auch=20den=20gew=C3=A4hlte=20POI=20Typ=20zuerst=20in=20d?= =?UTF-8?q?ropdown=20angezeigt=20wird?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 38 ++--- components/PoiUpdateModal copy.js | 264 ------------------------------ components/pois/PoiUpdateModal.js | 29 ++-- services/apiService copy.js | 1 + services/apiService.js | 1 + utils/poiUtils.js | 1 + utils/setupPOIs.js | 4 +- 7 files changed, 40 insertions(+), 298 deletions(-) delete mode 100644 components/PoiUpdateModal copy.js diff --git a/.env.local b/.env.local index 6ea9a3240..ee43d9cb9 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -#DB_HOST=10.10.0.70 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 - -######################### - -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -DB_HOST=192.168.10.168 +DB_HOST=10.10.0.70 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 DB_PORT=3306 + +######################### + +NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +#DB_HOST=192.168.10.168 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file diff --git a/components/PoiUpdateModal copy.js b/components/PoiUpdateModal copy.js deleted file mode 100644 index 07d80b8e6..000000000 --- a/components/PoiUpdateModal copy.js +++ /dev/null @@ -1,264 +0,0 @@ -// pages/api/poiUpdateModal.js -// -import React, { useState, useEffect } from "react"; -import { useRecoilValue } from "recoil"; -import { selectedPoiState } from "../store/atoms/poiState"; -import { currentPoiState } from "../store/atoms/currentPoiState"; - -const PoiUpdateModal = ({ onClose, poiData }) => { - const currentPoi = useRecoilValue(currentPoiState); - const selectedPoi = useRecoilValue(selectedPoiState); - const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : ""); - const [name, setName] = useState(poiData ? poiData.name : ""); - const [poiTypData, setPoiTypData] = useState([]); - const [poiTypeId, setPoiTypeId] = useState(""); - const [locationDeviceData, setLocationDeviceData] = useState([]); - const [deviceName, setDeviceName] = useState(""); - const [idLD, setIdLD] = useState(poiData ? poiData.idLD : ""); - const [idLocationDevice, setIdLocationDevice] = useState(""); - - const [description, setDescription] = useState(poiData ? poiData.description : ""); - - // Log the initial POI data - useEffect(() => { - if (poiData) { - setPoiId(poiData.idPoi); - setName(poiData.name); - setPoiTypeId(poiData.idPoiTyp); - setIdLD(poiData.idLD); - - setDescription(poiData.description); - setDeviceName(poiData.idLD); - console.log("Loaded POI Data for editing:", poiData); - console.log("POI ID:", poiData.idPoi); - console.log("POI Name:", poiData.name); - console.log("POI Typ ID:", poiData.idPoiTyp); - console.log("POI Beschreibung:", poiData.description); - console.log("POI Geräte-ID:", poiData.idLD); - } - }, [poiData]); - - /* const fetchDeviceNameById = async (idLD) => { - try { - const response = await fetch(`/api/getDeviceNameById?idLD=${idLD}`); - const data = await response.json(); - setDeviceName(data.deviceName); - } catch (error) { - console.error("Error fetching device name:", error); - } - }; */ - - /* const fetchDeviceNameById = async (idLD) => { - try { - const response = await fetch(`/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`); - const data = await response.json(); - setDeviceName(data.deviceName); - } catch (error) { - console.error("Error fetching device name:", error); - } - }; */ - - // Beim Öffnen des Modals die Geräte-ID basierend auf dem Gerätenamen abrufen, wenn vorhanden - useEffect(() => { - const fetchDeviceId = async () => { - if (poiData && poiData.idLD) { - try { - const response = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceIdById?idLD=${poiData.idLD}`); - const data = await response.json(); - if (data) setDeviceName(data.name); - } catch (error) { - console.error("Fehler beim Abrufen der Geräteinformation in PoiUpdateModel.js: ", error); - } - } - }; - - fetchDeviceId(); - }, [poiData]); - - // Function to handle deleting a POI - const handleDeletePoi = async () => { - if (confirm("Sind Sie sicher, dass Sie diesen POI löschen möchten?")) { - try { - const response = await fetch(`/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, { - method: "DELETE", - }); - if (response.ok) { - // alert("POI wurde erfolgreich gelöscht."); - onClose(); // Close the modal - //Browser neu laden, um die aktualisierte Liste anzuzeigen - window.location.reload(); - } else { - throw new Error("Fehler beim Löschen des POI."); - } - } catch (error) { - console.error("Fehler beim Löschen des POI 1:", error); - alert("Fehler beim Löschen des POI."); - } - } - }; - - // Fetch POI types - useEffect(() => { - const fetchPoiTypData = async () => { - try { - const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp"); - const data = await response.json(); - setPoiTypData(data); - if (selectedPoi && data) { - const matchingType = data.find((pt) => pt.name === selectedPoi.typ); - if (matchingType) { - setPoiTypeId(matchingType.idPoiTyp); - } - } - } catch (error) { - console.error("Fehler beim Abrufen der poiTyp Daten:", error); - } - }; - fetchPoiTypData(); - }, [selectedPoi]); - - // Fetch device data um den Gerät Namen in den dropdown menu anzuzeigen also erstmal die Liste der Geräte abrufen - useEffect(() => { - const fetchData = async () => { - try { - const response = await fetch("/api/talas_v5/location_device"); - const data = await response.json(); - //console.log("Standort- und Gerätedaten:", data); - setLocationDeviceData(data); - console.log("Standort- und Gerätedaten poiData:", poiData); - if (poiData && poiData.idLD) { - const selectedDevice = data.find((device) => device.id === poiData.idLD); - setDeviceName(selectedDevice ? selectedDevice.id : data[0].id); // Hier wird die ID als initialer Zustand gesetzt - console.log("Selected Device:", selectedDevice); - console.log("Selected devciceName:", deviceName); - } - } catch (error) { - console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error); - } - }; - fetchData(); - }, []); - //-------------------------------------------------------------------------------------------- - // Fetch device name basierend auf der Geräte-ID - - useEffect(() => { - console.log("currentPoi von PoiUpdateModal.js : ", currentPoi.idLD); - fetch("/api/talas_v5_DB/locationDevice/locationDevices") - .then((response) => response.json()) - .then((data) => { - setLocationDeviceData(data); - console.log("Standort- und Gerätedaten 3:", data); - console.log("Standort- und Gerätedaten 3 poiData:", poiData); - // Findet das Gerät, das der aktuellen IDLD entspricht - const currentDevice = data.find((device) => device.idLD === currentPoi.idLD); - if (currentDevice) { - setDeviceName(currentDevice.name); - } - }) - .catch((error) => { - console.error("Fehler beim Abrufen der Gerätedaten:", error); - setLocationDeviceData([]); - }); - }, [poiData?.idLD, currentPoi]); - - //-------------------------------------------------------------------------------------------- - // Angenommen, deviceName enthält die Geräte-ID - //const idLD = deviceName; // Stellen Sie sicher, dass dies eine ID ist und kein Name - - const handleSubmit = async (event) => { - event.preventDefault(); - const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`); - const idLDData = await idLDResponse.json(); - const idLD = idLDData.idLD; - try { - const response = await fetch("/api/talas_v5_DB/pois/updatePoi", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - idPoi: poiId, - name: name, - description: description, - idPoiTyp: poiTypeId, - idLD: idLD, - //idLD: parseInt(deviceName, 10), // Konvertieren in eine Ganzzahl - }), - }); - - if (response.ok) { - onClose(); - window.location.reload(); - } else { - const errorResponse = await response.json(); - throw new Error(errorResponse.error || "Fehler beim Aktualisieren des POI."); - } - } catch (error) { - console.error("Fehler beim Aktualisieren des POI:", error); - alert("Fehler beim Aktualisieren des POI."); - } - }; - - //ausgewählte poi Informationen in Console anzeigen - console.log("Selected POI:", selectedPoi); - console.log("Selected POI Gerät id in poiUpdateModal.js:", selectedPoi.id); - console.log("Selected POI Typ name in poiUpdateModal.js:", selectedPoi.typ); //als Typ in dropdown menu - console.log("Selected POI Beschreibung in poiUpdateModal.js:", selectedPoi.description); - console.log("Selected POI Gerät deviceId in poiUpdateModal.js:", selectedPoi.deviceId); - - return ( -
-
- - setDescription(e.target.value)} placeholder="Beschreibung der Station" className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm" /> -
- -
- - -
- -
- - -
- - - - -
- ); -}; - -export default PoiUpdateModal; diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index 8d1b61ee7..70919c8bb 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -16,6 +16,15 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const [idLD, setIdLD] = useState(poiData ? poiData.idLD : ""); const [description, setDescription] = useState(poiData ? poiData.description : ""); + // Debugging + useEffect(() => { + console.log("poiData:", poiData); + if (!poiData.idLD) { + console.error("Fehlender idLD in poiData"); + console.log("poiData:", poiData); + } + }, [poiData]); + // Fetch and set POI data useEffect(() => { if (poiData) { @@ -24,6 +33,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { setPoiTypeId(poiData.idPoiTyp); setIdLD(poiData.idLD); setDescription(poiData.description); + console.log("Initial Device ID (idLD):", poiData.idLD); } }, [poiData]); @@ -61,22 +71,13 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { if (cachedDeviceData) { const data = JSON.parse(cachedDeviceData); setLocationDeviceData(data); - if (poiData) { + if (poiData && poiData.idLD) { const selectedDevice = data.find((device) => device.idLD === poiData.idLD); - setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device - } - } else { - try { - const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); - const data = await response.json(); - setLocationDeviceData(data); - localStorage.setItem("locationDeviceData", JSON.stringify(data)); - if (poiData) { - const selectedDevice = data.find((device) => device.idLD === poiData.idLD); - setDeviceName(selectedDevice ? selectedDevice.name : ""); // Pre-select the current device + console.log("Selected Device:", selectedDevice); // Debugging + setDeviceName(selectedDevice ? selectedDevice.name : ""); + if (!selectedDevice) { + console.error(`Kein Gerät mit idLD: ${poiData.idLD} gefunden.`); } - } catch (error) { - console.error("Fehler beim Abrufen der Standort- und Gerätedaten:", error); } } }; diff --git a/services/apiService copy.js b/services/apiService copy.js index aef459476..e3b1df44d 100644 --- a/services/apiService copy.js +++ b/services/apiService copy.js @@ -75,6 +75,7 @@ export const fetchPoiData = async (idPoi) => { idPoi, name: data.name, description: data.description, + idLD: data.idLD, }; } catch (error) { console.error("Fehler beim Abrufen der POI-Daten", error); diff --git a/services/apiService.js b/services/apiService.js index 733ab3100..930a9565f 100644 --- a/services/apiService.js +++ b/services/apiService.js @@ -80,6 +80,7 @@ export const fetchPoiData = async (idPoi) => { idPoi, name: data.name, description: data.description, + idLD: data.idLD, }; } catch (error) { console.error("Fehler beim Abrufen der POI-Daten", error); diff --git a/utils/poiUtils.js b/utils/poiUtils.js index 8348cbde6..229e10a0b 100644 --- a/utils/poiUtils.js +++ b/utils/poiUtils.js @@ -109,6 +109,7 @@ export const handleEditPoi = ( idPoi: marker.options.id, name: marker.options.name, description: marker.options.description, + idLD: marker.options.idLD, }); fetchPoiData(marker.options.id); diff --git a/utils/setupPOIs.js b/utils/setupPOIs.js index 435742bf0..7abc7c945 100644 --- a/utils/setupPOIs.js +++ b/utils/setupPOIs.js @@ -55,6 +55,7 @@ export const setupPOIs = async ( id: location.idPoi, name: location.name, description: location.description, + idLD: location.idLD, link: location.link, }); @@ -82,7 +83,7 @@ export const setupPOIs = async ( `); marker.on("mouseover", function () { - console.log("Device Name:", deviceName); // Debugging + console.log("Device Name:", marker); // Debugging handlePoiSelect( { id: location.idPoi, @@ -90,6 +91,7 @@ export const setupPOIs = async ( idPoiTyp: location.idPoiTyp, typ: poiTypName, description: location.description, + idLD: location.idLD, }, setSelectedPoi, setLocationDeviceData, From 864644c5435902d70a171bbe7304006a7c9f4d90 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 13 Sep 2024 10:21:07 +0200 Subject: [PATCH 38/47] feat(PoiUpdateModal): Display correct POI type in dropdown on modal open - Added logic to store the selected POI type in localStorage during POI selection. - Updated PoiUpdateModal to pre-select the correct POI type from localStorage when opening the modal. - Implemented fallback to fetch POI types if not found in localStorage. - Ensured the selected device is also pre-filled in the dropdown. --- components/pois/PoiUpdateModal.js | 67 ++++-------- services/apiService copy.js | 173 ------------------------------ utils/handlePoiSelect.js | 30 +++--- 3 files changed, 34 insertions(+), 236 deletions(-) delete mode 100644 services/apiService copy.js diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index 70919c8bb..4fa4247b9 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -10,34 +10,34 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const [poiId, setPoiId] = useState(poiData ? poiData.idPoi : ""); const [name, setName] = useState(poiData ? poiData.name : ""); const [poiTypData, setPoiTypData] = useState([]); - const [poiTypeId, setPoiTypeId] = useState(""); + const [poiTypeId, setPoiTypeId] = useState(""); // Sicherstellen, dass der Typ korrekt vorgewählt ist const [locationDeviceData, setLocationDeviceData] = useState([]); const [deviceName, setDeviceName] = useState(""); const [idLD, setIdLD] = useState(poiData ? poiData.idLD : ""); const [description, setDescription] = useState(poiData ? poiData.description : ""); - // Debugging - useEffect(() => { - console.log("poiData:", poiData); - if (!poiData.idLD) { - console.error("Fehlender idLD in poiData"); - console.log("poiData:", poiData); - } - }, [poiData]); - - // Fetch and set POI data + // Beim Öffnen des Modals den POI-Typ aus dem localStorage laden useEffect(() => { if (poiData) { setPoiId(poiData.idPoi); setName(poiData.name); - setPoiTypeId(poiData.idPoiTyp); + setPoiTypeId(poiData.idPoiTyp); // Setze den Typ-ID + + // Prüfe, ob der Typ im localStorage gespeichert ist + const selectedPoiType = localStorage.getItem("selectedPoiType"); + if (selectedPoiType) { + const matchingType = poiTypData.find((type) => type.name === selectedPoiType); + if (matchingType) { + setPoiTypeId(matchingType.idPoiTyp); // Setze die Typ-ID auf den gespeicherten Wert + } + } + setIdLD(poiData.idLD); setDescription(poiData.description); - console.log("Initial Device ID (idLD):", poiData.idLD); } - }, [poiData]); + }, [poiData, poiTypData]); - // Fetch POI types and pre-select the current POI type + // Fetch POI types and set the current POI type in the dropdown useEffect(() => { const fetchPoiTypData = async () => { const cachedPoiTypData = localStorage.getItem("poiTypData"); @@ -45,7 +45,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { const data = JSON.parse(cachedPoiTypData); setPoiTypData(data); if (poiData) { - setPoiTypeId(poiData.idPoiTyp); // Set the selected POI type ID + setPoiTypeId(poiData.idPoiTyp); } } else { try { @@ -54,7 +54,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { setPoiTypData(data); localStorage.setItem("poiTypData", JSON.stringify(data)); if (poiData) { - setPoiTypeId(poiData.idPoiTyp); // Set the selected POI type ID + setPoiTypeId(poiData.idPoiTyp); } } catch (error) { console.error("Fehler beim Abrufen der poiTyp Daten:", error); @@ -73,36 +73,13 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { setLocationDeviceData(data); if (poiData && poiData.idLD) { const selectedDevice = data.find((device) => device.idLD === poiData.idLD); - console.log("Selected Device:", selectedDevice); // Debugging setDeviceName(selectedDevice ? selectedDevice.name : ""); - if (!selectedDevice) { - console.error(`Kein Gerät mit idLD: ${poiData.idLD} gefunden.`); - } } } }; fetchLocationDevices(); }, [poiData]); - const handleDeletePoi = async () => { - if (confirm("Sind Sie sicher, dass Sie diesen POI löschen möchten?")) { - try { - const response = await fetch(`/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, { - method: "DELETE", - }); - if (response.ok) { - onClose(); - window.location.reload(); - } else { - throw new Error("Fehler beim Löschen des POI."); - } - } catch (error) { - console.error("Fehler beim Löschen des POI:", error); - alert("Fehler beim Löschen des POI."); - } - } - }; - const handleSubmit = async (event) => { event.preventDefault(); const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`); @@ -119,7 +96,7 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { idPoi: poiId, name: name, description: description, - idPoiTyp: poiTypeId, + idPoiTyp: poiTypeId, // Den ausgewählten Typ mitsenden idLD: idLD, }), }); @@ -167,10 +144,10 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => {
-
- - diff --git a/services/apiService copy.js b/services/apiService copy.js deleted file mode 100644 index e3b1df44d..000000000 --- a/services/apiService copy.js +++ /dev/null @@ -1,173 +0,0 @@ -// services/apiService.js -import * as config from "../config/config"; -import * as urls from "../config/urls"; - -let timeoutId; - -const fetchWithTimeout = async (url, options, timeout = 5000) => { - const controller = new AbortController(); - const id = setTimeout(() => controller.abort(), timeout); - - try { - const response = await fetch(url, { - ...options, - signal: controller.signal, - }); - clearTimeout(id); - return response; - } catch (error) { - clearTimeout(id); // Im Falle eines Fehlers den Timeout abbrechen - throw error; - } -}; - -export const fetchGisStatusStations = async (idMap, idUser) => { - // Verhindere wiederholte schnelle API-Aufrufe durch Debouncing - if (timeoutId) { - clearTimeout(timeoutId); - } - - timeoutId = setTimeout(async () => { - const SERVER_URL = process.env.NEXT_PUBLIC_SERVER_URL; - - try { - // Verwende das Timeout für die API-Anfrage - const response = await fetchWithTimeout( - `${SERVER_URL}/talas5/ClientData/WebServiceMap.asmx/GisStationsStatusDistrict?idMap=${idMap}&idUser=${idUser}`, - null, - 5000 // Timeout auf 5 Sekunden gesetzt - ); - - if (!response.ok) { - throw new Error(`Error: ${response.statusText}`); - } - - const data = await response.json(); - return data; - } catch (error) { - console.error("Fehler beim Abrufen der Daten:", error); - throw error; - } - }, 500); // Debounce-Zeit auf 500ms gesetzt -}; - -// ---------------------------------------------- -/* export const fetchPriorityConfig = async () => { - try { - const response = await fetch("/api/talas_v5_DB/priorityConfig"); - const data = await response.json(); - console.log("Prioritätskonfiguration:", data); - setPriorityConfig(data); - } catch (error) { - console.error("Fehler beim Laden der Prioritätskonfiguration:", error); - } -}; */ - -// ---------------------------------------------- -export const fetchPoiData = async (idPoi) => { - try { - const response = await fetch(`/api/talas_v5_DB/pois/getPoiById?idPoi=${idPoi}`); - if (!response.ok) { - throw new Error("Fehler beim Abrufen der POI-Daten"); - } - const data = await response.json(); - return { - idPoi, - name: data.name, - description: data.description, - idLD: data.idLD, - }; - } catch (error) { - console.error("Fehler beim Abrufen der POI-Daten", error); - return null; - } -}; -// ---------------------------------------------- -// Funktion zum Aktualisieren der Position in der Datenbank -export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => { - const response = await fetch("/api/talas_v5_DB/pois/updateLocation", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - id, - latitude: newLatitude, - longitude: newLongitude, - }), - }); - - if (response.ok) { - //schreib die neue Kooridnaten in die Console - //akuellisiere die Position in der Datenbank mit den neuen Koordinaten mit updateLocation mit SQL Anweisung UPDATE - } else { - console.error("Fehler beim Aktualisieren der Position"); - } -}; - -// ---------------------------------------------- -// Funktionen zur Überwachung der Internetverbindung -export const checkInternet = () => { - fetch("https://tile.openstreetmap.org/1/1/1.png", { method: "HEAD" }) - .then((response) => setOnline(response.ok)) - .catch(() => setOnline(false)); -}; - -// ---------------------------------------------- -export const fetchDeviceNameById = async (idLD) => { - try { - const response = await fetch(`/api/talas_v5_DB/locationDevice/locationDeviceNameById?idLD=${idLD}`); - const data = await response.json(); - if (response.ok) { - return data.name; - } else { - //throw new Error(data.error || "Gerät nicht gefunden"); - throw new Error("Gerät nicht gefunden in apiService.js"); - } - } catch (error) { - console.error("Fehler beim Abrufen des Gerätenamens in apiService.js:", error); - return "Unbekannt"; - } -}; - -// ---------------------------------------------- -// services/apiService.js -export const fetchUserRights = async () => { - // Zähler für API-Aufrufe in localStorage speichern - let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0; - userRightsRequestCount++; - localStorage.setItem("userRightsRequestCount", userRightsRequestCount); - console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); - - // Debouncing, um wiederholte schnelle API-Aufrufe zu verhindern - if (timeoutId) { - clearTimeout(timeoutId); // Falls innerhalb der Debounce-Zeit wieder ein Aufruf erfolgt, wird der alte abgebrochen - } - - timeoutId = setTimeout(async () => { - try { - const response = await fetchWithTimeout( - `${process.env.NEXT_PUBLIC_SERVER_URL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, - null, - 5000 // Timeout für die API-Anfrage auf 5 Sekunden gesetzt - ); - - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); - } - - const data = await response.json(); - - // Überprüfen der Struktur der Antwort - if (!data || !data.Rights || !Array.isArray(data.Rights)) { - throw new Error("Invalid response structure"); - } - - const rightsArray = data.Rights; // Nehmen an, dass 'Rights' das Array von Rechten ist - const userRightsIds = rightsArray.map((right) => right.IdRight); - - return userRightsIds; - } catch (error) { - console.error("Fehler beim Abrufen der Benutzerrechte", error); - return []; - } - }, 500); // Debounce-Zeit auf 500 ms gesetzt -}; diff --git a/utils/handlePoiSelect.js b/utils/handlePoiSelect.js index 2dc5688c3..46252b236 100644 --- a/utils/handlePoiSelect.js +++ b/utils/handlePoiSelect.js @@ -1,37 +1,35 @@ // utils/handlePoiSelect.js const handlePoiSelect = async (poiData, setSelectedPoi, setLocationDeviceData, setDeviceName, poiLayerRef, poiTypMap) => { - setSelectedPoi(poiData); // poiData should be the data of the selected POI - //console.log("Selected POI:", poiData); - //console.log("Selected POI idLD:", poiData.deviceId); + setSelectedPoi(poiData); // Setzt das ausgewählte POI try { const response = await fetch("/api/talas_v5_DB/locationDevice/locationDevices"); const data = await response.json(); setLocationDeviceData(data); - //console.log("Standort- und Gerätedaten:", data); const currentDevice = data.find((device) => device.idLD === poiData.deviceId); if (currentDevice) { setDeviceName(currentDevice.name); - //console.log("Current Device name in poiUpdate2:", currentDevice.name); - // Update the marker popup with the device name and type + // Hier speichern wir den POI-Typ im localStorage + const poiTypeName = poiTypMap.get(poiData.idPoiTyp); + localStorage.setItem("selectedPoiType", poiTypeName); + + // Optional: Update des Markers mit dem POI-Typ const marker = poiLayerRef.current.getLayers().find((m) => m.options.id === poiData.id); if (marker) { - marker.setPopupContent( - ` -
- ${poiData.description || "Unbekannt"}
- ${currentDevice.name}
- ${poiTypMap.get(poiData.idPoiTyp) || "Unbekannt"}
-
- `, - ); + marker.setPopupContent(` +
+ ${poiData.description || "Unbekannt"}
+ ${currentDevice.name}
+ ${poiTypeName || "Unbekannt"}
+
+ `); marker.openPopup(); } } } catch (error) { - console.error("Fehler beim Abrufen der Gerätedaten2:", error); + console.error("Fehler beim Abrufen der Gerätedaten:", error); setLocationDeviceData([]); } }; From 84f2dafd17aa741924408c24a5deb65cedf677c0 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 13 Sep 2024 11:28:34 +0200 Subject: [PATCH 39/47] =?UTF-8?q?fix:=20POI=20l=C3=B6schen=20in=20PoiUpdat?= =?UTF-8?q?eModal.js=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pois/PoiUpdateModal.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/components/pois/PoiUpdateModal.js b/components/pois/PoiUpdateModal.js index 4fa4247b9..70b60d166 100644 --- a/components/pois/PoiUpdateModal.js +++ b/components/pois/PoiUpdateModal.js @@ -80,6 +80,25 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { fetchLocationDevices(); }, [poiData]); + const handleDeletePoi = async () => { + if (confirm("Sind Sie sicher, dass Sie diesen POI löschen möchten?")) { + try { + const response = await fetch(`/api/talas_v5_DB/pois/deletePoi?id=${poiId}`, { + method: "DELETE", + }); + if (response.ok) { + onClose(); + window.location.reload(); + } else { + throw new Error("Fehler beim Löschen des POI."); + } + } catch (error) { + console.error("Fehler beim Löschen des POI:", error); + alert("Fehler beim Löschen des POI."); + } + } + }; + const handleSubmit = async (event) => { event.preventDefault(); const idLDResponse = await fetch(`/api/talas_v5_DB/locationDevice/getDeviceId?deviceName=${encodeURIComponent(deviceName)}`); @@ -155,7 +174,9 @@ const PoiUpdateModal = ({ onClose, poiData, onSubmit }) => { ))}
- + From 465aa6d848ff5d3eeda4e481b75be8ddb2512649 Mon Sep 17 00:00:00 2001 From: ISA Date: Fri, 13 Sep 2024 14:44:10 +0200 Subject: [PATCH 40/47] fix: TypeError: Cannot read properties of null (reading 'contextmenu') MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Korrigiert TypeError, der auftrat, wenn versucht wurde, auf `contextmenu` zuzugreifen, während es null war. - Implementiert präzise Zeitmessung mithilfe von `Date.now()`, um das Schließen des Kontextmenüs nach genau 17 Sekunden sicherzustellen. - Verbessert Benutzererfahrung durch zuverlässigere und stabilere Menüverwaltung. --- hooks/useLineData.js | 8 --- utils/setupPolylines.js | 105 ++++++++++++++++++++++++++++++++++------ 2 files changed, 91 insertions(+), 22 deletions(-) diff --git a/hooks/useLineData.js b/hooks/useLineData.js index 3798f3fbe..2f1bdc172 100644 --- a/hooks/useLineData.js +++ b/hooks/useLineData.js @@ -103,15 +103,7 @@ const useLineData = (webserviceGisLinesStatusUrl, setLineStatusData) => { } }; - const scheduleNextFetch = () => { - if (!isCancelled) { - fetchData(); - setTimeout(scheduleNextFetch, 20000); - } - }; - fetchData(); - scheduleNextFetch(); return () => { isCancelled = true; diff --git a/utils/setupPolylines.js b/utils/setupPolylines.js index 050b5711d..a6bdcb16e 100644 --- a/utils/setupPolylines.js +++ b/utils/setupPolylines.js @@ -204,25 +204,70 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, color: lineColors[`${lineData.idLD}-${lineData.idModul}`] || "#000000", weight: 3, contextmenu: true, + contextmenuInheritItems: false, // Standard-Kontextmenü deaktivieren contextmenuItems: [], }).addTo(map); // Füge "Stützpunkt hinzufügen" nur hinzu, wenn editMode aktiv ist if (editMode) { - polyline.options.contextmenuItems.push({ - text: "Stützpunkt hinzufügen", - icon: "/img/icons/gisLines/add-support-point.svg", - callback: (e) => { - if (tempMarker) { - tempMarker.remove(); - } - const newPoint = e.latlng; - const closestPoints = findClosestPoints(lineData.coordinates, newPoint, map); - insertNewPOI(closestPoints, newPoint, lineData, map); - redrawPolyline(lineData, lineColors, tooltipContents, map); - window.location.reload(); + polyline.options.contextmenuItems.push( + { + text: "Station öffnen (Tab)", + icon: "/img/screen_new.png", + callback: (e) => { + const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`; + window.open(link, "_blank"); + }, }, - }); + { separator: true }, + + { + text: "Koordinaten anzeigen", + icon: "/img/not_listed_location.png", + callback: (e) => { + alert("Breitengrad: " + e.latlng.lat.toFixed(5) + "\nLängengrad: " + e.latlng.lng.toFixed(5)); + }, + }, + { separator: true }, + { + text: "Reinzoomen", + icon: "/img/zoom_in.png", + callback: (e) => map.zoomIn(), + }, + { + text: "Rauszoomen", + icon: "/img/zoom_out.png", + callback: (e) => map.zoomOut(), + }, + { + text: "Hier zentrieren", + icon: "/img/center_focus.png", + callback: (e) => map.panTo(e.latlng), + }, + { separator: true }, + { + text: "POI hinzufügen", + icon: "/img/add_station.png", + callback: (e) => { + // Hier kannst du die Logik für das Hinzufügen eines POIs implementieren + alert("POI hinzufügen an: " + e.latlng); + }, + }, + { + text: "Stützpunkt hinzufügen", + icon: "/img/icons/gisLines/add-support-point.svg", + callback: (e) => { + if (tempMarker) { + tempMarker.remove(); + } + const newPoint = e.latlng; + const closestPoints = findClosestPoints(lineData.coordinates, newPoint, map); + insertNewPOI(closestPoints, newPoint, lineData, map); + redrawPolyline(lineData, lineColors, tooltipContents, map); + window.location.reload(); + }, + } + ); } // Hier wird der Tooltip hinzugefügt @@ -232,6 +277,24 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, }); polyline.on("mouseover", (e) => { + const startTime = Date.now(); // Startzeit erfassen + localStorage.setItem("contextMenuStartTime", startTime); // Speichern in localStorage + + // Starte einen Intervall-Timer, um die Differenz zu berechnen + const countdownInterval = setInterval(() => { + const currentTime = Date.now(); + const elapsedTime = (currentTime - startTime) / 1000; // Differenz in Sekunden + + // Speichern der abgelaufenen Zeit in localStorage + localStorage.setItem("contextMenuCountdown", elapsedTime); + + // Wenn die Zeit 17 Sekunden erreicht, schließe das Menü + if (elapsedTime >= 17) { + clearInterval(countdownInterval); + const contextMenu = map.contextmenu; // Zugriff auf das Kontextmenü + contextMenu.hide(); // Kontextmenü schließen + } + }, 1000); // Jede Sekunde //console.log("Mouseover on polyline", lineData); polyline.setStyle({ weight: 14 }); const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`; @@ -243,14 +306,28 @@ export const setupPolylines = (map, linePositions, lineColors, tooltipContents, polyline.on("mouseout", (e) => { // console.log("Mouseout from polyline", lineData); polyline.setStyle({ weight: 3 }); + // Setze den Countdown auf 0, wenn mouseout ausgelöst wird + localStorage.setItem("contextMenuCountdown", 0); }); // Speichere den Link bei einem Rechtsklick (Kontextmenü) - polyline.on("contextmenu", (e) => { + /* + polyline.on("contextmenu", (e) => { const link = `${process.env.NEXT_PUBLIC_BASE_URL}cpl.aspx?ver=35&kue=24&id=${lineData.idLD}`; console.log("Link der Linie (via Rechtsklick):", link); localStorage.setItem("lastElementType", "polyline"); localStorage.setItem("polylineLink", link); }); + */ + // Starte den Timer zum Schließen des Kontextmenüs nach 15 Sekunden + polyline.on("contextmenu", function (e) { + const contextMenu = this._map.contextmenu; // Zugriff auf das Kontextmenü + const closeMenu = () => contextMenu.hide(); // Funktion zum Schließen des Menüs + + const countdown = parseInt(localStorage.getItem("contextMenuCountdown"), 10); + if (countdown >= 17) { + closeMenu(); + } + }); polylines.push(polyline); markers.push(...lineMarkers); From 3a934bff26667aa9c940f6a01867df6b8fd96c4c Mon Sep 17 00:00:00 2001 From: ISA Date: Sat, 14 Sep 2024 15:17:51 +0200 Subject: [PATCH 41/47] =?UTF-8?q?sachen-anhalt:=20hat=20kein=20DAUZ=20Ger?= =?UTF-8?q?=C3=A4te,=20deswegen=20alle=20anzeigen,=20die=20IP=20in=20.env.?= =?UTF-8?q?local=20muss=20angepasst=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.env.local b/.env.local index ee43d9cb9..6ea9a3240 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -DB_HOST=10.10.0.70 -DB_USER=root -DB_PASSWORD="root#$" -DB_NAME=talas_v5 -DB_PORT=3306 - -######################### - -NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -#DB_HOST=192.168.10.168 +#DB_HOST=10.10.0.70 #DB_USER=root #DB_PASSWORD="root#$" #DB_NAME=talas_v5 #DB_PORT=3306 + +######################### + +#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +DB_HOST=192.168.10.168 +DB_USER=root +DB_PASSWORD="root#$" +DB_NAME=talas_v5 +DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file From d367fbd25e84da0750c307f20b1d314b515b2131 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 16 Sep 2024 10:24:52 +0200 Subject: [PATCH 42/47] .env.local auf 10.10.0.70 --- .env.local | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.env.local b/.env.local index 6ea9a3240..ee43d9cb9 100644 --- a/.env.local +++ b/.env.local @@ -15,31 +15,31 @@ ######################### -#DB_HOST=10.10.0.70 -#DB_USER=root -#DB_PASSWORD="root#$" -#DB_NAME=talas_v5 -#DB_PORT=3306 - -######################### - -#NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" -#NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" -#NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" -#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" -######################### - -DB_HOST=192.168.10.168 +DB_HOST=10.10.0.70 DB_USER=root DB_PASSWORD="root#$" DB_NAME=talas_v5 DB_PORT=3306 + +######################### + +NEXT_PUBLIC_BASE_URL="http://10.10.0.30/talas5/devices/" +NEXT_PUBLIC_SERVER_URL="http://10.10.0.70" +NEXT_PUBLIC_PROXY_TARGET="http://10.10.0.70" +NEXT_PUBLIC_ONLINE_TILE_LAYER="http://10.10.0.13:3000/mapTiles/{z}/{x}/{y}.png" +######################### + +#DB_HOST=192.168.10.168 +#DB_USER=root +#DB_PASSWORD="root#$" +#DB_NAME=talas_v5 +#DB_PORT=3306 ######################### #URLs für den Client (clientseitig) -NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" -NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" -NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" -NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" +#NEXT_PUBLIC_BASE_URL="http://192.168.10.168/talas5/devices/" +#NEXT_PUBLIC_SERVER_URL="http://192.168.10.168" +#NEXT_PUBLIC_PROXY_TARGET="http://192.168.10.168" +#NEXT_PUBLIC_ONLINE_TILE_LAYER="http://192.168.10.14:3000/mapTiles/{z}/{x}/{y}.png" ######################### online #NEXT_PUBLIC_ONLINE_TILE_LAYER="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" \ No newline at end of file From 8c85b2dbf3ed49ced6ec42881bf82d32affafb18 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 16 Sep 2024 10:30:49 +0200 Subject: [PATCH 43/47] git commit -m "Remove redundant ShowAddStationPopup.js as its functionality is duplicated by AddPoiModalWindow.js" --- components/ShowAddStationPopup.js | 201 ------------------------------ 1 file changed, 201 deletions(-) delete mode 100644 components/ShowAddStationPopup.js diff --git a/components/ShowAddStationPopup.js b/components/ShowAddStationPopup.js deleted file mode 100644 index a303772fe..000000000 --- a/components/ShowAddStationPopup.js +++ /dev/null @@ -1,201 +0,0 @@ -// components/ShowAddStationPopup.js -import React, { useState, useEffect, use } from "react"; -import ReactDOM from "react-dom"; -import { useRecoilValue, useRecoilState, useSetRecoilState } from "recoil"; -import { readPoiMarkersStore } from "../store/selectors/readPoiMarkersStore"; -import { poiReadFromDbTriggerAtom } from "../store/atoms/poiReadFromDbTriggerAtom"; - -const ShowAddStationPopup = ({ onClose, map, latlng }) => { - const [poiTypData, setpoiTypData] = useState(); // Recoil State verwenden - const [name, setName] = useState(""); - const [poiTypeId, setPoiTypeId] = useState(""); // Initialize as string - const [poiTypeName, setPoiTypeName] = useState(""); // Initialize as string - const [latitude] = useState(latlng.lat.toFixed(5)); - const [longitude] = useState(latlng.lng.toFixed(5)); - const setLoadData = useSetRecoilState(readPoiMarkersStore); - const setTrigger = useSetRecoilState(poiReadFromDbTriggerAtom); - const [locationDeviceData, setLocationDeviceData] = useState([]); - const [deviceName, setDeviceName] = useState(""); - - useEffect(() => { - const fetchpoiTypData = async () => { - try { - const response = await fetch("/api/talas_v5_DB/poiTyp/readPoiTyp"); - const data = await response.json(); - setpoiTypData(data); - if (data && data.length > 0) { - setPoiTypeId(data[0].idPoiTyp); // Set initial poiTypeId to the id of the first poiType - setPoiTypeName(data[1].name); // Set initial poiTypeName to the name of the first poiType - console.log( - "Initial poiTypeId set in ShowAddStationPopup.js :", - data[0].idPoiTyp - ); - } - } catch (error) { - console.error("Fehler beim Abrufen der poiTyp Daten:", error); - } - }; - - fetchpoiTypData(); - }, []); - - //--------------------------------------------------------------------------------------- - /* useEffect(() => { - // Funktion zum Abrufen der Daten von der API -> DB talas_v5.location_device - const fetchData = async () => { - try { - const response = await fetch("/api/talas_v5/location_device"); // Pfad zu Ihrem API-Endpunkt - const data = await response.json(); - setLocationDeviceData(data); // Setzt den Zustand mit den abgerufenen Daten - console.log("Abgerufene Standort- und Gerätedaten:", data); - } catch (error) { - console.error( - "Fehler beim Abrufen der Standort- und Gerätedaten:", - error - ); - } - }; - - fetchData(); - }, []); // Leerarray als Dependency, um den Effekt nur beim Laden der Komponente auszuführen */ - - //------------------------------------------------------------------------------------------ - useEffect(() => { - // Funktion zum Abrufen der Daten von der API -> DB talas_v5.location_device - const fetchData = async () => { - try { - const response = await fetch("/api/talas5/location_device"); - const data = await response.json(); - setLocationDeviceData(data); - if (data.length > 0) { - setDeviceName(data[0].name); // Setzen des anfänglichen Gerätenamens - } - console.log("Abgerufene Standort- und Gerätedaten:", data); - } catch (error) { - console.error( - "Fehler beim Abrufen der Standort- und Gerätedaten:", - error - ); - } - }; - - fetchData(); - }, []); - - //------------------------------------------------------------------------------------------ - //-----------------handleSubmit------------------- - const handleSubmit = async (event) => { - event.preventDefault(); - const formData = { - name, - poiTypeId, - latitude, - longitude, - idLD: locationDeviceData.find((device) => device.name === deviceName) - .idLD, - }; - - const response = await fetch("/api/talas_v5_DB/pois/addLocation", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(formData), - }); - - if (response.ok) { - setTrigger((trigger) => { - console.log("Aktueller Trigger-Wert:", trigger); // Vorheriger Wert - const newTrigger = trigger + 1; - console.log("Neuer Trigger-Wert:", newTrigger); // Aktualisierter Wert - onClose(); - return newTrigger; - }); - } else { - console.error("Fehler beim Hinzufügen des POI"); - } - - if (map && typeof map.closePopup === "function") { - map.closePopup(); - } - }; - //-----------------handleSubmit------------------- - - return ( -
-
- - setName(e.target.value)} - placeholder="Name der Station" - className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm" - /> -
- - {/* {locationDeviceData.----------------------------------------------*/} -
- - -
- {/* {locationDeviceData.----------------------------------------------*/} -
- - -
-
-
- -
-
- -
-
- - -
- ); -}; - -export default ShowAddStationPopup; From 1d6b3d638561f5c1aa3083d7de58033ac8d415db Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 16 Sep 2024 10:51:04 +0200 Subject: [PATCH 44/47] git commit -m "Implement react-select as a Combobox Dropdown Menu with consistent width for device selection" --- components/pois/AddPoiModalWindow.js | 92 ++++++++++++++-------------- package-lock.json | 74 +++++++++++++++++++--- package.json | 1 + 3 files changed, 111 insertions(+), 56 deletions(-) diff --git a/components/pois/AddPoiModalWindow.js b/components/pois/AddPoiModalWindow.js index 56677bf79..f0e90efb6 100644 --- a/components/pois/AddPoiModalWindow.js +++ b/components/pois/AddPoiModalWindow.js @@ -1,22 +1,20 @@ // components/pois/AddPoiModalWindow.js -import React, { useState, useEffect, use } from "react"; -import ReactDOM from "react-dom"; -import { useRecoilValue, useRecoilState, useSetRecoilState } from "recoil"; +import React, { useState, useEffect } from "react"; +import Select from "react-select"; // Import react-select +import { useSetRecoilState } from "recoil"; import { readPoiMarkersStore } from "../../store/selectors/readPoiMarkersStore"; import { poiReadFromDbTriggerAtom } from "../../store/atoms/poiReadFromDbTriggerAtom"; const AddPoiModalWindow = ({ onClose, map, latlng }) => { - const [poiTypData, setpoiTypData] = useState(); // Recoil State verwenden + const [poiTypData, setpoiTypData] = useState([]); const [name, setName] = useState(""); - const [poiTypeId, setPoiTypeId] = useState(""); // Initialize as string - const [poiTypeName, setPoiTypeName] = useState(""); // Initialize as string + const [poiTypeId, setPoiTypeId] = useState(""); const [latitude] = useState(latlng.lat.toFixed(5)); const [longitude] = useState(latlng.lng.toFixed(5)); - const setLoadData = useSetRecoilState(readPoiMarkersStore); const setTrigger = useSetRecoilState(poiReadFromDbTriggerAtom); const [locationDeviceData, setLocationDeviceData] = useState([]); - const [deviceName, setDeviceName] = useState(""); - //------------------------------------------------------------------------------------------ + const [deviceName, setDeviceName] = useState(null); // Initialize as null + useEffect(() => { const fetchInitialData = async () => { try { @@ -25,13 +23,6 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { const poiTypData = await poiTypResponse.json(); setpoiTypData(poiTypData); - if (poiTypData.length > 0) { - setPoiTypeId(poiTypData[0].idPoiTyp); // Set initial poiTypeId to the id of the first poiType - if (poiTypData[1]) { - setPoiTypeName(poiTypData[1].name); - } - } - const locationDeviceData = await locationDeviceResponse.json(); setLocationDeviceData(locationDeviceData); @@ -46,8 +37,6 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { fetchInitialData(); }, []); - //------------------------------------------------------------------------------------------ - //-----------------handleSubmit------------------- const handleSubmit = async (event) => { event.preventDefault(); const formData = { @@ -55,7 +44,7 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { poiTypeId, latitude, longitude, - idLD: locationDeviceData.find((device) => device.name === deviceName).idLD, + idLD: locationDeviceData.find((device) => device.name === deviceName?.value).idLD, }; const response = await fetch("/api/talas_v5_DB/pois/addLocation", { @@ -65,16 +54,8 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { }); if (response.ok) { - setTrigger((trigger) => { - //console.log("Aktueller Trigger-Wert:", trigger); // Vorheriger Wert - const newTrigger = trigger + 1; - //console.log("Neuer Trigger-Wert:", newTrigger); // Aktualisierter Wert - onClose(); - return newTrigger; - }); - - // Browser aktualisieren - window.location.reload(); + setTrigger((trigger) => trigger + 1); + onClose(); } else { console.error("Fehler beim Hinzufügen des POI"); } @@ -84,10 +65,29 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { } }; - //-----------------handleSubmit------------------- + // Erstelle Optionen für react-select + const deviceOptions = locationDeviceData.map((device) => ({ + value: device.name, + label: device.name, + })); + + // Custom styles for react-select + const customStyles = { + control: (provided) => ({ + ...provided, + width: "100%", + minWidth: "300px", // Minimum width for the dropdown + maxWidth: "100%", // Maximum width (you can adjust this if needed) + }), + menu: (provided) => ({ + ...provided, + width: "100%", + minWidth: "300px", // Ensure the dropdown menu stays at the minimum width + }), + }; return ( -
+
- {/* {locationDeviceData.----------------------------------------------*/} + {/* React Select for Devices */}
- + setPoiTypeId(e.target.value)} className="block p-2 w-full border-2 border-gray-200 rounded-md text-sm"> - {poiTypData && - poiTypData.map((poiTyp, index) => ( - - ))} + {poiTypData.map((poiTyp, index) => ( + + ))}
diff --git a/package-lock.json b/package-lock.json index 65982e38b..7c64886c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "09.09.2024 NodeMap", + "name": "16.09.2024 NodeMap", "lockfileVersion": 3, "requires": true, "packages": { @@ -25,6 +25,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-redux": "^9.1.2", + "react-select": "^5.8.0", "react-toastify": "^10.0.5", "recoil": "^0.7.7", "redux": "^5.0.1", @@ -2087,6 +2088,28 @@ "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.4.0.tgz", "integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==" }, + "node_modules/@floating-ui/core": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.8.tgz", + "integrity": "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==", + "dependencies": { + "@floating-ui/utils": "^0.2.8" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.6.11", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.11.tgz", + "integrity": "sha512-qkMCxSR24v2vGkhYDo/UzxfJN3D4syqSjyuTFz6C7XcpU1pASPRieNI0Kj5VP3/503mOfYiGY891ugBX1GlABQ==", + "dependencies": { + "@floating-ui/core": "^1.6.0", + "@floating-ui/utils": "^0.2.8" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz", + "integrity": "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==" + }, "node_modules/@heroicons/react": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@heroicons/react/-/react-2.1.5.tgz", @@ -3810,14 +3833,12 @@ "node_modules/@types/prop-types": { "version": "15.7.12", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz", - "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==", - "peer": true + "integrity": "sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==" }, "node_modules/@types/react": { "version": "18.3.5", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.5.tgz", "integrity": "sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==", - "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -3827,7 +3848,6 @@ "version": "4.4.11", "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.11.tgz", "integrity": "sha512-RM05tAniPZ5DZPzzNFP+DmrcOdD0efDUxMy3145oljWSl3x9ZV5vhme98gTxFrj2lhXvmGNnUiuDyJgY9IKkNA==", - "peer": true, "dependencies": { "@types/react": "*" } @@ -5732,7 +5752,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", "integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==", - "peer": true, "dependencies": { "@babel/runtime": "^7.8.7", "csstype": "^3.0.2" @@ -9573,6 +9592,11 @@ "tmpl": "1.0.5" } }, + "node_modules/memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -10462,7 +10486,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "peer": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -10472,8 +10495,7 @@ "node_modules/prop-types/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "peer": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/proxy-from-env": { "version": "1.0.0", @@ -10644,6 +10666,26 @@ } } }, + "node_modules/react-select": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/react-select/-/react-select-5.8.0.tgz", + "integrity": "sha512-TfjLDo58XrhP6VG5M/Mi56Us0Yt8X7xD6cDybC7yoRMUNm7BGO7qk8J0TLQOua/prb8vUOtsfnXZwfm30HGsAA==", + "dependencies": { + "@babel/runtime": "^7.12.0", + "@emotion/cache": "^11.4.0", + "@emotion/react": "^11.8.1", + "@floating-ui/dom": "^1.0.1", + "@types/react-transition-group": "^4.4.0", + "memoize-one": "^6.0.0", + "prop-types": "^15.6.0", + "react-transition-group": "^4.3.0", + "use-isomorphic-layout-effect": "^1.1.2" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/react-toastify": { "version": "10.0.5", "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-10.0.5.tgz", @@ -10660,7 +10702,6 @@ "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", "integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==", - "peer": true, "dependencies": { "@babel/runtime": "^7.5.5", "dom-helpers": "^5.0.1", @@ -11900,6 +11941,19 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-isomorphic-layout-effect": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz", + "integrity": "sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/use-sync-external-store": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz", diff --git a/package.json b/package.json index 5083e77ca..18b4262b8 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-redux": "^9.1.2", + "react-select": "^5.8.0", "react-toastify": "^10.0.5", "recoil": "^0.7.7", "redux": "^5.0.1", From 02f393f51a190defecb6f822646ef8338269d8f8 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 16 Sep 2024 15:27:29 +0200 Subject: [PATCH 45/47] fix: POI Update Modal --- components/pois/AddPoiModalWindow.js | 15 ++++- components/pois/PoiUpdateModal.js | 96 +++++++++++++--------------- 2 files changed, 59 insertions(+), 52 deletions(-) diff --git a/components/pois/AddPoiModalWindow.js b/components/pois/AddPoiModalWindow.js index f0e90efb6..01f077fdd 100644 --- a/components/pois/AddPoiModalWindow.js +++ b/components/pois/AddPoiModalWindow.js @@ -8,7 +8,7 @@ import { poiReadFromDbTriggerAtom } from "../../store/atoms/poiReadFromDbTrigger const AddPoiModalWindow = ({ onClose, map, latlng }) => { const [poiTypData, setpoiTypData] = useState([]); const [name, setName] = useState(""); - const [poiTypeId, setPoiTypeId] = useState(""); + const [poiTypeId, setPoiTypeId] = useState(""); // Initialize as empty string const [latitude] = useState(latlng.lat.toFixed(5)); const [longitude] = useState(latlng.lng.toFixed(5)); const setTrigger = useSetRecoilState(poiReadFromDbTriggerAtom); @@ -39,6 +39,13 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { const handleSubmit = async (event) => { event.preventDefault(); + + // Check for valid poiTypeId + if (!poiTypeId) { + alert("Bitte wählen Sie einen Typ aus."); + return; + } + const formData = { name, poiTypeId, @@ -56,6 +63,8 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { if (response.ok) { setTrigger((trigger) => trigger + 1); onClose(); + // Browser aktualisieren + window.location.reload(); } else { console.error("Fehler beim Hinzufügen des POI"); } @@ -115,6 +124,9 @@ const AddPoiModalWindow = ({ onClose, map, latlng }) => { Typ:
+