Feature/extract import all (#2796)

* use existing route to get all chatflows

* add export all chatflows functionality

* add read exported all chatflows json file functionality

* add save chatflows functionality in server

* chore rename saveChatflows to importChatflows and others

* chore rewrite snackbar message

* fix import chatflows when no data in chatflows db

* add handle when import file array length is 0

* chore update and add meaning comment in importChatflows

* update method of storing flowdata for importChatflows function

* Refresh/redirect to chatflows when import is successful

* fix lint

---------

Co-authored-by: Ilango <rajagopalilango@gmail.com>
This commit is contained in:
Ong Chung Yau
2024-07-16 09:47:41 +08:00
committed by GitHub
parent 074bb738a3
commit 95b2cf7b7f
7 changed files with 254 additions and 30 deletions
+12
View File
@@ -340,6 +340,18 @@ export const getFolderName = (base64ArrayStr) => {
}
}
export const sanitizeChatflows = (arrayChatflows) => {
const sanitizedChatflows = arrayChatflows.map((chatFlow) => {
const sanitizeFlowData = generateExportFlowData(JSON.parse(chatFlow.flowData))
return {
id: chatFlow.id,
name: chatFlow.name,
flowData: JSON.stringify(sanitizeFlowData, null, 2)
}
})
return sanitizedChatflows
}
export const generateExportFlowData = (flowData) => {
const nodes = flowData.nodes
const edges = flowData.edges