From f58f2758ed7e6681a87fc3dce2ba15d0466737cc Mon Sep 17 00:00:00 2001 From: shiva raj badu Date: Tue, 24 Mar 2026 13:08:47 +0545 Subject: [PATCH] fix:Theme issues --- ...476a7_add_theme_column_to_presentations.py | 31 ++++++++++++++++++ ...74449_add_theme_column_to_presentations.py | 31 ++++++++++++++++++ .../api/v1/ppt/endpoints/presentation.py | 6 ++-- .../fastapi/api/v1/ppt/endpoints/theme.py | 5 ++- .../models/presentation_with_slides.py | 1 + .../fastapi/models/sql/presentation.py | 1 + electron/servers/fastapi/placeholder | Bin 12288 -> 98304 bytes .../components/PresentationHeader.tsx | 4 ++- .../presentation/components/ThemeSelector.tsx | 5 ++- .../services/api/types.ts | 8 ++--- 10 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 electron/servers/fastapi/alembic/versions/82abdbc476a7_add_theme_column_to_presentations.py create mode 100644 electron/servers/fastapi/alembic/versions/f42ad4074449_add_theme_column_to_presentations.py diff --git a/electron/servers/fastapi/alembic/versions/82abdbc476a7_add_theme_column_to_presentations.py b/electron/servers/fastapi/alembic/versions/82abdbc476a7_add_theme_column_to_presentations.py new file mode 100644 index 00000000..c7282a6e --- /dev/null +++ b/electron/servers/fastapi/alembic/versions/82abdbc476a7_add_theme_column_to_presentations.py @@ -0,0 +1,31 @@ +"""add theme column to presentations + +Revision ID: 82abdbc476a7 +Revises: f42ad4074449 +Create Date: 2026-03-24 12:42:46.220359 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision: str = '82abdbc476a7' +down_revision: Union[str, None] = 'f42ad4074449' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/electron/servers/fastapi/alembic/versions/f42ad4074449_add_theme_column_to_presentations.py b/electron/servers/fastapi/alembic/versions/f42ad4074449_add_theme_column_to_presentations.py new file mode 100644 index 00000000..4cc8c46f --- /dev/null +++ b/electron/servers/fastapi/alembic/versions/f42ad4074449_add_theme_column_to_presentations.py @@ -0,0 +1,31 @@ +"""add theme column to presentations + +Revision ID: f42ad4074449 +Revises: 00b3c27a13bc +Create Date: 2026-03-24 12:42:32.369006 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision: str = 'f42ad4074449' +down_revision: Union[str, None] = '00b3c27a13bc' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('presentations', sa.Column('theme', sa.JSON(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('presentations', 'theme') + # ### end Alembic commands ### diff --git a/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py index 27a01244..cb616c15 100644 --- a/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -366,6 +366,7 @@ async def update_presentation( id: Annotated[uuid.UUID, Body()], n_slides: Annotated[Optional[int], Body()] = None, title: Annotated[Optional[str], Body()] = None, + theme: Annotated[Optional[dict], Body()] = None, slides: Annotated[Optional[List[SlideModel]], Body()] = None, sql_session: AsyncSession = Depends(get_async_session), ): @@ -378,10 +379,11 @@ async def update_presentation( presentation_update_dict["n_slides"] = n_slides if title: presentation_update_dict["title"] = title + if theme: + presentation_update_dict["theme"] = theme - if n_slides or title: + if presentation_update_dict: presentation.sqlmodel_update(presentation_update_dict) - if slides: # Just to make sure id is UUID for slide in slides: diff --git a/electron/servers/fastapi/api/v1/ppt/endpoints/theme.py b/electron/servers/fastapi/api/v1/ppt/endpoints/theme.py index 4ddd38d9..f597b82f 100644 --- a/electron/servers/fastapi/api/v1/ppt/endpoints/theme.py +++ b/electron/servers/fastapi/api/v1/ppt/endpoints/theme.py @@ -1,3 +1,4 @@ +import copy import uuid from typing import Any, List, Optional @@ -67,7 +68,9 @@ def _read_themes_from_row(row: Optional[KeyValueSqlModel]) -> list[dict[str, Any return [] value = row.value if isinstance(row.value, dict) else {} themes = value.get("themes", []) - return themes if isinstance(themes, list) else [] + if not isinstance(themes, list): + return [] + return copy.deepcopy(themes) async def _resolve_logo_url( diff --git a/electron/servers/fastapi/models/presentation_with_slides.py b/electron/servers/fastapi/models/presentation_with_slides.py index 3a4d83b4..f508f4a3 100644 --- a/electron/servers/fastapi/models/presentation_with_slides.py +++ b/electron/servers/fastapi/models/presentation_with_slides.py @@ -18,3 +18,4 @@ class PresentationWithSlides(BaseModel): tone: Optional[str] = None verbosity: Optional[str] = None slides: List[SlideModel] + theme: Optional[dict] = None diff --git a/electron/servers/fastapi/models/sql/presentation.py b/electron/servers/fastapi/models/sql/presentation.py index 050bf2f2..d2d57e6c 100644 --- a/electron/servers/fastapi/models/sql/presentation.py +++ b/electron/servers/fastapi/models/sql/presentation.py @@ -41,6 +41,7 @@ class PresentationModel(SQLModel, table=True): include_table_of_contents: bool = Field(sa_column=Column(Boolean), default=False) include_title_slide: bool = Field(sa_column=Column(Boolean), default=True) web_search: bool = Field(sa_column=Column(Boolean), default=False) + theme: Optional[dict] = Field(sa_column=Column(JSON), default=None) def get_new_presentation(self): return PresentationModel( diff --git a/electron/servers/fastapi/placeholder b/electron/servers/fastapi/placeholder index aa73729d84185a6c6e30386b3f7d5b2846669bf4..4ff509e6070692f535a1286542464362234664d9 100644 GIT binary patch literal 98304 zcmeI&U31ge8NhLi5GyeWVZ(yp3c-{io|N73(k06_F&mU9V>a`h(JylA@Hp)%8-Tv?~AJkbmQ!75U;~{6_w-%)HKfxmx<-Pt|4Ft0@ml zE7w;3x$Is3+mf^VRZ38 zH`g9~Rn;52ZN2f`&d$&E%3{au2l9ma_w{DjpXlqGzGHWVuWvWn#tS3a=~(^!p|vkE zj|}XQ`kLLX zR;of%wMRFV(Y)R7iVyaONlwf}hNCpym{h=a6Tj>nAuy`HG7_~`tSnmzBd=tAdlg3Nu-9S&mJM206B%&NsZQTTT3F?7mYACNjtr1JU5y~ zW6NlzZ#CVco;`?W15>=0H*#jzwRB}gac? zswaFHr!T>* zrCXMQMOAw&BV3M){ZJgex16Dn-v~WfmE--WcC^UQB{{Cu72Ws&FL4)!55Soq;zQtBCwJ57T6<6~YcFo+)!NC` zo3)eI>hYsFRcp1Bk8dIc%RlOO64RWyFZ#lZ78CNh)<5(=VaUaV+b0}w#=SSW#j>WP zp78yd)kXBZ?Rl;@t(x<4ao%b{t|hGL$xefdi)HPol?VO_VVkv27&JesDyp`=t{g9p zQ{;%=p4~C!3dEPI6f61mLXtk&88S}}GyB6{TxO>hd|SJXR=Zi3Un6?z^yc8OqbDS0 z&L>wQPcD?TSL?YX$;*-9CmZI%wYjqLzmojJ4+01vfB*srAbXxFE$=p8x;HlzmoN}O009ILKmY**5I_I{1Q3`AtjyhAoL&Ei`~UKn z{`o-w0R#|0009ILKmY**5I_Kd0t%m0IciJzB&pO=5 } - +
diff --git a/electron/servers/nextjs/app/(presentation-generator)/presentation/components/ThemeSelector.tsx b/electron/servers/nextjs/app/(presentation-generator)/presentation/components/ThemeSelector.tsx index a31f9bfc..5c58df1d 100644 --- a/electron/servers/nextjs/app/(presentation-generator)/presentation/components/ThemeSelector.tsx +++ b/electron/servers/nextjs/app/(presentation-generator)/presentation/components/ThemeSelector.tsx @@ -3,12 +3,11 @@ import React, { useState } from 'react' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { Palette } from 'lucide-react'; -import { useDispatch, useSelector } from 'react-redux'; +import { useDispatch } from 'react-redux'; import { updateTheme } from '@/store/slices/presentationGeneration'; import { useRouter } from 'next/navigation'; import { useFontLoader } from '../../hooks/useFontLoad'; -import { RootState } from '@/store/store'; -const ThemeSelector = ({ presentation_id, current_theme, themes: allThemes }: { presentation_id: string, current_theme: any, themes: any[] }) => { +const ThemeSelector = ({ current_theme, themes: allThemes }: { current_theme: any, themes: any[] }) => { const [currentTheme, setCurrentTheme] = useState(current_theme) const dispatch = useDispatch() const [isOpen, setIsOpen] = useState(false) diff --git a/electron/servers/nextjs/app/(presentation-generator)/services/api/types.ts b/electron/servers/nextjs/app/(presentation-generator)/services/api/types.ts index f1f45afd..ac5b6108 100644 --- a/electron/servers/nextjs/app/(presentation-generator)/services/api/types.ts +++ b/electron/servers/nextjs/app/(presentation-generator)/services/api/types.ts @@ -25,10 +25,10 @@ export interface DeplotResponse { } export interface ImageAssetResponse { - message: string; - path: string; - id: string; - file_url?: string; + message: string; + path: string; + id: string; + file_url?: string; }