Class AiChatHubFragment
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.flowui.fragment.Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.aitoolsflowui.view.chathub.AiChatHubFragment
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,FacetOwner,FragmentOwner,Serializable
public class AiChatHubFragment
extends Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
Self-contained chat hub UI. Embeds the reusable chat input, shows the
current user's most recent chats next to it, and a full searchable,
date-bucketed history in a
SidePanelLayout. Designed to be dropped
into any host view.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.flowui.fragment.Fragment
Fragment.ReadyEvent -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChatDateTimeSupportprotected AiChatServiceprotected AiChatInputFragmentprotected AiConversationServiceprotected Dialogsprotected static final Stringprotected CollectionContainer<AiConversation> protected CollectionLoader<AiConversation> protected Stringprotected com.vaadin.flow.component.orderedlayout.VerticalLayoutprotected com.vaadin.flow.component.html.Spanprotected SidePanelLayoutprotected com.vaadin.flow.component.html.Divprotected AiIconProviderprotected @Nullable com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.Component> protected MessageBundleprotected MetadataToolsprotected Notificationsprotected AiToolsFlowuiPropertiesprotected @Nullable Integerprotected CollectionContainer<AiConversation> protected CollectionLoader<AiConversation> protected GridLayout<AiConversation> protected com.vaadin.flow.component.Componentprotected RouteSupportprotected ViewNavigatorsFields inherited from class io.jmix.flowui.fragment.Fragment
fragmentActions, fragmentData, fragmentFacets, parentController, uiComponents -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<AiConversation> applyHistoryFilter(List<AiConversation> conversations) protected StringbucketLabel(HistoryBucket bucket) protected voidconfirmDelete(AiConversation conversation) protected AiConversationCardcreateCard(AiConversation conversation, boolean deletable) protected AiConversationCardcreateHistoryCard(AiConversation conversation) protected com.vaadin.flow.component.ComponentcreateHistoryGroup(String bucketLabel, List<AiConversation> conversations) protected AiConversationCardcreateRecentCard(AiConversation conversation) protected voiddeleteConversation(AiConversation conversation) protected @Nullable StringformatDateTime(@Nullable OffsetDateTime dateTime) protected Map<HistoryBucket, List<AiConversation>> groupByBucket(List<AiConversation> conversations) historyConversationsLoadDelegate(LoadContext<AiConversation> loadContext) protected voidvoidonHistoryCloseBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) voidonHistoryNewBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) voidonHistorySearchFieldValueChange(SupportsTypedValue.TypedValueChangeEvent<TypedTextField<String>, String> event) voidonReady(Fragment.ReadyEvent event) voidonShowAllHistoryBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) protected voidopenConversation(AiConversation conversation) protected com.vaadin.flow.data.renderer.ComponentRenderer<AiConversationCard, AiConversation> recentConversationsLoadDelegate(LoadContext<AiConversation> loadContext) protected voidDisables the composer and warns the user when the chat model is not configured — starting a new chat would fail.protected voidprotected voidprotected com.vaadin.flow.component.Componentprotected intvoidsetMarkIconSupplier(@Nullable com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.Component> markIconSupplier) Sets a supplier of the brand mark icon shown on the hub hero and conversation cards, letting the host override the default add-on icon.voidsetRecentChatsCount(int recentChatsCount) Overrides the number of recent chats shown next to the chat input.protected voidstartConversation(String prompt) Methods inherited from class io.jmix.flowui.fragment.Fragment
addReadyListener, findInnerComponent, getFragmentActions, getFragmentData, getFragmentFacets, getInnerComponent, getParentController, initContent, onAttach, onDetach, setFragmentActions, setFragmentData, setFragmentFacets, setParentController, setUiComponentsMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface io.jmix.flowui.facet.FacetOwner
getIdMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
HERO_ICON_CN
- See Also:
-
messageBundle
-
hubHeroIcon
-
composerFragment
-
recentConversationsDc
-
recentConversationsDl
-
historyConversationsDc
-
historyConversationsDl
-
recentConversationsGridLayout
-
recentConversationsHeader
-
historySidePanel
-
historyListContainer
@ViewComponent protected com.vaadin.flow.component.orderedlayout.VerticalLayout historyListContainer -
historyPanelCount
-
metadataTools
-
chatDateTimeSupport
-
routeSupport
-
dialogs
-
notifications
-
conversationService
-
chatService
-
properties
-
iconProvider
-
recentChatsCount
-
historyFilter
-
markIconSupplier
protected @Nullable com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.Component> markIconSupplier
-
-
Constructor Details
-
AiChatHubFragment
public AiChatHubFragment()
-
-
Method Details
-
setMarkIconSupplier
public void setMarkIconSupplier(@Nullable com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.Component> markIconSupplier) Sets a supplier of the brand mark icon shown on the hub hero and conversation cards, letting the host override the default add-on icon. The supplier must return a fresh component on every call.- Parameters:
markIconSupplier- supplier of the mark icon, ornullto use the default
-
setRecentChatsCount
public void setRecentChatsCount(int recentChatsCount) Overrides the number of recent chats shown next to the chat input. When unset, the value comes fromjmix.aitools.ui.chat-hub-recent-chats-count(default 6).- Parameters:
recentChatsCount- number of recent chats to show
-
onReady
-
recentConversationsLoadDelegate
@Install(to="recentConversationsDl", target=DATA_LOADER) public List<AiConversation> recentConversationsLoadDelegate(LoadContext<AiConversation> loadContext) -
historyConversationsLoadDelegate
@Install(to="historyConversationsDl", target=DATA_LOADER) public List<AiConversation> historyConversationsLoadDelegate(LoadContext<AiConversation> loadContext) -
recentConversationsGridLayoutRenderer
@Supply(to="recentConversationsGridLayout", subject="renderer") protected com.vaadin.flow.data.renderer.ComponentRenderer<AiConversationCard,AiConversation> recentConversationsGridLayoutRenderer() -
onShowAllHistoryBtnClick
@Subscribe("showAllHistoryBtn") public void onShowAllHistoryBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) -
onHistoryCloseBtnClick
@Subscribe("historyCloseBtn") public void onHistoryCloseBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) -
onHistoryNewBtnClick
@Subscribe("historyNewBtn") public void onHistoryNewBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event) -
onHistorySearchFieldValueChange
@Subscribe("historySearchField") public void onHistorySearchFieldValueChange(SupportsTypedValue.TypedValueChangeEvent<TypedTextField<String>, String> event) -
startConversation
-
refreshRecentConversationsVisibility
protected void refreshRecentConversationsVisibility() -
refreshComposerAvailability
protected void refreshComposerAvailability()Disables the composer and warns the user when the chat model is not configured — starting a new chat would fail. -
loadConversations
protected void loadConversations() -
createRecentCard
-
createHistoryCard
-
createCard
-
openConversation
-
confirmDelete
-
deleteConversation
-
renderHistoryList
protected void renderHistoryList() -
applyHistoryFilter
-
groupByBucket
-
bucketLabel
-
createHistoryGroup
protected com.vaadin.flow.component.Component createHistoryGroup(String bucketLabel, List<AiConversation> conversations) -
resolveRecentChatsCount
protected int resolveRecentChatsCount() -
resolveMarkIcon
protected com.vaadin.flow.component.Component resolveMarkIcon() -
formatDateTime
-