From ed82bf7f1fb6d8e8aebc4deb995ba10e71f5cc18 Mon Sep 17 00:00:00 2001 From: Anahita-Mahmoudi Date: Sat, 30 May 2026 13:29:48 +0330 Subject: [PATCH] git add . git commit -m "feat: improve wheel UI with gold pointer and center circle sync" --- backend/.env | 3 +- backend/__pycache__/config.cpython-313.pyc | Bin 958 -> 716 bytes backend/__pycache__/main.cpython-313.pyc | Bin 939 -> 669 bytes backend/__pycache__/schemas.cpython-313.pyc | Bin 1151 -> 913 bytes ...808a86947_add_prize_column.cpython-313.pyc | Bin 997 -> 0 bytes .../versions/b55808a86947_add_prize_column.py | 28 -- backend/api/__pycache__/admin.cpython-313.pyc | Bin 4101 -> 3116 bytes backend/api/__pycache__/user.cpython-313.pyc | Bin 2509 -> 1613 bytes backend/api/admin.py | 34 +- backend/api/user.py | 26 +- .../app/db/__pycache__/models.cpython-313.pyc | Bin 711 -> 672 bytes backend/app/db/models.py | 5 - backend/config.py | 8 +- .../core/__pycache__/logger.cpython-313.pyc | Bin 2548 -> 2548 bytes backend/logs/app.log | 205 ----------- backend/logs/error.log | 40 --- backend/main.py | 20 +- backend/schemas.py | 9 - .../services/__pycache__/crud.cpython-313.pyc | Bin 2212 -> 1665 bytes backend/services/crud.py | 54 ++- backend/{spinwheel.db => wheel.db} | Bin 12288 -> 20480 bytes frontend/admin.html | 86 +---- frontend/assets/css/style.css | 322 ++---------------- frontend/assets/js/admin.js | 98 +----- frontend/assets/js/api.js | 34 +- frontend/assets/js/wheel.js | 306 +---------------- frontend/index.html | 14 +- 27 files changed, 137 insertions(+), 1155 deletions(-) delete mode 100644 backend/alembic/versions/__pycache__/b55808a86947_add_prize_column.cpython-313.pyc delete mode 100644 backend/alembic/versions/b55808a86947_add_prize_column.py rename backend/{spinwheel.db => wheel.db} (56%) diff --git a/backend/.env b/backend/.env index e8403d6..7841a24 100644 --- a/backend/.env +++ b/backend/.env @@ -1,3 +1,4 @@ -DATABASE_URL=sqlite:///./spinwheel.db +DATABASE_URL=sqlite:///./wheel.db + LOG_ENABLED=true LOG_LEVEL=DEBUG \ No newline at end of file diff --git a/backend/__pycache__/config.cpython-313.pyc b/backend/__pycache__/config.cpython-313.pyc index ac76f951acad4b23501fdeb5b42e3285f607802e..3a0cad92c3ce9a5ee6a6fa64f9ccf7ae09400953 100644 GIT binary patch literal 716 zcmY*X&ubGw6n?Wio2+%y&>w*|AeMs2ddSIKN)b}+MI{GE(Zj;9O}24sIvd|?3KcJ2 zROq>Xga`i`FEStqo^n$X5O2=g-H4sTH}B1S?|t9=m^T_LV8@F;{>f)M|Da?!yegRA zwZSC_5bO~=WXN`43wA*`Z4hq6x^BrsCvtY7TNR-@;-NRAEMz7)h;<^8JWtg~4=PGA z@hYiAB0wep9l_AO1rd)t;oP>ALeRB>yz7(|SQ8%BN42nS{AK4ESuw$b-qYSePaMi; zPaaN|Au!Gb@mDRVa@nbs`xaK(yT~% znhmF8iUTQMPvdd5)0FZ!MV*gRm8i^a`?lOJjT6(7Qs;4=4rH9?m>x~@L`#X+t;(D% znwy7vk(i`v=lRPd8AnI);8miA(V%eCnVg$iX$-GfHks1|@8Rpl_Jxn@HpWc?>evr` z3@B+3tP(UW7+2?LtjSoZjLc+;JQQVXM55ZV)dofM8w#L1)+F%(zOT2w@YZk6y!HYt zlyqYDLvGe4=fhahDRuSoNVP>1k3wk6Yx=^GY)x{R@JaA(0i*8cc* R0e1Se3c=>Z-n;U|e*vW+p`QQ% literal 958 zcmY*X%}*0S6rcTM=!bl3DJm6XOf~jagT$ysiUFFEFsPSJCfjzYtIKYk-I`!Lpa&)K z!i9uC0sj)ugbPf%G``yQnO{-6Iwe3L`>giqP&5%*<4#G5wJ$49m0zn06Q9 zV%}h8%u{O+c=LiEU^M0vaXdvn);$Qi6Gb(yN<@++MXH&~rzP#{Izuf5nOZ2Vm*z{X z%wMimunF69?QmTtE2}Sfxmud9lozDFR9#$^gGg1%ugaB6J;Ce7t8*Q;%RMnw=u8s^ z(}jsIC5QUe3(o_8!)=}=;m$|B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Fta=QRemU N8qfR_mf0e2=|6>F^w|Ia diff --git a/backend/__pycache__/schemas.cpython-313.pyc b/backend/__pycache__/schemas.cpython-313.pyc index b605276d6510164284c681d315fdc70372f0e732..069f2abe526d95d19731591155b430499c7eb153 100644 GIT binary patch delta 538 zcmZvYO-lk%6o&8B`SNoLDL=pug0R`=A}}{DA}bf!elQ(nARRe#CEDadutgiiU(w%a zAGDN#et^3mBWPpi=pu;*?lW`eyf5!LXQ@rp=tm?HWcZYBm-aK8L=(I?$sbE?#ZV{r z2Rt`@;pzRFAC$Ia$X@VNSe-Ihbz#l@=<;M?iyP~SRZ;$Zp4c%>SJZ{wFzZ5qeccz9 zYnq@<8~iX%23JKquvsWNs=yY0gFHR+C3y*R@`VK3V>KzoYI4DcH7ct$1+=zmXkM7I zFDkI9|xVYInqDsm!CkmZiwB&I$bH3^s!Nc2_`@WD&y3@J|-Rs7jzw++76jMGFm2 za5=-um&E1lf+5zqB&-^er}gfd^)7B0Xq_MvVyue%Gm2L1IL-czRf05XI372Lc=vP8 a-&kfLajuV(n85XgBJ=F{=#$}VmG%QxfO6LW literal 1151 zcmb_bO>fgc5Z(1xoR2m@sc3`L77&6U)C=kXgg8(kAc!7n5En};H`$~H#|~o$spm-L zz@?Y|i2ezFN3{|sPPrjDh$}PeL?oyO4y@$2GjG;A<2U1cX{o|+J@~r*{w`stWhVQ( zAcIVfEet3-3$sWn`%@4Ni_}-iy*2~=#wvNbF5(yJqHmy;zd-nx?&*$N)JHurHcpJQW6%|tqvVyqrI}GR z>g~Qv2dKRqFJn*{Vdqcn3q{~a>y@wJwpfH`faRHB_pGL^R^~6=-c90e*c;P#y(y$< zI#5Lqs3)*QpcB`-ko4#J4Ob|nmC>S*V#+D5gAH_uO-bfscHY?dQZKZ-fy6XV`Jy~< znGRecs1xY(7o>s)MG2_7^g03#kXs!+pH0!I^~>V+=7b>>x#{#CD&P)|Izf!%3-sF+ zqo{kW@BHhN+{eWa^8{|;VG=pLkMP6foPT2*6UX57ll2M1ZBm)H9lm+;@F&AfXa5Z> Ch2cT~ diff --git a/backend/alembic/versions/__pycache__/b55808a86947_add_prize_column.cpython-313.pyc b/backend/alembic/versions/__pycache__/b55808a86947_add_prize_column.cpython-313.pyc deleted file mode 100644 index 4f01da5173370cb00fcbbd94a3f2d153fa20be3f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 997 zcmah|&ubG=5Pth3$!42PTD6KrbfJhwNl4Oc+61u&Tf`Q6a4B9EmY3aUns&3B&L-6q zgdB6Mhl1YfO>Z9kGg^8n&x;@)ycMf>^}S6hRV+Suvorh6&V2I?d!lJ7V&~0=tLtSE zq0c-xJ@UvodC#0(bQ75fkSUnrvalqAxFmt3^H^Gzmtqi$e0ezz2{Q(Ym9$hdev5r+ zCSc5xSS(t}7?0($#GedTB3y>lIe2n}YvxC+=8->}z(^>Ta5Zod9 z0y8zeR47$)1tV9g>cwhprc^5z^Od4eF=kZtD;o%9MXH!&vrBx3(AcWa8f6742JID^ zI@^pYFycW|XWLQD4W9Y-Z&0fP_MJ7`!*$|?RCP(4_-<$izQfy{9)UR$yC-~MyQm># z#qG>$y8+lGdg!c?7S6A{L!j{-b`gEJShLJ_)7PJ@5#m{O>};^Y7WPQ1-gK-j0$ilf zI!oGSYTA*S_E61yyGIk4LwK9j6J~b_2(@X}r^8Gd6&016&)L7)=PAB~`;s4|`mn z9u-3j3I0+FJ3uqGjeS4p;0~9;wjs$&@IM8{xZ%@AJpQJs+-n7H*CY4g8cX4e346>O zOM)PL6XSyXGmV7lFX-||bmdq<6F2(GVEPbUKPt}mwLy2se06(o=5_AvrTxj=K_-8Q u=8uZTzY*goU+Sxa#hvM$=X=u27klphg*ykSyN9UsJuV8#A1X7EJih<{%lIJx diff --git a/backend/alembic/versions/b55808a86947_add_prize_column.py b/backend/alembic/versions/b55808a86947_add_prize_column.py deleted file mode 100644 index 623134a..0000000 --- a/backend/alembic/versions/b55808a86947_add_prize_column.py +++ /dev/null @@ -1,28 +0,0 @@ -"""add prize column - -Revision ID: b55808a86947 -Revises: ab09ab5070f7 -Create Date: 2026-05-29 19:32:41.615653 - -""" -from typing import Sequence, Union - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision: str = 'b55808a86947' -down_revision: Union[str, Sequence[str], None] = 'ab09ab5070f7' -branch_labels: Union[str, Sequence[str], None] = None -depends_on: Union[str, Sequence[str], None] = None - - -def upgrade() -> None: - """Upgrade schema.""" - pass - - -def downgrade() -> None: - """Downgrade schema.""" - pass diff --git a/backend/api/__pycache__/admin.cpython-313.pyc b/backend/api/__pycache__/admin.cpython-313.pyc index d8926f41b5fc54b4f4a2be9ca7f28c34d9852b95..80a2500c6909a6bb18a0f06ded775ab8690b323a 100644 GIT binary patch delta 395 zcmZowSR8`D{9qQ&|L;Rn=fh(LZh#FksFucLR`}+ec z6D!}ZVhNxjO^(ctYzzn4xE%GE4+=;+YBC?xWOdZrEX)zhs8J>02{c+EFTX?~Ex$A` z#Y!P_3L^tU6(6dw=HwZib|AMs=JaJ$m~6;o$R_N&g+gzI!=c` z+%-Y9m~l$?#{If0Zi^0|#9EfF#JO>s-Vp#Z!APt3#I|F z!_OJ{`#(}e+7XQ9j1Tih(lk=4feP%aqL73cGm}iLpfdZu%em>S1YRm>rOOrn%${%+ z&2m@iX8_&hhtLk^3&lXxW?kcCpI};cj$RVbsBjJ)au>aJi|0Y27l0gtxh>3Hvt5~0 zPhSJVRj4MRkuWp4Wi?|O??u$G07?6*a`W7Hhn!Y9Gh?n8RqlhtN&)TIUh7ZcklUax z**K-MKZW$z6<7~UOz;+{f2{=y5*w~Ca;O8pi8^qw$tAUOW6b2O(M zulaF_Pc%hygR)!FCYf?~mp0Cn$2o2Ceu00R8aj3@;AgA3RZ~r`7ILYGdiVvN(y?;( z_%1pYrX6SA3q{1&sUX@AgElfmIE=m(KWcUO)Lqb&G)N~IlxKX@4OHZZ=G7P#WpTp4 z7C!y2*0&>bOpF<7XQV;^vNPEU&lKm`U^ za#@M(39?I;q(RhcaVNWOi?Is0Oj{x*HFS_;H8xG9!4%U6(o~pVg#9=L4iI<_fOi2r zkIkE{b{6uf1eRt*y?LgSO@%bMQwovV3Tfpu6#}u&0PG{+BX9u&%8MQA91Ie_n}C9$ z%D0~c1K3;RFsNifCy5xbV4jelW56P_D_CTn&V5hlu_v_s{5|%8v@4b7ez^Yd`V-Im z2LGG0vu5{fEp9GW&W#k8i*HrBuk6`htaFY{{GQXSwY+w-+kDOMAlT zfwOZ%dG=KHHvq*cSd}%|*8o_TH5~iDqP?Vzf%2Gdwx4;#b0SU&};?RVH6B;Rx!J1M&>^$uDQ^B8BGUpJR2}Nh$RZpoKeuj{_BZ zZ}HacK!tkwNC4izm*>&w5$~mx1Ba{5;QbfLy)X6rB=yue?A2{Rbp1*A1_S7+BN|(9 H8W;Zu4No#R diff --git a/backend/api/__pycache__/user.cpython-313.pyc b/backend/api/__pycache__/user.cpython-313.pyc index 51e0d47184544f5459d38d4a92f401b83065319f..891e14ff6013d5e8379fffb7b5497987f1927148 100644 GIT binary patch delta 870 zcmZ`%PfyfP5P$EruiJlHmNv+;bytGuS_I?(2NFZng9i`9Y$ce`xCd!)$pYqe2}hQT z8b~CYM%k~xN6>@cfJDQ=rilj=H1XDT`2fz_f)WxZ?e91J&Age;v`5yFZgjI*6@dkU zvie?V8F`#*l^3=>Jc4Gp4#qTBE+D3RTE$M4i|8tz;YpR!MJ@FykgLuTkBlHspTVg* zja|*7)5O&aXjNRrf4k(M{`Ipe_s^J|1JpF+l^Lgor}`ogEU5`MyO%|krz5GF&R zm_Dy>1pZ<8jNB`Yf$$48(TOs!S86^;M3GvNk=vCM2`O6mkt`Sjr0}~t3GgnwCft59 ziWuJ(6wCm{%8K8p)*Aj=z;t*H_=v;I0A%JlT;%}^pova%NYCxh?asAFj=IX)B|dh=1zeHN^?wX1pYM{nbdpTrQRGPT;Rk7I zJC?R;>+3#qNK9(WF>TZub>E@sBx>-owqD(O;rn&QJF`58Apn>)%l$!s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eaKj#61|d}T@KF7e1$zueGvTm4X7ZVr9YcDD_*8pRUJ z)woNDbGe_ci^$ttMwk;JV}9A5P(2H^3v99J$dYihDxsR-tk_WS|yJUg^q`NkXfy>D1{&LN^7dRa0tG z(JM|D6S-VhYP?IY+>@1i#*@qvrK?hc2raKBPpsS4ii>rTm@E`4(~(hi!}Oj8QpGmz z0ITSjj$BqZEU$l#%3uKgZBR495x61p8Ks{bfFZpi^t;fMSd8&1+OdjSS5e2WDEt_S ztEhPu?OsLUpIw3Lt<(G?SKZvnMHisoc@Ec=0*DdbZMoVqb87zF{oOzA?f(IOyN*q_ z6!Gy#Z9C^re*DH7a$<3A_d4y$EMlU#!~iTcP}SC}tuyBras8vl_B&G_y|adzu{d*n Qopy9@!x{sK?1$6+4bF!D=Kufz diff --git a/backend/api/admin.py b/backend/api/admin.py index 2d76f01..1677316 100644 --- a/backend/api/admin.py +++ b/backend/api/admin.py @@ -30,7 +30,7 @@ def get_items(db: Session = Depends(get_db)): logger.info(f"Items fetched: {len(items)} items") return items except Exception as e: - logger.critical(f"Unexpected error fetching items: {e}") + logger.error(f"Error fetching items: {e}") raise @@ -41,11 +41,11 @@ def create_item( db: Session = Depends(get_db) ): try: - result = crud.create_item(db, item.title, item.value) # ✅ value اضافه شد + result = crud.create_item(db, item.title) logger.info(f"Item created: {item.title}") return result except Exception as e: - logger.critical(f"Unexpected error creating item: {e}") + logger.error(f"Error creating item: {e}") raise @@ -65,29 +65,5 @@ def delete_item( except HTTPException: raise except Exception as e: - logger.critical(f"Unexpected error deleting item: {e}") - raise - -@router.put("/items/{item_id}", response_model=ItemResponse) -def update_item( - item_id: int, - item: schemas.ItemCreate, - db: Session = Depends(get_db) -): - try: - updated = crud.update_item(db, item_id, item.title, item.value) - - if not updated: - logger.warning(f"Item not found: {item_id}") - raise HTTPException(status_code=404, detail="Item not found") - - logger.info(f"Item updated: {item_id}") - return updated - - except HTTPException: - raise - except Exception as e: - logger.critical(f"Unexpected error updating item: {e}") - raise - - \ No newline at end of file + logger.error(f"Error deleting item: {e}") + raise \ No newline at end of file diff --git a/backend/api/user.py b/backend/api/user.py index e8e0fb9..a93d67b 100644 --- a/backend/api/user.py +++ b/backend/api/user.py @@ -29,7 +29,7 @@ def get_items(db: Session = Depends(get_db)): logger.info(f"User fetched items: {len(items)} items") return items except Exception as e: - logger.critical(f"Unexpected error fetching items: {e}") + logger.error(f"Error fetching items: {e}") raise @@ -38,26 +38,4 @@ def get_items(db: Session = Depends(get_db)): def spin(db: Session = Depends(get_db)): try: winner = crud.spin_wheel(db) - - if not winner: - logger.warning("Spin attempted but no items available") - raise HTTPException( - status_code=400, - detail="No items available" - ) - - logger.info(f"Spin result: {winner.title}") - - return { - "winner": { - "id": winner.id, - "title": winner.title - } - } - - except HTTPException: - raise - - except Exception as e: - logger.critical(f"Unexpected error during spin: {e}") - raise \ No newline at end of file + if not winner: \ No newline at end of file diff --git a/backend/app/db/__pycache__/models.cpython-313.pyc b/backend/app/db/__pycache__/models.cpython-313.pyc index 36d6023ebb114ce55998bc46dbced8c03614517f..4c2cd42c567043db812546cea06607276ea2bbe8 100644 GIT binary patch delta 101 zcmX@kx`37UGcPX}0}vGa=g5kf$h(@+Y~oI1mSFZGu8IHb7`Z3gGR99{%oxt7Gx;~8 zE=#j(k@#dgCO1)Wpq3&DAaRSsCO1E&G$+-rNP6;2CV75dMz#)_yxYKiDzy zOx9lucM;7kx@?F&KZ zD=YpUewg%X`(wApOMFGjp*5aL6@HmirNUx|(w=>m8{r?cM0gxgPU=`G=?l?(@||K!WmHMzS8uYDZ}+dxc$VnC@zE7>NDx z3!r+9$zK`B%gC@gGwqp!2RjRgdcLdYKk82F?sv_Ot<1OZm6YW)Iud@6t~b;DMVzgo3G&M;sbrOFRAG8%USYYJcvAyX^a%R^l zh92Z%Xxtd=LkvBpP-t_@vHw8t6%JTz?Ob~5O<;#y``)Z(S2d+ja_PX%d-LABH?!~e z-kY;rE<<3P{(9}f8-)2IWh&ib?#$o7gQb+3yAeu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%-{>|}+2AWvV%phyL8*GL5o zBm*_MG;NvK!~?Y%88Y)yQY(rJbAWz{Pb@9T2lM06+!JqzCcq2~K@LzT@`4Bf5W%on zO<@iH#0F0`E)Y*(v!cRA5Lb+s{{aIV|3n7<^ZZBnH}fyzpUD57zZWQ7&R;Lc&dk6M z#Hu&e+*p3Q=fOC5cHnshK6Ixy4|DY4R36cb>AuoYGVUPrndXch|{p`4l8T z#&Pi5G4OxkzskRje>%|Ebbc>>JD|~O{PkQMEDVwyH}~D_xYZ`j&ca~MbYsTQ@y4oK>u>ikoZwR- zvam4NG9t;}*nG1cE-xp`43>@tTZYhoV>3{H%guHpStc~?D8`F$F(O>U1@_=22L3<% r-}pc9zv6$we~ - - - - - پنل مدیریت - + پنل ادمین - +

