Skip to content

Commit

Permalink
Analysis
Browse files Browse the repository at this point in the history
- dependency upgrades
- added new Analysis
  • Loading branch information
H3rmt authored Jun 11, 2023
2 parents 7f95cf6 + 3abf135 commit 2adbe38
Show file tree
Hide file tree
Showing 19 changed files with 406 additions and 147 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ UI-Tests with vitest and testing-library

### Overview:
<img src="./img/overview.png">
<div style="display: flex;gap:10px">
<div style="display:flex;gap:10px;flex-direction:row;">
<img src="./img/overview_edit.png" style="width:calc(50% - 5px)">
<img src="./img/edit.png" style="width:calc(50% - 5px)">
<img src="./img/overview_edit_2.png" style="width:calc(50% - 5px)">
</div>

### New Grade Dialog
<img src="./img/new.png">
<img src="./img/new_grade.png">

### Analysis (beta)
<img src="./img/analysis.png">


### Settings
<img src="./img/settings.png">
<img src="./img/settings.png">
<img src="./img/settings_2.png">
Binary file added img/analysis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/edit.png
Binary file not shown.
Binary file removed img/new.png
Binary file not shown.
Binary file added img/new_grade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/overview_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/overview_edit_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/settings_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
"dependencies": {
"@emotion/react": "^11.10",
"@emotion/styled": "^11.10",
"@babel/core": "^7.21",
"@babel/core": "^7.21.4",

"@fontsource/roboto": "~4.5",
"@mui/icons-material": "~5.11",
"@mui/material": "~5.11",
"@mui/system": "~5.11",
"@mui/x-date-pickers": "~6.0",
"@mui/system": "~5.12.1",
"@mui/x-date-pickers": "~6.1.0",

"notistack": "^3.0",
"dayjs": "^1.11",
"zustand": "^4.3",
"zustand": "^4.3.7",
"zod": "^3.21",
"@tanstack/react-query": "^4.28",
"@tanstack/react-query": "^4.29.5",
"@tanstack/react-query-devtools": "^4.29",
"@tanstack/react-router": "0.0.1-beta.83",
"recharts": "^2.5",

"react": "18.2",
"react-dom": "18.2",

"typescript": "^5.0",
"typescript": "^5.0.3",
"vite": "^4.2",
"@vitejs/plugin-react-swc": "^3.2",
"@vitejs/plugin-react-swc": "^3.3.0",

"@tauri-apps/cli": "1.2.3",
"@tauri-apps/api": "1.2.0"
Expand Down
16 changes: 9 additions & 7 deletions src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "grades"
version = "0.4.3"
version = "0.5.0"
description = "tauri app to manage grades in school"
authors = ["H3rmt"]
edition = "2021"
Expand All @@ -17,7 +17,7 @@ members = [".", "entity", "migrations"]
[dependencies]
serde_json = "^1.0"
serde = { version = "^1.0", features = ["derive"] }
tauri = { version = "1.2.3", features = ["cli", "devtools", "fs-write-file", "path-all", "shell-open", "updater"] }
tauri = { version = "1.2.5", features = ["cli", "devtools", "fs-write-file", "path-all", "shell-open", "updater"] }
dirs = "^4.0.0"
tokio = { version = "^1.24", features = ["full"] }
sea-orm = { version = "0.11.0", features = ["sqlx-sqlite", "runtime-tokio-native-tls", "macros", "debug-print"] }
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ0ODhFRDEwQkFCODgyMTgKUldRWWdyaTZFTzJJUkd1VWQvZEt5eVFxRXViYnBnMkRUNUFwd3VmalU1bDBTU2RqL1dad29XVEQK",
"windows": {
"installMode": "basicUi"
"installMode": "passive"
}
},
"windows": [
{
"fullscreen": false,
"height": 500,
"height": 800,
"resizable": true,
"title": "Grades",
"width": 900
Expand Down
7 changes: 5 additions & 2 deletions src/Analysis/Analysis.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {Grid} from '@mui/material'
import SubjectsOverPeriods from './SubjectsOverPeriods'
import GradesSumm from './GradesSum'

export default function Component() {
return (<Grid container spacing={2} padding={2}>
<Grid item xs={12} sm={12} md={12} xl={6}>
<Grid key={0} item xs={12} sm={12} md={12} xl={6}>
<SubjectsOverPeriods/>
</Grid>

<Grid key={1} item xs={12} sm={12} md={12} xl={6}>
<GradesSumm/>
</Grid>
{/*<Grid item xs={12} sm={12} md={6} xl={6}>
<AnalysisBox title="TITLE">
INTERN
Expand Down
105 changes: 105 additions & 0 deletions src/Analysis/GradesSum/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {useGrades, useNoteRange, usePeriods} from '../../commands/get'
import {useEffect, useState} from 'react'
import {Chart, Data} from '../../components/Chart/Chart'
import {Period} from '../../entity'
import ReactQueryDataMultiple from '../../components/ReactQueryData/ReactQueryDataMultiple'
import {AnalysisBox} from '../../components/AnalysisBox/AnalysisBox'
import {Checkbox, FormControlLabel, FormGroup} from '@mui/material'
import {randColor} from '../../ts/utils'

type PeriodWithColor = Period & { color: string }

export default function GradesSumm() {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [grades, gradesS] = useGrades()

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [periods, periodsS] = usePeriods()

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [noteRange, noteRangeS] = useNoteRange()

const [periodsSelected, setPeriodsSelected] = useState<PeriodWithColor[]>([])

const [data, setData] = useState<Data[]>([])
const [max, setMax] = useState<number>(0)

useEffect(() => {
if (periodsSelected.length === 0 || grades === undefined || periods === undefined || noteRange === undefined)
return

// period: [grade: count]
const split: number[][] = []

// set 0 for each grade so that X axis is always same
// for (let i = noteRange.from; i <= noteRange.to; i++) {
// map.set(i, 0)
// }


grades.filter(grade => periodsSelected.find(s => s.id === grade.period) !== undefined)
.filter(grade => grade.grade !== null)
.forEach(grade =>
split[grade.period] ? // @ts-ignore (already filtered)
split[grade.period][grade.grade] ? // @ts-ignore (already filtered)
split[grade.period][grade.grade]++ : // @ts-ignore (already filtered)
(split[grade.period][grade.grade] = 1) : // @ts-ignore (already filtered)
(split[grade.period] = Array(grade.grade + 1).fill(0).map((_, i) => i === grade.grade ? 1 : 0))
)

// console.warn(split)

let max = 1

const data: Data[] = Array(noteRange.to - noteRange.from + 1).fill(0)
.map((_, note) => {
const d: { [key: string]: number } = {}

periodsSelected.forEach(period => {
// console.log('period', period, note, split, split[period.id], split[period.id][note])
d[period.name] = split[period.id][note]

if (split[period.id][note] > max)
max = split[period.id][note]
})

return {x: note, data: d}
})
.sort((a, b) => b.x - a.x)

// console.warn(data)

setMax(max)
setData(data)
}, [periodsSelected, grades, periods, noteRange])

return <ReactQueryDataMultiple<[Period[]]>
queries={[
{query: periodsS, data: periods},
]}
display={(d) => {
const periods = d[0]

return <AnalysisBox title="Grades Overview" top={[
<FormGroup>{
periods.map((period, index) =>
<FormControlLabel control={
<Checkbox checked={periodsSelected.find(s => s.id === period.id) !== undefined} onClick={() => {
if (periodsSelected.find(s => s.id === period.id) !== undefined)
setPeriodsSelected(periodsSelected.filter(s => s.id !== period.id))
else
setPeriodsSelected([...periodsSelected, Object.assign(period, {color: randColor()})])
}} key={index}/>
} label={period.name} sx={{padding: 1}}/>)
}
</FormGroup>
]}>{<Chart YAxisDomain={[0, max + 1]} data={data} lines={
periodsSelected.map(period => ({
name: period.name,
color: period.color,
}))
} height={400} width={600}></Chart>}
</AnalysisBox>
}}/>

}
2 changes: 1 addition & 1 deletion src/Analysis/SubjectsOverPeriods/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function SubjectsOverPeriods() {
.map(period => {
const d: { [key: string]: number } = {}

subjectsSelected.map(subject => {
subjectsSelected.forEach(subject => {
const grades = split[subject.id]?.[period.id]
if (grades === undefined)
return
Expand Down
12 changes: 6 additions & 6 deletions src/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export default function Component() {
const toast = useSnackbar()

const handleClickUpdate = () => {switch (updateState) {
case 'NONE':
case 'ERROR': {
setAskUpdate(true)
break
}
}
case 'NONE':
case 'ERROR': {
setAskUpdate(true)
break
}
}
}

useEffect(() => {
Expand Down
Loading

0 comments on commit 2adbe38

Please sign in to comment.