From 0f8c56e08bc21fddf8e2a4f3169f7556cca2a739 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Tue, 3 Sep 2024 14:14:29 +0200 Subject: [PATCH 01/21] [CHATBOT-630 Export documentary resources and create documentaryResourceConfig file] --- .../chatbot/commons/mda/webservices.ksp | 17 +- .../services/DocumentaryResourceServices.java | 64 +++++- .../services/bot/AttachmentServices.java | 2 +- .../topic/export/BotExportServices.java | 5 + .../chatbot/commons/domain/BotExport.java | 20 ++ .../domain/DocumentaryResourceExport.java | 202 ++++++++++++++++++ .../chatbot/commons/domain/DtResources.java | 44 ++++ .../commons/domain/DtResources.properties | 13 ++ .../vertigo/chatbot/domain/DtDefinitions.java | 27 +++ .../manager/ExecutorConfigManager.java | 39 ++++ .../executor/manager/ExecutorManager.java | 1 + .../chatbot/commons/domain/Attachment.java | 43 ++++ .../commons/domain/AttachmentType.java | 91 ++++++++ .../commons/domain/AttachmentTypeEnum.java | 25 +++ .../chatbot/commons/domain/BotExport.java | 20 ++ .../domain/DocumentaryResourceExport.java | 202 ++++++++++++++++++ .../vertigo/chatbot/domain/DtDefinitions.java | 42 ++++ 17 files changed, 850 insertions(+), 7 deletions(-) create mode 100644 vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java create mode 100644 vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentType.java create mode 100644 vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentTypeEnum.java create mode 100644 vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index e7df6fa14..bebe101cf 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -13,8 +13,9 @@ create DtDefinition DtBotExport { field confluenceSetting {domain: DoDtConfluenceSettingExport label: "Confluence setting" cardinality : "?"} field jiraSetting {domain: DoDtJiraSettingExport label: "Jira setting" cardinality : "?"} field jiraFieldSetting {domain: DoDtJiraFieldSettingExport label: "Jira fields setting" cardinality : "*"} - field questionAnswerList {domain: DoText label: "Questions answers List" cardinality : "1"} - field mapContext {domain: DoText label: "map Context" cardinality : "1"} + field questionAnswerList {domain: DoText label: "Questions answers List" cardinality : "1"} + field documentaryResources {domain: DoText label: "Documentary resources" cardinality : "1"} + field mapContext {domain: DoText label: "map Context" cardinality : "1"} } create DtDefinition DtTopicExport { @@ -115,3 +116,15 @@ create DtDefinition DtQuestionAnswerExport { field answer {domain: DoText label: "Answer" cardinality : "1"} field catLabel {domain: DoLabel label: "Category" cardinality : "1"} } + +create DtDefinition DtDocumentaryResourceExport { + field title {domain: DoLabel label: "Title" cardinality : "1" } + field dreTypeCd {domain: DoLabel label: "Resource Type" cardinality : "1" } + field text {domain: DoText label: "Text" } + field url {domain: DoText label: "Url" } + field fileData {domain: DoText label: "File data" } + field fileName {domain: DoLabel label: "File name" } + field fileMimeType {domain: DoLabel label: "File mime type" } + field fileLength {domain: DoSize label: "File size" } + field fileUrn {domain: DoText label: "File urn" } +} diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java index 34cb346db..975800a9d 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java @@ -1,24 +1,37 @@ package io.vertigo.chatbot.designer.builder.services; +import java.io.IOException; +import java.io.InputStream; +import java.util.Base64; + import java.util.Optional; import javax.inject.Inject; import io.vertigo.account.authorization.annotations.Secured; import io.vertigo.account.authorization.annotations.SecuredOperation; +import io.vertigo.chatbot.commons.LogsUtils; import io.vertigo.chatbot.commons.domain.Attachment; +import io.vertigo.chatbot.commons.domain.AttachmentFileInfo; import io.vertigo.chatbot.commons.domain.AttachmentTypeEnum; import io.vertigo.chatbot.commons.domain.Chatbot; +import io.vertigo.chatbot.commons.domain.DocumentaryResourceExport; +import io.vertigo.chatbot.commons.multilingual.attachment.AttachmentMultilingualResources; import io.vertigo.chatbot.designer.builder.services.bot.AttachmentServices; +import io.vertigo.chatbot.designer.commons.services.DesignerFileServices; import io.vertigo.chatbot.designer.dao.DocumentaryResourceDAO; import io.vertigo.chatbot.designer.domain.DocumentaryResource; import io.vertigo.chatbot.designer.domain.DocumentaryResourceTypeEnum; import io.vertigo.chatbot.domain.DtDefinitions; import io.vertigo.commons.transaction.Transactional; +import io.vertigo.core.lang.VUserException; import io.vertigo.core.node.component.Component; import io.vertigo.datamodel.criteria.Criterions; import io.vertigo.datamodel.structure.model.DtList; import io.vertigo.datamodel.structure.model.DtListState; +import io.vertigo.datamodel.structure.util.VCollectors; +import io.vertigo.datastore.filestore.model.VFile; +import io.vertigo.vega.engines.webservice.json.JsonEngine; import io.vertigo.datastore.filestore.model.FileInfoURI; import static io.vertigo.chatbot.designer.utils.ListUtils.MAX_ELEMENTS_PLUS_ONE; @@ -27,12 +40,18 @@ public class DocumentaryResourceServices implements Component { @Inject - DocumentaryResourceDAO documentaryResourceDAO; + private DocumentaryResourceDAO documentaryResourceDAO; + + @Inject + private AttachmentServices attachmentServices; + + @Inject + private DesignerFileServices designerFileServices; @Inject - AttachmentServices attachmentServices; + private JsonEngine jsonEngine; - public DocumentaryResource getDocResById(final Long dreId) { + public DocumentaryResource getDocResById(final Long dreId) { return documentaryResourceDAO.get(dreId); } @@ -72,7 +91,7 @@ public void saveDocumentaryResource(@SecuredOperation("botAdm") final Chatbot bo @Secured("BotUser") public void deleteDocumentaryResource(@SecuredOperation("botAdm") final Chatbot bot, final DocumentaryResource documentaryResource) { documentaryResourceDAO.delete(documentaryResource.getDreId()); - if(documentaryResource.getAttId() != null){ + if (documentaryResource.getAttId() != null) { attachmentServices.delete(bot, documentaryResource.getAttId()); } } @@ -82,4 +101,41 @@ public DocumentaryResource getNewdocumentaryResource(final Long botId) { documentaryResource.setBotId(botId); return documentaryResource; } + + public String exportDocumentaryResourceByBot(@SecuredOperation("botAdm") final Chatbot bot, final StringBuilder logs) { + LogsUtils.addLogs(logs, "Export documentary resources: "); + try { + return jsonEngine.toJson(getAllDocResByBot(bot).stream().map(documentaryResource -> { + documentaryResource.attachment().load(); + + final DocumentaryResourceExport documentaryResourceExport = new DocumentaryResourceExport(); + documentaryResourceExport.setTitle(documentaryResource.getTitle()); + documentaryResourceExport.setDreTypeCd(documentaryResource.getDreTypeCd()); + documentaryResourceExport.setText(documentaryResource.getText()); + documentaryResourceExport.setUrl(documentaryResource.getUrl()); + if (documentaryResource.getAttId() != null) { + Attachment attachment = documentaryResource.attachment().get(); + attachment.attachmentFileInfo().load(); + AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get(); + documentaryResourceExport.setFileName(attachmentFileInfo.getFileName()); + documentaryResourceExport.setFileMimeType(attachmentFileInfo.getMimeType()); + documentaryResourceExport.setFileLength(attachmentFileInfo.getLength()); + final VFile file = designerFileServices.getAttachment(attachment.getAttFiId()); + try (final InputStream inputStream = file.createInputStream()) { + documentaryResourceExport.setFileData(Base64.getEncoder().encodeToString(inputStream.readAllBytes())); + } catch (final IOException e) { + LogsUtils.logKO(logs); + LogsUtils.addLogs(logs, e); + } + } + return documentaryResourceExport; + }).collect(VCollectors.toDtList(DocumentaryResourceExport.class))); + + } catch (final Exception e) { + LogsUtils.logKO(logs); + LogsUtils.addLogs(logs, e); + throw new VUserException(AttachmentMultilingualResources.EXPORT_UNEXPECTED_ERROR, e); + } + } + } diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java index 0759c5a5b..97da7607a 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java @@ -99,7 +99,7 @@ public void delete (@SecuredOperation("botAdm") final Chatbot bot, final long at public DtList exportAttachmentByBot(@SecuredOperation("botAdm") final Chatbot bot, final StringBuilder logs) { LogsUtils.addLogs(logs, "Export attachments : "); try { - return findAllByBotId(bot.getBotId()).stream().map(attachment -> { + return findAllByBotIdAndType(bot.getBotId(), AttachmentTypeEnum.ATTACHMENT.name()).stream().map(attachment -> { attachment.attachmentFileInfo().load(); final AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get(); final AttachmentExport attachmentExport = new AttachmentExport(); diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java index 49f891766..60777598c 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java @@ -16,6 +16,7 @@ import io.vertigo.chatbot.commons.domain.JiraSettingExport; import io.vertigo.chatbot.commons.domain.topic.KindTopicEnum; import io.vertigo.chatbot.designer.builder.services.ConfluenceSettingServices; +import io.vertigo.chatbot.designer.builder.services.DocumentaryResourceServices; import io.vertigo.chatbot.designer.builder.services.FontFamilyServices; import io.vertigo.chatbot.designer.builder.services.JiraFieldSettingServices; import io.vertigo.chatbot.designer.builder.services.JiraSettingServices; @@ -58,6 +59,9 @@ public class BotExportServices implements Component { @Inject private QuestionAnswerServices questionAnswerServices; + @Inject + private DocumentaryResourceServices documentaryResourceServices; + @Inject private FontFamilyServices fontFamilyServices; @@ -76,6 +80,7 @@ public BotExport exportBot(final Chatbot bot, final StringBuilder logs) { export.setMapContext(contextValueServices.exportContextValuesToMapByBot(bot, logs)); export.setJiraFieldSetting(jiraFieldSettingServices.exportJiraSetting(bot)); export.setQuestionAnswerList(questionAnswerServices.exportActiveQuestionsAnswers(bot, logs)); + export.setDocumentaryResources(documentaryResourceServices.exportDocumentaryResourceByBot(bot, logs)); return export; } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java index 645820bc0..120706762 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java @@ -25,6 +25,7 @@ public final class BotExport implements DtObject { private io.vertigo.chatbot.commons.domain.JiraSettingExport jiraSetting; private io.vertigo.datamodel.structure.model.DtList jiraFieldSetting = new io.vertigo.datamodel.structure.model.DtList<>(io.vertigo.chatbot.commons.domain.JiraFieldSettingExport.class); private String questionAnswerList; + private String documentaryResources; private String mapContext; /** @@ -261,6 +262,25 @@ public void setQuestionAnswerList(final String questionAnswerList) { this.questionAnswerList = questionAnswerList; } + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Documentary resources'. + * @return String documentaryResources Obligatoire + */ + @Field(smartType = "STyText", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Documentary resources") + public String getDocumentaryResources() { + return documentaryResources; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Documentary resources'. + * @param documentaryResources String Obligatoire + */ + public void setDocumentaryResources(final String documentaryResources) { + this.documentaryResources = documentaryResources; + } + /** * Champ : DATA. * Récupère la valeur de la propriété 'map Context'. diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java new file mode 100644 index 000000000..b9b0edec4 --- /dev/null +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java @@ -0,0 +1,202 @@ +package io.vertigo.chatbot.commons.domain; + +import io.vertigo.core.lang.Generated; +import io.vertigo.datamodel.structure.model.DtObject; +import io.vertigo.datamodel.structure.stereotype.Field; +import io.vertigo.datamodel.structure.util.DtObjectUtil; + +/** + * This class is automatically generated. + * DO NOT EDIT THIS FILE DIRECTLY. + */ +@Generated +public final class DocumentaryResourceExport implements DtObject { + private static final long serialVersionUID = 1L; + + private String title; + private String dreTypeCd; + private String text; + private String url; + private String fileData; + private String fileName; + private String fileMimeType; + private Long fileLength; + private String fileUrn; + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Title'. + * @return String title Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Title") + public String getTitle() { + return title; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Title'. + * @param title String Obligatoire + */ + public void setTitle(final String title) { + this.title = title; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Resource Type'. + * @return String dreTypeCd Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Resource Type") + public String getDreTypeCd() { + return dreTypeCd; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Resource Type'. + * @param dreTypeCd String Obligatoire + */ + public void setDreTypeCd(final String dreTypeCd) { + this.dreTypeCd = dreTypeCd; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Text'. + * @return String text + */ + @Field(smartType = "STyText", label = "Text") + public String getText() { + return text; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Text'. + * @param text String + */ + public void setText(final String text) { + this.text = text; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Url'. + * @return String url + */ + @Field(smartType = "STyText", label = "Url") + public String getUrl() { + return url; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Url'. + * @param url String + */ + public void setUrl(final String url) { + this.url = url; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File data'. + * @return String fileData + */ + @Field(smartType = "STyText", label = "File data") + public String getFileData() { + return fileData; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File data'. + * @param fileData String + */ + public void setFileData(final String fileData) { + this.fileData = fileData; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File name'. + * @return String fileName + */ + @Field(smartType = "STyLabel", label = "File name") + public String getFileName() { + return fileName; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File name'. + * @param fileName String + */ + public void setFileName(final String fileName) { + this.fileName = fileName; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File mime type'. + * @return String fileMimeType + */ + @Field(smartType = "STyLabel", label = "File mime type") + public String getFileMimeType() { + return fileMimeType; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File mime type'. + * @param fileMimeType String + */ + public void setFileMimeType(final String fileMimeType) { + this.fileMimeType = fileMimeType; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File size'. + * @return Long fileLength + */ + @Field(smartType = "STySize", label = "File size") + public Long getFileLength() { + return fileLength; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File size'. + * @param fileLength Long + */ + public void setFileLength(final Long fileLength) { + this.fileLength = fileLength; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File urn'. + * @return String fileUrn + */ + @Field(smartType = "STyText", label = "File urn") + public String getFileUrn() { + return fileUrn; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File urn'. + * @param fileUrn String + */ + public void setFileUrn(final String fileUrn) { + this.fileUrn = fileUrn; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return DtObjectUtil.toString(this); + } +} diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index b5328ae66..a37d19685 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -159,6 +159,10 @@ public enum DtResources implements MessageKey { * Questions answers List. */ fldBotExport$questionAnswerList, + /** + * Documentary resources. + */ + fldBotExport$documentaryResources, /** * map Context. */ @@ -500,6 +504,46 @@ public enum DtResources implements MessageKey { */ fldContextValue$botId, + /*********************************************************** + /** DocumentaryResourceExport. + /*********************************************************** + /** + * Title. + */ + fldDocumentaryResourceExport$title, + /** + * Resource Type. + */ + fldDocumentaryResourceExport$dreTypeCd, + /** + * Text. + */ + fldDocumentaryResourceExport$text, + /** + * Url. + */ + fldDocumentaryResourceExport$url, + /** + * File data. + */ + fldDocumentaryResourceExport$fileData, + /** + * File name. + */ + fldDocumentaryResourceExport$fileName, + /** + * File mime type. + */ + fldDocumentaryResourceExport$fileMimeType, + /** + * File size. + */ + fldDocumentaryResourceExport$fileLength, + /** + * File urn. + */ + fldDocumentaryResourceExport$fileUrn, + /*********************************************************** /** ExecutorConfiguration. /*********************************************************** diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 4330cad8a..5814bdd7f 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -48,6 +48,7 @@ fldBotExport$confluenceSetting = Confluence setting fldBotExport$jiraSetting = Jira setting fldBotExport$jiraFieldSetting = Jira fields setting fldBotExport$questionAnswerList = Questions answers List +fldBotExport$documentaryResources = Documentary resources fldBotExport$mapContext = map Context ################################################################################"); @@ -156,6 +157,18 @@ fldContextValue$botId = Chatbot ################################################################################"); +fldDocumentaryResourceExport$title = Title +fldDocumentaryResourceExport$dreTypeCd = Resource Type +fldDocumentaryResourceExport$text = Text +fldDocumentaryResourceExport$url = Url +fldDocumentaryResourceExport$fileData = File data +fldDocumentaryResourceExport$fileName = File name +fldDocumentaryResourceExport$fileMimeType = File mime type +fldDocumentaryResourceExport$fileLength = File size +fldDocumentaryResourceExport$fileUrn = File urn + +################################################################################"); + fldExecutorConfiguration$botId = Bot ID fldExecutorConfiguration$nodId = Node ID fldExecutorConfiguration$traId = Model ID diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index 84bd3ad1d..7c93e68aa 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -73,6 +73,8 @@ public enum Definitions { DictionaryEntityWrapper(io.vertigo.chatbot.designer.domain.DictionaryEntityWrapper.class), /** Objet de données DocumentaryResource. */ DocumentaryResource(io.vertigo.chatbot.designer.domain.DocumentaryResource.class), + /** Objet de données DocumentaryResourceExport. */ + DocumentaryResourceExport(io.vertigo.chatbot.commons.domain.DocumentaryResourceExport.class), /** Objet de données DocumentaryResourceType. */ DocumentaryResourceType(io.vertigo.chatbot.designer.domain.DocumentaryResourceType.class), /** Objet de données ExecutorConfiguration. */ @@ -362,6 +364,8 @@ public enum BotExportFields implements DtFieldName { + /** Propriété 'Title'. */ + title, + /** Propriété 'Resource Type'. */ + dreTypeCd, + /** Propriété 'Text'. */ + text, + /** Propriété 'Url'. */ + url, + /** Propriété 'File data'. */ + fileData, + /** Propriété 'File name'. */ + fileName, + /** Propriété 'File mime type'. */ + fileMimeType, + /** Propriété 'File size'. */ + fileLength, + /** Propriété 'File urn'. */ + fileUrn } + /** * Enumération des champs de DocumentaryResourceType. */ diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java index d3489c9e4..1acfccf2b 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java @@ -38,6 +38,7 @@ import io.vertigo.chatbot.commons.domain.AttachmentExport; import io.vertigo.chatbot.commons.domain.BotExport; +import io.vertigo.chatbot.commons.domain.DocumentaryResourceExport; import io.vertigo.chatbot.commons.domain.QuestionAnswerExport; import io.vertigo.chatbot.commons.domain.WelcomeTourExport; import io.vertigo.chatbot.executor.ExecutorPlugin; @@ -69,7 +70,9 @@ public class ExecutorConfigManager implements Manager, Activeable { private DtList questionAnswerList; private final List plugins = new ArrayList<>(); private Map mapAttachments; + private DtList documentaryResourceList; private File attachmentDataFile; + private File documentaryResourceDataFile; @Inject private ExecutorFileServices executorFileServices; @@ -153,6 +156,19 @@ public void start() { } else { mapAttachments = new HashMap<>(); } + + final String documentaryResourceDataFilePath = paramManager.getOptionalParam("DOCUMENTARY_RESOURCE_DATA_FILE") + .map(Param::getValueAsString).orElse("/tmp/documentaryResourceConfig"); + documentaryResourceDataFile = new File(documentaryResourceDataFilePath); + if (documentaryResourceDataFile.exists() && documentaryResourceDataFile.canRead()) { + try { + final String json = FileUtils.readFileToString(documentaryResourceDataFile, StandardCharsets.UTF_8); + documentaryResourceList = jsonEngine.fromJson(json, new TypeToken>(){}.getType()); + } catch (final Exception e) { + throw new VSystemException(e, "Error reading parameter file {0}", documentaryResourceDataFilePath); } + } else { + documentaryResourceList = new DtList<>(DocumentaryResourceExport.class); + } } @Override @@ -260,6 +276,29 @@ public void updateAttachments(final DtList attachmentExports) } } + public void updateDocumentaryResourceList(final BotExport botExport) { + try { + documentaryResourceList.forEach(documentaryResource -> { + if(documentaryResource.getFileUrn() != null){ + executorFileServices.deleteFile(FileInfoURI.fromURN(documentaryResource.getFileUrn())); + }}); + documentaryResourceList = jsonEngine.fromJson(botExport.getDocumentaryResources(), new TypeToken>(){}.getType()); + documentaryResourceList.forEach(documentaryResource -> { + if(documentaryResource.getFileData() != null) { + final StreamFile streamFile = StreamFile.of(documentaryResource.getFileName(), documentaryResource.getFileMimeType(), + Instant.now(), documentaryResource.getFileLength(), + () -> new ByteArrayInputStream((Base64.getDecoder().decode(documentaryResource.getFileData())))); + + final FileInfoURI fileInfoURI = executorFileServices.saveFile(streamFile); + documentaryResource.setFileUrn(fileInfoURI.toURN()); + } + }); + FileUtils.writeStringToFile(documentaryResourceDataFile, jsonEngine.toJson(documentaryResourceList), StandardCharsets.UTF_8); + } catch (final IOException e) { + throw new VSystemException(e, "Error writing parameter file {0}", attachmentDataFile.getPath()); + } + } + public VFile getAttachment(final String label) { final String urn = mapAttachments.get(label); if (urn == null) { diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java index 4c5a2e797..14a5348eb 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java @@ -155,6 +155,7 @@ private void doLoadModel(final BotExport botExport, final StringBuilder logs) { executorConfigManager.updateMapContext(botExport); executorConfigManager.updateQuestionAnswerList(botExport); + executorConfigManager.updateDocumentaryResourceList(botExport); botManager.updateConfig(topics, logs); } diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/Attachment.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/Attachment.java index b62755dc2..a4bf8de19 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/Attachment.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/Attachment.java @@ -2,6 +2,7 @@ import io.vertigo.core.lang.Generated; import io.vertigo.datamodel.structure.model.Entity; +import io.vertigo.datastore.impl.entitystore.EnumStoreVAccessor; import io.vertigo.datamodel.structure.model.UID; import io.vertigo.datastore.impl.entitystore.StoreVAccessor; import io.vertigo.datamodel.structure.stereotype.Field; @@ -20,6 +21,21 @@ public final class Attachment implements Entity { private String type; private Long length; + @io.vertigo.datamodel.structure.stereotype.Association( + name = "AAttachmentAttachmentType", + fkFieldName = "attTypeCd", + primaryDtDefinitionName = "DtAttachmentType", + primaryIsNavigable = true, + primaryRole = "AttachmentType", + primaryLabel = "Attachment type", + primaryMultiplicity = "1..1", + foreignDtDefinitionName = "DtAttachment", + foreignIsNavigable = false, + foreignRole = "Attachment", + foreignLabel = "Attachment", + foreignMultiplicity = "0..*") + private final EnumStoreVAccessor attTypeCdAccessor = new EnumStoreVAccessor<>(io.vertigo.chatbot.commons.domain.AttachmentType.class, "AttachmentType", io.vertigo.chatbot.commons.domain.AttachmentTypeEnum.class); + @io.vertigo.datamodel.structure.stereotype.Association( name = "AAttachmentAttachmentFileInfo", fkFieldName = "attFiId", @@ -132,6 +148,25 @@ public void setLength(final Long length) { this.length = length; } + /** + * Champ : FOREIGN_KEY. + * Récupère la valeur de la propriété 'Attachment type'. + * @return String attTypeCd Obligatoire + */ + @io.vertigo.datamodel.structure.stereotype.ForeignKey(smartType = "STyCode", label = "Attachment type", fkDefinition = "DtAttachmentType", cardinality = io.vertigo.core.lang.Cardinality.ONE ) + public String getAttTypeCd() { + return (String) attTypeCdAccessor.getId(); + } + + /** + * Champ : FOREIGN_KEY. + * Définit la valeur de la propriété 'Attachment type'. + * @param attTypeCd String Obligatoire + */ + public void setAttTypeCd(final String attTypeCd) { + attTypeCdAccessor.setId(attTypeCd); + } + /** * Champ : FOREIGN_KEY. * Récupère la valeur de la propriété 'AttachmentFileInfo'. @@ -178,6 +213,14 @@ public StoreVAccessor atta return attFiIdAccessor; } + /** + * Association : Attachment type. + * @return l'accesseur vers la propriété 'Attachment type' + */ + public EnumStoreVAccessor attachmentType() { + return attTypeCdAccessor; + } + /** * Association : Chatbot. * @return l'accesseur vers la propriété 'Chatbot' diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentType.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentType.java new file mode 100644 index 000000000..a655bec74 --- /dev/null +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentType.java @@ -0,0 +1,91 @@ +package io.vertigo.chatbot.commons.domain; + +import io.vertigo.core.lang.Generated; +import io.vertigo.datamodel.structure.model.DtStaticMasterData; +import io.vertigo.datamodel.structure.model.UID; +import io.vertigo.datamodel.structure.stereotype.Field; +import io.vertigo.datamodel.structure.util.DtObjectUtil; + +/** + * This class is automatically generated. + * DO NOT EDIT THIS FILE DIRECTLY. + */ +@Generated +public final class AttachmentType implements DtStaticMasterData { + private static final long serialVersionUID = 1L; + + private String attTypeCd; + private String label; + private String labelFr; + + /** {@inheritDoc} */ + @Override + public UID getUID() { + return UID.of(this); + } + + /** + * Champ : ID. + * Récupère la valeur de la propriété 'Code'. + * @return String attTypeCd Obligatoire + */ + @Field(smartType = "STyCode", type = "ID", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Code") + @io.vertigo.datamodel.structure.stereotype.SortField + public String getAttTypeCd() { + return attTypeCd; + } + + /** + * Champ : ID. + * Définit la valeur de la propriété 'Code'. + * @param attTypeCd String Obligatoire + */ + public void setAttTypeCd(final String attTypeCd) { + this.attTypeCd = attTypeCd; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Label'. + * @return String label Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Label") + @io.vertigo.datamodel.structure.stereotype.DisplayField + public String getLabel() { + return label; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Label'. + * @param label String Obligatoire + */ + public void setLabel(final String label) { + this.label = label; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'LabelFr'. + * @return String labelFr Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "LabelFr") + public String getLabelFr() { + return labelFr; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'LabelFr'. + * @param labelFr String Obligatoire + */ + public void setLabelFr(final String labelFr) { + this.labelFr = labelFr; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return DtObjectUtil.toString(this); + } +} diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentTypeEnum.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentTypeEnum.java new file mode 100644 index 000000000..4b3940a43 --- /dev/null +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentTypeEnum.java @@ -0,0 +1,25 @@ +package io.vertigo.chatbot.commons.domain; + +import java.io.Serializable; + +import io.vertigo.datamodel.structure.model.MasterDataEnum; +import io.vertigo.datamodel.structure.model.UID; + +public enum AttachmentTypeEnum implements MasterDataEnum { + + DOCUMENT("DOCUMENT"), // + ATTACHMENT("ATTACHMENT") + ; + + private final Serializable entityId; + + private AttachmentTypeEnum(final Serializable id) { + entityId = id; + } + + @Override + public UID getEntityUID() { + return UID.of(io.vertigo.chatbot.commons.domain.AttachmentType.class, entityId); + } + +} diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java index 645820bc0..120706762 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/BotExport.java @@ -25,6 +25,7 @@ public final class BotExport implements DtObject { private io.vertigo.chatbot.commons.domain.JiraSettingExport jiraSetting; private io.vertigo.datamodel.structure.model.DtList jiraFieldSetting = new io.vertigo.datamodel.structure.model.DtList<>(io.vertigo.chatbot.commons.domain.JiraFieldSettingExport.class); private String questionAnswerList; + private String documentaryResources; private String mapContext; /** @@ -261,6 +262,25 @@ public void setQuestionAnswerList(final String questionAnswerList) { this.questionAnswerList = questionAnswerList; } + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Documentary resources'. + * @return String documentaryResources Obligatoire + */ + @Field(smartType = "STyText", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Documentary resources") + public String getDocumentaryResources() { + return documentaryResources; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Documentary resources'. + * @param documentaryResources String Obligatoire + */ + public void setDocumentaryResources(final String documentaryResources) { + this.documentaryResources = documentaryResources; + } + /** * Champ : DATA. * Récupère la valeur de la propriété 'map Context'. diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java new file mode 100644 index 000000000..b9b0edec4 --- /dev/null +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java @@ -0,0 +1,202 @@ +package io.vertigo.chatbot.commons.domain; + +import io.vertigo.core.lang.Generated; +import io.vertigo.datamodel.structure.model.DtObject; +import io.vertigo.datamodel.structure.stereotype.Field; +import io.vertigo.datamodel.structure.util.DtObjectUtil; + +/** + * This class is automatically generated. + * DO NOT EDIT THIS FILE DIRECTLY. + */ +@Generated +public final class DocumentaryResourceExport implements DtObject { + private static final long serialVersionUID = 1L; + + private String title; + private String dreTypeCd; + private String text; + private String url; + private String fileData; + private String fileName; + private String fileMimeType; + private Long fileLength; + private String fileUrn; + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Title'. + * @return String title Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Title") + public String getTitle() { + return title; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Title'. + * @param title String Obligatoire + */ + public void setTitle(final String title) { + this.title = title; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Resource Type'. + * @return String dreTypeCd Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Resource Type") + public String getDreTypeCd() { + return dreTypeCd; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Resource Type'. + * @param dreTypeCd String Obligatoire + */ + public void setDreTypeCd(final String dreTypeCd) { + this.dreTypeCd = dreTypeCd; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Text'. + * @return String text + */ + @Field(smartType = "STyText", label = "Text") + public String getText() { + return text; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Text'. + * @param text String + */ + public void setText(final String text) { + this.text = text; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Url'. + * @return String url + */ + @Field(smartType = "STyText", label = "Url") + public String getUrl() { + return url; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Url'. + * @param url String + */ + public void setUrl(final String url) { + this.url = url; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File data'. + * @return String fileData + */ + @Field(smartType = "STyText", label = "File data") + public String getFileData() { + return fileData; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File data'. + * @param fileData String + */ + public void setFileData(final String fileData) { + this.fileData = fileData; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File name'. + * @return String fileName + */ + @Field(smartType = "STyLabel", label = "File name") + public String getFileName() { + return fileName; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File name'. + * @param fileName String + */ + public void setFileName(final String fileName) { + this.fileName = fileName; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File mime type'. + * @return String fileMimeType + */ + @Field(smartType = "STyLabel", label = "File mime type") + public String getFileMimeType() { + return fileMimeType; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File mime type'. + * @param fileMimeType String + */ + public void setFileMimeType(final String fileMimeType) { + this.fileMimeType = fileMimeType; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File size'. + * @return Long fileLength + */ + @Field(smartType = "STySize", label = "File size") + public Long getFileLength() { + return fileLength; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File size'. + * @param fileLength Long + */ + public void setFileLength(final Long fileLength) { + this.fileLength = fileLength; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'File urn'. + * @return String fileUrn + */ + @Field(smartType = "STyText", label = "File urn") + public String getFileUrn() { + return fileUrn; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'File urn'. + * @param fileUrn String + */ + public void setFileUrn(final String fileUrn) { + this.fileUrn = fileUrn; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return DtObjectUtil.toString(this); + } +} diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index e2a62ad39..61ee2652f 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -23,6 +23,8 @@ public enum Definitions { AttachmentExport(io.vertigo.chatbot.commons.domain.AttachmentExport.class), /** Objet de données AttachmentFileInfo. */ AttachmentFileInfo(io.vertigo.chatbot.commons.domain.AttachmentFileInfo.class), + /** Objet de données AttachmentType. */ + AttachmentType(io.vertigo.chatbot.commons.domain.AttachmentType.class), /** Objet de données BotExport. */ BotExport(io.vertigo.chatbot.commons.domain.BotExport.class), /** Objet de données Chatbot. */ @@ -33,6 +35,8 @@ public enum Definitions { ConfluenceSettingExport(io.vertigo.chatbot.commons.domain.ConfluenceSettingExport.class), /** Objet de données ContextValue. */ ContextValue(io.vertigo.chatbot.commons.domain.ContextValue.class), + /** Objet de données DocumentaryResourceExport. */ + DocumentaryResourceExport(io.vertigo.chatbot.commons.domain.DocumentaryResourceExport.class), /** Objet de données ExecutorConfiguration. */ ExecutorConfiguration(io.vertigo.chatbot.commons.domain.ExecutorConfiguration.class), /** Objet de données JiraFieldSettingExport. */ @@ -83,6 +87,8 @@ public enum AttachmentFields implements DtFieldName { + /** Propriété 'Code'. */ + attTypeCd, + /** Propriété 'Label'. */ + label, + /** Propriété 'LabelFr'. */ + labelFr } + /** * Enumération des champs de BotExport. */ @@ -148,6 +165,8 @@ public enum BotExportFields implements DtFieldName { + /** Propriété 'Title'. */ + title, + /** Propriété 'Resource Type'. */ + dreTypeCd, + /** Propriété 'Text'. */ + text, + /** Propriété 'Url'. */ + url, + /** Propriété 'File data'. */ + fileData, + /** Propriété 'File name'. */ + fileName, + /** Propriété 'File mime type'. */ + fileMimeType, + /** Propriété 'File size'. */ + fileLength, + /** Propriété 'File urn'. */ + fileUrn } + /** * Enumération des champs de ExecutorConfiguration. */ From bd3916d727bf15352b92008b98bb95dc759876d4 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Tue, 3 Sep 2024 16:59:06 +0200 Subject: [PATCH 02/21] [CHATBOT-630 add type to AttachmentExport class] --- .../chatbot/commons/mda/webservices.ksp | 1 + .../commons/domain/AttachmentExport.java | 20 +++++++++++++++++++ .../chatbot/commons/domain/DtResources.java | 4 ++++ .../commons/domain/DtResources.properties | 1 + .../vertigo/chatbot/domain/DtDefinitions.java | 4 +++- .../commons/domain/AttachmentExport.java | 20 +++++++++++++++++++ .../vertigo/chatbot/domain/DtDefinitions.java | 4 +++- 7 files changed, 52 insertions(+), 2 deletions(-) diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index bebe101cf..346a57286 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -59,6 +59,7 @@ create DtDefinition DtAttachmentExport { field mimeType {domain : DoLabel label : "MimeType" cardinality : "1" } field length {domain : DoSize label : "Size" cardinality : "1" } field fileData {domain: DoText label: "Data" cardinality : "1"} + field type {domain: DoLabel label: "Type" cardinality : "1"} } create DtDefinition DtRunnerInfo { diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentExport.java index b6e7125f9..8434225fa 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/AttachmentExport.java @@ -18,6 +18,7 @@ public final class AttachmentExport implements DtObject { private String mimeType; private Long length; private String fileData; + private String type; /** * Champ : DATA. @@ -114,6 +115,25 @@ public void setFileData(final String fileData) { this.fileData = fileData; } + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Type'. + * @return String type Obligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Type") + public String getType() { + return type; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Type'. + * @param type String Obligatoire + */ + public void setType(final String type) { + this.type = type; + } + /** {@inheritDoc} */ @Override public String toString() { diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index a37d19685..9699e3221 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -63,6 +63,10 @@ public enum DtResources implements MessageKey { * Data. */ fldAttachmentExport$fileData, + /** + * Type. + */ + fldAttachmentExport$type, /*********************************************************** /** AttachmentFileInfo. diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 5814bdd7f..44a80df41 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -18,6 +18,7 @@ fldAttachmentExport$fileName = Name fldAttachmentExport$mimeType = MimeType fldAttachmentExport$length = Size fldAttachmentExport$fileData = Data +fldAttachmentExport$type = Type ################################################################################"); diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index 7c93e68aa..14bbebceb 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -306,7 +306,9 @@ public enum AttachmentExportFields implements DtFieldNameObligatoire + */ + @Field(smartType = "STyLabel", cardinality = io.vertigo.core.lang.Cardinality.ONE, label = "Type") + public String getType() { + return type; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Type'. + * @param type String Obligatoire + */ + public void setType(final String type) { + this.type = type; + } + /** {@inheritDoc} */ @Override public String toString() { diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index 61ee2652f..5c1722083 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -107,7 +107,9 @@ public enum AttachmentExportFields implements DtFieldName Date: Tue, 3 Sep 2024 17:15:39 +0200 Subject: [PATCH 03/21] [CHATBOT-630 simplify DocumentaryResourceExport class] --- .../chatbot/commons/mda/webservices.ksp | 4 - .../domain/DocumentaryResourceExport.java | 80 ------------------- .../chatbot/commons/domain/DtResources.java | 16 ---- .../commons/domain/DtResources.properties | 4 - .../vertigo/chatbot/domain/DtDefinitions.java | 10 +-- .../domain/DocumentaryResourceExport.java | 80 ------------------- .../vertigo/chatbot/domain/DtDefinitions.java | 10 +-- 7 files changed, 2 insertions(+), 202 deletions(-) diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index 346a57286..ab7f90cb9 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -123,9 +123,5 @@ create DtDefinition DtDocumentaryResourceExport { field dreTypeCd {domain: DoLabel label: "Resource Type" cardinality : "1" } field text {domain: DoText label: "Text" } field url {domain: DoText label: "Url" } - field fileData {domain: DoText label: "File data" } field fileName {domain: DoLabel label: "File name" } - field fileMimeType {domain: DoLabel label: "File mime type" } - field fileLength {domain: DoSize label: "File size" } - field fileUrn {domain: DoText label: "File urn" } } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java index b9b0edec4..dfbfb715e 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DocumentaryResourceExport.java @@ -17,11 +17,7 @@ public final class DocumentaryResourceExport implements DtObject { private String dreTypeCd; private String text; private String url; - private String fileData; private String fileName; - private String fileMimeType; - private Long fileLength; - private String fileUrn; /** * Champ : DATA. @@ -99,25 +95,6 @@ public void setUrl(final String url) { this.url = url; } - /** - * Champ : DATA. - * Récupère la valeur de la propriété 'File data'. - * @return String fileData - */ - @Field(smartType = "STyText", label = "File data") - public String getFileData() { - return fileData; - } - - /** - * Champ : DATA. - * Définit la valeur de la propriété 'File data'. - * @param fileData String - */ - public void setFileData(final String fileData) { - this.fileData = fileData; - } - /** * Champ : DATA. * Récupère la valeur de la propriété 'File name'. @@ -137,63 +114,6 @@ public void setFileName(final String fileName) { this.fileName = fileName; } - /** - * Champ : DATA. - * Récupère la valeur de la propriété 'File mime type'. - * @return String fileMimeType - */ - @Field(smartType = "STyLabel", label = "File mime type") - public String getFileMimeType() { - return fileMimeType; - } - - /** - * Champ : DATA. - * Définit la valeur de la propriété 'File mime type'. - * @param fileMimeType String - */ - public void setFileMimeType(final String fileMimeType) { - this.fileMimeType = fileMimeType; - } - - /** - * Champ : DATA. - * Récupère la valeur de la propriété 'File size'. - * @return Long fileLength - */ - @Field(smartType = "STySize", label = "File size") - public Long getFileLength() { - return fileLength; - } - - /** - * Champ : DATA. - * Définit la valeur de la propriété 'File size'. - * @param fileLength Long - */ - public void setFileLength(final Long fileLength) { - this.fileLength = fileLength; - } - - /** - * Champ : DATA. - * Récupère la valeur de la propriété 'File urn'. - * @return String fileUrn - */ - @Field(smartType = "STyText", label = "File urn") - public String getFileUrn() { - return fileUrn; - } - - /** - * Champ : DATA. - * Définit la valeur de la propriété 'File urn'. - * @param fileUrn String - */ - public void setFileUrn(final String fileUrn) { - this.fileUrn = fileUrn; - } - /** {@inheritDoc} */ @Override public String toString() { diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index 9699e3221..a56d3abdc 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -527,26 +527,10 @@ public enum DtResources implements MessageKey { * Url. */ fldDocumentaryResourceExport$url, - /** - * File data. - */ - fldDocumentaryResourceExport$fileData, /** * File name. */ fldDocumentaryResourceExport$fileName, - /** - * File mime type. - */ - fldDocumentaryResourceExport$fileMimeType, - /** - * File size. - */ - fldDocumentaryResourceExport$fileLength, - /** - * File urn. - */ - fldDocumentaryResourceExport$fileUrn, /*********************************************************** /** ExecutorConfiguration. diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 44a80df41..6e2607281 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -162,11 +162,7 @@ fldDocumentaryResourceExport$title = Title fldDocumentaryResourceExport$dreTypeCd = Resource Type fldDocumentaryResourceExport$text = Text fldDocumentaryResourceExport$url = Url -fldDocumentaryResourceExport$fileData = File data fldDocumentaryResourceExport$fileName = File name -fldDocumentaryResourceExport$fileMimeType = File mime type -fldDocumentaryResourceExport$fileLength = File size -fldDocumentaryResourceExport$fileUrn = File urn ################################################################################"); diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index 14bbebceb..e966c28c4 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -745,16 +745,8 @@ public enum DocumentaryResourceExportFields implements DtFieldName Date: Wed, 4 Sep 2024 15:59:25 +0200 Subject: [PATCH 04/21] [CHATBOT-630 Export and init documentary resources and documentary resource files] --- .../services/DocumentaryResourceServices.java | 22 +----- .../services/bot/AttachmentServices.java | 3 +- .../manager/ExecutorConfigManager.java | 72 +++++++++++++------ .../executor/manager/ExecutorManager.java | 8 +++ .../DocumentaryResourceWebService.java | 29 ++++++++ .../src/main/webapp/static/chatbot/index.html | 26 ++++++- .../main/webapp/static/chatbot/js/chatbot.js | 30 ++++++-- .../webapp/static/chatbot/style/style.css | 12 ++++ 8 files changed, 152 insertions(+), 50 deletions(-) create mode 100644 vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/DocumentaryResourceWebService.java diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java index 975800a9d..41364fca9 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/DocumentaryResourceServices.java @@ -1,9 +1,5 @@ package io.vertigo.chatbot.designer.builder.services; -import java.io.IOException; -import java.io.InputStream; -import java.util.Base64; - import java.util.Optional; import javax.inject.Inject; @@ -12,7 +8,6 @@ import io.vertigo.account.authorization.annotations.SecuredOperation; import io.vertigo.chatbot.commons.LogsUtils; import io.vertigo.chatbot.commons.domain.Attachment; -import io.vertigo.chatbot.commons.domain.AttachmentFileInfo; import io.vertigo.chatbot.commons.domain.AttachmentTypeEnum; import io.vertigo.chatbot.commons.domain.Chatbot; import io.vertigo.chatbot.commons.domain.DocumentaryResourceExport; @@ -30,7 +25,6 @@ import io.vertigo.datamodel.structure.model.DtList; import io.vertigo.datamodel.structure.model.DtListState; import io.vertigo.datamodel.structure.util.VCollectors; -import io.vertigo.datastore.filestore.model.VFile; import io.vertigo.vega.engines.webservice.json.JsonEngine; import io.vertigo.datastore.filestore.model.FileInfoURI; @@ -113,20 +107,8 @@ public String exportDocumentaryResourceByBot(@SecuredOperation("botAdm") final C documentaryResourceExport.setDreTypeCd(documentaryResource.getDreTypeCd()); documentaryResourceExport.setText(documentaryResource.getText()); documentaryResourceExport.setUrl(documentaryResource.getUrl()); - if (documentaryResource.getAttId() != null) { - Attachment attachment = documentaryResource.attachment().get(); - attachment.attachmentFileInfo().load(); - AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get(); - documentaryResourceExport.setFileName(attachmentFileInfo.getFileName()); - documentaryResourceExport.setFileMimeType(attachmentFileInfo.getMimeType()); - documentaryResourceExport.setFileLength(attachmentFileInfo.getLength()); - final VFile file = designerFileServices.getAttachment(attachment.getAttFiId()); - try (final InputStream inputStream = file.createInputStream()) { - documentaryResourceExport.setFileData(Base64.getEncoder().encodeToString(inputStream.readAllBytes())); - } catch (final IOException e) { - LogsUtils.logKO(logs); - LogsUtils.addLogs(logs, e); - } + if(documentaryResource.getAttId() != null) { + documentaryResourceExport.setFileName(documentaryResource.attachment().get().getLabel()); } return documentaryResourceExport; }).collect(VCollectors.toDtList(DocumentaryResourceExport.class))); diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java index 97da7607a..929fa2e67 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/AttachmentServices.java @@ -99,7 +99,7 @@ public void delete (@SecuredOperation("botAdm") final Chatbot bot, final long at public DtList exportAttachmentByBot(@SecuredOperation("botAdm") final Chatbot bot, final StringBuilder logs) { LogsUtils.addLogs(logs, "Export attachments : "); try { - return findAllByBotIdAndType(bot.getBotId(), AttachmentTypeEnum.ATTACHMENT.name()).stream().map(attachment -> { + return findAllByBotId(bot.getBotId()).stream().map(attachment -> { attachment.attachmentFileInfo().load(); final AttachmentFileInfo attachmentFileInfo = attachment.attachmentFileInfo().get(); final AttachmentExport attachmentExport = new AttachmentExport(); @@ -107,6 +107,7 @@ public DtList exportAttachmentByBot(@SecuredOperation("botAdm" attachmentExport.setFileName(attachmentFileInfo.getFileName()); attachmentExport.setMimeType(attachmentFileInfo.getMimeType()); attachmentExport.setLength(attachmentFileInfo.getLength()); + attachmentExport.setType(attachment.getAttTypeCd()); final VFile file = designerFileServices.getAttachment(attachment.getAttFiId()); try (final InputStream inputStream = file.createInputStream()) { attachmentExport.setFileData(Base64.getEncoder().encodeToString(inputStream.readAllBytes())); diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java index 1acfccf2b..0957782fc 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorConfigManager.java @@ -65,14 +65,17 @@ public class ExecutorConfigManager implements Manager, Activeable { private File configDataFile; private File contextDataFile; private File questionAnswerListDataFile; + private File attachmentDataFile; + private File documentaryResourceDataFile; + private File documentaryResourceFileDataFile; private ExecutorGlobalConfig executorGlobalConfig; private HashMap contextMap; private DtList questionAnswerList; private final List plugins = new ArrayList<>(); private Map mapAttachments; - private DtList documentaryResourceList; - private File attachmentDataFile; - private File documentaryResourceDataFile; + private Map mapDocumentaryResourceFiles; + private DtList documentaryResources; + @Inject private ExecutorFileServices executorFileServices; @@ -163,11 +166,26 @@ public void start() { if (documentaryResourceDataFile.exists() && documentaryResourceDataFile.canRead()) { try { final String json = FileUtils.readFileToString(documentaryResourceDataFile, StandardCharsets.UTF_8); - documentaryResourceList = jsonEngine.fromJson(json, new TypeToken>(){}.getType()); + documentaryResources = jsonEngine.fromJson(json, new TypeToken>(){}.getType()); } catch (final Exception e) { throw new VSystemException(e, "Error reading parameter file {0}", documentaryResourceDataFilePath); } } else { - documentaryResourceList = new DtList<>(DocumentaryResourceExport.class); + documentaryResources = new DtList<>(DocumentaryResourceExport.class); + } + + final String documentaryResourceFileDataFilePath = paramManager.getOptionalParam("DOCUMENTARY_RESOURCE_FILE_DATA_FILE") + .map(Param::getValueAsString).orElse("/tmp/documentaryResourceFileConfig"); + documentaryResourceFileDataFile = new File(documentaryResourceFileDataFilePath); + if (documentaryResourceFileDataFile.exists() && documentaryResourceFileDataFile.canRead()) { + try { + final String json = FileUtils.readFileToString(documentaryResourceFileDataFile, StandardCharsets.UTF_8); + mapDocumentaryResourceFiles = jsonEngine.fromJson(json, HashMap.class); + } catch (final Exception e) { + throw new VSystemException(e, "Error reading parameter file {0}", documentaryResourceFileDataFilePath); + } + + } else { + mapDocumentaryResourceFiles = new HashMap<>(); } } @@ -237,6 +255,11 @@ public DtList getQuestionAnswerList() { return questionAnswerList; } + public DtList getDocumentaryResourceList() { + return documentaryResources; + } + + public synchronized void updateMapContext(final BotExport botExport) { try { @@ -260,40 +283,35 @@ public synchronized void updateQuestionAnswerList(final BotExport botExport) { public void updateAttachments(final DtList attachmentExports) { try { mapAttachments.forEach((key, value) -> executorFileServices.deleteFile(FileInfoURI.fromURN(value))); + mapDocumentaryResourceFiles.forEach((key, value) -> executorFileServices.deleteFile(FileInfoURI.fromURN(value))); final HashMap attachmentsMap = new HashMap<>(); + final HashMap documentaryResourceFilesMap = new HashMap<>(); attachmentExports.forEach(attachmentExport -> { final StreamFile streamFile = StreamFile.of(attachmentExport.getFileName(), attachmentExport.getMimeType(), Instant.now(), attachmentExport.getLength(), () -> new ByteArrayInputStream((Base64.getDecoder().decode(attachmentExport.getFileData())))); final FileInfoURI fileInfoURI = executorFileServices.saveFile(streamFile); - attachmentsMap.put(attachmentExport.getLabel(), fileInfoURI.toURN()); + + if(attachmentExport.getType().equals("ATTACHMENT")){ + attachmentsMap.put(attachmentExport.getLabel(), fileInfoURI.toURN()); + }else if(attachmentExport.getType().equals("DOCUMENT")){ + documentaryResourceFilesMap.put(attachmentExport.getLabel(), fileInfoURI.toURN()); + } }); FileUtils.writeStringToFile(attachmentDataFile, jsonEngine.toJson(attachmentsMap), StandardCharsets.UTF_8); + FileUtils.writeStringToFile(documentaryResourceFileDataFile, jsonEngine.toJson(documentaryResourceFilesMap), StandardCharsets.UTF_8); mapAttachments = attachmentsMap; + mapDocumentaryResourceFiles = documentaryResourceFilesMap; } catch (final IOException e) { - throw new VSystemException(e, "Error writing parameter file {0}", attachmentDataFile.getPath()); + throw new VSystemException("Could not retrieve attachments and documentary resource files at startup...", e); } } public void updateDocumentaryResourceList(final BotExport botExport) { try { - documentaryResourceList.forEach(documentaryResource -> { - if(documentaryResource.getFileUrn() != null){ - executorFileServices.deleteFile(FileInfoURI.fromURN(documentaryResource.getFileUrn())); - }}); - documentaryResourceList = jsonEngine.fromJson(botExport.getDocumentaryResources(), new TypeToken>(){}.getType()); - documentaryResourceList.forEach(documentaryResource -> { - if(documentaryResource.getFileData() != null) { - final StreamFile streamFile = StreamFile.of(documentaryResource.getFileName(), documentaryResource.getFileMimeType(), - Instant.now(), documentaryResource.getFileLength(), - () -> new ByteArrayInputStream((Base64.getDecoder().decode(documentaryResource.getFileData())))); - - final FileInfoURI fileInfoURI = executorFileServices.saveFile(streamFile); - documentaryResource.setFileUrn(fileInfoURI.toURN()); - } - }); - FileUtils.writeStringToFile(documentaryResourceDataFile, jsonEngine.toJson(documentaryResourceList), StandardCharsets.UTF_8); + FileUtils.writeStringToFile(documentaryResourceDataFile, botExport.getDocumentaryResources(), StandardCharsets.UTF_8); + documentaryResources = jsonEngine.fromJson(botExport.getDocumentaryResources(), new TypeToken>(){}.getType()); } catch (final IOException e) { throw new VSystemException(e, "Error writing parameter file {0}", attachmentDataFile.getPath()); } @@ -307,6 +325,14 @@ public VFile getAttachment(final String label) { return executorFileServices.getFile(urn); } + public VFile getDocumentaryResourceFile(final String label) { + final String urn = mapDocumentaryResourceFiles.get(label); + if (urn == null) { + throw new VSystemException("Documentary resource file with label " + label + " doesn't exist..."); + } + return executorFileServices.getFile(urn); + } + public Optional getWelcomeToursFile() { final String welcomeToursFileURN = executorGlobalConfig.getWelcomeToursFileURN(); return welcomeToursFileURN != null ? Optional.of(executorFileServices.getFile(welcomeToursFileURN)) : Optional.empty(); diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java index 14a5348eb..64491469a 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java @@ -239,8 +239,16 @@ public VFile getAttachment(final String label) { return executorConfigManager.getAttachment(label); } + public VFile getDocumentaryResourceFile(final String label) { + return executorConfigManager.getDocumentaryResourceFile(label); + } + public Optional getWelcomeToursFile() { return executorConfigManager.getWelcomeToursFile(); } + public DtList getDocumentaryResourceList() { + return executorConfigManager.getDocumentaryResourceList(); + } + } diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/DocumentaryResourceWebService.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/DocumentaryResourceWebService.java new file mode 100644 index 000000000..879ffe7b9 --- /dev/null +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/DocumentaryResourceWebService.java @@ -0,0 +1,29 @@ +package io.vertigo.chatbot.executor.webservices; + +import javax.inject.Inject; + +import io.vertigo.chatbot.commons.domain.DocumentaryResourceExport; +import io.vertigo.chatbot.executor.manager.ExecutorManager; +import io.vertigo.datamodel.structure.model.DtList; +import io.vertigo.datastore.filestore.model.VFile; +import io.vertigo.vega.webservice.WebServices; +import io.vertigo.vega.webservice.stereotype.GET; +import io.vertigo.vega.webservice.stereotype.PathPrefix; +import io.vertigo.vega.webservice.stereotype.QueryParam; + +@PathPrefix("/docres") +public class DocumentaryResourceWebService implements WebServices { + + @Inject + private ExecutorManager executorManager; + + @GET("/getDocumentaryResources") + public DtList getDocumentaryResourceList() { + return executorManager.getDocumentaryResourceList(); + } + + @GET("/getDocumentaryResourceFile") + public VFile getDocumentaryResourceFile(@QueryParam("label") final String label) { + return executorManager.getDocumentaryResourceFile(label); + } +} \ No newline at end of file diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index 0a75453bd..cf9c875fc 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -73,7 +73,7 @@ class="column col-grow no-wrap"> + style="height: 500px">
+ + + +
+
diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js index 41f68773c..e63f4b9a4 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js @@ -20,6 +20,7 @@ const _avatar = _botRunnerUrl + '/static/chatbot/images/avatar/avatar.png'; const _botBaseUrl = _botRunnerUrl + '/api/chatbot'; const _qAndABaseUrl = _botRunnerUrl + '/api/qanda'; +const _documentaryResourceBaseUrl = _botRunnerUrl + '/api/docres'; const scanContextKeys = (context) => new Promise((res, rej) => { const channel = new MessageChannel(); @@ -40,7 +41,8 @@ window.addEventListener( function (event) { if (event.data === 'start') { chatbot.initBot(); - chatbot.initQAndA() + chatbot.initQAndA(); + chatbot.initDocumentaryResources(); } if (event.data.sendTopic) { const button = chatbot.inputConfig.buttons.find((button) => button.payload === event.data.sendTopic.topic) @@ -127,10 +129,15 @@ const chatbot = new Vue({ contextMap: {}, qAndAConfig: { - qAndAUrl : _qAndABaseUrl, + qAndAUrl: _qAndABaseUrl, questionAnswerList: [], - filteredQuestionAnswerList:[], - filterInput : '' + filteredQuestionAnswerList: [], + filterInput: '' + }, + documentaryResourceConfig: { + documentaryResourceUrl: _documentaryResourceBaseUrl, + documentaryResourceList: [], + documentaryResourceFileBaseUrl: _documentaryResourceBaseUrl + '/getDocumentaryResourceFile?label=' } }, methods: { @@ -486,6 +493,9 @@ const chatbot = new Vue({ //todo : change url bot to simulate language change }, + + /* Q&A */ + initQAndA(){ this.$http.get(chatbot.qAndAConfig.qAndAUrl + '/getQuestionsAnswers').then(questionAnswerResponse => { chatbot.qAndAConfig.questionAnswerList = questionAnswerResponse.data; @@ -500,7 +510,17 @@ const chatbot = new Vue({ }else{ chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList } - } + }, + + + /* Documentary resources */ + + initDocumentaryResources() { + this.$http.get(chatbot.documentaryResourceConfig.documentaryResourceUrl + '/getDocumentaryResources').then(documentaryResourceResponse => { + chatbot.documentaryResourceConfig.documentaryResourceList = documentaryResourceResponse.data; + console.log(chatbot.documentaryResourceConfig.documentaryResourceList); + }); + }, } }) ; diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index 81740a473..421b73c9f 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -276,4 +276,16 @@ img { .q-tabs { box-shadow: 0 -1px 2px 1px rgba(0, 0, 0, 0.2); +} + +/* Documentary resources */ + +.documentary-resource-container{ + background-color: var(--bot-message-bg-color) !important; + color: var(--bot-message-font-color) !important; + margin-top: 12px; + padding: 6px 15px; + border-radius: 5px; + box-shadow: 3px 4px 2px 0 rgba(0, 0, 0, 0.1); + font-size: 14px; } \ No newline at end of file From 9a237d7b5ea41ebe563b0753270c223e5f22c8fa Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Mon, 9 Sep 2024 10:06:12 +0200 Subject: [PATCH 05/21] [CHATBOT-630 Platform layout update] --- .../src/main/webapp/static/chatbot/index.html | 156 +++++++++--------- .../main/webapp/static/chatbot/js/chatbot.js | 9 +- .../webapp/static/chatbot/style/style.css | 98 ++++++----- 3 files changed, 144 insertions(+), 119 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index cf9c875fc..312b15355 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -66,14 +66,17 @@ class="column items-center q-pt-xl">Chargement ...
+ class="column animate-fade">
- +
+ Chatbot +
+ + style="height: 320px">
@@ -192,85 +194,86 @@
-
-
-
- +
+
+ +
+ +
- -
-
- -
- -
- -
-
+
+
+ FAQ
-
- - - -
-
- - {{documentaryResource.title}} - - - {{documentaryResource.title}} - -
- {{documentaryResource.title}} -
+
+ +
+ +
+ +
+
+
+
+
+ +
+
+ Ressources documentaires
-
- + + + +
-
-
diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js index e63f4b9a4..f2ac85222 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js @@ -482,10 +482,11 @@ const chatbot = new Vue({ refresh(){ if(chatbot.tab === 'qAndA'){ - chatbot.initQAndA() - }else{ - chatbot.refreshBot() - + chatbot.initQAndA(); + chatbot.initDocumentaryResources(); + }else if(chatbot.tab === 'bot') { + chatbot.refreshBot(); + chatbot.initDocumentaryResources(); } }, // Function to complete to switch to another bot diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index 421b73c9f..108f74e4a 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -1,7 +1,7 @@ :root { --background-color: #000091; --font-color: #ffffff; - --bot-message-bg-color: #ccccc6; + --bot-message-bg-color: #ebebeb; --bot-message-font-color: #000000; --user-message-bg-color: #e0e0e0; --user-message-font-color: #000000; @@ -22,7 +22,7 @@ body { } main { - padding: 8px; + padding: 12px; } footer { @@ -43,8 +43,31 @@ footer { height: 4px !important; } +.chatbot-qanda-container, .docres-container { + border-radius: 16px; + background-color: #ffffff; + box-shadow: 3px 3px 2px 0 rgba(0, 0, 0, 0.2); +} + +.docres-container { + margin-top: 16px; +} + +.containers-title { + z-index: 1; + height: 38px; + border-top-left-radius: 16px; + border-top-right-radius: 16px; + background-color: #e4e4e4; + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2); +} + .message-processing { width: 80px; + margin-left: 44px; } .docs-btn .q-btn { @@ -55,8 +78,13 @@ footer { border-radius: 5px; } +.q-message { + margin-bottom: 14px +} + .q-message-text{ padding: 10px 15px; + max-width: 230px; } .q-message-received .q-message-text-content { font-family: var(--font-family); @@ -64,7 +92,7 @@ footer { } .q-btn { - padding: 8px 16px !important; + border-radius: 18px; font-family: var(--font-family); color: var(--font-color) !important; background-color: var(--background-color) !important; @@ -87,21 +115,23 @@ footer { } .q-message-received .q-message-text, .q-message-sent .q-message-text { - border-radius: 5px; - margin-top: 12px; + border-radius: 18px; + margin-top: 5px; + min-height: unset; + padding: 8px 12px 8px 12px; } .q-message-sent .q-message-text-content { font-family: var(--font-family) !important; color: var(--user-message-font-color) !important; - line-height: 1.7; + line-height: 1.4; font-size: 14px; } .q-message-received .q-message-text-content { font-family: var(--font-family) !important; color: var(--bot-message-font-color) !important; - line-height: 1.7; + line-height: 1.4; font-size: 14px; } @@ -109,16 +139,14 @@ footer { background-color: var(--bot-message-bg-color) !important; /* received message*/ border: solid 1px rgba(224, 224, 224, 1); - box-shadow: 10px 10px 10px 0px rgba(0, 0, 0, 0.1); } .q-message-sent .q-message-text { - box-shadow: 3px 4px 2px 0px rgba(0, 0, 0, 0.1) !important; background-color: var(--user-message-bg-color) !important; } .custom-header { - padding: 8px 0px; + padding: 4px 0; font-family: var(--font-family) !important; background: var(--background-color) !important; box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.15); @@ -145,9 +173,11 @@ footer { user-select: none !important; pointer-events: none !important; border-radius: 50px !important; - max-height: 42px !important; - max-width: 42px !important; - margin-right: 12px !important; + max-height: 32px !important; + max-width: 32px !important; + margin-right: 8px !important; + margin-left: 4px; + } .q-btn-lowercase { @@ -207,26 +237,25 @@ img { box-shadow: none !important; } -.custom-input { - border-bottom: 0px solid !important; -} - -.custom-input-top, .custom-input-bottom{ +.custom-input-chatbot, .custom-input-qanda { position: relative; z-index: 1; - padding-left: 12px; + padding-left: 16px; + background: #e8e8e8; border-radius: 20px; - background: linear-gradient(to bottom, #e6e6e6, #ffffff); - box-shadow: 3px 3px 3px 0 rgba(0, 0, 0, 0.4); -} -.custom-input-bottom { - margin : -18px 12px 16px 10px; + margin-left: 16px; + margin-right: 16px; } -.custom-input-top { - margin : 16px 18px -15px 18px; +.custom-input-chatbot { + margin-top: 8px; + margin-bottom: 8px; } +.custom-input-qanda { + margin-top: 14px; + margin-bottom: 8px; +} /* quasar style for q-input without bottom border*/ .q-if:after, .q-if:before{ border-bottom: 0px solid !important; @@ -234,7 +263,6 @@ img { /* carousel customization */ .custom-carousel { - border-radius: 5px !important; background-color: var(--background-color) !important; } .q-carousel-right-arrow, .q-carousel-left-arrow{ @@ -248,21 +276,20 @@ img { .q-message-text:last-child:before{ - border: 0px !important; + border: 0 !important; } /* Q&A */ .q-collapsible-question, .q-collapsible-answer{ - padding: 6px 15px; - border-radius: 5px; - box-shadow: 10px 10px 10px 0 rgba(0, 0, 0, 0.1); + padding: 8px 12px; + border-radius: 10px; font-size: 14px; } .q-collapsible-question { background-color: var(--bot-message-bg-color) !important; color: var(--bot-message-font-color) !important; - margin-top: 12px; + margin-top: 10px; } .q-collapsible-answer { @@ -281,11 +308,6 @@ img { /* Documentary resources */ .documentary-resource-container{ - background-color: var(--bot-message-bg-color) !important; - color: var(--bot-message-font-color) !important; - margin-top: 12px; - padding: 6px 15px; - border-radius: 5px; - box-shadow: 3px 4px 2px 0 rgba(0, 0, 0, 0.1); + margin-top: 5px; font-size: 14px; } \ No newline at end of file From 5ca20cffbc13c18163fb48358b3474911557b378 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Mon, 9 Sep 2024 16:10:25 +0200 Subject: [PATCH 06/21] [CHATBOT-630 Creating chatbot q&a and documentary resources display parameters] --- .../domain/DtResources_en_US.properties | 3 + .../domain/DtResources_fr_FR.properties | 3 + .../bot/ChatbotCustomConfigServices.java | 3 + .../commons/domain/ChatbotCustomConfig.java | 60 +++++++++++++++++++ .../chatbot/commons/domain/DtResources.java | 12 ++++ .../commons/domain/DtResources.properties | 3 + .../vertigo/chatbot/domain/DtDefinitions.java | 6 ++ .../src/main/javagen/sqlgen/crebas.sql | 12 ++++ .../mda/chatbot/chatbotCustomConfig.ksp | 3 + .../liquibase/changeLog/v_2_0/v_2_0.xml | 4 ++ .../resources/sql/v_2_0/alter_24_09_09.sql | 13 ++++ .../WEB-INF/views/builder/bot/botDetail.html | 31 ++++++++++ 12 files changed, 153 insertions(+) create mode 100644 vertigo-bot-designer/src/main/resources/sql/v_2_0/alter_24_09_09.sql diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_en_US.properties b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_en_US.properties index 6cf1d156f..ae24ab5cf 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_en_US.properties +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_en_US.properties @@ -53,6 +53,9 @@ fldChatbotCustomConfig$userMessageFontColor=User side font color fldChatbotCustomConfig$fofCd=Bot font family fldChatbotCustomConfig$displayAvatar=Display avatar fldChatbotCustomConfig$totalMaxAttachmentSize=Total maximum attachment size +fldChatbotCustomConfig$chatbotDisplay = Display chatbot +fldChatbotCustomConfig$qandaDisplay = Display Q&A +fldChatbotCustomConfig$documentaryResourceDisplay = Display documentary resources fldChatbotCustomConfig$disableNlu=Disable NlU fldChatbotCustomConfig$botId=Chatbot ################################################################################"); diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_fr_FR.properties b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_fr_FR.properties index 8da426134..580df563b 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_fr_FR.properties +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/commons/domain/DtResources_fr_FR.properties @@ -53,6 +53,9 @@ fldChatbotCustomConfig$userMessageFontColor=Couleur de la police coté utilisate fldChatbotCustomConfig$fofCd=Police d''écriture du bot fldChatbotCustomConfig$displayAvatar=Affichage de l''avatar fldChatbotCustomConfig$totalMaxAttachmentSize=Taille totale autorisée pour les pièces-jointes (en Mo) +fldChatbotCustomConfig$chatbotDisplay = Affichage du chatbot +fldChatbotCustomConfig$qandaDisplay = Affichage de la FAQ +fldChatbotCustomConfig$documentaryResourceDisplay = Affichage des ressources documentaires fldChatbotCustomConfig$disableNlu=Désactiver la saisie utilisateur fldChatbotCustomConfig$botId=Chatbot ################################################################################"); diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java index 01c91ab4f..aceeaabc0 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java @@ -86,6 +86,9 @@ public ChatbotCustomConfig getDefaultChatbotCustomConfig() { chatbotCustomConfig.setUserMessageFontColor("#000000"); chatbotCustomConfig.setFofCd(FontFamilyEnum.ARIAL.name()); chatbotCustomConfig.setTotalMaxAttachmentSize(-1L); + chatbotCustomConfig.setChatbotDisplay(true); + chatbotCustomConfig.setQandaDisplay(true); + chatbotCustomConfig.setDocumentaryResourceDisplay(true); return chatbotCustomConfig; } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfig.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfig.java index 5eb482bc9..aba341ac9 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfig.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfig.java @@ -29,6 +29,9 @@ public final class ChatbotCustomConfig implements Entity { private Long totalMaxAttachmentSize; private Boolean disableNlu; private Long maxSavedTraining; + private Boolean chatbotDisplay; + private Boolean qandaDisplay; + private Boolean documentaryResourceDisplay; @io.vertigo.datamodel.structure.stereotype.Association( name = "AChatbotCustomConfigChatbot", @@ -313,6 +316,63 @@ public void setMaxSavedTraining(final Long maxSavedTraining) { this.maxSavedTraining = maxSavedTraining; } + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display chatbot'. + * @return Boolean chatbotDisplay + */ + @Field(smartType = "STyYesNo", label = "Display chatbot") + public Boolean getChatbotDisplay() { + return chatbotDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display chatbot'. + * @param chatbotDisplay Boolean + */ + public void setChatbotDisplay(final Boolean chatbotDisplay) { + this.chatbotDisplay = chatbotDisplay; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display Q&A'. + * @return Boolean qandaDisplay + */ + @Field(smartType = "STyYesNo", label = "Display Q&A") + public Boolean getQandaDisplay() { + return qandaDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display Q&A'. + * @param qandaDisplay Boolean + */ + public void setQandaDisplay(final Boolean qandaDisplay) { + this.qandaDisplay = qandaDisplay; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display documentary resources'. + * @return Boolean documentaryResourceDisplay + */ + @Field(smartType = "STyYesNo", label = "Display documentary resources") + public Boolean getDocumentaryResourceDisplay() { + return documentaryResourceDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display documentary resources'. + * @param documentaryResourceDisplay Boolean + */ + public void setDocumentaryResourceDisplay(final Boolean documentaryResourceDisplay) { + this.documentaryResourceDisplay = documentaryResourceDisplay; + } + /** * Champ : FOREIGN_KEY. * Récupère la valeur de la propriété 'Chatbot'. diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index a56d3abdc..b3f8af8ad 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -255,6 +255,18 @@ public enum DtResources implements MessageKey { * Maximum of saved trainings. */ fldChatbotCustomConfig$maxSavedTraining, + /** + * Display chatbot. + */ + fldChatbotCustomConfig$chatbotDisplay, + /** + * Display Q&A. + */ + fldChatbotCustomConfig$qandaDisplay, + /** + * Display documentary resources. + */ + fldChatbotCustomConfig$documentaryResourceDisplay, /** * Chatbot. */ diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 6e2607281..3bce0d71d 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -76,6 +76,9 @@ fldChatbotCustomConfig$displayAvatar = Display avatar fldChatbotCustomConfig$totalMaxAttachmentSize = Total maximum attachment size fldChatbotCustomConfig$disableNlu = Disable NlU fldChatbotCustomConfig$maxSavedTraining = Maximum of saved trainings +fldChatbotCustomConfig$chatbotDisplay = Display chatbot +fldChatbotCustomConfig$qandaDisplay = Display Q&A +fldChatbotCustomConfig$documentaryResourceDisplay = Display documentary resources fldChatbotCustomConfig$botId = Chatbot fldChatbotCustomConfig$fofCd = fontFamily diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index e966c28c4..d7cf668bf 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -431,6 +431,12 @@ public enum ChatbotCustomConfigFields implements DtFieldName + + + + \ No newline at end of file diff --git a/vertigo-bot-designer/src/main/resources/sql/v_2_0/alter_24_09_09.sql b/vertigo-bot-designer/src/main/resources/sql/v_2_0/alter_24_09_09.sql new file mode 100644 index 000000000..8a3051dc7 --- /dev/null +++ b/vertigo-bot-designer/src/main/resources/sql/v_2_0/alter_24_09_09.sql @@ -0,0 +1,13 @@ +ALTER TABLE CHATBOT_CUSTOM_CONFIG + ADD COLUMN CHATBOT_DISPLAY bool DEFAULT true, + ADD COLUMN QANDA_DISPLAY bool DEFAULT true, + ADD COLUMN DOCUMENTARY_RESOURCE_DISPLAY bool DEFAULT true; + +comment on column CHATBOT_CUSTOM_CONFIG.CHATBOT_DISPLAY is +'Display chatbot'; + +comment on column CHATBOT_CUSTOM_CONFIG.QANDA_DISPLAY is +'Display Q&A'; + +comment on column CHATBOT_CUSTOM_CONFIG.DOCUMENTARY_RESOURCE_DISPLAY is +'Display documentary resources'; \ No newline at end of file diff --git a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html index 09e554772..5a252a4f3 100644 --- a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html +++ b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html @@ -115,6 +115,16 @@ changeBotMessageFontColor() changeChatMessageFontFamily(); }); + function onChatbotDisplayChange() { + if (!VertigoUi.vueData.chatbotCustomConfig.chatbotDisplay && !VertigoUi.vueData.chatbotCustomConfig.qandaDisplay) { + VertigoUi.vueData.chatbotCustomConfig.qandaDisplay = true; + } + } + function onQandaDisplayChange() { + if (!VertigoUi.vueData.chatbotCustomConfig.chatbotDisplay && !VertigoUi.vueData.chatbotCustomConfig.qandaDisplay) { + VertigoUi.vueData.chatbotCustomConfig.chatbotDisplay = true; + } + } @@ -160,9 +170,30 @@ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + From 1e33239770fdae945670c82549bb15c4568f70e8 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Tue, 10 Sep 2024 10:15:54 +0200 Subject: [PATCH 07/21] [CHATBOT-630 Small bug fix] --- .../webapp/WEB-INF/views/builder/bot/botDetail.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html index 5a252a4f3..409db1ffc 100644 --- a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html +++ b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/botDetail.html @@ -179,14 +179,18 @@
- +
- - + +
From 27cb0936c5314ebfc4ffdbea8d01deae0186c0b7 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Tue, 10 Sep 2024 17:21:02 +0200 Subject: [PATCH 08/21] [CHATBOT-630 Setting up changeable platform layout + layout changes] --- .../src/main/webapp/static/chatbot/index.html | 50 ++++++++----------- .../main/webapp/static/chatbot/js/chatbot.js | 13 ++++- .../webapp/static/chatbot/style/style.css | 45 ++++++++++------- 3 files changed, 59 insertions(+), 49 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index 312b15355..c8e168673 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -71,12 +71,9 @@ id="main" class="column col-grow no-wrap chatbot-qanda-container" > -
- Chatbot -
+ style="height: 400px">
-
+
- + Date: Wed, 11 Sep 2024 10:05:40 +0200 Subject: [PATCH 09/21] [CHATBOT-630 Small layout update] --- .../src/main/webapp/static/chatbot/index.html | 4 ++-- .../src/main/webapp/static/chatbot/style/style.css | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index c8e168673..6466130b9 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -248,14 +248,14 @@ target="_blank" class="docres-a"> - {{documentaryResource.title}} + {{documentaryResource.title}} - {{documentaryResource.title}} + {{documentaryResource.title}}
diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index 64aaf296a..e9380a8f3 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -317,4 +317,12 @@ img { display: flex; align-items: center; width: 100%; +} + +.docres-text { + flex-grow: 1; + padding-right: 4px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } \ No newline at end of file From 0a1ba928c860819136348165dd06b33a3c11791c Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Thu, 12 Sep 2024 10:25:19 +0200 Subject: [PATCH 10/21] [CHATBOT-630 Small layout update] --- .../builder/bot/questionAnswerDetail.html | 2 +- .../src/main/webapp/static/css/designer.css | 4 +- .../webapp/static/js/c-queAnsTextExample.js | 4 +- .../src/main/webapp/static/chatbot/index.html | 58 ++++++++++++------- .../main/webapp/static/chatbot/js/chatbot.js | 10 +++- .../webapp/static/chatbot/style/style.css | 30 +++++++--- 6 files changed, 69 insertions(+), 39 deletions(-) diff --git a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/questionAnswerDetail.html b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/questionAnswerDetail.html index 290f63400..0b716061b 100644 --- a/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/questionAnswerDetail.html +++ b/vertigo-bot-designer/src/main/webapp/WEB-INF/views/builder/bot/questionAnswerDetail.html @@ -67,7 +67,7 @@
diff --git a/vertigo-bot-designer/src/main/webapp/static/css/designer.css b/vertigo-bot-designer/src/main/webapp/static/css/designer.css index 9266bb338..cc4376f12 100644 --- a/vertigo-bot-designer/src/main/webapp/static/css/designer.css +++ b/vertigo-bot-designer/src/main/webapp/static/css/designer.css @@ -476,14 +476,14 @@ table .col_DoInstant { .q-message-text--received { margin-left: 12px; border: solid 1px rgba(224, 224, 224, 1); - box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.1); + box-shadow: 0 0 8px rgba(89, 89, 89, 0.1); color: var(--chat-bot-bg-color) !important; font-family: var(--chat-message-font-family) !important; } .q-message-text--sent { margin-right: 12px; margin-bottom: 12px; - box-shadow: 3px 4px 2px 0px rgba(0, 0, 0, 0.2) !important; + box-shadow: 0 0 8px rgba(89, 89, 89, 0.1); color: var(--chat-user-bg-color) !important; font-family: var(--chat-message-font-family) !important; } diff --git a/vertigo-bot-designer/src/main/webapp/static/js/c-queAnsTextExample.js b/vertigo-bot-designer/src/main/webapp/static/js/c-queAnsTextExample.js index f9b0f6e03..31549f164 100644 --- a/vertigo-bot-designer/src/main/webapp/static/js/c-queAnsTextExample.js +++ b/vertigo-bot-designer/src/main/webapp/static/js/c-queAnsTextExample.js @@ -9,8 +9,8 @@ Vue.component('c-queanstextexample', { }, template : ` -
- +
+
` , diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index 6466130b9..6e039af10 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -66,14 +66,14 @@ class="column items-center q-pt-xl">Chargement ...
+ class="column animate-fade" style="min-height: unset; height: calc(-98px + 100vh)">
+ ref="scroller">
-
-
- +
+
+
+ +
+ +
+ + +
+
+
- -
- -
-
+ + +
+ + Retour + +
+
+
-
+
- +
diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js index 97b8a6f78..33e397130 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js @@ -136,7 +136,8 @@ const chatbot = new Vue({ qAndAUrl: _qAndABaseUrl, questionAnswerList: [], filteredQuestionAnswerList: [], - filterInput: '' + filterInput: '', + selectedQuestion: null }, documentaryResourceConfig: { documentaryResourceUrl: _documentaryResourceBaseUrl, @@ -518,19 +519,22 @@ const chatbot = new Vue({ filterQuestionsAnswers(){ if (chatbot.qAndAConfig.filterInput !== ''){ - chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList.filter(questionAnswer => questionAnswer.question.toLowerCase().includes(chatbot.qAndAConfig.filterInput) || questionAnswer.answer.toLowerCase().includes(chatbot.qAndAConfig.filterInput)) + chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList.filter(questionAnswer => questionAnswer.question.toLowerCase().includes(chatbot.qAndAConfig.filterInput.toLowerCase())) }else{ chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList } }, + selectQuestion(selected){ + chatbot.qAndAConfig.selectedQuestion = selected; + }, + /* Documentary resources */ initDocumentaryResources() { this.$http.get(chatbot.documentaryResourceConfig.documentaryResourceUrl + '/getDocumentaryResources').then(documentaryResourceResponse => { chatbot.documentaryResourceConfig.documentaryResourceList = documentaryResourceResponse.data; - console.log(chatbot.documentaryResourceConfig.documentaryResourceList); }); }, } diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index e9380a8f3..dfd3f2122 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -269,24 +269,26 @@ img { /* Q&A */ -.q-collapsible-question, .q-collapsible-answer{ +.q-btn-question { + text-transform: none; + text-align: start; + width: 100%; padding: 8px 12px; border-radius: 10px; - font-size: 14px; -} -.q-collapsible-question { + font-size: 15px; background-color: var(--bot-message-bg-color) !important; color: var(--bot-message-font-color) !important; margin-top: 10px; } -.q-collapsible-answer { - background-color: white !important; - border: solid 2px var(--bot-message-bg-color); +.question-title { + color: black; + font-size: 22px; + font-weight: bold; } -.q-collapsible-sub-item { - padding : 6px 0 6px 0 !important; +.answer-text { + font-size: 14px; } .q-tabs { @@ -325,4 +327,14 @@ img { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; +} + +.full-height { + height: 100%; +} + +.q-page-container { + display: flex; + flex-direction: column; + height: 100%; } \ No newline at end of file From 48d196a52fc27b63398d7ee163139a11445f3a36 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Wed, 18 Sep 2024 11:35:27 +0200 Subject: [PATCH 11/21] [CHATBOT-630 flexible platform refresh] --- .../src/main/webapp/static/chatbot/index.html | 2 +- .../main/webapp/static/chatbot/js/chatbot.js | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index 6e039af10..165e584d2 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -48,7 +48,7 @@ color="white" text-color="white" size="md" - @click="refresh()" + @click="refreshPlatform()" icon="refresh"> button.payload === event.data.sendTopic.topic) @@ -54,7 +51,7 @@ window.addEventListener( if (event.data === 'clearSessionStorage') { sessionStorage.clear(); } else if (event.data === 'refresh') { - chatbot.refreshBot() + chatbot.refreshPlatform() } else if (event.data === 'conversationExist') { parent.postMessage({conversationExist: sessionStorage.convId !== undefined}, '*'); } @@ -147,6 +144,13 @@ const chatbot = new Vue({ }, methods: { + initPlatform(){ + if(chatbot.chatbotDisplay) {chatbot.initBot()} + if(chatbot.qAndADisplay) {chatbot.initQAndA()} + if(chatbot.documentaryResourceDisplay) {chatbot.initDocumentaryResources()} + chatbot.initLayout(); + }, + initBot: function () { document.getElementById('page').style.visibility = 'visible'; document.getElementById('loading').style.display = 'none'; @@ -485,12 +489,14 @@ const chatbot = new Vue({ } }, - refresh(){ - if(chatbot.tab === 'qAndA'){ + refreshPlatform(){ + if (chatbot.tab === 'bot') { + chatbot.refreshBot() + } else if (chatbot.tab === 'qAndA') { chatbot.initQAndA(); - chatbot.initDocumentaryResources(); - }else if(chatbot.tab === 'bot') { - chatbot.refreshBot(); + } + + if (chatbot.documentaryResourceDisplay) { chatbot.initDocumentaryResources(); } }, From fc26ee8ef325d2c55809808c4bc624d6f5417bb6 Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Wed, 18 Sep 2024 14:12:07 +0200 Subject: [PATCH 12/21] [CHATBOT-630 small layout changes] --- .../src/main/webapp/static/chatbot/index.html | 11 +++++------ .../src/main/webapp/static/chatbot/js/chatbot.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index 165e584d2..8270fdfc5 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -69,8 +69,7 @@ class="column animate-fade" style="min-height: unset; height: calc(-98px + 100vh)">
@@ -216,7 +215,7 @@
-
+
-
+
{{documentaryResource.title}} - +
@@ -279,7 +278,7 @@ - + questionAnswer.question.toLowerCase().includes(chatbot.qAndAConfig.filterInput.toLowerCase())) + chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList.filter(questionAnswer => questionAnswer.question.toLowerCase().includes(chatbot.qAndAConfig.filterInput.toLowerCase()) || questionAnswer.answer.toLowerCase().includes(chatbot.qAndAConfig.filterInput.toLowerCase())) }else{ chatbot.qAndAConfig.filteredQuestionAnswerList = chatbot.qAndAConfig.questionAnswerList } From 262f359947db4fb463f80378f0a4c17a0e59a66d Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Thu, 19 Sep 2024 10:32:55 +0200 Subject: [PATCH 13/21] [CHATBOT-630 small layout changes] --- .../src/main/webapp/static/chatbot/chatbot.css | 1 + .../main/webapp/static/chatbot/style/style.css | 16 +--------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/vertigo-bot-designer/src/main/webapp/static/chatbot/chatbot.css b/vertigo-bot-designer/src/main/webapp/static/chatbot/chatbot.css index f4559aa0a..c9a0b0960 100644 --- a/vertigo-bot-designer/src/main/webapp/static/chatbot/chatbot.css +++ b/vertigo-bot-designer/src/main/webapp/static/chatbot/chatbot.css @@ -38,6 +38,7 @@ width: 100%; height: 100%; color: white; + border: none; } .q-drawer__content { diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index dfd3f2122..bce8c2c0e 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -47,7 +47,7 @@ footer { border-radius: 16px; background-color: #ffffff; border: solid 1px rgba(0, 0, 0, 0.2); - box-shadow: 0 0 6px rgba(89, 89, 89, 0.1); + box-shadow: 0 0 8px rgba(58, 58, 58, 0.25); } .docres-container { @@ -198,10 +198,6 @@ img { background: white; } -.q-layout-page-container{ - filter: drop-shadow(0px 10px 5px rgba(0, 0, 0, 0.1)); -} - /*btn send msg*/ .btn-send { @@ -327,14 +323,4 @@ img { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -} - -.full-height { - height: 100%; -} - -.q-page-container { - display: flex; - flex-direction: column; - height: 100%; } \ No newline at end of file From 35d1c0e084efe4f269bc467a612aa81b4ca11cce Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Thu, 19 Sep 2024 11:30:21 +0200 Subject: [PATCH 14/21] [CHATBOT-630 Export chatbotDisplay qAndADisplay and documentaryResourceDisplay params] --- .../chatbot/commons/mda/webservices.ksp | 3 + .../bot/ChatbotCustomConfigServices.java | 5 +- .../topic/export/BotExportServices.java | 3 + .../domain/ChatbotCustomConfigExport.java | 60 +++++++++++++++++++ .../chatbot/commons/domain/DtResources.java | 12 ++++ .../commons/domain/DtResources.properties | 3 + .../vertigo/chatbot/domain/DtDefinitions.java | 8 ++- .../domain/ChatbotCustomConfigExport.java | 60 +++++++++++++++++++ .../vertigo/chatbot/domain/DtDefinitions.java | 8 ++- 9 files changed, 159 insertions(+), 3 deletions(-) diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index ab7f90cb9..d093ad008 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -110,6 +110,9 @@ create DtDefinition DtChatbotCustomConfigExport { field displayAvatar {domain: DoYesNo label: "Display avatar" cardinality:"?"} field totalMaxAttachmentSize {domain: DoNumber label: "Total maximum attachment size" cardinality:"?"} field disableNlu {domain: DoYesNo label: "Disable NlU" cardinality:"?"} + field chatbotDisplay {domain: DoYesNo label: "Display chatbot" cardinality:"?"} + field qandaDisplay {domain: DoYesNo label: "Display Q&A" cardinality:"?"} + field documentaryResourceDisplay {domain: DoYesNo label: "Display documentary resources" cardinality:"?"} } create DtDefinition DtQuestionAnswerExport { diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java index aceeaabc0..5a481d0bd 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/bot/ChatbotCustomConfigServices.java @@ -50,7 +50,10 @@ private static boolean checkIfChatbotStyleChanged(final ChatbotCustomConfig oldC (oldChatbotCustomConfig.getUserMessageFontColor() != null && !oldChatbotCustomConfig.getUserMessageFontColor().equals(chatbotCustomConfig.getUserMessageFontColor())) || (oldChatbotCustomConfig.getFofCd() != null && !oldChatbotCustomConfig.getFofCd().equals(chatbotCustomConfig.getFofCd())) || (oldChatbotCustomConfig.getFontColor() != null && !oldChatbotCustomConfig.getFontColor().equals(chatbotCustomConfig.getFontColor())) || - (oldChatbotCustomConfig.getUserMessageBackgroundColor() != null && !oldChatbotCustomConfig.getUserMessageBackgroundColor().equals(chatbotCustomConfig.getUserMessageBackgroundColor())); + (oldChatbotCustomConfig.getUserMessageBackgroundColor() != null && !oldChatbotCustomConfig.getUserMessageBackgroundColor().equals(chatbotCustomConfig.getUserMessageBackgroundColor())) || + (oldChatbotCustomConfig.getChatbotDisplay() != null && !oldChatbotCustomConfig.getChatbotDisplay().equals(chatbotCustomConfig.getChatbotDisplay())) || + (oldChatbotCustomConfig.getQandaDisplay() != null && !oldChatbotCustomConfig.getQandaDisplay().equals(chatbotCustomConfig.getQandaDisplay())) || + (oldChatbotCustomConfig.getDocumentaryResourceDisplay() != null && !oldChatbotCustomConfig.getDocumentaryResourceDisplay().equals(chatbotCustomConfig.getDocumentaryResourceDisplay())); } private static boolean checkIfEmailOrAttachmentSettingsChanged(final ChatbotCustomConfig oldChatbotCustomConfig, final ChatbotCustomConfig chatbotCustomConfig) { diff --git a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java index 60777598c..ac329f028 100644 --- a/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java +++ b/vertigo-bot-designer/src/main/java/io/vertigo/chatbot/designer/builder/services/topic/export/BotExportServices.java @@ -113,6 +113,9 @@ public ChatbotCustomConfigExport exportChatbotCustomSettings(final long botId) { chatbotCustomConfigExport.setDisplayAvatar(chatbotCustomConfig.getDisplayAvatar()); chatbotCustomConfigExport.setReinitializationButton(chatbotCustomConfig.getReinitializationButton()); chatbotCustomConfigExport.setFontFamily(fontFamily.getLabel()); + chatbotCustomConfigExport.setChatbotDisplay(chatbotCustomConfig.getChatbotDisplay()); + chatbotCustomConfigExport.setQandaDisplay(chatbotCustomConfig.getQandaDisplay()); + chatbotCustomConfigExport.setDocumentaryResourceDisplay(chatbotCustomConfig.getDocumentaryResourceDisplay()); return chatbotCustomConfigExport; } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java index c00d66ccb..15e92402c 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java @@ -25,6 +25,9 @@ public final class ChatbotCustomConfigExport implements DtObject { private Boolean displayAvatar; private Long totalMaxAttachmentSize; private Boolean disableNlu; + private Boolean chatbotDisplay; + private Boolean qandaDisplay; + private Boolean documentaryResourceDisplay; /** * Champ : DATA. @@ -254,6 +257,63 @@ public void setDisableNlu(final Boolean disableNlu) { this.disableNlu = disableNlu; } + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display chatbot'. + * @return Boolean chatbotDisplay + */ + @Field(smartType = "STyYesNo", label = "Display chatbot") + public Boolean getChatbotDisplay() { + return chatbotDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display chatbot'. + * @param chatbotDisplay Boolean + */ + public void setChatbotDisplay(final Boolean chatbotDisplay) { + this.chatbotDisplay = chatbotDisplay; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display Q&A'. + * @return Boolean qandaDisplay + */ + @Field(smartType = "STyYesNo", label = "Display Q&A") + public Boolean getQandaDisplay() { + return qandaDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display Q&A'. + * @param qandaDisplay Boolean + */ + public void setQandaDisplay(final Boolean qandaDisplay) { + this.qandaDisplay = qandaDisplay; + } + + /** + * Champ : DATA. + * Récupère la valeur de la propriété 'Display documentary resources'. + * @return Boolean documentaryResourceDisplay + */ + @Field(smartType = "STyYesNo", label = "Display documentary resources") + public Boolean getDocumentaryResourceDisplay() { + return documentaryResourceDisplay; + } + + /** + * Champ : DATA. + * Définit la valeur de la propriété 'Display documentary resources'. + * @param documentaryResourceDisplay Boolean + */ + public void setDocumentaryResourceDisplay(final Boolean documentaryResourceDisplay) { + this.documentaryResourceDisplay = documentaryResourceDisplay; + } + /** {@inheritDoc} */ @Override public String toString() { diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index b3f8af8ad..7962a1f13 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -327,6 +327,18 @@ public enum DtResources implements MessageKey { * Disable NlU. */ fldChatbotCustomConfigExport$disableNlu, + /** + * Display chatbot. + */ + fldChatbotCustomConfigExport$chatbotDisplay, + /** + * Display Q&A. + */ + fldChatbotCustomConfigExport$qandaDisplay, + /** + * Display documentary resources. + */ + fldChatbotCustomConfigExport$documentaryResourceDisplay, /*********************************************************** /** ChatbotNode. diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 3bce0d71d..fdf50c0e5 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -96,6 +96,9 @@ fldChatbotCustomConfigExport$fontFamily = Bot font family fldChatbotCustomConfigExport$displayAvatar = Display avatar fldChatbotCustomConfigExport$totalMaxAttachmentSize = Total maximum attachment size fldChatbotCustomConfigExport$disableNlu = Disable NlU +fldChatbotCustomConfigExport$chatbotDisplay = Display chatbot +fldChatbotCustomConfigExport$qandaDisplay = Display Q&A +fldChatbotCustomConfigExport$documentaryResourceDisplay = Display documentary resources ################################################################################"); diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index d7cf668bf..a884ba611 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -469,7 +469,13 @@ public enum ChatbotCustomConfigExportFields implements DtFieldName Date: Thu, 19 Sep 2024 14:04:55 +0200 Subject: [PATCH 15/21] [CHATBOT-630 rename qAndADisplay param in ChatbotCustomConfigExport] --- .../io/vertigo/chatbot/commons/mda/webservices.ksp | 2 +- .../commons/domain/ChatbotCustomConfigExport.java | 14 +++++++------- .../chatbot/commons/domain/DtResources.java | 2 +- .../chatbot/commons/domain/DtResources.properties | 2 +- .../io/vertigo/chatbot/domain/DtDefinitions.java | 2 +- .../commons/domain/ChatbotCustomConfigExport.java | 14 +++++++------- .../io/vertigo/chatbot/domain/DtDefinitions.java | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index d093ad008..e9d5fbd37 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -111,7 +111,7 @@ create DtDefinition DtChatbotCustomConfigExport { field totalMaxAttachmentSize {domain: DoNumber label: "Total maximum attachment size" cardinality:"?"} field disableNlu {domain: DoYesNo label: "Disable NlU" cardinality:"?"} field chatbotDisplay {domain: DoYesNo label: "Display chatbot" cardinality:"?"} - field qandaDisplay {domain: DoYesNo label: "Display Q&A" cardinality:"?"} + field qAndADisplay {domain: DoYesNo label: "Display Q&A" cardinality:"?"} field documentaryResourceDisplay {domain: DoYesNo label: "Display documentary resources" cardinality:"?"} } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java index 15e92402c..b3a2f6192 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java @@ -26,7 +26,7 @@ public final class ChatbotCustomConfigExport implements DtObject { private Long totalMaxAttachmentSize; private Boolean disableNlu; private Boolean chatbotDisplay; - private Boolean qandaDisplay; + private Boolean qAndADisplay; private Boolean documentaryResourceDisplay; /** @@ -279,20 +279,20 @@ public void setChatbotDisplay(final Boolean chatbotDisplay) { /** * Champ : DATA. * Récupère la valeur de la propriété 'Display Q&A'. - * @return Boolean qandaDisplay + * @return Boolean qAndADisplay */ @Field(smartType = "STyYesNo", label = "Display Q&A") - public Boolean getQandaDisplay() { - return qandaDisplay; + public Boolean getQAndADisplay() { + return qAndADisplay; } /** * Champ : DATA. * Définit la valeur de la propriété 'Display Q&A'. - * @param qandaDisplay Boolean + * @param qAndADisplay Boolean */ - public void setQandaDisplay(final Boolean qandaDisplay) { - this.qandaDisplay = qandaDisplay; + public void setQAndADisplay(final Boolean qAndADisplay) { + this.qAndADisplay = qAndADisplay; } /** diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index 7962a1f13..e5d805703 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -334,7 +334,7 @@ public enum DtResources implements MessageKey { /** * Display Q&A. */ - fldChatbotCustomConfigExport$qandaDisplay, + fldChatbotCustomConfigExport$qAndADisplay, /** * Display documentary resources. */ diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index fdf50c0e5..48bdaaf56 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -97,7 +97,7 @@ fldChatbotCustomConfigExport$displayAvatar = Display avatar fldChatbotCustomConfigExport$totalMaxAttachmentSize = Total maximum attachment size fldChatbotCustomConfigExport$disableNlu = Disable NlU fldChatbotCustomConfigExport$chatbotDisplay = Display chatbot -fldChatbotCustomConfigExport$qandaDisplay = Display Q&A +fldChatbotCustomConfigExport$qAndADisplay = Display Q&A fldChatbotCustomConfigExport$documentaryResourceDisplay = Display documentary resources ################################################################################"); diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index a884ba611..bed0088fd 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -473,7 +473,7 @@ public enum ChatbotCustomConfigExportFields implements DtFieldName Date: Tue, 24 Sep 2024 10:48:29 +0200 Subject: [PATCH 16/21] [CHATBOT-630 enable chatbot layout parameters] --- .../chatbot/commons/mda/webservices.ksp | 2 +- .../domain/ChatbotCustomConfigExport.java | 14 ++-- .../chatbot/commons/domain/DtResources.java | 2 +- .../commons/domain/DtResources.properties | 2 +- .../vertigo/chatbot/domain/DtDefinitions.java | 2 +- .../manager/ExecutorConfigManager.java | 6 ++ .../executor/manager/ExecutorManager.java | 5 +- .../webservices/PlatformWebService.java | 22 ++++++ .../executor/webservices/QAndAWebService.java | 1 - .../executor/webservices/TalkWebService.java | 13 ++-- .../domain/ChatbotCustomConfigExport.java | 14 ++-- .../vertigo/chatbot/domain/DtDefinitions.java | 2 +- .../src/main/webapp/static/chatbot/index.html | 6 +- .../main/webapp/static/chatbot/js/chatbot.js | 73 +++++++++++-------- 14 files changed, 102 insertions(+), 62 deletions(-) create mode 100644 vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/PlatformWebService.java diff --git a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp index e9d5fbd37..d093ad008 100644 --- a/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp +++ b/vertigo-bot-commons/src/main/resources/io/vertigo/chatbot/commons/mda/webservices.ksp @@ -111,7 +111,7 @@ create DtDefinition DtChatbotCustomConfigExport { field totalMaxAttachmentSize {domain: DoNumber label: "Total maximum attachment size" cardinality:"?"} field disableNlu {domain: DoYesNo label: "Disable NlU" cardinality:"?"} field chatbotDisplay {domain: DoYesNo label: "Display chatbot" cardinality:"?"} - field qAndADisplay {domain: DoYesNo label: "Display Q&A" cardinality:"?"} + field qandaDisplay {domain: DoYesNo label: "Display Q&A" cardinality:"?"} field documentaryResourceDisplay {domain: DoYesNo label: "Display documentary resources" cardinality:"?"} } diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java index b3a2f6192..15e92402c 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java @@ -26,7 +26,7 @@ public final class ChatbotCustomConfigExport implements DtObject { private Long totalMaxAttachmentSize; private Boolean disableNlu; private Boolean chatbotDisplay; - private Boolean qAndADisplay; + private Boolean qandaDisplay; private Boolean documentaryResourceDisplay; /** @@ -279,20 +279,20 @@ public void setChatbotDisplay(final Boolean chatbotDisplay) { /** * Champ : DATA. * Récupère la valeur de la propriété 'Display Q&A'. - * @return Boolean qAndADisplay + * @return Boolean qandaDisplay */ @Field(smartType = "STyYesNo", label = "Display Q&A") - public Boolean getQAndADisplay() { - return qAndADisplay; + public Boolean getQandaDisplay() { + return qandaDisplay; } /** * Champ : DATA. * Définit la valeur de la propriété 'Display Q&A'. - * @param qAndADisplay Boolean + * @param qandaDisplay Boolean */ - public void setQAndADisplay(final Boolean qAndADisplay) { - this.qAndADisplay = qAndADisplay; + public void setQandaDisplay(final Boolean qandaDisplay) { + this.qandaDisplay = qandaDisplay; } /** diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java index e5d805703..7962a1f13 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.java @@ -334,7 +334,7 @@ public enum DtResources implements MessageKey { /** * Display Q&A. */ - fldChatbotCustomConfigExport$qAndADisplay, + fldChatbotCustomConfigExport$qandaDisplay, /** * Display documentary resources. */ diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties index 48bdaaf56..fdf50c0e5 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/commons/domain/DtResources.properties @@ -97,7 +97,7 @@ fldChatbotCustomConfigExport$displayAvatar = Display avatar fldChatbotCustomConfigExport$totalMaxAttachmentSize = Total maximum attachment size fldChatbotCustomConfigExport$disableNlu = Disable NlU fldChatbotCustomConfigExport$chatbotDisplay = Display chatbot -fldChatbotCustomConfigExport$qAndADisplay = Display Q&A +fldChatbotCustomConfigExport$qandaDisplay = Display Q&A fldChatbotCustomConfigExport$documentaryResourceDisplay = Display documentary resources ################################################################################"); diff --git a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index bed0088fd..a884ba611 100644 --- a/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-designer/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -473,7 +473,7 @@ public enum ChatbotCustomConfigExportFields implements DtFieldName getWelcomeToursFile() { return welcomeToursFileURN != null ? Optional.of(executorFileServices.getFile(welcomeToursFileURN)) : Optional.empty(); } + public JsonElement getCustomConfig(){ + return jsonEngine.fromJson(getConfig().getExecutorConfiguration().getCustomConfig(), JsonElement.class); + } + public void addPlugin(final ExecutorPlugin executorPlugin) { plugins.add(executorPlugin); } diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java index 64491469a..eb7927232 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/manager/ExecutorManager.java @@ -179,7 +179,6 @@ public BotResponse startNewConversation(final BotInput input) { if (executorConfiguration.getAvatar() != null) { botResponse.getMetadatas().put("avatar", executorConfiguration.getAvatar()); } - botResponse.getMetadatas().put("customConfig", jsonEngine.fromJson(executorConfiguration.getCustomConfig(), JsonElement.class)); return botResponse; } @@ -251,4 +250,8 @@ public DtList getDocumentaryResourceList() { return executorConfigManager.getDocumentaryResourceList(); } + public JsonElement getCustomConfig() { + return executorConfigManager.getCustomConfig(); + } + } diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/PlatformWebService.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/PlatformWebService.java new file mode 100644 index 000000000..5d1ac2f3f --- /dev/null +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/PlatformWebService.java @@ -0,0 +1,22 @@ +package io.vertigo.chatbot.executor.webservices; + +import com.google.gson.JsonElement; + +import javax.inject.Inject; + +import io.vertigo.chatbot.executor.manager.ExecutorManager; +import io.vertigo.vega.webservice.WebServices; +import io.vertigo.vega.webservice.stereotype.GET; +import io.vertigo.vega.webservice.stereotype.PathPrefix; + +@PathPrefix("/platform-config") +public class PlatformWebService implements WebServices { + + @Inject + private ExecutorManager executorManager; + + @GET("/getCustomConfig") + public JsonElement getCustomConfig() { + return executorManager.getCustomConfig(); + } +} diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/QAndAWebService.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/QAndAWebService.java index 9ad5f57bb..33872d55c 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/QAndAWebService.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/QAndAWebService.java @@ -7,7 +7,6 @@ import io.vertigo.datamodel.structure.model.DtList; import io.vertigo.vega.webservice.WebServices; import io.vertigo.vega.webservice.stereotype.GET; -import io.vertigo.vega.webservice.stereotype.POST; import io.vertigo.vega.webservice.stereotype.PathPrefix; @PathPrefix("/qanda") diff --git a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/TalkWebService.java b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/TalkWebService.java index c1e60b294..a06583548 100644 --- a/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/TalkWebService.java +++ b/vertigo-bot-executor/src/main/java/io/vertigo/chatbot/executor/webservices/TalkWebService.java @@ -17,12 +17,16 @@ */ package io.vertigo.chatbot.executor.webservices; -import io.vertigo.chatbot.commons.domain.QuestionAnswerExport; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import javax.inject.Inject; + import io.vertigo.chatbot.engine.model.BotInput; import io.vertigo.chatbot.engine.model.BotResponse; import io.vertigo.chatbot.executor.manager.ExecutorManager; import io.vertigo.chatbot.executor.model.IncomeRating; -import io.vertigo.datamodel.structure.model.DtList; import io.vertigo.datastore.filestore.model.VFile; import io.vertigo.vega.webservice.WebServices; import io.vertigo.vega.webservice.stereotype.GET; @@ -31,11 +35,6 @@ import io.vertigo.vega.webservice.stereotype.PathPrefix; import io.vertigo.vega.webservice.stereotype.QueryParam; -import javax.inject.Inject; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - @PathPrefix("/chatbot") public class TalkWebService implements WebServices { diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java index b3a2f6192..15e92402c 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/commons/domain/ChatbotCustomConfigExport.java @@ -26,7 +26,7 @@ public final class ChatbotCustomConfigExport implements DtObject { private Long totalMaxAttachmentSize; private Boolean disableNlu; private Boolean chatbotDisplay; - private Boolean qAndADisplay; + private Boolean qandaDisplay; private Boolean documentaryResourceDisplay; /** @@ -279,20 +279,20 @@ public void setChatbotDisplay(final Boolean chatbotDisplay) { /** * Champ : DATA. * Récupère la valeur de la propriété 'Display Q&A'. - * @return Boolean qAndADisplay + * @return Boolean qandaDisplay */ @Field(smartType = "STyYesNo", label = "Display Q&A") - public Boolean getQAndADisplay() { - return qAndADisplay; + public Boolean getQandaDisplay() { + return qandaDisplay; } /** * Champ : DATA. * Définit la valeur de la propriété 'Display Q&A'. - * @param qAndADisplay Boolean + * @param qandaDisplay Boolean */ - public void setQAndADisplay(final Boolean qAndADisplay) { - this.qAndADisplay = qAndADisplay; + public void setQandaDisplay(final Boolean qandaDisplay) { + this.qandaDisplay = qandaDisplay; } /** diff --git a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java index 35146e1ee..dc2daa93c 100644 --- a/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java +++ b/vertigo-bot-executor/src/main/javagen/io/vertigo/chatbot/domain/DtDefinitions.java @@ -220,7 +220,7 @@ public enum ChatbotCustomConfigExportFields implements DtFieldName + ref="scroller" v-if="">
-
+
- + new Promise((res, rej) => { window.addEventListener( 'message', - function (event) { + async function (event) { if (event.data === 'start') { - chatbot.initPlatform(); + await chatbot.initPlatform(); } if (event.data.sendTopic) { const button = chatbot.inputConfig.buttons.find((button) => button.payload === event.data.sendTopic.topic) @@ -78,6 +79,7 @@ const chatbot = new Vue({ }, data: { // config + convId: null, botName: _botName, botUrl: _botBaseUrl, @@ -106,14 +108,15 @@ const chatbot = new Vue({ userMessageFontColor: 'black', fontFamily: 'Arial, Helvetica, sans-serif', displayAvatar: true, - disableNlu: false + disableNlu: false, + chatbotDisplay: false, + qandaDisplay: false, + documentaryResourceDisplay: false }, isEnded: false, tab: '', - chatbotDisplay: true, - qAndADisplay: true, - documentaryResourceDisplay: true, + platformUrl: _platformBaseUrl, prevInputConfig: {}, lastPayload: null, processing: false, @@ -144,39 +147,57 @@ const chatbot = new Vue({ }, methods: { - initPlatform(){ - if(chatbot.chatbotDisplay) {chatbot.initBot()} - if(chatbot.qAndADisplay) {chatbot.initQAndA()} - if(chatbot.documentaryResourceDisplay) {chatbot.initDocumentaryResources()} - chatbot.initLayout(); + async initPlatform(){ + await chatbot.initPlatformConfig() + if(chatbot.customConfig.chatbotDisplay) {chatbot.startConversation()} + if(chatbot.customConfig.qandaDisplay) {chatbot.initQAndA()} + if(chatbot.customConfig.documentaryResourceDisplay) {chatbot.initDocumentaryResources()} + chatbot.initLayout() }, - initBot: function () { + async initPlatformConfig() { document.getElementById('page').style.visibility = 'visible'; document.getElementById('loading').style.display = 'none'; + + try { + await this.$http.get(chatbot.platformUrl + '/getCustomConfig').then(httpResponse => { + chatbot.customConfig.reinitializationButton = httpResponse.body.reinitializationButton; + chatbot.customConfig.backgroundColor = httpResponse.body.backgroundColor; + chatbot.customConfig.fontColor = httpResponse.body.fontColor; + chatbot.customConfig.botMessageBackgroundColor = httpResponse.body.botMessageBackgroundColor; + chatbot.customConfig.botMessageFontColor = httpResponse.body.botMessageFontColor; + chatbot.customConfig.userMessageBackgroundColor = httpResponse.body.userMessageBackgroundColor; + chatbot.customConfig.userMessageFontColor = httpResponse.body.userMessageFontColor; + chatbot.customConfig.fontFamily = httpResponse.body.fontFamily; + chatbot.customConfig.displayAvatar = httpResponse.body.displayAvatar; + chatbot.customConfig.disableNlu = httpResponse.body.disableNlu; + chatbot.customConfig.chatbotDisplay = httpResponse.body.chatbotDisplay; + chatbot.customConfig.qandaDisplay = httpResponse.body.qandaDisplay; + chatbot.customConfig.documentaryResourceDisplay = httpResponse.body.documentaryResourceDisplay; + sessionStorage.setItem('customConfig', JSON.stringify(chatbot.customConfig)); + }); + } catch (error) { + console.error('Erreur lors de la récupération de la configuration du chatbot', error); + } if (sessionStorage.contextMap) { chatbot.contextMap = JSON.parse(sessionStorage.contextMap); - this.startConversation(); } else { this.$http.post(chatbot.botUrl + '/context').then(contextResponse => { chatbot.contextMap = contextResponse.data; sessionStorage.setItem('contextMap', JSON.stringify(chatbot.contextMap)); - chatbot.startConversation(); }); } - }, + updateSessionStorage() { sessionStorage.convId = chatbot.convId; sessionStorage.setItem('inputConfig', JSON.stringify(chatbot.inputConfig)); sessionStorage.setItem('messages', JSON.stringify(chatbot.messages)); - sessionStorage.setItem('customConfig', JSON.stringify(chatbot.customConfig)); }, restoreFromSessionStorage() { chatbot.convId = sessionStorage.convId; chatbot.inputConfig = JSON.parse(sessionStorage.inputConfig); chatbot.messages = JSON.parse(sessionStorage.messages); - chatbot.customConfig = JSON.parse(sessionStorage.customConfig); }, clearSessionStorage() { sessionStorage.clear(); @@ -184,16 +205,6 @@ const chatbot = new Vue({ setParametersFromHttpResponse(httpResponse) { chatbot.convId = httpResponse.data.metadatas.sessionId; - chatbot.customConfig.reinitializationButton = httpResponse.data.metadatas.customConfig.reinitializationButton; - chatbot.customConfig.backgroundColor = httpResponse.data.metadatas.customConfig.backgroundColor; - chatbot.customConfig.fontColor = httpResponse.data.metadatas.customConfig.fontColor; - chatbot.customConfig.botMessageBackgroundColor = httpResponse.data.metadatas.customConfig.botMessageBackgroundColor; - chatbot.customConfig.botMessageFontColor = httpResponse.data.metadatas.customConfig.botMessageFontColor; - chatbot.customConfig.userMessageBackgroundColor = httpResponse.data.metadatas.customConfig.userMessageBackgroundColor; - chatbot.customConfig.userMessageFontColor = httpResponse.data.metadatas.customConfig.userMessageFontColor; - chatbot.customConfig.fontFamily = httpResponse.data.metadatas.customConfig.fontFamily; - chatbot.customConfig.displayAvatar = httpResponse.data.metadatas.customConfig.displayAvatar; - chatbot.customConfig.disableNlu = httpResponse.data.metadatas.customConfig.disableNlu; chatbot.updateSessionStorage(); chatbot._handleResponse(httpResponse, false); }, @@ -485,18 +496,18 @@ const chatbot = new Vue({ chatbot.clearSessionStorage(); if (!isAnotherConversation) { - chatbot.initBot(); + chatbot.startConversation(); } }, refreshPlatform(){ + chatbot.initPlatformConfig() if (chatbot.tab === 'bot') { chatbot.refreshBot() } else if (chatbot.tab === 'qAndA') { chatbot.initQAndA(); } - - if (chatbot.documentaryResourceDisplay) { + if (chatbot.customConfig.documentaryResourceDisplay) { chatbot.initDocumentaryResources(); } }, @@ -506,7 +517,7 @@ const chatbot = new Vue({ }, initLayout(){ - if (chatbot.qAndADisplay && !chatbot.chatbotDisplay){ + if (chatbot.customConfig.qandaDisplay && !chatbot.customConfig.chatbotDisplay){ chatbot.tab = 'qAndA' } else { chatbot.tab = 'bot' From bab00b29b0ad238187ed7f121cd2dc8bfb633d6a Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Wed, 25 Sep 2024 09:59:50 +0200 Subject: [PATCH 17/21] [CHATBOT-630 small layout changes] --- .../src/main/webapp/static/chatbot/index.html | 25 +++++++------------ .../main/webapp/static/chatbot/js/chatbot.js | 15 +++++++++-- .../webapp/static/chatbot/style/style.css | 15 ++++++++--- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index aefe0bb2b..ec73c8a43 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -29,9 +29,9 @@ + '; --bot-message-font-color: ' + customConfig.botMessageFontColor + '; --user-message-bg-color: ' + customConfig.userMessageBackgroundColor + '; --user-message-font-color: ' + customConfig.userMessageFontColor + ';'"> - + -
+
{{ botName }}
@@ -61,18 +61,18 @@
- +
Chargement ...
+ class="row col column animate-fade">
- +
@@ -278,15 +277,9 @@ - - - - - + + +
diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js index e2f75193e..8a2a2e906 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/js/chatbot.js @@ -303,8 +303,8 @@ const chatbot = new Vue({ _scrollToBottom() { const scrollHeight = this.$refs.scroller.$el.children[0].children[0].scrollHeight; // workaround this.$refs.scroller.setScrollPosition(scrollHeight, 400); - } - , + }, + askBot(value, label, isButton, fileContent, fileName, rating) { chatbot.prevInputConfig = JSON.parse(JSON.stringify(chatbot.inputConfig)); chatbot.reinitInput(); @@ -347,6 +347,7 @@ const chatbot = new Vue({ // success if (httpResponse.data.metadatas.sessionId && chatbot.convId !== httpResponse.data.metadatas.sessionId) { chatbot.refreshBot(true); + console.log('le bug') chatbot.setParametersFromHttpResponse(httpResponse); } else { @@ -524,6 +525,16 @@ const chatbot = new Vue({ } }, + tabChange(tab) { + chatbot.tab = tab + if(tab === 'bot'){ + this.$nextTick(() => { + chatbot._scrollToBottom(); + chatbot.qAndAConfig.selectedQuestion = null; + }); + } + }, + /* Q&A */ initQAndA(){ diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css index bce8c2c0e..151187ecf 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/style/style.css @@ -193,8 +193,7 @@ img { } .q-layout-footer{ - webkit-box-shadow: none !important; - box-shadow: none; + box-shadow: 0 -1px 2px 1px rgba(0, 0, 0, 0.2); background: white; } @@ -287,8 +286,16 @@ img { font-size: 14px; } -.q-tabs { - box-shadow: 0 -1px 2px 1px rgba(0, 0, 0, 0.2); +.q-btn-footer { + flex:1; + height: 48px; + border-radius: unset; + font-size: 18px; + color: var(--font-color) !important; +} + +.q-btn-footer-selected { + opacity: 80%; } /* Documentary resources */ From 76029160493981ec23a2807529d788812f16398e Mon Sep 17 00:00:00 2001 From: rsaintpaul Date: Fri, 27 Sep 2024 10:48:34 +0200 Subject: [PATCH 18/21] [CHATBOT-630 create services for chatbot.js] --- .../src/main/webapp/static/chatbot/index.html | 30 +- .../webapp/static/chatbot/js/botService.js | 307 +++++++ .../main/webapp/static/chatbot/js/chatbot.js | 812 ++++++------------ .../chatbot/js/documentaryResourceService.js | 5 + .../webapp/static/chatbot/js/qAndAService.js | 19 + .../webapp/static/chatbot/style/style.css | 8 +- 6 files changed, 595 insertions(+), 586 deletions(-) create mode 100644 vertigo-bot-executor/src/main/webapp/static/chatbot/js/botService.js create mode 100644 vertigo-bot-executor/src/main/webapp/static/chatbot/js/documentaryResourceService.js create mode 100644 vertigo-bot-executor/src/main/webapp/static/chatbot/js/qAndAService.js diff --git a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html index ec73c8a43..e2ae4c5ad 100644 --- a/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html +++ b/vertigo-bot-executor/src/main/webapp/static/chatbot/index.html @@ -32,8 +32,8 @@
-
- {{ botName }} +
+ {{ platformName }}