mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
add current version
This commit is contained in:
@@ -571,6 +571,34 @@ export class App {
|
|||||||
return res.json(availableConfigs)
|
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
|
// 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 { Dialog, DialogContent, DialogTitle, TableContainer, Table, TableHead, TableRow, TableCell, TableBody, Paper } from '@mui/material'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { baseURL } from 'store/constant'
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
const AboutDialog = ({ show, onCancel }) => {
|
const AboutDialog = ({ show, onCancel }) => {
|
||||||
const portalElement = document.getElementById('portal')
|
const portalElement = document.getElementById('portal')
|
||||||
@@ -24,12 +13,30 @@ const AboutDialog = ({ show, onCancel }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show) {
|
if (show) {
|
||||||
const fetchData = async (api) => {
|
const username = localStorage.getItem('username')
|
||||||
let response = await fetchLatestVer({ api })
|
const password = localStorage.getItem('password')
|
||||||
setData(response)
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -53,12 +60,16 @@ const AboutDialog = ({ show, onCancel }) => {
|
|||||||
<Table aria-label='simple table'>
|
<Table aria-label='simple table'>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
<TableCell>Current Version</TableCell>
|
||||||
<TableCell>Latest Version</TableCell>
|
<TableCell>Latest Version</TableCell>
|
||||||
<TableCell>Published At</TableCell>
|
<TableCell>Published At</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
|
<TableRow sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
|
||||||
|
<TableCell component='th' scope='row'>
|
||||||
|
{data.currentVersion}
|
||||||
|
</TableCell>
|
||||||
<TableCell component='th' scope='row'>
|
<TableCell component='th' scope='row'>
|
||||||
<a target='_blank' rel='noreferrer' href={data.html_url}>
|
<a target='_blank' rel='noreferrer' href={data.html_url}>
|
||||||
{data.name}
|
{data.name}
|
||||||
|
|||||||
Reference in New Issue
Block a user