use config

main
Cameron Clough 2022-01-10 22:44:50 +00:00
parent b95f87f98b
commit 1daf4c2321
5 changed files with 44 additions and 26 deletions

View File

@ -6,11 +6,16 @@ WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm ci RUN npm ci
ARG PUBLIC_URL
ENV PUBLIC_URL $PUBLIC_URL
ARG API_URL
ENV API_URL $API_URL
# Build the app # Build the app
COPY . . COPY . .
RUN npm run build RUN npm run build
FROM nginx:1.20-alpine AS server FROM nginx:1.20-alpine AS server
COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/default.conf

View File

@ -68,24 +68,23 @@ function ViewDrive(props) {
let gitRemote = ''; let gitRemote = '';
let gitBranch = ''; let gitBranch = '';
let gitCommit = ''; let gitCommit = '';
let metadata = {};
try { try {
metadata = JSON.parse(drive.metadata); const { InitData, CarParams } = JSON.parse(drive.metadata) || {};
if (metadata.InitData) { if (InitData) {
version = metadata.InitData.Version || 'Unknown'; version = InitData.Version || 'Unknown';
gitRemote = metadata.InitData.GitRemote || 'Unknown'; gitRemote = InitData.GitRemote || 'Unknown';
gitBranch = metadata.InitData.GitBranch || 'Unknown'; gitBranch = InitData.GitBranch || 'Unknown';
gitCommit = metadata.InitData.GitCommit || 'Unknown'; gitCommit = InitData.GitCommit || 'Unknown';
} }
if (metadata.CarParams) { if (CarParams) {
if (metadata.CarParams.CarName !== undefined) { if (CarParams.CarName !== undefined) {
vehicle += `${metadata.CarParams.CarName.toUpperCase()} `; vehicle += `${CarParams.CarName.toUpperCase()} `;
} }
if (metadata.CarParams.CarFingerprint !== undefined) { if (CarParams.CarFingerprint !== undefined) {
vehicle += (metadata.CarParams.CarFingerprint.toUpperCase()); vehicle += (CarParams.CarFingerprint.toUpperCase());
} }
} }
} catch (exception) { console.log(exception); } } catch (exception) { console.log(exception); }
@ -96,6 +95,16 @@ function ViewDrive(props) {
const directorySegments = {}; const directorySegments = {};
if (directoryTree) { if (directoryTree) {
console.log('directoryTree:', directoryTree);
// directoryTree.children.reduce((directorySegments, segmentDir) => {
// directorySegments[segmentDir.]
// }, directorySegments);
// directoryTree.children.forEach((file) => {
//
// })
// eslint-disable-next-line no-restricted-syntax
for (const i in directoryTree.children) { for (const i in directoryTree.children) {
// skip any non-directory entries (for example m3u8 file in the drive directory) // skip any non-directory entries (for example m3u8 file in the drive directory)
if (directoryTree.children[i].type !== 'directory') continue; if (directoryTree.children[i].type !== 'directory') continue;
@ -103,7 +112,11 @@ function ViewDrive(props) {
const segment = directoryTree.children[i].name; const segment = directoryTree.children[i].name;
const logSegment = {}; const logSegment = {};
// eslint-disable-next-line no-restricted-syntax
for (const c in directoryTree.children[i].children) { for (const c in directoryTree.children[i].children) {
// skip any directory entries
if (directoryTree.children[i].children[c].type !== 'file') continue;
logSegment[directoryTree.children[i].children[c].name] = { logSegment[directoryTree.children[i].children[c].name] = {
url: `${driveUrl}/${segment}/${directoryTree.children[i].children[c].name}`, url: `${driveUrl}/${segment}/${directoryTree.children[i].children[c].name}`,
name: directoryTree.children[i].children[c].name, name: directoryTree.children[i].children[c].name,

View File

@ -14,6 +14,7 @@ export default function SignIn() {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [state, dispatch] = useContext(UserContext); const [state, dispatch] = useContext(UserContext);
console.log('component', state); console.log('component', state);
const handleSubmit = (event) => { const handleSubmit = (event) => {
dispatch({ type: 'toggle_button' }); dispatch({ type: 'toggle_button' });
@ -30,11 +31,8 @@ export default function SignIn() {
return ( return (
<Container component="main" maxWidth="xs" style={{ height: '100vh' }}> <Container component="main" maxWidth="xs" style={{ height: '100vh' }}>
<Grid container direction="row" justifyContent="center" alignItems="center" style={{ height: '100vh' }}> <Grid container direction="row" justifyContent="center" alignItems="center" style={{ height: '100vh' }}>
<Grid item xs={12}> <Grid item xs={12}>
<Paper <Paper
sx={{ sx={{
display: 'flex', display: 'flex',
@ -82,16 +80,14 @@ export default function SignIn() {
Sign In Sign In
</LoadingButton> </LoadingButton>
<Link href="#" variant="body2"> <Link href="#Forgot" variant="body2">
New Here or Forgotten password? New Here or Forgotten password?
</Link> </Link>
</Box> </Box>
</Paper> </Paper>
</Grid> </Grid>
</Grid> </Grid>
</Container> </Container>
); );
} }

View File

@ -1,7 +1,9 @@
import axios from 'axios'; import axios from 'axios';
import config from '../config';
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export async function getSession() { export async function getSession() {
const req = await axios.get('http://localhost/retropilot/0/useradmin/session', { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/useradmin/session`, { withCredentials: true });
return req.data; return req.data;
} }

View File

@ -1,27 +1,29 @@
import axios from 'axios'; import axios from 'axios';
import config from '../config';
export async function getDrives(dongleId) { export async function getDrives(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/false`, { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/device/${dongleId}/drives/false`, { withCredentials: true });
return req.data; return req.data;
} }
export async function getBootlogs(dongleId) { export async function getBootlogs(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/bootlogs`, { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/device/${dongleId}/bootlogs`, { withCredentials: true });
return req.data; return req.data;
} }
export async function getCrashlogs(dongleId) { export async function getCrashlogs(dongleId) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/crashlogs`, { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/device/${dongleId}/crashlogs`, { withCredentials: true });
return req.data; return req.data;
} }
export async function getDriveSegments(dongleId, driveIdentifier) { export async function getDriveSegments(dongleId, driveIdentifier) {
const req = await axios.get(`http://localhost/retropilot/0/device/${dongleId}/drives/${driveIdentifier}/segment`, { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/device/${dongleId}/drives/${driveIdentifier}/segment`, { withCredentials: true });
return req.data; return req.data;
} }
export async function getAllDevices() { export async function getAllDevices() {
const req = await axios.get('http://localhost/retropilot/0/devices', { withCredentials: true }); const req = await axios.get(`${config.apiUrl}/retropilot/0/devices`, { withCredentials: true });
const responseData = req.data; const responseData = req.data;
if (!responseData.success) { if (!responseData.success) {