مدیریت آیتم‌ها

-
- -
-

مدیریت گردونه شانس

-

مدیریت آیتم‌ها و جوایز گردونه

-
- - -
- - - - - - - -
- - -
- - - - - - - - - - - - - - - - - - - -
#عنوان جایزهمقدارعملیات
- -
- +
+ +
+
    + - - \ No newline at end of file diff --git a/frontend/assets/css/style.css b/frontend/assets/css/style.css index 5f262d2..b183966 100644 --- a/frontend/assets/css/style.css +++ b/frontend/assets/css/style.css @@ -1,325 +1,61 @@ -/* ========================= - ADMIN PANEL -========================= */ - -.admin-container { - width: 100%; - max-width: 1200px; - padding: 30px; -} - -.admin-header { - text-align: center; - margin-bottom: 30px; -} - -.admin-header h1 { - color: #FFD700; - font-size: 38px; - text-shadow: 0 0 15px rgba(255,215,0,0.5); -} - -.admin-header p { - color: #f5d6a0; - margin-top: 10px; - font-size: 18px; -} - -.add-section { - background: rgba(0,0,0,0.25); - backdrop-filter: blur(8px); - - border: 1px solid rgba(255,255,255,0.1); - - border-radius: 20px; - - padding: 20px; - - display: flex; - gap: 15px; - - margin-bottom: 30px; - - box-shadow: - 0 10px 30px rgba(0,0,0,0.4), - inset 0 0 20px rgba(255,255,255,0.03); -} - -.add-section input { - flex: 1; - - padding: 14px; - - border: none; - - border-radius: 12px; - - background: rgba(255,255,255,0.08); - - color: white; - - font-size: 16px; - - outline: none; -} - -.add-section input::placeholder { - color: rgba(255,255,255,0.5); -} - -#add-btn { - padding: 14px 28px; - - background: linear-gradient( - 135deg, - #FFD700, - #D4AC0D - ); - - color: #4a0f0f; - - border: none; - - border-radius: 14px; - - font-weight: bold; - - cursor: pointer; - - transition: 0.2s; - - box-shadow: - 0 4px 20px rgba(255,215,0,0.3); -} - -#add-btn:hover { - transform: translateY(-2px); - - box-shadow: - 0 8px 25px rgba(255,215,0,0.45); -} - -.table-wrapper { - background: rgba(0,0,0,0.25); - - backdrop-filter: blur(10px); - - border-radius: 22px; - - overflow: hidden; - - border: 1px solid rgba(255,255,255,0.08); - - box-shadow: - 0 10px 40px rgba(0,0,0,0.45); -} - -table { - width: 100%; - border-collapse: collapse; -} - -thead { - background: - linear-gradient( - 135deg, - #FFD700, - #D4AC0D - ); - - color: #4a0f0f; -} - -th { - padding: 18px; - font-size: 17px; -} - -td { - padding: 18px; - text-align: center; - color: white; -} - -tbody tr { - border-bottom: - 1px solid rgba(255,255,255,0.06); - - transition: 0.2s; -} - -tbody tr:hover { - background: - rgba(255,255,255,0.05); -} - -.action-buttons { - display: flex; - justify-content: center; - gap: 10px; -} - -.edit-btn, -.delete-btn { - border: none; - - padding: 10px 16px; - - border-radius: 10px; - - cursor: pointer; - - font-weight: bold; - - transition: 0.2s; -} - -.edit-btn { - background: - linear-gradient( - 135deg, - #9B59B6, - #7D3C98 - ); - - color: white; -} - -.delete-btn { - background: - linear-gradient( - 135deg, - #E74C3C, - #922B21 - ); - - color: white; -} - -.edit-btn:hover, -.delete-btn:hover { - transform: scale(1.05); -} - -@media (max-width: 768px) { - - .add-section { - flex-direction: column; - } - - table { - font-size: 14px; - } - - th, - td { - padding: 12px; - } -} - - -/* ========================= - WHEEL PAGE -========================= */ - * { + box-sizing: border-box; margin: 0; padding: 0; - box-sizing: border-box; } body { - min-height: 100vh; - background: linear-gradient(135deg, #8B0000 0%, #4a0f0f 50%, #2d0000 100%); - display: flex; - justify-content: center; - align-items: center; font-family: Tahoma, sans-serif; -} - -.page { + background: #f5f5f5; display: flex; flex-direction: column; align-items: center; - gap: 24px; - padding: 30px; + padding: 40px 20px; + gap: 20px; } -.page h1 { - color: #FFD700; - font-size: 36px; - text-shadow: 0 0 20px rgba(255, 215, 0, 0.5); - letter-spacing: 2px; +h1 { + color: #2c3e50; + margin-bottom: 10px; } -.wheel-wrapper { - position: relative; - width: 500px; - height: 500px; +canvas { + border-radius: 50%; + box-shadow: 0 4px 20px rgba(0,0,0,0.2); } -.wheel-wrapper canvas { - display: block; - width: 100%; - height: 100%; -} - -#spin-btn { - padding: 16px 48px; - font-size: 20px; - font-weight: bold; +button { + padding: 12px 30px; + font-size: 18px; font-family: Tahoma, sans-serif; - background: linear-gradient(135deg, #FFD700, #D4AC0D); - color: #4a0f0f; + background: #e74c3c; + color: white; border: none; - border-radius: 50px; + border-radius: 8px; cursor: pointer; - box-shadow: 0 6px 25px rgba(255, 215, 0, 0.4); - transition: 0.2s; } -#spin-btn:hover { - transform: translateY(-3px); - box-shadow: 0 10px 30px rgba(255, 215, 0, 0.55); +button:hover { + background: #c0392b; } -#spin-btn:disabled { - opacity: 0.5; +button:disabled { + background: #aaa; cursor: not-allowed; - transform: none; } #result { - min-height: 50px; - text-align: center; -} - -.winner-text { - font-size: 28px; + font-size: 24px; font-weight: bold; - color: #FFD700; - text-shadow: 0 0 20px rgba(255, 215, 0, 0.7); - animation: pop 0.4s ease; + color: #2c3e50; } -@keyframes pop { - 0% { transform: scale(0.5); opacity: 0; } - 70% { transform: scale(1.1); } - 100% { transform: scale(1); opacity: 1; } +/* ادمین */ +#add-section { + display: flex; + gap: 10px; + margin-bottom: 20px; } -@media (max-width: 550px) { - .wheel-wrapper { - width: 340px; - height: 340px; - } - - .page h1 { - font-size: 26px; - } - - #spin-btn { - font-size: 16px; - padding: 12px 36px; - } -} \ No newline at end of file +input { + padding: 10px; \ No newline at end of file diff --git a/frontend/assets/js/admin.js b/frontend/assets/js/admin.js index c81efca..2058645 100644 --- a/frontend/assets/js/admin.js +++ b/frontend/assets/js/admin.js @@ -1,103 +1,33 @@ -import { - adminGetItems, - createItem, - deleteItem, - updateItem // 👈 باید اینو هم به api.js اضافه کنی -} from './api.js'; +import { adminGetItems, createItem, deleteItem } from './api.js'; -const tableBody = document.getElementById('items-table-body'); -const titleInput = document.getElementById('title-input'); -const valueInput = document.getElementById('value-input'); +const list = document.getElementById('items-list'); +const input = document.getElementById('new-item'); const addBtn = document.getElementById('add-btn'); -let editId = null; // 👈 حالت ویرایش - -// -------------------- Render -------------------- async function renderItems() { const items = await adminGetItems(); - - tableBody.innerHTML = ''; - - items.forEach((item, index) => { - const row = document.createElement('tr'); - - row.innerHTML = ` - ${index + 1} - ${item.title} - ${item.value} - - - - - - - + list.innerHTML = ''; + items.forEach(item => { + const li = document.createElement('li'); + li.innerHTML = ` + ${item.title} + `; - - tableBody.appendChild(row); + list.appendChild(li); }); } -// -------------------- Delete -------------------- window.removeItem = async (id) => { await deleteItem(id); renderItems(); }; -// -------------------- Edit -------------------- -window.editItem = (id, title, value) => { - titleInput.value = title; - valueInput.value = value; - - editId = id; - - addBtn.textContent = 'آپدیت ✏️'; -}; - -// -------------------- Add / Update -------------------- addBtn.onclick = async () => { - const title = titleInput.value.trim(); - const value = valueInput.value.trim(); - - if (!title || !value) { - alert('همه فیلدها را پر کن'); - return; - } - - // حالت ویرایش - if (editId) { - await updateItem(editId, { - title, - value: parseInt(value) - }); - - editId = null; - addBtn.textContent = 'افزودن'; - } - - // حالت افزودن - else { - await createItem({ - title, - value: parseInt(value) - }); - } - - titleInput.value = ''; - valueInput.value = ''; - + const title = input.value.trim(); + if (!title) return; + await createItem(title); + input.value = ''; renderItems(); }; -// -------------------- Init -------------------- renderItems(); \ No newline at end of file diff --git a/frontend/assets/js/api.js b/frontend/assets/js/api.js index 17958bc..a55795f 100644 --- a/frontend/assets/js/api.js +++ b/frontend/assets/js/api.js @@ -1,40 +1,20 @@ const BASE = 'http://127.0.0.1:8000'; export const getItems = () => - fetch(`${BASE}/user/items`) - .then(r => r.json()); + fetch(`${BASE}/user/items`).then(r => r.json()); export const spinWheel = () => - fetch(`${BASE}/user/spin`, { - method: 'POST' - }).then(r => r.json()); + fetch(`${BASE}/user/spin`, { method: 'POST' }).then(r => r.json()); export const adminGetItems = () => - fetch(`${BASE}/admin/items`) - .then(r => r.json()); + fetch(`${BASE}/admin/items`).then(r => r.json()); -export const createItem = (data) => +export const createItem = (title) => fetch(`${BASE}/admin/items`, { method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }).then(r => r.json()); - -export const updateItem = (id, data) => - fetch(`${BASE}/admin/items/${id}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ title }) }).then(r => r.json()); export const deleteItem = (id) => - fetch(`${BASE}/admin/items/${id}`, { - method: 'DELETE' - }).then(r => { - if (r.status === 204) return {}; - return r.json(); - }); \ No newline at end of file + fetch(`${BASE}/admin/items/${id}`, { method: 'DELETE' }).then(r => r.json()); \ No newline at end of file diff --git a/frontend/assets/js/wheel.js b/frontend/assets/js/wheel.js index e4ca45c..83cc99b 100644 --- a/frontend/assets/js/wheel.js +++ b/frontend/assets/js/wheel.js @@ -4,309 +4,43 @@ const canvas = document.getElementById('wheel'); const ctx = canvas.getContext('2d'); const btn = document.getElementById('spin-btn'); const result = document.getElementById('result'); - -const DARK = { edge: '#6D0025', main: '#cb183d', highlight: '#E8005E', text: '#fff' }; -const LIGHT = { edge: '#D4889A', main: '#FAD4DC', highlight: '#FFF0F3', text: '#7B0030' }; +const colors = ['#e74c3c','#3498db','#2ecc71','#f39c12','#9b59b6','#1abc9c']; let items = []; let angle = 0; let spinning = false; -let lampOn = true; async function init() { items = await getItems(); - draw(angle); - setInterval(() => { - lampOn = !lampOn; - draw(angle); - }, 600); + drawWheel(angle); } -function getTheme(i, total) { - if (total % 2 === 0) { - return i % 2 === 0 ? DARK : LIGHT; - } else { - if (i === total - 1) return DARK; - return i % 2 === 0 ? DARK : LIGHT; - } -} - -function drawSegment(cx, cy, r, start, end, theme) { - ctx.beginPath(); - ctx.moveTo(cx, cy); - ctx.arc(cx, cy, r, start, end); - ctx.closePath(); - ctx.fillStyle = theme.edge; - ctx.fill(); - - const mid = (start + end) / 2; - const gx = cx + r * 0.5 * Math.cos(mid); - const gy = cy + r * 0.5 * Math.sin(mid); - const grad = ctx.createRadialGradient(gx, gy, 0, cx, cy, r); - grad.addColorStop(0, theme.highlight); - grad.addColorStop(0.45, theme.main); - grad.addColorStop(1, theme.edge); - - ctx.beginPath(); - ctx.moveTo(cx, cy); - ctx.arc(cx, cy, r - 2, start, end); - ctx.closePath(); - ctx.fillStyle = grad; - ctx.fill(); - - const hGrad = ctx.createRadialGradient(gx, gy, 0, gx, gy, r * 0.35); - hGrad.addColorStop(0, 'rgba(255,255,255,0.28)'); - hGrad.addColorStop(1, 'rgba(255,255,255,0)'); - ctx.beginPath(); - ctx.moveTo(cx, cy); - ctx.arc(cx, cy, r - 2, start, end); - ctx.closePath(); - ctx.fillStyle = hGrad; - ctx.fill(); -} - -function draw(rotation) { +function drawWheel(rotation) { if (items.length === 0) return; const cx = canvas.width / 2; const cy = canvas.height / 2; - const r = cx - 40; + const r = cx - 10; const slice = (2 * Math.PI) / items.length; - const total = items.length; ctx.clearRect(0, 0, canvas.width, canvas.height); - - // ═══ سایه کلی ═══ - ctx.save(); - ctx.shadowColor = 'rgba(0,0,0,0.6)'; - ctx.shadowBlur = 30; - ctx.shadowOffsetX = 5; - ctx.shadowOffsetY = 8; - ctx.beginPath(); - ctx.arc(cx, cy, r + 40, 0, Math.PI * 2); - ctx.fillStyle = '#1A0008'; - ctx.fill(); - ctx.restore(); - - // ═══ حلقه بیرونی تیره ═══ - const rimGrad = ctx.createRadialGradient(cx - 28, cy - 28, r, cx, cy, r + 40); - rimGrad.addColorStop(0, '#A0003A'); - rimGrad.addColorStop(0.3, '#6D0025'); - rimGrad.addColorStop(0.7, '#3D0015'); - rimGrad.addColorStop(1, '#1A0008'); - ctx.beginPath(); - ctx.arc(cx, cy, r + 40, 0, Math.PI * 2); - ctx.fillStyle = rimGrad; - ctx.fill(); - - // ═══ بخش‌های گردونه ═══ items.forEach((item, i) => { const start = rotation + i * slice; const end = start + slice; - drawSegment(cx, cy, r, start, end, getTheme(i, total)); - }); - - // ═══ خطوط طلایی ═══ - items.forEach((_, i) => { - const lineAngle = rotation + i * slice; - const lGrad = ctx.createLinearGradient( - cx, cy, - cx + r * Math.cos(lineAngle), - cy + r * Math.sin(lineAngle) - ); - lGrad.addColorStop(0, 'rgba(700,550,0,5)'); - lGrad.addColorStop(0.4, '#a2922e'); - lGrad.addColorStop(1, '#c8b43b'); ctx.beginPath(); ctx.moveTo(cx, cy); - ctx.lineTo(cx + r * Math.cos(lineAngle), cy + r * Math.sin(lineAngle)); - ctx.strokeStyle = lGrad; - ctx.lineWidth = 5; + ctx.arc(cx, cy, r, start, end); + ctx.fillStyle = colors[i % colors.length]; + ctx.fill(); ctx.stroke(); - }); - - // ═══ متن آیتم‌ها ═══ - items.forEach((item, i) => { - const start = rotation + i * slice; - const theme = getTheme(i, total); ctx.save(); ctx.translate(cx, cy); ctx.rotate(start + slice / 2); ctx.textAlign = 'right'; - ctx.fillStyle = theme.text; - ctx.font = 'bold 12px Tahoma'; - ctx.shadowColor = 'rgba(0,0,0,0.6)'; - ctx.shadowBlur = 4; - const text = item.title; - const maxWidth = r - 52; - if (ctx.measureText(text).width > maxWidth) { - const mid = Math.ceil(text.length / 2); - ctx.fillText(text.slice(0, mid), r - 20, -7); - ctx.fillText(text.slice(mid), r - 20, 9); - } else { - ctx.fillText(text, r - 20, 5); - } + ctx.fillStyle = '#fff'; + ctx.font = 'bold 16px Tahoma'; + ctx.fillText(item.title, r - 10, 5); ctx.restore(); }); - - // ═══ حلقه طلایی داخلی ═══ - ctx.beginPath(); - ctx.arc(cx, cy, r + 2, 0, Math.PI * 2); - ctx.strokeStyle = '#dfd498'; - ctx.lineWidth = 4.5; - ctx.shadowColor = 'rgba(255,215,0,0.9)'; - ctx.shadowBlur = 10; - ctx.stroke(); - ctx.shadowBlur = 0; - - // ═══ لامپ‌ها ═══ - const lampCount = 24; - const lampR = r + 23; - for (let i = 0; i < lampCount; i++) { - const lampAngle = (i / lampCount) * Math.PI * 2; - const lx = cx + lampR * Math.cos(lampAngle); - const ly = cy + lampR * Math.sin(lampAngle); - const isOn = lampOn ? i % 2 === 0 : i % 2 !== 0; - - if (isOn) { - const glowGrad = ctx.createRadialGradient(lx, ly, 0, lx, ly, 14); - glowGrad.addColorStop(0, 'rgba(255,220,80,0.55)'); - glowGrad.addColorStop(1, 'rgba(255,220,80,0)'); - ctx.beginPath(); - ctx.arc(lx, ly, 14, 0, Math.PI * 2); - ctx.fillStyle = glowGrad; - ctx.fill(); - } - - const lGrad = ctx.createRadialGradient(lx - 2.5, ly - 2.5, 0.5, lx, ly, 7.5); - if (isOn) { - lGrad.addColorStop(0, '#FFFFF5'); - lGrad.addColorStop(0.2, '#FFE566'); - lGrad.addColorStop(0.6, '#FFB300'); - lGrad.addColorStop(1, '#E65100'); - ctx.shadowColor = 'rgba(255,180,0,1)'; - ctx.shadowBlur = 14; - } else { - lGrad.addColorStop(0, '#B8954A'); - lGrad.addColorStop(1, '#4A3010'); - } - - ctx.beginPath(); - ctx.arc(lx, ly, 7.5, 0, Math.PI * 2); - ctx.fillStyle = lGrad; - ctx.fill(); - ctx.shadowBlur = 0; - - ctx.beginPath(); - ctx.arc(lx, ly, 7.5, 0, Math.PI * 2); - ctx.strokeStyle = isOn ? '#C8960C' : '#6A4A18'; - ctx.lineWidth = 1.2; - ctx.stroke(); - - ctx.beginPath(); - ctx.arc(lx - 2.5, ly - 2.5, 2.5, 0, Math.PI * 2); - ctx.fillStyle = isOn ? 'rgba(255,255,255,0.6)' : 'rgba(255,255,255,0.2)'; - ctx.fill(); - } - - // ═══ حلقه طلایی بیرونی ═══ - ctx.beginPath(); - ctx.arc(cx, cy, r + 35, 0, Math.PI * 2); - ctx.strokeStyle = '#C8960C'; - ctx.lineWidth = 4.5; - ctx.shadowColor = 'rgba(150,100,12,0.5)'; - ctx.shadowBlur = 6; - ctx.stroke(); - ctx.shadowBlur = 0; - - // ═══ دایره مرکزی — هماهنگ با نشانگر ═══ - const cGrad = ctx.createRadialGradient(cx - 8, cy - 8, 1, cx, cy, 22); - cGrad.addColorStop(0, '#FFFFF0'); - cGrad.addColorStop(0.15, '#FFE566'); - cGrad.addColorStop(0.45, '#FFD700'); - cGrad.addColorStop(0.75, '#ff962a'); - cGrad.addColorStop(1, '#b37900'); - - ctx.beginPath(); - ctx.arc(cx, cy, 22, 0, Math.PI * 2); - ctx.fillStyle = cGrad; - ctx.shadowColor = 'rgba(0,0,0,0.6)'; - ctx.shadowBlur = 14; - ctx.fill(); - ctx.shadowBlur = 0; - - ctx.beginPath(); - ctx.arc(cx, cy, 22, 0, Math.PI * 2); - ctx.strokeStyle = '#8B6914'; - ctx.lineWidth = 2; - ctx.stroke(); - - // بازتاب روی دایره مرکزی - ctx.beginPath(); - ctx.arc(cx - 6, cy - 6, 7, 0, Math.PI * 2); - ctx.fillStyle = 'rgba(255,255,255,0.3)'; - ctx.fill(); - - // ═══ نشانگر ═══ - drawPointer(cx); -} - -function drawPointer(cx) { - // سایه - ctx.save(); - ctx.shadowColor = 'rgba(0,0,0,0.4)'; - ctx.shadowBlur = 8; - ctx.shadowOffsetX = 3; - ctx.shadowOffsetY = 4; - ctx.beginPath(); - ctx.arc(cx, 20, 17, 0, Math.PI * 2); - ctx.fillStyle = 'rgba(0,0,0,0.1)'; - ctx.fill(); - ctx.restore(); - - // دایره طلایی — همرنگ مرکز - const pGrad = ctx.createRadialGradient(cx - 6, 14, 1, cx, 20, 18); - pGrad.addColorStop(0, '#FFFFF0'); - pGrad.addColorStop(0.15, '#FFE566'); - pGrad.addColorStop(0.45, '#FFD700'); - pGrad.addColorStop(0.75, '#ff962a'); - pGrad.addColorStop(1, '#b37900'); - - ctx.beginPath(); - ctx.arc(cx, 20, 17, 0, Math.PI * 2); - ctx.fillStyle = pGrad; - ctx.shadowColor = 'rgba(200,150,0,0.8)'; - ctx.shadowBlur = 12; - ctx.fill(); - ctx.shadowBlur = 0; - ctx.strokeStyle = '#8B6914'; - ctx.lineWidth = 2; - ctx.stroke(); - - // بازتاب - ctx.beginPath(); - ctx.arc(cx - 5, 13, 6, 0, Math.PI * 2); - ctx.fillStyle = 'rgba(255,255,255,0.35)'; - ctx.fill(); - - // مثلث — همرنگ - const triGrad = ctx.createLinearGradient(cx, 34, cx, 62); - triGrad.addColorStop(0, '#FFE566'); - triGrad.addColorStop(0.35, '#FFD700'); - triGrad.addColorStop(1, '#b37900'); - - ctx.beginPath(); - ctx.moveTo(cx - 13, 35); - ctx.lineTo(cx + 13, 35); - ctx.lineTo(cx, 62); - ctx.closePath(); - ctx.fillStyle = triGrad; - ctx.shadowColor = 'rgba(0,0,0,0.5)'; - ctx.shadowBlur = 8; - ctx.fill(); - ctx.shadowBlur = 0; - ctx.strokeStyle = '#8B6914'; - ctx.lineWidth = 1.5; - ctx.stroke(); } btn.onclick = async () => { @@ -319,30 +53,26 @@ btn.onclick = async () => { const winner = data.winner; const winnerIdx = items.findIndex(i => i.id === winner.id); const slice = (2 * Math.PI) / items.length; + const targetAngle = angle + (Math.PI * 2 * 5) + + (Math.PI * 2 - (winnerIdx * slice + slice / 2)); - const targetAngle = - angle + - Math.PI * 2 * 8 + - (-Math.PI / 2 - (winnerIdx * slice + slice / 2) - angle % (Math.PI * 2) + Math.PI * 2 * 3); - - const duration = 5500; - const startTime = performance.now(); + const duration = 4000; + const start = performance.now(); const from = angle; function animate(now) { - const elapsed = now - startTime; + const elapsed = now - start; const t = Math.min(elapsed / duration, 1); - const ease = 1 - Math.pow(1 - t, 4); + const ease = 1 - Math.pow(1 - t, 3); angle = from + (targetAngle - from) * ease; - draw(angle); + drawWheel(angle); if (t < 1) { requestAnimationFrame(animate); } else { spinning = false; btn.disabled = false; - draw(angle); - result.innerHTML = `🎉 ${winner.title} 🎉`; + result.textContent = `🎉 ${winner.title}`; } } diff --git a/frontend/index.html b/frontend/index.html index a2039d2..0713603 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -6,14 +6,12 @@ -
    -

    گردونه شانس

    -
    - -
    - -
    -
    +

    گردونه شانس

    + +
    + +

    + \ No newline at end of file