Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ on:
description: "Create as draft release"
type: boolean
default: true
include-testing:
description: "Include Testing View"
type: boolean
default: true
include-competition:
description: "Include Competition View"
type: boolean
default: true
include-flashing:
description: "Include Flashing View"
type: boolean
default: true


jobs:
Expand All @@ -19,12 +31,18 @@ jobs:
outputs:
version: ${{ steps.get_version.outputs.version }}
is_draft: ${{ steps.get_version.outputs.is_draft }}
include_testing: ${{ steps.get_version.outputs.include_testing }}
include_competition: ${{ steps.get_version.outputs.include_competition }}
include_flashing: ${{ steps.get_version.outputs.include_flashing }}
steps:
- name: Determine version
id: get_version
run: |
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "is_draft=${{ github.event.inputs.draft }}" >> $GITHUB_OUTPUT
echo "include_testing=${{ github.event.inputs.include-testing }}" >> $GITHUB_OUTPUT
echo "include_competition=${{ github.event.inputs.include-competition }}" >> $GITHUB_OUTPUT
echo "include_flashing=${{ github.event.inputs.include-flashing }}" >> $GITHUB_OUTPUT

create-draft-release:
name: Create Draft Release
Expand Down Expand Up @@ -66,21 +84,35 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build with Turbo
run: pnpm turbo build --filter=testing-view --filter=competition-view --filter=flashing-view
run: |
FILTERS=""
if [ "${{ needs.determine-version.outputs.include_testing }}" = "true" ]; then
FILTERS="$FILTERS --filter=testing-view"
fi
if [ "${{ needs.determine-version.outputs.include_competition }}" = "true" ]; then
FILTERS="$FILTERS --filter=competition-view"
fi
if [ "${{ needs.determine-version.outputs.include_flashing }}" = "true" ]; then
FILTERS="$FILTERS --filter=flashing-view"
fi
pnpm turbo build $FILTERS

- uses: actions/upload-artifact@v4
if: needs.determine-version.outputs.include_testing == 'true'
with:
name: frontend-dist
path: frontend/testing-view/dist/**
retention-days: 1

- uses: actions/upload-artifact@v4
if: needs.determine-version.outputs.include_competition == 'true'
with:
name: competition-dist
path: frontend/competition-view/dist/**
retention-days: 1

- uses: actions/upload-artifact@v4
if: needs.determine-version.outputs.include_flashing == 'true'
with:
name: flashing-dist
path: frontend/flashing-view/dist/**
Expand Down Expand Up @@ -248,18 +280,21 @@ jobs:
run: chmod +x electron-app/binaries/*

- name: Download frontend dist
if: needs.determine-version.outputs.include_testing == 'true'
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: electron-app/renderer/testing-view

- name: Download competition-view dist
if: needs.determine-version.outputs.include_competition == 'true'
uses: actions/download-artifact@v4
with:
name: competition-dist
path: electron-app/renderer/competition-view

- name: Download flashing-view dist
if: needs.determine-version.outputs.include_flashing == 'true'
uses: actions/download-artifact@v4
with:
name: flashing-dist
Expand Down
2 changes: 2 additions & 0 deletions electron-app/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ contextBridge.exposeInMainWorld("electronAPI", {
blcuReadFile: (path) => ipcRenderer.invoke("blcu-read-file", path),
// Get the application version from the main process
getAppVersion: () => ipcRenderer.invoke("get-app-version"),
// Get the list of views available in this build
getAvailableViews: () => ipcRenderer.invoke("get-available-views"),
// Set initial mode (used by mode selector renderer)
setInitialMode: (mode) => {
ipcRenderer.send("mode-selected", mode);
Expand Down
41 changes: 33 additions & 8 deletions electron-app/renderer/mode-selector/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@
<div class="header">
<h1>Control Station</h1>
</div>
<div class="button-grid">
<button id="testing" class="primary">Testing View</button>
<button id="competition" class="secondary">Competition View</button>
<button id="flashing" class="secondary">Flashing View</button>
</div>
<div class="button-grid" id="button-grid"></div>
<div class="aux-logo-wrap">
<img src="src/sign.png" alt="Logo auxiliar" class="logo-aux" />
<div class="app-footer">
Expand All @@ -229,9 +225,38 @@ <h1>Control Station</h1>
try { window.ipcRenderer && window.ipcRenderer.send('set-initial-mode', mode); window.close(); } catch (e) { }
}
};
document.getElementById('testing').addEventListener('click', () => sendMode('testing'));
document.getElementById('competition').addEventListener('click', () => sendMode('competition'));
document.getElementById('flashing').addEventListener('click', () => sendMode('flashing'));

const FALLBACK_VIEWS = [
{ mode: 'testing', label: 'Testing View' },
{ mode: 'competition', label: 'Competition View' },
{ mode: 'flashing', label: 'Flashing View' },
];

async function renderButtons() {
let views = FALLBACK_VIEWS;
try {
if (window.electronAPI?.getAvailableViews) {
const available = await window.electronAPI.getAvailableViews();
if (available && available.length > 0) views = available;
}
} catch (e) { }

const grid = document.getElementById('button-grid');
views.forEach(({ mode, label }, i) => {
const btn = document.createElement('button');
btn.id = mode;
btn.className = i === 0 ? 'primary' : 'secondary';
btn.textContent = label;
btn.addEventListener('click', () => sendMode(mode));
grid.appendChild(btn);
});

if (views.length === 1) {
sendMode(views[0].mode);
}
}

renderButtons();

const appVersionNode = document.getElementById('app-version');
if (appVersionNode && window.electronAPI?.getAppVersion) {
Expand Down
13 changes: 13 additions & 0 deletions electron-app/src/ipc/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "../config/configInstance.js";
import { getBackendWorkingDir } from "../processes/backend.js";
import { logger } from "../utils/logger.js";
import { getAppPath } from "../utils/paths.js";
import {
getCurrentView,
getMainWindow,
Expand All @@ -42,6 +43,18 @@ function setupIpcHandlers() {

ipcMain.handle("get-app-version", () => app.getVersion());

ipcMain.handle("get-available-views", () => {
const ALL_VIEWS = [
{ mode: "testing", label: "Testing View" },
{ mode: "competition", label: "Competition View" },
{ mode: "flashing", label: "Flashing View" },
];
const rendererDir = join(getAppPath(), "renderer");
return ALL_VIEWS.filter(({ mode }) =>
fs.existsSync(join(rendererDir, `${mode}-view`))
);
});

/**
* @event switch-view
* @description Switches the main window to the specified view.
Expand Down
Loading