mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
add current version
This commit is contained in:
@@ -571,6 +571,34 @@ export class App {
|
||||
return res.json(availableConfigs)
|
||||
})
|
||||
|
||||
this.app.get('/api/v1/version', async (req: Request, res: Response) => {
|
||||
const getPackageJsonPath = (): string => {
|
||||
const checkPaths = [
|
||||
path.join(__dirname, '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', '..', 'package.json'),
|
||||
path.join(__dirname, '..', '..', '..', '..', '..', 'package.json')
|
||||
]
|
||||
for (const checkPath of checkPaths) {
|
||||
if (fs.existsSync(checkPath)) {
|
||||
return checkPath
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
const packagejsonPath = getPackageJsonPath()
|
||||
if (!packagejsonPath) return res.status(404).send('Version not found')
|
||||
try {
|
||||
const content = await fs.promises.readFile(packagejsonPath, 'utf8')
|
||||
const parsedContent = JSON.parse(content)
|
||||
return res.json({ version: parsedContent.version })
|
||||
} catch (error) {
|
||||
return res.status(500).send(`Version not found: ${error}`)
|
||||
}
|
||||
})
|
||||
|
||||
// ----------------------------------------
|
||||
// Export Load Chatflow & ChatMessage & Apikeys
|
||||
// ----------------------------------------
|
||||
|
||||
@@ -4,18 +4,7 @@ import PropTypes from 'prop-types'
|
||||
import { Dialog, DialogContent, DialogTitle, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Paper } from '@mui/material'
|
||||
import moment from 'moment'
|
||||
import axios from 'axios'
|
||||
|
||||
const fetchLatestVer = async ({ api }) => {
|
||||
let apiReturn = await axios
|
||||
.get(api)
|
||||
.then(async function (response) {
|
||||
return response.data
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error)
|
||||
})
|
||||
return apiReturn
|
||||
}
|
||||
import { baseURL } from 'store/constant'
|
||||
|
||||
const AboutDialog = ({ show, onCancel }) => {
|
||||
const portalElement = document.getElementById('portal')
|
||||
@@ -24,12 +13,30 @@ const AboutDialog = ({ show, onCancel }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (show) {
|
||||
const fetchData = async (api) => {
|
||||
let response = await fetchLatestVer({ api })
|
||||
setData(response)
|
||||
}
|
||||
const username = localStorage.getItem('username')
|
||||
const password = localStorage.getItem('password')
|
||||
|
||||
fetchData('https://api.github.com/repos/FlowiseAI/Flowise/releases/latest')
|
||||
const config = {}
|
||||
if (username && password) {
|
||||
config.auth = {
|
||||
username,
|
||||
password
|
||||
}
|
||||
}
|
||||
const latestReleaseReq = axios.get('https://api.github.com/repos/FlowiseAI/Flowise/releases/latest')
|
||||
const currentVersionReq = axios.get(`${baseURL}/api/v1/version`, { ...config })
|
||||
|
||||
Promise.all([latestReleaseReq, currentVersionReq])
|
||||
.then(([latestReleaseData, currentVersionData]) => {
|
||||
const finalData = {
|
||||
...latestReleaseData.data,
|
||||
currentVersion: currentVersionData.data.version
|
||||
}
|
||||
setData(finalData)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching data:', error)
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -53,12 +60,16 @@ const AboutDialog = ({ show, onCancel }) => {
|
||||
<Table aria-label='simple table'>
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
<TableCell>Current Version</TableCell>
|
||||
<TableCell>Latest Version</TableCell>
|
||||
<TableCell>Published At</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
<TableRow sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
|
||||
<TableCell component='th' scope='row'>
|
||||
{data.currentVersion}
|
||||
</TableCell>
|
||||
<TableCell component='th' scope='row'>
|
||||
<a target='_blank' rel='noreferrer' href={data.html_url}>
|
||||
{data.name}
|
||||
|
||||
Reference in New Issue
Block a user