Skip to content

Commit 460db38

Browse files
committed
Merge branch 'dev-channel'
2 parents 1dd1562 + e775675 commit 460db38

File tree

7 files changed

+146
-65
lines changed

7 files changed

+146
-65
lines changed

package-lock.json

Lines changed: 17 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ecole-directe-plus",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"type": "module",
55
"description": "Ecole Directe plus is a React web app that is designed to replace and improve EcoleDirecte",
66
"dependencies": {
@@ -15,7 +15,7 @@
1515
"react-content-loader": "^6.2.1",
1616
"react-router-dom": "^6.16.0",
1717
"uuid": "^9.0.1",
18-
"vite": "^4.4.9"
18+
"vite": "^4.5.5"
1919
},
2020
"scripts": {
2121
"dev": "vite",

src/App.jsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function consoleLogEDPLogo() {
7070

7171
consoleLogEDPLogo();
7272

73-
const currentEDPVersion = "0.4.0";
73+
const currentEDPVersion = "0.4.1";
7474
const apiVersion = "4.64.0";
7575

7676
// secret webhooks
@@ -112,7 +112,8 @@ const defaultSettings = {
112112
shareSettings: true,
113113
negativeBadges: false,
114114
allowAnonymousReports: true,
115-
isDevChannel: false
115+
isDevChannel: false,
116+
selectedChart: 0
116117
}
117118

118119
const browserExtensionDownloadLink = {
@@ -168,6 +169,10 @@ function initSettings(accountList) {
168169
value: getSetting("displayMode", i),
169170
values: ["quality", "balanced", "performance"]
170171
},
172+
selectedChart: {
173+
value: getSetting("selectedChart", i),
174+
values: [0, 1, 2]
175+
},
171176
isSepiaEnabled: {
172177
value: getSetting("isSepiaEnabled", i),
173178
},
@@ -391,7 +396,7 @@ export default function App({ edpFetch }) {
391396
> Value of displayTheme of current user
392397
393398
394-
You can pass the setting you wan in arguments of useUserSettings
399+
You can pass the setting you want in arguments of useUserSettings
395400
396401
EX :
397402
userDisplayTheme = useUserSettings("displayTheme")
@@ -644,6 +649,12 @@ export default function App({ edpFetch }) {
644649
document.documentElement.style.fontSize = newFontSize + "em";
645650
}
646651
}
652+
} else if (window.innerHeight < 900) {
653+
if (window.innerHeight >= 650) {
654+
document.documentElement.style.zoom = (.35 / 350) * window.innerHeight + .1;
655+
} else {
656+
document.documentElement.style.zoom = .75;
657+
}
647658
} else {
648659
document.documentElement.style.fontSize = "";
649660
document.documentElement.style.zoom = "";
@@ -2754,4 +2765,4 @@ export default function App({ edpFetch }) {
27542765
</Suspense>
27552766
</AppContext.Provider>
27562767
);
2757-
}
2768+
}

src/components/Root.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default function Root({ currentEDPVersion, token, accountsList, fakeLogin
9393
return 0;
9494
} else {
9595
localStorage.clear();
96+
localStorage.setItem("EDPVersion", currentEDPVersion);
9697
}
9798
}
9899

@@ -103,7 +104,6 @@ export default function Root({ currentEDPVersion, token, accountsList, fakeLogin
103104
setIsNewUser(true);
104105
} else {
105106
localStorage.setItem("EDPVersion", currentEDPVersion);
106-
setIsNewEDPVersion(true);
107107
necessaryResets(localStorage.getItem("EDPVersion"));
108108
}
109109
} else {

src/components/app/Grades/Charts.jsx

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
21
import { useState, useEffect, useRef, useContext } from "react";
32
// import { Chart } from 'chart.js';
43
import { applyZoom, getZoomedBoudingClientRect } from "../../../utils/zoom";
54

6-
75
import "./Charts.css";
86
import DropDownMenu from "../../generic/UserInputs/DropDownMenu";
97

10-
118
import { AppContext } from "../../../App";
129

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

21-
// States
22-
const [chartType, setChartType] = useState(0);
18+
// States
19+
20+
const { useUserSettings } = useContext(AppContext);
21+
22+
const settings = useUserSettings()
23+
const [selectedChart, setSelectedChart] = useState(settings.get("selectedChart"));
2324

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

4243
useEffect(() => {
43-
4444
window.addEventListener("resize", resizeChart);
4545
resizeChart();
4646

@@ -49,16 +49,15 @@ export default function Charts({ selectedPeriod }) {
4949
}
5050
}, [])
5151

52-
5352
function getChartData() {
5453
/**
55-
* return the appropriate dataset according to the chartType
54+
* return the appropriate dataset according to the selectedChart
5655
*/
5756
const userData = useUserData();
5857
const minMaxEnabled = userData.get("gradesEnabledFeatures")?.moyenneMin && userData.get("gradesEnabledFeatures")?.moyenneMax;
5958

6059

61-
switch (chartType) {
60+
switch (selectedChart) {
6261
case 0:
6362
// General average + streak history | line
6463
chartOptions.current = {
@@ -71,17 +70,17 @@ export default function Charts({ selectedPeriod }) {
7170
suggestedMax: 20
7271
},
7372
// y1: {
74-
// type: 'linear',
75-
// display: true,
76-
// position: 'right',
77-
// suggestedMax: 20
73+
// type: 'linear',
74+
// display: true,
75+
// position: 'right',
76+
// suggestedMax: 20
7877
// }
7978
// xAxes: [{
80-
// type: 'time',
81-
// ticks: {
82-
// autoSkip: true,
83-
// maxTicksLimit: 20
84-
// }
79+
// type: 'time',
80+
// ticks: {
81+
// autoSkip: true,
82+
// maxTicksLimit: 20
83+
// }
8584
// }]
8685
},
8786
interaction: {
@@ -179,24 +178,24 @@ export default function Charts({ selectedPeriod }) {
179178
order: 1,
180179
},
181180
// {
182-
// type: "line",
183-
// label: "Moyennes max classe",
184-
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.maxAverage),
185-
// borderColor: 'rgb(53, 162, 235)',
186-
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
187-
// tension: 0.2,
188-
// // yAxisID: "y1"
189-
// order: 2,
181+
// type: "line",
182+
// label: "Moyennes max classe",
183+
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.maxAverage),
184+
// borderColor: 'rgb(53, 162, 235)',
185+
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
186+
// tension: 0.2,
187+
// // yAxisID: "y1"
188+
// order: 2,
190189
// },
191190
// {
192-
// type: "line",
193-
// label: "Moyennes min classe",
194-
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.minAverage),
195-
// borderColor: 'rgb(53, 162, 235)',
196-
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
197-
// tension: 0.2,
198-
// // yAxisID: "y1"
199-
// order: 3,
191+
// type: "line",
192+
// label: "Moyennes min classe",
193+
// data: subjectsComparativeInformation[selectedPeriod].map((subject) => subject.minAverage),
194+
// borderColor: 'rgb(53, 162, 235)',
195+
// backgroundColor: 'rgba(53, 162, 235, 0.5)',
196+
// tension: 0.2,
197+
// // yAxisID: "y1"
198+
// order: 3,
200199
// },
201200
],
202201
};
@@ -214,7 +213,7 @@ export default function Charts({ selectedPeriod }) {
214213
beginAtZero: true,
215214
suggestedMax: 20,
216215
grid: {
217-
color: actualDisplayTheme == "dark" ? "rgba(180, 180, 240, .4)" : "rgba(76, 76, 184, .4)"
216+
color: actualDisplayTheme == "dark" ? "rgba(180, 180, 240, .4)" : "rgba(76, 76, 184, .4)"
218217
}
219218
}
220219
},
@@ -308,9 +307,9 @@ export default function Charts({ selectedPeriod }) {
308307
}
309308

310309
useEffect(() => {
311-
console.log(chartType);
312310
refreshChart();
313-
}, [chartType, activeAccount, selectedPeriod]);
311+
useUserSettings("selectedChart").set(selectedChart);
312+
}, [selectedChart, activeAccount, selectedPeriod]);
314313

315314
useEffect(() => {
316315
const script = document.createElement("script");
@@ -330,7 +329,15 @@ export default function Charts({ selectedPeriod }) {
330329
return (
331330
<div id="charts">
332331
<div className="top-container">
333-
<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))} />
332+
<DropDownMenu
333+
name="chart-type"
334+
options={[0, 1, 2]}
335+
displayedOptions={["Moyenne générale Courbe", "Moyennes par matière Barres", "Moyennes par matière Radar"]}
336+
selected={selectedChart}
337+
onChange={(value) => {
338+
setSelectedChart(parseInt(value));
339+
}}
340+
/>
334341
<h3>Graphiques</h3>
335342
<div className="artificial-horizontal-center"></div>
336343
</div>

0 commit comments

Comments
 (0)