Add version to navigation bar.

This commit is contained in:
SergeantPanda 2025-04-10 17:14:41 -05:00
parent bf5dc9fa19
commit c223914402
3 changed files with 42 additions and 13 deletions

View file

@ -42,6 +42,9 @@ class CoreSettingsViewSet(viewsets.ModelViewSet):
@api_view(['GET'])
@permission_classes([IsAuthenticated])
def environment(request):
# Import version information
from version import __version__, __build__
public_ip = None
local_ip = None
country_code = None
@ -83,4 +86,6 @@ def environment(request):
'country_code': country_code,
'country_name': country_name,
'env_mode': "dev" if os.getenv('DISPATCHARR_ENV') == "dev" else "prod",
'version': __version__,
'build': __build__,
})

View file

@ -155,8 +155,8 @@ export default class API {
...(channel.logo_file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body: body,
});
@ -220,8 +220,8 @@ export default class API {
...(values.logo_file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body: body,
});
@ -518,8 +518,8 @@ export default class API {
...(values.file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body,
});
@ -602,8 +602,8 @@ export default class API {
...(values.file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body,
});
@ -663,8 +663,8 @@ export default class API {
...(values.epg_file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body,
});
@ -704,8 +704,8 @@ export default class API {
...(values.epg_file
? {}
: {
'Content-Type': 'application/json',
}),
'Content-Type': 'application/json',
}),
},
body,
});

View file

@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React, { useRef, useEffect, useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import {
ListOrdered,
@ -26,6 +26,7 @@ import logo from '../images/logo.png';
import useChannelsStore from '../store/channels';
import './sidebar.css';
import useSettingsStore from '../store/settings';
import API from '../api';
const NavLink = ({ item, isActive, collapsed }) => {
return (
@ -64,6 +65,24 @@ const Sidebar = ({ collapsed, toggleDrawer, drawerWidth, miniDrawerWidth }) => {
const { channels } = useChannelsStore();
const { environment } = useSettingsStore();
const publicIPRef = useRef(null);
const [appVersion, setAppVersion] = useState({ version: '', build: '' });
// Fetch environment settings including version on component mount
useEffect(() => {
const fetchEnvironment = async () => {
try {
const envData = await API.getEnvironmentSettings();
setAppVersion({
version: envData.version || '',
build: envData.build || ''
});
} catch (error) {
console.error('Failed to fetch environment settings:', error);
}
};
fetchEnvironment();
}, []);
// Navigation Items
const navItems = [
@ -224,6 +243,11 @@ const Sidebar = ({ collapsed, toggleDrawer, drawerWidth, miniDrawerWidth }) => {
)}
</Group>
</Box>
{!collapsed && (
<Text size="xs" color="dimmed">
v{appVersion.version}{appVersion.build !== '0' ? `-${appVersion.build}` : ''}
</Text>
)}
</AppShell.Navbar>
);
};