17 Commits

Author SHA1 Message Date
Primakov Alexandr Alexandrovich
c1311f351c 3.6.8 2025-01-08 18:39:22 +03:00
Primakov Alexandr Alexandrovich
c2fe846c5b fix getNavigationValue name 2025-01-08 18:39:18 +03:00
Primakov Alexandr Alexandrovich
81533c3342 3.6.7 2025-01-08 18:33:10 +03:00
Primakov Alexandr Alexandrovich
462ba85fe8 check exam link to render 2025-01-08 18:33:02 +03:00
Primakov Alexandr Alexandrovich
d0f7dfb87d login required back
All checks were successful
platform/bro-js/journal.pl/pipeline/head This commit looks good
2025-01-07 18:09:54 +03:00
Primakov Alexandr Alexandrovich
a133cea95c 3.6.6 2025-01-07 18:04:01 +03:00
Primakov Alexandr Alexandrovich
4704b404f9 update ts config 2025-01-07 17:00:37 +03:00
Primakov Alexandr Alexandrovich
55d23f1e47 twik a bit 2025-01-07 16:57:37 +03:00
Primakov Alexandr Alexandrovich
6b07fef62f up kc js version 2025-01-07 16:49:55 +03:00
Primakov Alexandr Alexandrovich
3242576a12 check sso 2 debug 2025-01-07 16:42:04 +03:00
Primakov Alexandr Alexandrovich
a7168231a1 kc params from env 2025-01-07 16:20:20 +03:00
Primakov Alexandr Alexandrovich
cc7f3d3371 3.6.5
All checks were successful
platform/bro-js/journal.pl/pipeline/head This commit looks good
2024-12-21 16:19:32 +03:00
Primakov Alexandr Alexandrovich
d20cb7257b 3.6.4 2024-12-21 16:16:40 +03:00
Primakov Alexandr Alexandrovich
ab9e5f6d19 3.6.3
All checks were successful
platform/bro-js/journal.pl/pipeline/head This commit looks good
2024-12-15 20:35:48 +03:00
Primakov Alexandr Alexandrovich
71d2f59750 teachers in Attendance 2024-12-15 20:35:39 +03:00
Primakov Alexandr Alexandrovich
bdd53ca15b 3.6.2 2024-12-15 17:20:20 +03:00
Primakov Alexandr Alexandrovich
789d2ed6ca manual add for teacher only 2024-12-15 17:20:16 +03:00
13 changed files with 2007 additions and 3792 deletions

24
@types/index.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
declare const IS_PROD: string
declare const KC_URL: string
declare const KC_REALM: string
declare const KC_CLIENT_ID: string
declare module '*.svg' {
const value: string
export default value
}
declare module '*.jpg' {
const value: string
export default value
}
declare module '*.png' {
const value: string
export default value
}
declare const __webpack_public_path__: string

View File

