Skip to content

Commit

Permalink
feat: another wip commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chaseconey committed Mar 2, 2022
1 parent d668320 commit 2b73c78
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 31 deletions.
6 changes: 1 addition & 5 deletions packages/main/src/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,11 @@ async function createWindow() {
client.start();

setInterval(() => {
console.log('Sending session');

browserWindow?.webContents.send('session', session);
browserWindow?.webContents.send('drivers', drivers);
}, 10000);

setInterval(() => {
console.log('Sending lapData');

browserWindow?.webContents.send('lapData', lapData);
browserWindow?.webContents.send('lapHistory', lapHistory);
browserWindow?.webContents.send('fastestLap', fastestLap);
Expand All @@ -94,7 +90,7 @@ async function createWindow() {
? import.meta.env.VITE_DEV_SERVER_URL
: new URL(
'../renderer/dist/index.html',
'file://' + __dirname
'file://' + __dirname,
).toString();

await browserWindow.loadURL(pageUrl);
Expand Down
10 changes: 10 additions & 0 deletions packages/main/src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

export const out = (rawData, name) => {
BigInt.prototype['toJSON'] = function () {
return this.toString();
};

let data = JSON.stringify(rawData, null, 2);
fs.writeFileSync(`data/${name}.json`, data);
};
13 changes: 9 additions & 4 deletions packages/renderer/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script>
import Nav from '/@/components/Nav.vue';
import TopNav from '/@/components/TopNav.vue';
export default {
components: { Nav },
components: { TopNav },
data() {
return {};
},
Expand All @@ -28,8 +28,13 @@ export default {
</script>
<template>
<div class="container">
<Nav />
<TopNav />
<router-view />
<div v-if="$store.drivers" class="text-center">Waiting for match ...</div>
<div
v-if="$store.drivers"
class="text-center"
>
Waiting for match ...
</div>
</div>
</template>
17 changes: 13 additions & 4 deletions packages/renderer/src/components/DriverTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
return mergeData(
this.lapData.m_lapData,
this.drivers.m_participants,
this.lapHistory
this.lapHistory,
);
},
sortedLapData() {
Expand All @@ -26,7 +26,7 @@ export default {
// Remove dead cars
const filtered = this.mergedDriverData?.filter(
(car) => car.m_carPosition > 0
(car) => car.m_carPosition > 0,
);
// TODO: Map in driver names
Expand Down Expand Up @@ -68,7 +68,10 @@ export default {
</tr>
</thead>
<tbody>
<tr v-for="(driver, idx) in sortedLapData" :key="idx">
<tr
v-for="(driver, idx) in sortedLapData"
:key="idx"
>
<td>{{ driver.m_carPosition }}</td>
<td>{{ driver.m_raceNumber || idx }}</td>
<td
Expand Down Expand Up @@ -103,7 +106,13 @@ export default {
>
{{ formatNonZero(driver.m_sector2TimeInMS) }}
</td>
<td>{{ driver.m_penalties || 0 }}s ({{ driver.m_warnings || 0 }})</td>
<td class="text-end">
{{ driver.m_penalties || 0 }}s
<span
:class="{ 'bg-warning text-dark': driver.m_warnings > 0 }"
class="badge bg-secondary text-white"
>{{ driver.m_warnings || 0 }}</span>
</td>
</tr>
</tbody>
</table>
Expand Down
13 changes: 0 additions & 13 deletions packages/renderer/src/components/Nav.vue

This file was deleted.

File renamed without changes.
12 changes: 9 additions & 3 deletions packages/renderer/src/components/SessionInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ export default {
>
Safety Car: {{ session?.m_safetyCarStatus == 1 ? 'Yes' : 'No' }}
</div>
<div class="col py-2">Air Temp: {{ session?.m_airTemperature }}</div>
<div class="col py-2">Session Type: {{ session?.m_sessionType }}</div>
<div class="col py-2">Fastest Lap: {{ fastestLap }}</div>
<div class="col py-2">
Air Temp: {{ session?.m_airTemperature }}
</div>
<div class="col py-2">
Session Type: {{ session?.m_sessionType }}
</div>
<div class="col py-2">
Fastest Lap: {{ fastestLap }}
</div>
</div>
</template>
28 changes: 28 additions & 0 deletions packages/renderer/src/components/TopNav.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<ul class="nav">
<li class="nav-item">
<router-link
to="/"
class="nav-link"
>
Session
</router-link>
</li>
<li class="nav-item">
<router-link
to="/quali"
class="nav-link"
>
Quali
</router-link>
</li>
<li class="nav-item">
<router-link
to="/race"
class="nav-link"
>
Race
</router-link>
</li>
</ul>
</template>
4 changes: 2 additions & 2 deletions packages/renderer/src/router.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createRouter, createWebHashHistory } from 'vue-router';
import DriverTable from '/@/components/DriverTable.vue';
import SessionInfo from '/@/components/SessionInfo.vue';
import Quali from '/@/components/Quali.vue';
import QualiTable from '/@/components/QualiTable.vue';

const routes = [
{ path: '/', component: SessionInfo },
{ path: '/quali', component: Quali },
{ path: '/quali', component: QualiTable },
{ path: '/race', component: DriverTable },
];

Expand Down

0 comments on commit 2b73c78

Please sign in to comment.