forked from FlowiseAI/Flowise
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move file * perf: dataset file manage * v441 description * fix: qa csv update file * feat: rename file * frontend show system-version
- Loading branch information
Showing
53 changed files
with
570 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { RequestPaging } from '../../../types/index'; | ||
|
||
export type GetFileListProps = RequestPaging & { | ||
kbId: string; | ||
searchText: string; | ||
}; | ||
|
||
export type UpdateFileProps = { id: string; name?: string; datasetUsed?: boolean }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { GET, POST, PUT, DELETE } from '@/api/request'; | ||
import type { FileInfo, KbFileItemType } from '@/types/plugin'; | ||
|
||
import type { GetFileListProps, UpdateFileProps } from './file.d'; | ||
|
||
export const getDatasetFiles = (data: GetFileListProps) => | ||
POST<KbFileItemType[]>(`/core/dataset/file/list`, data); | ||
export const delDatasetFileById = (params: { fileId: string; kbId: string }) => | ||
DELETE(`/core/dataset/file/delById`, params); | ||
export const getFileInfoById = (fileId: string) => | ||
GET<FileInfo>(`/core/dataset/file/detail`, { fileId }); | ||
export const delDatasetEmptyFiles = (kbId: string) => | ||
DELETE(`/core/dataset/file/delEmptyFiles`, { kbId }); | ||
|
||
export const updateDatasetFile = (data: UpdateFileProps) => PUT(`/core/dataset/file/update`, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { GET, POST } from '../request'; | ||
|
||
import { AxiosProgressEvent } from 'axios'; | ||
|
||
export const uploadImg = (base64Img: string) => POST<string>('/system/uploadImage', { base64Img }); | ||
|
||
export const postUploadFiles = ( | ||
data: FormData, | ||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void | ||
) => | ||
POST<string[]>('/support/file/upload', data, { | ||
onUploadProgress, | ||
headers: { | ||
'Content-Type': 'multipart/form-data; charset=utf-8' | ||
} | ||
}); | ||
|
||
export const getFileViewUrl = (fileId: string) => GET<string>('/support/file/readUrl', { fileId }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,4 @@ | ||
import { GET, POST, PUT } from './request'; | ||
import type { InitDateResponse } from '@/pages/api/system/getInitData'; | ||
import { AxiosProgressEvent } from 'axios'; | ||
|
||
export const getInitData = () => GET<InitDateResponse>('/system/getInitData'); | ||
|
||
export const uploadImg = (base64Img: string) => POST<string>('/system/uploadImage', { base64Img }); | ||
|
||
export const postUploadFiles = ( | ||
data: FormData, | ||
onUploadProgress: (progressEvent: AxiosProgressEvent) => void | ||
) => | ||
POST<string[]>('/plugins/file/upload', data, { | ||
onUploadProgress, | ||
headers: { | ||
'Content-Type': 'multipart/form-data; charset=utf-8' | ||
} | ||
}); | ||
|
||
export const getFileViewUrl = (fileId: string) => GET<string>('/plugins/file/readUrl', { fileId }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { jsonRes } from '@/service/response'; | ||
import { authUser } from '@/service/utils/auth'; | ||
import { connectToDatabase } from '@/service/mongo'; | ||
import mongoose from 'mongoose'; | ||
import { PgClient } from '@/service/pg'; | ||
import { PgDatasetTableName } from '@/constants/plugin'; | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
try { | ||
await connectToDatabase(); | ||
await authUser({ req, authRoot: true }); | ||
|
||
const data = await mongoose.connection.db | ||
.collection('dataset.files') | ||
.updateMany({}, { $set: { 'metadata.datasetUsed': true } }); | ||
|
||
// update pg data | ||
const pg = await PgClient.query(`UPDATE ${PgDatasetTableName} | ||
SET file_id = '' | ||
WHERE (file_id = 'undefined' OR LENGTH(file_id) < 20) AND file_id != '';`); | ||
|
||
jsonRes(res, { | ||
data: { | ||
data, | ||
pg | ||
} | ||
}); | ||
} catch (error) { | ||
jsonRes(res, { | ||
code: 500, | ||
error | ||
}); | ||
} | ||
} |
Oops, something went wrong.