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 ./
RUN npm ci
ARG PUBLIC_URL
ENV PUBLIC_URL $PUBLIC_URL
ARG API_URL
ENV API_URL $API_URL
# Build the app
COPY . .
RUN npm run build
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

View File

@ -68,24 +68,23 @@ function ViewDrive(props) {
let gitRemote = '';
let gitBranch = '';
let gitCommit = '';
let metadata = {};
try {
metadata = JSON.parse(drive.metadata);
const { InitData, CarParams } = JSON.parse(drive.metadata) || {};
if (metadata.InitData) {
version = metadata.InitData.Version || 'Unknown';
gitRemote = metadata.InitData.GitRemote || 'Unknown';
gitBranch = metadata.InitData.GitBranch || 'Unknown';
gitCommit = metadata.InitData.GitCommit || 'Unknown';
if (InitData) {
version = InitData.Version || 'Unknown';
gitRemote = InitData.GitRemote || 'Unknown';
gitBranch = InitData.GitBranch || 'Unknown';
gitCommit = InitData.GitCommit || 'Unknown';
}
if (metadata.CarParams) {
if (metadata.CarParams.CarName !== undefined) {
vehicle += `${metadata.CarParams.CarName.toUpperCase()} `;
if (CarParams) {
if (CarParams.CarName !== undefined) {
vehicle += `${CarParams.CarName.toUpperCase()} `;
}
if (metadata.CarParams.CarFingerprint !== undefined) {
vehicle += (metadata.CarParams.CarFingerprint.toUpperCase());
if (CarParams.CarFingerprint !== undefined) {
vehicle += (CarParams.CarFingerprint.toUpperCase());
}
}
} catch (exception) { console.log(exception); }
@ -96,6 +95,16 @@ function ViewDrive(props) {
const directorySegments = {};
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) {
// skip any non-directory entries (for example m3u8 file in the drive directory)
if (directoryTree.children[i].type !== 'directory') continue;
@ -103,7 +112,11 @@ function ViewDrive(props) {
const segment = directoryTree.children[i].name;
const logSegment = {};
// eslint-disable-next-line no-restricted-syntax
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] = {
url: `${driveUrl}/${segment}/${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 [state, dispatch] = useContext(UserContext);
console.log('component', state);
const handleSubmit = (event) => {
dispatch({ type: 'toggle_button' });
@ -30,11 +31,8 @@ export default function SignIn() {
return (
<Container component="main" maxWidth="xs" style={{ height: '100vh' }}>
<Grid container direction="row" justifyContent="center" alignItems="center" style={{ height: '100vh' }}>
<Grid item xs={12}>
<Paper
sx={{
display: 'flex',
@ -82,16 +80,14 @@ export default function SignIn() {
Sign In
</LoadingButton>
<Link href="#" variant="body2">
<Link href="#Forgot" variant="body2">
New Here or Forgotten password?
</Link>
</Box>
</Paper>
</Grid>
</Grid>
</Container>
);
}

View File

@ -1,7 +1,9 @@
import axios from 'axios';
import config from '../config';
// eslint-disable-next-line import/prefer-default-export
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;
}

View File

@ -1,27 +1,29 @@
import axios from 'axios';
import config from '../config';
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;
}
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;
}
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;
}
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;
}
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;
if (!responseData.success) {