@@ -1,3 +1,5 @@
const webpack = require('webpack');
const pkg = require('./package')
module.exports = {
@@ -6,6 +8,13 @@ module.exports = {
output: {
publicPath: `/static/${pkg.name}/${process.env.VERSION || pkg.version}/`,
},
plugins: [
new webpack.DefinePlugin({
KC_URL: process.env.KC_URL || '"https://kc.bro-js.ru"',
KC_REALM: process.env.KC_REALM || '"bro-js"',
KC_CLIENT_ID: process.env.KC_CLIENT_ID || '"microfrontend-admin"',
}),
],
},
navigations: {
'journal.main': '/journal.pl',

6
index.d.ts vendored
View File

@@ -1,6 +0,0 @@
declare module '*.svg' {
const src: string;
export default src;
}
declare const __webpack_public_path__: string;

5650
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "journal.pl",
"version": "3.6.1",
"version": "3.6.8",
"description": "bro-js platform journal ui repo",
"main": "./src/index.tsx",
"scripts": {
@@ -25,7 +25,7 @@
"eslint-plugin-react": "^7.34.1"
},
"dependencies": {
"@brojs/cli": "^0.0.4-beta.0",
"@brojs/cli": "^1.8.4",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.4",
@@ -37,7 +37,7 @@
"dayjs": "^1.11.10",
"express": "^4.19.2",
"js-sha256": "^0.11.0",
"keycloak-js": "^23.0.7",
"keycloak-js": "^26.0.7",
"prettier": "^3.2.5",
"qrcode": "^1.5.3",
"react": "^18.3.1",

View File

@@ -1,9 +1,9 @@
import Keycloak from 'keycloak-js';
import Keycloak from 'keycloak-js'
export const keycloak = new Keycloak({
url: 'https://kc.bro-js.ru',
realm: 'bro-js',
clientId: 'journal'
url: KC_URL,
realm: KC_REALM,
clientId: KC_CLIENT_ID,
});
window.keycloak = keycloak;
(window as any).kc = keycloak

View File

@@ -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;

View File

@@ -17,11 +17,18 @@ let rootElement: ReactDOM.Root
export const mount = async (Component, element = document.getElementById('app')) => {
let user = null;
try {
await keycloak.init({ onLoad: "login-required" });
user = { ...(await keycloak.loadUserInfo()), ...keycloak.tokenParsed };
await keycloak.init({ onLoad: 'login-required' })
const userInfo = await keycloak.loadUserInfo()
if (userInfo && keycloak.tokenParsed) {
user = { ...userInfo, ...keycloak.tokenParsed }
} else {
console.error('No userInfo or tokenParsed', userInfo, keycloak.tokenParsed)
}
} catch (error) {
console.error("Failed to initialize adapter:", error);
keycloak.login();
console.error('Failed to initialize adapter:', error)
keycloak.login()
}
const store = createStore({ user });

View File

@@ -21,8 +21,15 @@ 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) || {}
@@ -39,11 +46,13 @@ export const Attendance = () => {
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])
@@ -60,6 +69,9 @@ 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) => (
@@ -70,6 +82,22 @@ export const Attendance = () => {
<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>{<ShortText text={lesson.name} />}</td>

View File

@@ -1,7 +1,7 @@
import React from 'react'
import dayjs from 'dayjs'
import { Link as ConnectedLink } from 'react-router-dom'
import { getNavigationsValue, getHistory } from '@brojs/cli'
import { getNavigationValue, getHistory } from '@brojs/cli'
import { Stack, Heading, Link, Button, Tooltip, Box } from '@chakra-ui/react'
import { useAppSelector } from '../../__data__/store'
@@ -27,23 +27,23 @@ export const CourseDetails = ({ populatedCourse }: CourseDetailsProps) => {
{isTeacher(user) && (
<Heading as="h3" mt={4} mb={3} size="lg">
Экзамен: {exam?.name}{' '}
{exam && (
{exam && getNavigationValue('exam.main') && getNavigationValue('link.exam.details') && (
<Tooltip label="Начать экзамен" fontSize="12px" top="16px">
<Button
leftIcon={<LinkIcon />}
as={'a'}
colorScheme="blue"
href={
getNavigationsValue('exam.main') +
getNavigationsValue('link.exam.details')
getNavigationValue('exam.main') +
getNavigationValue('link.exam.details')
.replace(':courseId', populatedCourse.id)
.replace(':examId', exam.id)
}
onClick={(event) => {
event.preventDefault()
history.push(
getNavigationsValue('exam.main') +
getNavigationsValue('link.exam.details')
getNavigationValue('exam.main') +
getNavigationValue('link.exam.details')
.replace(':courseId', populatedCourse.id)
.replace(':examId', exam.id),
)
@@ -95,7 +95,7 @@ export const CourseDetails = ({ populatedCourse }: CourseDetailsProps) => {
key={lesson.id}
to={
isTeacher(user)
? `${getNavigationsValue('journal.main')}/lesson/${populatedCourse.id}/${lesson.id}`
? `${getNavigationValue('journal.main')}/lesson/${populatedCourse.id}/${lesson.id}`
: ''
}
>

View File

@@ -149,7 +149,7 @@ const LessonDetail = () => {
<QRCanvas ref={canvRef} />
</a>
<StudentList>
{studentsArr.map((student) => (
{isTeacher(user) && studentsArr.map((student) => (
<UserCard
wrapperAS="li"
key={student.sub}

View File

@@ -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",

View File

@@ -1,25 +1,26 @@
{
"compilerOptions": {
"lib": [
"dom",
"es2017"
],
"lib": ["dom", "es2017"],
"outDir": "./dist/",
"sourceMap": true,
"esModuleInterop": true,
"noImplicitAny": false,
"module": "esnext",
"moduleResolution": "node",
"target": "es6",
"jsx": "react",
"typeRoots": ["node_modules/@types", "src/typings"],
"types" : ["webpack-env", "node"],
"resolveJsonModule": true
"typeRoots": ["node_modules/@types", "./@types"],
"types": ["webpack-env", "node"],
"resolveJsonModule": true,
"moduleResolution": "Bundler",
"skipLibCheck": true,
},
"types": [
"@types/*"
],
"exclude": [
"node_modules",
"**/*.test.ts",
"**/*.test.tsx",
"node_modules/@types/jest"
]
}
]
}