Skip to content

Commit

Permalink
Merge branch 'dev-channel'
Browse files Browse the repository at this point in the history
  • Loading branch information
saumon-brule committed Nov 14, 2024
2 parents 1dd1562 + e775675 commit 460db38
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 65 deletions.
32 changes: 17 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ecole-directe-plus",
"version": "0.4.0",
"version": "0.4.1",
"type": "module",
"description": "Ecole Directe plus is a React web app that is designed to replace and improve EcoleDirecte",
"dependencies": {
Expand All @@ -15,7 +15,7 @@
"react-content-loader": "^6.2.1",
"react-router-dom": "^6.16.0",
"uuid": "^9.0.1",
"vite": "^4.4.9"
"vite": "^4.5.5"
},
"scripts": {
"dev": "vite",
Expand Down
19 changes: 15 additions & 4 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function consoleLogEDPLogo() {

consoleLogEDPLogo();

const currentEDPVersion = "0.4.0";
const currentEDPVersion = "0.4.1";
const apiVersion = "4.64.0";

// secret webhooks
Expand Down Expand Up @@ -112,7 +112,8 @@ const defaultSettings = {
shareSettings: true,
negativeBadges: false,
allowAnonymousReports: true,
isDevChannel: false
isDevChannel: false,
selectedChart: 0
}

const browserExtensionDownloadLink = {
Expand Down Expand Up @@ -168,6 +169,10 @@ function initSettings(accountList) {
value: getSetting("displayMode", i),
values: ["quality", "balanced", "performance"]
},
selectedChart: {
value: getSetting("selectedChart", i),
values: [0, 1, 2]
},
isSepiaEnabled: {
value: getSetting("isSepiaEnabled", i),
},
Expand Down Expand Up @@ -391,7 +396,7 @@ export default function App({ edpFetch }) {
> Value of displayTheme of current user
You can pass the setting you wan in arguments of useUserSettings
You can pass the setting you want in arguments of useUserSettings
EX :
userDisplayTheme = useUserSettings("displayTheme")
Expand Down Expand Up @@ -644,6 +649,12 @@ export default function App({ edpFetch }) {
document.documentElement.style.fontSize = newFontSize + "em";
}
}
} else if (window.innerHeight < 900) {
if (window.innerHeight >= 650) {
document.documentElement.style.zoom = (.35 / 350) * window.innerHeight + .1;
} else {
document.documentElement.style.zoom = .75;
}
} else {
document.documentElement.style.fontSize = "";
document.documentElement.style.zoom = "";
Expand Down Expand Up @@ -2754,4 +2765,4 @@ export default function App({ edpFetch }) {
</Suspense>
</AppContext.Provider>
);
}
}
2 changes: 1 addition & 1 deletion src/components/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default function Root({ currentEDPVersion, token, accountsList, fakeLogin
return 0;
} else {
localStorage.clear();
localStorage.setItem("EDPVersion", currentEDPVersion);
}
}

Expand All @@ -103,7 +104,6 @@ export default function Root({ currentEDPVersion, token, accountsList, fakeLogin
setIsNewUser(true);
} else {
localStorage.setItem("EDPVersion", currentEDPVersion);
setIsNewEDPVersion(true);
necessaryResets(localStorage.getItem("EDPVersion"));
}
} else {
Expand Down
83 changes: 45 additions & 38 deletions src/components/app/Grades/Charts.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@

import { useState, useEffect, useRef, useContext } from "react";
// import { Chart } from 'chart.js';
import { applyZoom, getZoomedBoudingClientRect } from "../../../utils/zoom";


import "./Charts.css";
import DropDownMenu from "../../generic/UserInputs/DropDownMenu";


import { AppContext } from "../../../App";

export default function Charts({ selectedPeriod }) {
Expand All @@ -18,8 +15,12 @@ export default function Charts({ selectedPeriod }) {
* 2: Subjects average | radar
*/

// States
const [chartType, setChartType] = useState(0);
// States

const { useUserSettings } = useContext(AppContext);

const settings = useUserSettings()
const [selectedChart, setSelectedChart] = useState(settings.get("selectedChart"));

const chartContainerRef = useRef(null);
const canvasContainerRef = useRef(null);
Expand All @@ -40,7 +41,6 @@ export default function Charts({ selectedPeriod }) {
}

useEffect(() => {

window.addEventListener("resize", resizeChart);
resizeChart();

Expand All @@ -49,16 +49,15 @@ export default function Charts({ selectedPeriod }) {
}
}, [])


function getChartData() {
/**
* return the appropriate dataset according to the chartType
* return the appropriate dataset according to the selectedChart
*/
const userData = useUserData();
const minMaxEnabled = userData.get("gradesEnabledFeatures")?.moyenneMin && userData.get("gradesEnabledFeatures")?.moyenneMax;


switch (chartType) {
switch (selectedChart) {
case 0:
// General average + streak history | line
chartOptions.current = {
Expand All @@ -71,17 +70,17 @@ export default function Charts({ selectedPeriod }) {
suggestedMax: 20
},
// y1: {
// type: 'linear',
// display: true,
// position: 'right',
// suggestedMax: 20
// type: 'linear',
// display: true,
// position: 'right',
// suggestedMax: 20
// }
// xAxes: [{
// type: 'time',
// ticks: {
// autoSkip: true,
// maxTicksLimit: 20
// }
// type: 'time',
// ticks: {
// autoSkip: true,
// maxTicksLimit: 20
// }
// }]
},
interaction: {
Expand Down Expand Up @@ -179,24 +178,24 @@ export default function Charts({ selectedPeriod }) {
order: 1,
},
// {
// type: "line",
// label: "Moyennes max classe",
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.maxAverage),
// borderColor: 'rgb(53, 162, 235)',
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
// tension: 0.2,
// // yAxisID: "y1"
// order: 2,
// type: "line",
// label: "Moyennes max classe",
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.maxAverage),
// borderColor: 'rgb(53, 162, 235)',
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
// tension: 0.2,
// // yAxisID: "y1"
// order: 2,
// },
// {
// type: "line",
// label: "Moyennes min classe",
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.minAverage),
// borderColor: 'rgb(53, 162, 235)',
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
// tension: 0.2,
// // yAxisID: "y1"
// order: 3,
// type: "line",
// label: "Moyennes min classe",
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.minAverage),
// borderColor: 'rgb(53, 162, 235)',
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
// tension: 0.2,
// // yAxisID: "y1"
// order: 3,
// },
],
};
Expand All @@ -214,7 +213,7 @@ export default function Charts({ selectedPeriod }) {
beginAtZero: true,
suggestedMax: 20,
grid: {
color: actualDisplayTheme == "dark" ? "rgba(180, 180, 240, .4)" : "rgba(76, 76, 184, .4)"
color: actualDisplayTheme == "dark" ? "rgba(180, 180, 240, .4)" : "rgba(76, 76, 184, .4)"
}
}
},
Expand Down Expand Up @@ -308,9 +307,9 @@ export default function Charts({ selectedPeriod }) {
}

useEffect(() => {
console.log(chartType);
refreshChart();
}, [chartType, activeAccount, selectedPeriod]);
useUserSettings("selectedChart").set(selectedChart);
}, [selectedChart, activeAccount, selectedPeriod]);

useEffect(() => {
const script = document.createElement("script");
Expand All @@ -330,7 +329,15 @@ export default function Charts({ selectedPeriod }) {
return (
<div id="charts">
<div className="top-container">
<DropDownMenu name="chart-type" options={[0, 1, 2]} displayedOptions={["Moyenne générale Courbe", "Moyennes par matière Barres", "Moyennes par matière Radar"]} selected={chartType} onChange={(value) => setChartType(parseInt(value))} />
<DropDownMenu
name="chart-type"
options={[0, 1, 2]}
displayedOptions={["Moyenne générale Courbe", "Moyennes par matière Barres", "Moyennes par matière Radar"]}
selected={selectedChart}
onChange={(value) => {
setSelectedChart(parseInt(value));
}}
/>
<h3>Graphiques</h3>
<div className="artificial-horizontal-center"></div>
</div>
Expand Down
Loading

0 comments on commit 460db38

Please sign in to comment.