Compare commits

...

2 Commits

Author SHA1 Message Date
DmitriyB 240f28935d ui update progress 2023-03-07 15:59:17 +05:00
DmitriyB 4107a85a4d ui upddate ... 2023-03-07 15:58:56 +05:00
21 changed files with 161 additions and 35 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
"popup-control-btn-active": "Ссылка скопирована", "popup-control-btn-active": "Ссылка скопирована",
"language-control-btn": "Русский язык", "language-control-btn": "Русский язык",
"exit-control-btn": "Выйти", "exit-control-btn": "Выйти",
"popup-control-exit-title": "Вы уверены, что хотите закончить демонстрацию??", "popup-control-exit-title": "Вы уверены, что хотите закончить демонстрацию?",
"popup-control-yes": "Закончить", "popup-control-yes": "Закончить",
"popup-control-no": "Остаться" "popup-control-no": "Остаться"
+7
View File
@@ -28,7 +28,9 @@
.card-container { .card-container {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap;
gap: 30px; gap: 30px;
margin-bottom: 128px;
} }
.card-title { .card-title {
@@ -61,12 +63,14 @@
.card-container { .card-container {
gap: 24px; gap: 24px;
margin-bottom: 76px;
} }
} }
@media screen and (max-width: 1152px) { @media screen and (max-width: 1152px) {
.card-container { .card-container {
gap: 20px; gap: 20px;
} }
.card-title { .card-title {
@@ -77,6 +81,8 @@
@media screen and (max-width: 1024px) { @media screen and (max-width: 1024px) {
.card-container { .card-container {
gap: 10px; gap: 10px;
margin-bottom: 10px;
} }
} }
@@ -92,6 +98,7 @@
.card-container { .card-container {
flex-direction: column; flex-direction: column;
gap: 10px; gap: 10px;
margin-bottom: 115px;
} }
.content__container { .content__container {
+8 -4
View File
@@ -22,9 +22,10 @@ const App: React.FC = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const history = useHistory(); const history = useHistory();
const { handleCurrentCard } = cardSlice.actions; const { handleCurrentCard } = cardSlice.actions;
const { cards, currentCard } = useAppSelector((state) => state.cardReducer); const { cards, currentCard, error } = useAppSelector((state) => state.cardReducer);
const { isLoading } = useAppSelector((state) => state.sessionReducer)
const { currentLang } = useAppSelector((state) => state.languageReducer); const { currentLang } = useAppSelector((state) => state.languageReducer);
console.log(error)
useEffect(() => { useEffect(() => {
dispatch(fetchCards(cookies.get("i18next"))); dispatch(fetchCards(cookies.get("i18next")));
@@ -45,11 +46,13 @@ const App: React.FC = () => {
const { t } = useTranslation(); const { t } = useTranslation();
console.log(isLoading, 'LOADING')
return ( return (
<Switch> <Switch>
<Route exact path="/"> <Route exact path="/">
<div className="main"> <div className="main">
<h2 className="card-title">{t("demo-title")}</h2> <h2 className="card-title">{error ? error : t("demo-title")}</h2>
<div className="card-container"> <div className="card-container">
{cards.map((i: ICards) => ( {cards.map((i: ICards) => (
<Card onClick={() => handleCards(i)} key={i._id} item={i}></Card> <Card onClick={() => handleCards(i)} key={i._id} item={i}></Card>
@@ -60,7 +63,8 @@ const App: React.FC = () => {
<Route path="/connect-page"> <Route path="/connect-page">
{currentCard ? ( {currentCard ? (
<div className="background"> <div className="background">
<Header></Header> {isLoading && (<Header></Header>
)}
<div className="popup-container"> <div className="popup-container">
<div className="content__container"> <div className="content__container">
<PopupComponent></PopupComponent> <PopupComponent></PopupComponent>
@@ -53,7 +53,7 @@ export const PopupComponent: React.FC = () => {
<PopupConnect <PopupConnect
isLoading={true} isLoading={true}
logo={currentCard.logo} logo={currentCard.logo}
onConnect={() => dispatch(createSession(currentCard.title))} onConnect={() => dispatch(createSession(currentCard.app_title))}
></PopupConnect> ></PopupConnect>
</motion.div> </motion.div>
)} )}
+1 -1
View File
@@ -14,7 +14,7 @@ export const Card: React.FC<any> = ({ item, onClick }) => {
<div className="card-header"> <div className="card-header">
<img src={item.icon} className="card-icon" alt="лого" /> <img src={item.icon} className="card-icon" alt="лого" />
<div className="card-name"> <div className="card-name">
<h2 className="caption-name">{item.app_title}</h2> <h2 className="caption-name">{item.title}</h2>
<h2 className="card-location">{item.location}</h2> <h2 className="card-location">{item.location}</h2>
</div> </div>
</div> </div>
+6 -4
View File
@@ -5,9 +5,10 @@ import { planSlice } from "store/reducers/planSlice";
import useFormWithValidation from "hooks/useFormWithValidation"; import useFormWithValidation from "hooks/useFormWithValidation";
import { useAppDispatch, useAppSelector } from "hooks/redux"; import { useAppDispatch, useAppSelector } from "hooks/redux";
import { useEffect, useState } from "react"; import { useEffect, useRef, useState } from "react";
export const Form: React.FC<any> = ({ time }) => { export const Form: React.FC<any> = ({ time }) => {
const inputRef = useRef()
const [error, showError] = useState(false) const [error, showError] = useState(false)
const { values, handleChangeState, resetForm, errors, isValid } = const { values, handleChangeState, resetForm, errors, isValid } =
useFormWithValidation(); useFormWithValidation();
@@ -40,13 +41,14 @@ export const Form: React.FC<any> = ({ time }) => {
); );
}; };
return ( return (
<div className="calendar-container"> <div className="calendar-container">
<h3 className="plan-title"> <h3 className="plan-title">
Расскажите о себе. Расскажите о себе.
</h3> </h3>
<button <button
onClick={() => handleReturn()} onClick={(e) => handleReturn()}
style={{ width: "141px", padding: "4px 16px 4px 4px", height: "32px" }} style={{ width: "141px", padding: "4px 16px 4px 4px", height: "32px" }}
className="button button-type-small button-plan" className="button button-type-small button-plan"
> >
@@ -60,8 +62,8 @@ export const Form: React.FC<any> = ({ time }) => {
<form noValidate onSubmit={handleSubmit} className="form"> <form noValidate onSubmit={handleSubmit} className="form">
<div className="form-input-container"> <div className="form-input-container">
<label className="form-input-caption">Имя</label> <label className="form-input-caption">Имя</label>
<div className={errors.name ? "form-border-error" : 'form-border'}> <div onClick={(e: any) => console.log(e.target.closest('input')) } className={errors.name ? "form-border-error" : 'form-border'}>
<input required onChange={handleChangeState} name='name' value={values.name} minLength={2} maxLength={30} className="form-input" type="text"></input> <input ref={inputRef} required onChange={handleChangeState} name='name' value={values.name} minLength={2} maxLength={30} className="form-input" type="text"></input>
</div> </div>
<span className={errors.name ? "error-caption error-caption-active" : "error-caption"}>{errors.name}</span> <span className={errors.name ? "error-caption error-caption-active" : "error-caption"}>{errors.name}</span>
</div> </div>
@@ -29,7 +29,7 @@ export const ControlButton: React.FC<any> = ({
} }
return ( return (
<div onClick={handleClick} className="toolbar-button-area"> <div style={{pointerEvents: "none"}} onClick={handleClick} className="toolbar-button-area">
<Button <Button
isSidebarWide={isSidebarWide} isSidebarWide={isSidebarWide}
button={button} button={button}
@@ -28,7 +28,7 @@ export const MicroButton: React.FC<any> = ({
} }
return ( return (
<div tabIndex={-1} onClick={handleClick} className="toolbar-button-area"> <div style={{pointerEvents: "none"}} tabIndex={-1} onClick={handleClick} className="toolbar-button-area">
<Button <Button
isSidebarWide={isSidebarWide} isSidebarWide={isSidebarWide}
button={button} button={button}
@@ -1,6 +1,6 @@
import "./PlayerStyles.css"; import "./PlayerStyles.css";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState, useRef } from "react";
import { useParams } from "react-router-dom"; import { useHistory, useParams } from "react-router-dom";
import useWindowDimensions from "hooks/useWindowDimensions"; import useWindowDimensions from "hooks/useWindowDimensions";
import useMobile from "hooks/useMobile"; import useMobile from "hooks/useMobile";
@@ -15,12 +15,13 @@ type link = {
}; };
export const PlayerComponent: React.FC<any> = ({ closeStream }) => { export const PlayerComponent: React.FC<any> = ({ closeStream }) => {
const frameRef = useRef<HTMLIFrameElement>()
const { isMobile } = useMobile(); const { isMobile } = useMobile();
const windowDimensions = useWindowDimensions(); const windowDimensions = useWindowDimensions();
const width = windowDimensions.width; const width = windowDimensions.width;
const height = windowDimensions.height; const height = windowDimensions.height;
const [popup, setPopup] = useState(false); const [popup, setPopup] = useState(false);
const history = useHistory()
console.log(popup); console.log(popup);
const { id } = useParams<link>(); const { id } = useParams<link>();
@@ -58,6 +59,8 @@ export const PlayerComponent: React.FC<any> = ({ closeStream }) => {
} }
}, [width, height, isMobile]); }, [width, height, isMobile]);
return ( return (
<> <>
{popup && ( {popup && (
@@ -66,6 +69,7 @@ export const PlayerComponent: React.FC<any> = ({ closeStream }) => {
</div> </div>
)} )}
<iframe <iframe
ref={frameRef}
onLoad={(e: any) => e.target.focus()} onLoad={(e: any) => e.target.focus()}
id="player" id="player"
onBlur={(e) => e.target.focus()} /// element loosing focus and keyboard input doesn't work onBlur={(e) => e.target.focus()} /// element loosing focus and keyboard input doesn't work
@@ -84,3 +88,7 @@ export const PlayerComponent: React.FC<any> = ({ closeStream }) => {
</> </>
); );
}; };
function getElementById(arg0: string) {
throw new Error("Function not implemented.");
}
@@ -10,10 +10,15 @@ export const Sidebar: React.FC<any> = ({ closeStream, exitPopup, isMobile, heigh
const [isControl, setControl] = useState(false); const [isControl, setControl] = useState(false);
const [height, setHeight] = useState(heightDevice); const [height, setHeight] = useState(heightDevice);
useEffect(() => {
if (isMobile) {
setHeight(heightDevice)
}
}, [heightDevice])
console.log(isMobile);
const handleMuteClick = () => { const handleMuteClick = () => {
setMuted((prev) => !prev); setMuted((prev) => !prev);
@@ -27,6 +32,7 @@ export const Sidebar: React.FC<any> = ({ closeStream, exitPopup, isMobile, heigh
<> <>
{isMobile ? ( {isMobile ? (
<SidebarMobile <SidebarMobile
isMobile={isMobile}
height={height} height={height}
isMuted={isMuted} isMuted={isMuted}
isControl={isControl} isControl={isControl}
@@ -36,6 +42,7 @@ export const Sidebar: React.FC<any> = ({ closeStream, exitPopup, isMobile, heigh
></SidebarMobile> ></SidebarMobile>
) : ( ) : (
<SidebarDesktop <SidebarDesktop
isMobile={isMobile}
isMuted={isMuted} isMuted={isMuted}
isControl={isControl} isControl={isControl}
handleMuteClick={handleMuteClick} handleMuteClick={handleMuteClick}
@@ -22,6 +22,7 @@ export const SidebarDesktop: React.FC<any> = ({
isControl, isControl,
handleMuteClick, handleMuteClick,
handleControlClick, handleControlClick,
isMobile
}) => { }) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [popup, setPopup] = useState({ const [popup, setPopup] = useState({
@@ -33,7 +34,7 @@ export const SidebarDesktop: React.FC<any> = ({
console.log("test"); console.log("test");
}, [exitPopup]); }, [exitPopup]);
const isAdmin = true; const isAdmin = false;
const [wideSidebar, setWideSidebar] = useState(false); const [wideSidebar, setWideSidebar] = useState(false);
@@ -83,7 +84,7 @@ export const SidebarDesktop: React.FC<any> = ({
return ( return (
<> <>
<motion.div <motion.div
/// onHoverEnd={() => /// closeSideBar()} onHoverEnd={() => closeSideBar()}
initial={false} initial={false}
animate={open ? "open" : "closed"} animate={open ? "open" : "closed"}
variants={wideSidebar ? setAnimation() : sidebarVariants} variants={wideSidebar ? setAnimation() : sidebarVariants}
@@ -97,6 +98,7 @@ export const SidebarDesktop: React.FC<any> = ({
<FullscreenButton isSidebarWide={wideSidebar}> </FullscreenButton> <FullscreenButton isSidebarWide={wideSidebar}> </FullscreenButton>
<div className="toolbar-button-container-border-line"></div> <div className="toolbar-button-container-border-line"></div>
<UserList <UserList
isMobile={isMobile}
closeSidebar={closeSideBar} closeSidebar={closeSideBar}
isSidebarWide={wideSidebar} /// this is for disable showhing button's caption isSidebarWide={wideSidebar} /// this is for disable showhing button's caption
isAdmin={isAdmin} isAdmin={isAdmin}
@@ -12,17 +12,19 @@ import { UserButtonMobile } from "../UserButtonMobile/UserButtonMobile";
import { ControlButton } from "../ControlButton/ControlButton"; import { ControlButton } from "../ControlButton/ControlButton";
import { MicroButton } from "../MicroButton/MicroButton"; import { MicroButton } from "../MicroButton/MicroButton";
import { AdditionalButton } from "../AdditionalButton/AdditionalButton"; import { AdditionalButton } from "../AdditionalButton/AdditionalButton";
import { UserListMobile } from "../UserListMoblie/UserListMobile";
export const SidebarMobile: React.FC<any> = ({ height }) => { export const SidebarMobile: React.FC<any> = ({ height, isMobile }) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [userList, setUserList] = useState(false); const [userList, setUserList] = useState(false);
const [popupAdditional, setPopupAdditipnal] = useState(false); const [popupAdditional, setPopupAdditipnal] = useState(false);
console.log(userList, 'popup')
return ( return (
<motion.div <> <motion.div
initial={false} initial={false}
animate={open ? "open" : "closed"} animate={open ? "open" : "closed"}
variants={sidebarVariants} variants={sidebarVariants}
style={{ height: height}} style={{ height: height }}
className="toolbar-container" className="toolbar-container"
> >
<div className="toolbar-field"> <div className="toolbar-field">
@@ -60,5 +62,17 @@ export const SidebarMobile: React.FC<any> = ({ height }) => {
</AnimatePresence> </AnimatePresence>
</div> </div>
</motion.div> </motion.div>
<AnimatePresence>
{userList && (<motion.div key={1}
variants={popupAnimation}
initial={"hidden"}
animate={"show"}
exit={"hidden"}
>
<UserListMobile closePopup={() => setUserList(false)} isMobile={isMobile}></UserListMobile>
</motion.div>)}
</AnimatePresence>
</>
); );
}; };
+15
View File
@@ -7,6 +7,14 @@
justify-content: space-between; justify-content: space-between;
} }
.user-container-mobile {
box-sizing: border-box;
padding: 8px;
background: #1C1D21;
border-radius: 4px;
}
.user { .user {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -59,6 +67,13 @@
padding: 8px; padding: 8px;
} }
.user-button-container-mobile {
background: #1C1D21;
padding: 0px 8px 8px 8px;
}
.icon-container { .icon-container {
cursor: pointer; cursor: pointer;
padding: 8px; padding: 8px;
+4 -3
View File
@@ -22,11 +22,12 @@ export const User: React.FC<any> = ({
isAdmin, isAdmin,
isSidebarWide, isSidebarWide,
closeSidebar, closeSidebar,
isMobile
}) => { }) => {
const [hover, setHover] = useState(false); const [hover, setHover] = useState(false);
const [expand, setExpand] = useState(false); const [expand, setExpand] = useState(false);
const [mute, setMute] = useState(true); const [mute, setMute] = useState(true);
const [isControl, setControl] = useState(false); const [isControl, setControl] = useState(true);
useEffect(() => { useEffect(() => {
setExpand(false); setExpand(false);
@@ -45,7 +46,7 @@ export const User: React.FC<any> = ({
animate={expand ? "open" : "closed"} animate={expand ? "open" : "closed"}
className="user-wrapper" className="user-wrapper"
> >
<div onClick={expandMenu} className="user-container"> <div onClick={expandMenu} className={isMobile ? "user-container-mobile user-container" : "user-container"}>
<div className="user"> <div className="user">
<motion.div <motion.div
onHoverStart={() => setHover(true)} onHoverStart={() => setHover(true)}
@@ -111,7 +112,7 @@ export const User: React.FC<any> = ({
initial={"hidden"} initial={"hidden"}
animate={"show"} animate={"show"}
exit={"hidden"} exit={"hidden"}
className="user-button-container" className={isMobile ? "user-button-container user-button-container-mobile" : "user-button-container"}
> >
<div <div
onClick={() => setControl((prev) => !prev)} onClick={() => setControl((prev) => !prev)}
@@ -1,6 +1,6 @@
import { User } from "components/pages/Stream/User/User"; import { User } from "components/pages/Stream/User/User";
export const UserList: React.FC<any> = ({ isSidebarWide, isAdmin, closeSidebar }) => { export const UserList: React.FC<any> = ({ isSidebarWide, isAdmin, closeSidebar, isMobile }) => {
return ( return (
<div className="toolbar-field-part"> <div className="toolbar-field-part">
<User closeSidebar={closeSidebar} isAdmin={isAdmin} isSidebarWide={isSidebarWide}></User> <User closeSidebar={closeSidebar} isAdmin={isAdmin} isSidebarWide={isSidebarWide}></User>
@@ -0,0 +1,18 @@
import { User } from "../User/User"
import close from 'images/icons/close.svg'
export const UserListMobile: React.FC<any> = ({ isMobile, closePopup }) => {
return (<div className="popup-mobile">
<div className="popup-mobile-container">
<div style={{top:"-20px", right: "-20px"}} onClick={closePopup} className="icon-close-container">
<img src={close}></img>
</div>
<h2 style={{ marginBottom: "20px" }}>Участники демонстрации</h2>
<User isMobile={isMobile} closeSidebar={closePopup}
isSidebarWide={true} /// this is for disable showhing button's caption
isAdmin={false}
></User>
</div>
</div>)
}
+5 -2
View File
@@ -17,9 +17,12 @@ export default function useWindowDimensions() {
function handleResize() { function handleResize() {
setWindowDimensions(getWindowDimensions()); setWindowDimensions(getWindowDimensions());
} }
window.addEventListener("orientationchange", handleResize)
window.addEventListener("resize", handleResize); window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize); return () => {
window.removeEventListener('resize', handleResize)
window.removeEventListener('orientationchange', handleResize)
}
}, []); }, []);
return windowDimensions; return windowDimensions;
+27 -1
View File
@@ -11,6 +11,32 @@ body {
width: 100%; width: 100%;
} }
.popup-mobile {
position: absolute;
background: #151619;
width: calc(100% - 60px);
height: 100%;
top: 0px;
left: 59px;
padding: 30px 32px;
box-sizing: border-box;
}
.popup-mobile-container {
display: flex;
flex-direction: column;
gap: 8px;
position: relative;
}
.user-mobile-container {
background: #1C1D21;
border-radius: 4px;
padding: 8px 24px 8px 8px;
box-sizing: border-box;
}
button { button {
cursor: pointer; cursor: pointer;
@@ -64,4 +90,4 @@ button {
.main { .main {
padding: 0 10px; padding: 0 10px;
} }
} }
+23 -5
View File
@@ -2,7 +2,7 @@ import { createAsyncThunk } from "@reduxjs/toolkit";
import axios from 'axios'; import axios from 'axios';
const instance = axios.create({ const instance = axios.create({
baseURL: 'https://a1.test.coord.graff.tech', baseURL: 'https://a1.coord.graff.tech',
}); });
instance.defaults.headers.post['Content-Type'] = 'application/json'; instance.defaults.headers.post['Content-Type'] = 'application/json';
@@ -11,13 +11,19 @@ instance.defaults.headers.post['Content-Type'] = 'application/json';
export const fetchCards = createAsyncThunk( export const fetchCards = createAsyncThunk(
"cards/FetchAll", "cards/FetchAll",
async (language: string, thunkAPI) => { async (language: string, thunkApi) => {
try { try {
const { data } = await instance.get('/title/get_for_language/', { params: { start: 0, count: 100, language: language } }); const { data } = await instance.get('/title/get_for_language/', { params: { start: 0, count: 100, language: language } });
return data; return data;
} catch (e: any) { } catch (e: any) {
const { response } = e const { response } = e
return thunkAPI.rejectWithValue(response.data.message); if (!response) {
return thunkApi.rejectWithValue('Произошла ошибка, попробуйте позже');
} else {
return thunkApi.rejectWithValue(response.data.message);
}
} }
} }
@@ -32,7 +38,13 @@ export const createSession = createAsyncThunk(
return data; return data;
} catch (e: any) { } catch (e: any) {
const { response } = e const { response } = e
return thunkApi.rejectWithValue(response.data.message); if (!response) {
return thunkApi.rejectWithValue('Произошла ошибка, попробуйте позже');
} else {
return thunkApi.rejectWithValue(response.data.message);
}
} }
} }
); );
@@ -45,7 +57,13 @@ export const connectSession = createAsyncThunk(
return data; return data;
} catch (e: any) { } catch (e: any) {
const { response } = e const { response } = e
return thunkApi.rejectWithValue(response.data.message); if (!response) {
return thunkApi.rejectWithValue('Произошла ошибка, попробуйте позже');
} else {
return thunkApi.rejectWithValue(response.data.message);
}
} }
} }
); );
+1
View File
@@ -34,6 +34,7 @@ export const cardSlice = createSlice({
state.isLoading = true; state.isLoading = true;
}, },
[fetchCards.rejected.type]: (state, action: PayloadAction<any>) => { [fetchCards.rejected.type]: (state, action: PayloadAction<any>) => {
console.log(action.payload)
state.isLoading = false; state.isLoading = false;
state.error = action.payload; state.error = action.payload;
}, },
+1 -1
View File
@@ -53,7 +53,7 @@ export const sessionSlice = createSlice({
action: PayloadAction<ConnectSessionResponseInterface> action: PayloadAction<ConnectSessionResponseInterface>
) => { ) => {
state.isLoading = false; state.isLoading = false;
const url = action.payload.websocket_url.replace("wss://", "https://"); const url = action.payload.websocket_url.replace("wss://", "https://") + '?offerToReceive=true';
state.url = url; state.url = url;
}, },
[connectSession.rejected.type]: (state, action: PayloadAction<any>) => { [connectSession.rejected.type]: (state, action: PayloadAction<any>) => {