Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab9e5f6d19 | ||
|
|
71d2f59750 | ||
|
|
bdd53ca15b | ||
|
|
789d2ed6ca | ||
|
|
d4b7d0616e | ||
|
|
b5bd2e02d7 | ||
|
|
428b06f920 | ||
|
|
7d6f2a4ca0 | ||
|
|
2fe7600ef3 | ||
|
|
985b8ef315 | ||
|
|
956fdec7f5 | ||
|
|
d44a511a3d | ||
|
|
0aebb87210 | ||
|
|
9509f12d73 | ||
|
|
021031ced7 | ||
|
|
22a9199d9d |
@@ -1,12 +0,0 @@
|
||||
import type { ConfigFile } from '@rtk-query/codegen-openapi'
|
||||
|
||||
const config: ConfigFile = {
|
||||
schemaFile: 'https://platform.bro-js.ru/jrnl-bh/documentation/json',
|
||||
apiFile: './src/__data__/api/api.ts',
|
||||
apiImport: 'api',
|
||||
outputFile: './src/__data__/api/jrnl.ts',
|
||||
exportName: 'jrnlApi',
|
||||
hooks: true,
|
||||
}
|
||||
|
||||
export default config
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "journal.pl",
|
||||
"version": "3.5.0",
|
||||
"version": "3.6.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "journal.pl",
|
||||
"version": "3.5.0",
|
||||
"version": "3.6.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@brojs/cli": "^0.0.4-beta.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "journal.pl",
|
||||
"version": "3.5.0",
|
||||
"version": "3.6.3",
|
||||
"description": "bro-js platform journal ui repo",
|
||||
"main": "./src/index.tsx",
|
||||
"scripts": {
|
||||
@@ -19,7 +19,6 @@
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@rtk-query/codegen-openapi": "^1.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
||||
"@typescript-eslint/parser": "^7.4.0",
|
||||
"eslint": "^8.57.0",
|
||||
|
||||
@@ -53,10 +53,17 @@ export interface Lesson {
|
||||
id: string;
|
||||
name: string;
|
||||
students: User[];
|
||||
teachers: Teacher[];
|
||||
date: string;
|
||||
created: string;
|
||||
}
|
||||
|
||||
interface Teacher {
|
||||
sub: string;
|
||||
email_verified: boolean;
|
||||
preferred_username: string;
|
||||
}
|
||||
|
||||
export interface AccessCode {
|
||||
expires: string;
|
||||
lesson: Lesson;
|
||||
|
||||
@@ -14,7 +14,7 @@ export default (props) => <App {...props} />;
|
||||
|
||||
let rootElement: ReactDOM.Root
|
||||
|
||||
export const mount = async (Сomponent, element = document.getElementById('app')) => {
|
||||
export const mount = async (Component, element = document.getElementById('app')) => {
|
||||
let user = null;
|
||||
try {
|
||||
await keycloak.init({ onLoad: "login-required" });
|
||||
@@ -26,11 +26,11 @@ export const mount = async (Сomponent, element = document.getElementById('app')
|
||||
const store = createStore({ user });
|
||||
|
||||
rootElement = ReactDOM.createRoot(element);
|
||||
rootElement.render(<Сomponent store={store} />);
|
||||
rootElement.render(<Component store={store} />);
|
||||
|
||||
if(module.hot) {
|
||||
module.hot.accept('./app', ()=> {
|
||||
rootElement.render(<Сomponent store={store} />);
|
||||
rootElement.render(<Component store={store} />);
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import styled from '@emotion/styled'
|
||||
import { Box, Heading, Tooltip, Text } from '@chakra-ui/react'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
import { api } from '../../__data__/api/api'
|
||||
import { PageLoader } from '../../components/page-loader/page-loader'
|
||||
import { Box, Container, Heading } from '@chakra-ui/react'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
export const Attendance = () => {
|
||||
const { courseId } = useParams()
|
||||
@@ -22,26 +21,38 @@ export const Attendance = () => {
|
||||
if (!attendance) return null
|
||||
|
||||
const studentsMap = new Map()
|
||||
const teachersMap = new Map()
|
||||
|
||||
attendance.forEach((lesson) => {
|
||||
lesson.teachers?.map((teacher: any) => {
|
||||
teachersMap.set(teacher.sub, { id: teacher.sub, ...teacher, value: teacher.value || (teacher.family_name && teacher.given_name
|
||||
? `${teacher.family_name} ${teacher.given_name}`
|
||||
: teacher.name || teacher.email || teacher.preferred_username || teacher.family_name || teacher.given_name), })
|
||||
})
|
||||
|
||||
lesson.students.forEach((student) => {
|
||||
const current = studentsMap.get(student.sub) || {}
|
||||
|
||||
studentsMap.set(student.sub, {
|
||||
...student,
|
||||
value:
|
||||
student.family_name && student.given_name
|
||||
id: student.sub,
|
||||
value: current.value || (student.family_name && student.given_name
|
||||
? `${student.family_name} ${student.given_name}`
|
||||
: student.name || student.email,
|
||||
: student.name || student.email || student.preferred_username || student.family_name || student.given_name),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const compare = Intl.Collator('ru').compare
|
||||
|
||||
const students = [...studentsMap.values()]
|
||||
const taechers = [...teachersMap.values()]
|
||||
students.sort(({ family_name: name }, { family_name: nname }) =>
|
||||
compare(name, nname),
|
||||
)
|
||||
return {
|
||||
students,
|
||||
taechers,
|
||||
}
|
||||
}, [attendance])
|
||||
|
||||
@@ -58,25 +69,52 @@ export const Attendance = () => {
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{data.taechers.map(teacher => (
|
||||
<th id={teacher.id} key={teacher.id}>{teacher.value}</th>
|
||||
))}
|
||||
<th>Дата</th>
|
||||
<th>Название занятия</th>
|
||||
{data.students.map((student) => (
|
||||
<th key={student.sub}>{student.name}</th>
|
||||
<th id={student.id || student.sub} key={student.sub}>{student.name || student.value || 'Имя не определено'}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{attendance.map((lesson, index) => (
|
||||
<tr key={lesson.name}>
|
||||
{data?.taechers?.map((teacher) => {
|
||||
|
||||
const wasThere = Boolean(lesson.teachers) &&
|
||||
lesson?.teachers?.findIndex((u) => u.sub === teacher.sub) !== -1
|
||||
return (
|
||||
<td
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
backgroundColor: wasThere ? '#8ef78a' : '#e09797',
|
||||
}}
|
||||
key={teacher.sub}
|
||||
>
|
||||
{wasThere ? '+' : '-'}
|
||||
</td>
|
||||
)
|
||||
})}
|
||||
<td>{dayjs(lesson.date).format('DD.MM.YYYY')}</td>
|
||||
<td>{lesson.name}</td>
|
||||
<td>{<ShortText text={lesson.name} />}</td>
|
||||
|
||||
{data.students.map((st) => {
|
||||
const wasThere =
|
||||
lesson.students.findIndex((u) => u.sub === st.sub) !== -1
|
||||
return <td style={{
|
||||
textAlign: 'center',
|
||||
backgroundColor: wasThere ? '#8ef78a' : '#e09797',
|
||||
}} key={st.sub}>{wasThere ? '+' : '-'}</td>
|
||||
return (
|
||||
<td
|
||||
style={{
|
||||
textAlign: 'center',
|
||||
backgroundColor: wasThere ? '#8ef78a' : '#e09797',
|
||||
}}
|
||||
key={st.sub}
|
||||
>
|
||||
{wasThere ? '+' : '-'}
|
||||
</td>
|
||||
)
|
||||
})}
|
||||
</tr>
|
||||
))}
|
||||
@@ -86,3 +124,17 @@ export const Attendance = () => {
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
||||
const ShortText = ({ text }: { text: string }) => {
|
||||
const needShortText = text.length > 20
|
||||
|
||||
if (needShortText) {
|
||||
return (
|
||||
<Tooltip label="На страницу с лекциями" fontSize="12px" top="16px">
|
||||
<Text>{text.slice(0, 20)}...</Text>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
@@ -57,21 +57,27 @@ export const CourseCard = ({ course }: { course: Course }) => {
|
||||
<CourseDetails populatedCourse={populatedCourse.data} />
|
||||
)}
|
||||
|
||||
<Tooltip label="На страницу с лекциями" fontSize="12px" top="16px">
|
||||
<Button
|
||||
leftIcon={<LinkIcon />}
|
||||
as={ConnectedLink}
|
||||
variant="outline"
|
||||
colorScheme="blue"
|
||||
to={generatePath(
|
||||
`${getNavigationsValue('journal.main')}${getNavigationsValue('link.journal.attendance')}`,
|
||||
{ courseId: course.id },
|
||||
)}
|
||||
{getNavigationsValue('link.journal.attendance') && (
|
||||
<Tooltip
|
||||
label="На страницу с лекциями"
|
||||
fontSize="12px"
|
||||
top="16px"
|
||||
>
|
||||
<Box mt={3}></Box>
|
||||
Посещаемость
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Button
|
||||
leftIcon={<LinkIcon />}
|
||||
as={ConnectedLink}
|
||||
variant="outline"
|
||||
colorScheme="blue"
|
||||
to={generatePath(
|
||||
`${getNavigationsValue('journal.main')}${getNavigationsValue('link.journal.attendance')}`,
|
||||
{ courseId: course.id },
|
||||
)}
|
||||
>
|
||||
<Box mt={3}></Box>
|
||||
Посещаемость
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Stack>
|
||||
</CardBody>
|
||||
)}
|
||||
|
||||
@@ -24,6 +24,8 @@ import {
|
||||
StudentList,
|
||||
BreadcrumbsWrapper,
|
||||
} from './style'
|
||||
import { useAppSelector } from '../__data__/store'
|
||||
import { isTeacher } from '../utils/user'
|
||||
|
||||
export function getGravatarURL(email, user) {
|
||||
if (!email) return void 0
|
||||
@@ -37,6 +39,8 @@ export function getGravatarURL(email, user) {
|
||||
const LessonDetail = () => {
|
||||
const { lessonId, courseId } = useParams()
|
||||
const canvRef = useRef(null)
|
||||
const user = useAppSelector((s) => s.user)
|
||||
|
||||
const {
|
||||
isFetching,
|
||||
data: accessCode,
|
||||
@@ -45,6 +49,7 @@ const LessonDetail = () => {
|
||||
} = api.useCreateAccessCodeQuery(
|
||||
{ lessonId },
|
||||
{
|
||||
skip: !isTeacher(user),
|
||||
pollingInterval:
|
||||
Number(getConfigValue('journal.polling-interval')) || 3000,
|
||||
skipPollingIfUnfocused: true,
|
||||
@@ -144,7 +149,7 @@ const LessonDetail = () => {
|
||||
<QRCanvas ref={canvRef} />
|
||||
</a>
|
||||
<StudentList>
|
||||
{studentsArr.map((student) => (
|
||||
{isTeacher(user) && studentsArr.map((student) => (
|
||||
<UserCard
|
||||
wrapperAS="li"
|
||||
key={student.sub}
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
{
|
||||
"_id": "65e2e5fbec37fec650f28489",
|
||||
"name": "ВВЕДЕНИЕ В ВЕБ-РАЗРАБОТКУ. ИНСТРУМЕНТАРИЙ, ОБЗОР ВЕБ-ТЕХНОЛОГИЙ",
|
||||
"teachers": [
|
||||
{
|
||||
"sub": "f62905b1-e223-40ca-910f-c8d84c6137c1",
|
||||
"email_verified": true,
|
||||
"preferred_username": "primakov"
|
||||
}
|
||||
],
|
||||
"students": [
|
||||
{
|
||||
"sub": "fcde3f22-d9ba-412a-a572-c59e515a290f",
|
||||
|
||||
Reference in New Issue
Block a user