Skip to content

Commit

Permalink
fixed electron issue, added team selection in all teams, fixed some b…
Browse files Browse the repository at this point in the history
…ugs and added some graphs
  • Loading branch information
AsafMeizner committed Oct 13, 2024
1 parent 43faaea commit 461c9ef
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 30 deletions.
20 changes: 20 additions & 0 deletions android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.mashkif.app",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File"
}
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MAshkif",
"version": "0.1.1",
"version": "0.2.5",
"description": "General purpose scouting app for all applications with easy to use interface and data management",
"author": {
"name": "Asaf Meizner",
Expand Down
3 changes: 2 additions & 1 deletion electron/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const capacitorFileConfig: CapacitorElectronConfig = getCapacitorElectronConfig(

// Initialize our app. You can pass menu templates into the app here.
// const myCapacitorApp = new ElectronCapacitorApp(capacitorFileConfig);
const myCapacitorApp = new ElectronCapacitorApp(capacitorFileConfig, trayMenuTemplate, appMenuBarMenuTemplate);
// const myCapacitorApp = new ElectronCapacitorApp(capacitorFileConfig, trayMenuTemplate, appMenuBarMenuTemplate);
const myCapacitorApp = new ElectronCapacitorApp(capacitorFileConfig);

// If deeplinking is enabled then we will set it up here.
if (capacitorFileConfig.electron?.deepLinkingEnabled) {
Expand Down
10 changes: 5 additions & 5 deletions electron/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class ElectronCapacitorApp {
new MenuItem({ label: 'Quit App', role: 'quit' }),
];
private AppMenuBarMenuTemplate: (MenuItem | MenuItemConstructorOptions)[] = [
{ role: process.platform === 'darwin' ? 'appMenu' : 'fileMenu' },
{ role: 'viewMenu' },
// { role: process.platform === 'darwin' ? 'appMenu' : 'fileMenu' },
// { role: 'viewMenu' },
];
private mainWindowState;
private loadWebApp;
Expand Down Expand Up @@ -224,10 +224,10 @@ export function setupContentSecurityPolicy(customScheme: string): void {
...details.responseHeaders,
'Content-Security-Policy': [
electronIsDev
? `default-src ${customScheme}://* 'unsafe-inline' devtools://* 'unsafe-eval' data:`
: `default-src ${customScheme}://* 'unsafe-inline' data:`,
? `default-src ${customScheme}://* 'unsafe-inline' devtools://* 'unsafe-eval' data:; connect-src *`
: `default-src ${customScheme}://* 'unsafe-inline' data:; connect-src *`,
],
},
});
});
}
}
131 changes: 130 additions & 1 deletion src/components/chart-configs/specificTeam/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ export const autoPathPerRoundConfig = (scoutingData, teamNumber) => ({
stacked: true,
name: 'Midline 1 (Amp Edge)',
},
{
key: 'Path9',
label: 'Path 9',
color: '#82b5d8',
stacked: true,
name: 'Other',
},
{
key: 'Path10',
label: 'Path 10',
color: '#c4162a',
stacked: true,
name: "Didn't Move",
}
],
chartSettings: {
showGridlines: true,
Expand All @@ -286,6 +300,7 @@ export const autoPathPerRoundConfig = (scoutingData, teamNumber) => ({
yAxisLabel: 'Autonomous Path Taken',
yAxisMin: 0,
yAxisMax: 1,
xAxisLabel: 'Round Number',
xAxisLabelRotation: 0,
showTooltip: true,
tooltipSettings: {
Expand All @@ -303,6 +318,57 @@ export const autoPathPerRoundConfig = (scoutingData, teamNumber) => ({
sortOrder: 'ascending',
});

export const actualVsExpectedConfig = (scoutingData, teamNumber) => ({
data: specificTeamFunctions.actualVsExpectedData(scoutingData, teamNumber),
title: `Actual vs. Expected Autonomous Scores for Team ${teamNumber}`,
scoringTypes: [
{
key: 'actualScore',
label: 'Actual Score',
color: '#73bf69',
name: 'Actual Score',
},
{
key: 'expectedScore',
label: 'Expected Score',
color: '#ff8042',
name: 'Expected Score',
},
{
key: 'deviation',
label: 'Deviation',
color: '#ff4444',
name: 'Score Deviation',
},
],
chartSettings: {
showGridlines: true,
gridlineColor: '#444444',
},
xKey: 'roundNumber',
yAxisLabel: 'Score',
yAxisMin: 'auto',
yAxisMax: 'auto',
xAxisLabel: 'Round Number',
xAxisLabelRotation: 0,
showTooltip: true,
tooltipSettings: {
backgroundColor: '#333333',
borderRadius: '8px',
fontSize: '0.875rem',
cursorColor: 'rgba(255, 255, 255, 0.1)',
},
showLegend: true,
interactiveLegend: true,
legendPosition: 'top',
responsive: true,
maintainAspectRatio: true,
showDataLabels: true,
dataLabelPosition: 'inside',
dataLabelRotation: 0,
sortOrder: 'ascending',
});

export const autoPathUsagePieConfig = (scoutingData, teamNumber) => ({
data: specificTeamFunctions.autoPathPieData(scoutingData, teamNumber),
title: `Autonomous Path Usage Percentages for Team ${teamNumber}`,
Expand Down Expand Up @@ -355,6 +421,18 @@ export const autoPathUsagePieConfig = (scoutingData, teamNumber) => ({
color: '#d0ed57',
name: 'Midline 1 (Amp Edge)',
},
{
key: 'Path9',
label: 'Path 9',
color: '#82b5d8',
name: 'Other',
},
{
key: 'Path10',
label: 'Path 10',
color: '#c4162a',
name: "Didn't Move",
}
],
chartSettings: {
showTooltip: true,
Expand All @@ -371,7 +449,8 @@ export const autoPathUsagePieConfig = (scoutingData, teamNumber) => ({
maintainAspectRatio: true,
colors: [
'#8884d8', '#82ca9d', '#ff4444', '#ffc658',
'#ff8042', '#73bf69', '#a4de6c', '#d0ed57'
'#ff8042', '#73bf69', '#a4de6c', '#d0ed57',
'#82b5d8', '#c4162a'
],
showLabels: true,
labelPosition: 'outside',
Expand Down Expand Up @@ -792,6 +871,7 @@ export const endgameClimbDataPerRoundConfig = (scoutingData, teamNumber) => ({
yAxisMin: 0,
yAxisMax: 1,
xAxisLabelRotation: 0,
xAxisLabel: 'Round Number',
showTooltip: true,
tooltipSettings: {
backgroundColor: '#333333',
Expand Down Expand Up @@ -901,6 +981,55 @@ export const trapPerRoundConfig = (scoutingData, teamNumber) => ({
dataLabelRotation: 0,
});

export const endgameTrapUsagePieConfig = (scoutingData, teamNumber) => ({
data: specificTeamFunctions.endgameTrapPieData(scoutingData, teamNumber),
title: `Endgame Trap Score for Team ${teamNumber}`,
scoringTypes: [
{
key: '0',
label: 'Note 0',
color: '#8884d8',
name: '0 Note',
},
{
key: '1',
label: 'Note 1',
color: '#82ca9d',
name: '1 Note',
},
{
key: '2',
label: 'Note 2',
color: '#ff4444',
name: '2 Note',
},
{
key: '3',
label: 'Note 3',
color: '#ffc658',
name: '3 Note',
},
],
chartSettings: {
showTooltip: true,
tooltipSettings: {
backgroundColor: '#333333',
borderRadius: '8px',
fontSize: '0.875rem',
textColor: '#ffffff',
cursorColor: 'rgba(255, 255, 255, 0.1)',
},
showLegend: true,
legendPosition: 'top',
legendLayout: 'horizontal',
maintainAspectRatio: true,
colors: ['#8884d8', '#82ca9d', '#ff4444', '#ffc658'],
showLabels: true,
labelPosition: 'outside',
},
responsive: true,
});

export const teamPerformanceRadarConfig = (scoutingData, teamNumber) => {
// Calculate the max values across all teams for each category
const maxSpeakerTeleOp = allTeamsFunctions.speakerTeleOpMax(scoutingData); // Max for Teleop Speaker Score
Expand Down
68 changes: 68 additions & 0 deletions src/components/chart-configs/specificTeam/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export function autoPathStackedData(scoutingData, teamNumber) {
Path6: entry.a_gp_Path === "6" ? 1 : 0,
Path7: entry.a_gp_Path === "7" ? 1 : 0,
Path8: entry.a_gp_Path === "8" ? 1 : 0,
Path9: entry.a_gp_Path === "9" ? 1 : 0,
Path10: entry.a_gp_Path === "10" ? 1 : 0,
};
});

Expand All @@ -173,6 +175,8 @@ export function autoPathPieData(scoutingData, teamNumber) {
Path6: 0,
Path7: 0,
Path8: 0,
Path9: 0,
Path10: 0,
};

teamData.forEach((entry) => {
Expand All @@ -184,6 +188,8 @@ export function autoPathPieData(scoutingData, teamNumber) {
pathCounts.Path6 += entry.a_gp_Path === "6" ? 1 : 0;
pathCounts.Path7 += entry.a_gp_Path === "7" ? 1 : 0;
pathCounts.Path8 += entry.a_gp_Path === "8" ? 1 : 0;
pathCounts.Path9 += entry.a_gp_Path === "9" ? 1 : 0;
pathCounts.Path10 += entry.a_gp_Path === "10" ? 1 : 0;
});

return Object.keys(pathCounts).map((pathKey) => ({
Expand Down Expand Up @@ -533,6 +539,33 @@ export function endgameTrapPerRound(scoutingData, teamNumber) {
return trapData;
}

export function endgameTrapPieData(scoutingData, teamNumber) {
const teamData = scoutingData.filter((entry) => entry.teamNumber === teamNumber);

if (!teamData.length) {
return [];
}

const trapCounts = {
'0': 0,
'1': 0,
'2': 0,
'3': 0,
};

teamData.forEach((entry) => {
const trapScore = entry.cn || 0; // assuming cn represents the trap score
if (trapScore >= 0 && trapScore <= 3) {
trapCounts[trapScore] += 1;
}
});

return Object.keys(trapCounts).map((trapKey) => ({
name: `${trapKey} Note`,
value: trapCounts[trapKey],
}));
}

export function speakerAutoAverage(scoutingData, teamNumber) {
const teamData = scoutingData.filter((entry) => entry.teamNumber === teamNumber);

Expand Down Expand Up @@ -638,4 +671,39 @@ export function maxEndPositionForMatch(scoutingData, teamNumber) {
}, 0);

return maxScore;
}


export function actualVsExpectedData(scoutingData, teamNumber) {
const expectedScoresByPath = {
Path1: 3, // Speaker 3 (Source Side)
Path2: 2, // Speaker 2 (Middle)
Path3: 1, // Speaker 1 (Amp Side)
Path4: 5, // Midline 5 (Source Edge)
Path5: 4, // Midline 4
Path6: 3, // Midline 3 (Middle)
Path7: 2, // Midline 2
Path8: 1, // Midline 1 (Amp Edge)
Path9: 1, // Other
Path10: 0, // Didn't Move
};
const teamData = scoutingData.filter((entry) => entry.teamNumber === teamNumber);

if (!teamData.length) { return []; }

return teamData.map((entry) => {
const roundNumber = entry.matchNumber;
const actualScore = entry.ausc || 0; // Autonomous Speaker Score

// Find the path taken and expected score
let pathTaken = Object.keys(expectedScoresByPath).find(path => entry.a_gp_Path === path.slice(4));
let expectedScore = expectedScoresByPath[pathTaken] || 0;

return {
roundNumber,
actualScore,
expectedScore,
deviation: actualScore - expectedScore // Calculate the deviation
};
});
}
5 changes: 4 additions & 1 deletion src/components/charts/MultiNumberDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ResponsiveContainer } from 'recharts';

const MultiNumberDisplay = ({ config }) => {
const defaultConfig = {
mainTitle: '', // New main title in config
mainTitle: '',
values: [
{
color: '#00acc1',
Expand Down Expand Up @@ -60,6 +60,9 @@ const MultiNumberDisplay = ({ config }) => {
</text>
</svg>
</ResponsiveContainer>
<p style={{ fontSize: '1.5rem', marginTop: '10px', color: '#ffffff' }}>
{`${percentage.toFixed(2)}%`}
</p>
</div>
);
})}
Expand Down
7 changes: 5 additions & 2 deletions src/components/charts/barChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ const CustomBarShape = (props) => {
gradient,
} = props;

const adjustedY = height < 0 ? y + height : y;
const adjustedHeight = Math.abs(height);

return (
<rect
x={x}
y={y}
y={adjustedY}
width={width}
height={height}
height={adjustedHeight}
fill={gradient ? `url(#${gradient})` : fill}
stroke={stroke}
strokeWidth={strokeWidth}
Expand Down
Loading

0 comments on commit 461c9ef

Please sign in to comment.