diff --git a/api/controllers/console/app/site.py b/api/controllers/console/app/site.py index 2024db65b29975..6aa9f0b475f161 100644 --- a/api/controllers/console/app/site.py +++ b/api/controllers/console/app/site.py @@ -20,6 +20,8 @@ def parse_app_site_args(): parser.add_argument('icon_background', type=str, required=False, location='json') parser.add_argument('description', type=str, required=False, location='json') parser.add_argument('default_language', type=supported_language, required=False, location='json') + parser.add_argument('chat_color_theme', type=str, required=False, location='json') + parser.add_argument('chat_color_theme_inverted', type=bool, required=False, location='json') parser.add_argument('customize_domain', type=str, required=False, location='json') parser.add_argument('copyright', type=str, required=False, location='json') parser.add_argument('privacy_policy', type=str, required=False, location='json') @@ -55,6 +57,8 @@ def post(self, app_model): 'icon_background', 'description', 'default_language', + 'chat_color_theme', + 'chat_color_theme_inverted', 'customize_domain', 'copyright', 'privacy_policy', diff --git a/api/controllers/web/site.py b/api/controllers/web/site.py index c5c70d810a3a5b..c307959b204459 100644 --- a/api/controllers/web/site.py +++ b/api/controllers/web/site.py @@ -26,6 +26,8 @@ class AppSiteApi(WebApiResource): site_fields = { 'title': fields.String, + 'chat_color_theme': fields.String, + 'chat_color_theme_inverted': fields.Boolean, 'icon': fields.String, 'icon_background': fields.String, 'description': fields.String, diff --git a/api/fields/app_fields.py b/api/fields/app_fields.py index 9de578544140f4..83045f5c64d4bb 100644 --- a/api/fields/app_fields.py +++ b/api/fields/app_fields.py @@ -111,6 +111,8 @@ 'icon_background': fields.String, 'description': fields.String, 'default_language': fields.String, + 'chat_color_theme': fields.String, + 'chat_color_theme_inverted': fields.Boolean, 'customize_domain': fields.String, 'copyright': fields.String, 'privacy_policy': fields.String, diff --git a/api/migrations/versions/63f9175e515b_merge_branches.py b/api/migrations/versions/63f9175e515b_merge_branches.py new file mode 100644 index 00000000000000..062365994195fa --- /dev/null +++ b/api/migrations/versions/63f9175e515b_merge_branches.py @@ -0,0 +1,22 @@ +"""merge branches + +Revision ID: 63f9175e515b +Revises: 2a3aebbbf4bb, b69ca54b9208 +Create Date: 2024-06-26 09:46:36.573505 + +""" +import models as models + +# revision identifiers, used by Alembic. +revision = '63f9175e515b' +down_revision = ('2a3aebbbf4bb', 'b69ca54b9208') +branch_labels = None +depends_on = None + + +def upgrade(): + pass + + +def downgrade(): + pass diff --git a/api/migrations/versions/b69ca54b9208_add_chatbot_color_theme.py b/api/migrations/versions/b69ca54b9208_add_chatbot_color_theme.py new file mode 100644 index 00000000000000..dd5a7495e475f3 --- /dev/null +++ b/api/migrations/versions/b69ca54b9208_add_chatbot_color_theme.py @@ -0,0 +1,35 @@ +"""add chatbot color theme + +Revision ID: b69ca54b9208 +Revises: 4ff534e1eb11 +Create Date: 2024-06-25 01:14:21.523873 + +""" +import sqlalchemy as sa +from alembic import op + +import models as models + +# revision identifiers, used by Alembic. +revision = 'b69ca54b9208' +down_revision = '4ff534e1eb11' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('sites', schema=None) as batch_op: + batch_op.add_column(sa.Column('chat_color_theme', sa.String(length=255), nullable=True)) + batch_op.add_column(sa.Column('chat_color_theme_inverted', sa.Boolean(), server_default=sa.text('false'), nullable=False)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('sites', schema=None) as batch_op: + batch_op.drop_column('chat_color_theme_inverted') + batch_op.drop_column('chat_color_theme') + + # ### end Alembic commands ### diff --git a/api/models/model.py b/api/models/model.py index c7768acbf3b4ea..ecb89861db9410 100644 --- a/api/models/model.py +++ b/api/models/model.py @@ -1042,6 +1042,8 @@ class Site(db.Model): icon_background = db.Column(db.String(255)) description = db.Column(db.Text) default_language = db.Column(db.String(255), nullable=False) + chat_color_theme = db.Column(db.String(255)) + chat_color_theme_inverted = db.Column(db.Boolean, nullable=False, server_default=db.text('false')) copyright = db.Column(db.String(255)) privacy_policy = db.Column(db.String(255)) show_workflow_steps = db.Column(db.Boolean, nullable=False, server_default=db.text('true')) diff --git a/web/.vscode/settings.example.json b/web/.vscode/settings.example.json index 6162d021d0f8e6..a2dfe7c6694559 100644 --- a/web/.vscode/settings.example.json +++ b/web/.vscode/settings.example.json @@ -22,4 +22,4 @@ }, "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true -} \ No newline at end of file +} diff --git a/web/app/components/app/app-publisher/index.tsx b/web/app/components/app/app-publisher/index.tsx index c330b4c270ce43..d7e9856ce46cce 100644 --- a/web/app/components/app/app-publisher/index.tsx +++ b/web/app/components/app/app-publisher/index.tsx @@ -226,6 +226,7 @@ const AppPublisher = ({ setEmbeddingModalOpen(false)} appBaseUrl={appBaseURL} diff --git a/web/app/components/app/overview/appCard.tsx b/web/app/components/app/overview/appCard.tsx index 820c240603fe69..4f5f93f22b9ac4 100644 --- a/web/app/components/app/overview/appCard.tsx +++ b/web/app/components/app/overview/appCard.tsx @@ -247,12 +247,14 @@ function AppCard({ ? ( <> setShowSettingsModal(false)} onSave={onSaveSiteConfig} /> setShowEmbedded(false)} appBaseUrl={app_base_url} diff --git a/web/app/components/app/overview/embedded/index.tsx b/web/app/components/app/overview/embedded/index.tsx index c4e4f6a154b250..f16fc81f16a82d 100644 --- a/web/app/components/app/overview/embedded/index.tsx +++ b/web/app/components/app/overview/embedded/index.tsx @@ -8,8 +8,11 @@ import copyStyle from '@/app/components/base/copy-btn/style.module.css' import Tooltip from '@/app/components/base/tooltip' import { useAppContext } from '@/context/app-context' import { IS_CE_EDITION } from '@/config' +import type { SiteInfo } from '@/models/share' +import { useThemeContext } from '@/app/components/base/chat/embedded-chatbot/theme/theme-context' type Props = { + siteInfo?: SiteInfo isShow: boolean onClose: () => void accessToken: string @@ -28,7 +31,7 @@ const OPTION_MAP = { `, }, scripts: { - getContent: (url: string, token: string, isTestEnv?: boolean) => + getContent: (url: string, token: string, primaryColor: string, isTestEnv?: boolean) => ``, + +`, }, chromePlugin: { getContent: (url: string, token: string) => `ChatBot URL: ${url}/chatbot/${token}`, @@ -60,12 +68,14 @@ type OptionStatus = { chromePlugin: boolean } -const Embedded = ({ isShow, onClose, appBaseUrl, accessToken, className }: Props) => { +const Embedded = ({ siteInfo, isShow, onClose, appBaseUrl, accessToken, className }: Props) => { const { t } = useTranslation() const [option, setOption] = useState