Skip to content

Commit

Permalink
Merge pull request #13 from mconf/develop
Browse files Browse the repository at this point in the history
chore: update from develop
  • Loading branch information
pedrobmarin authored Aug 11, 2021
2 parents e9cb405 + 84134aa commit a0e64f9
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 41 deletions.
21 changes: 21 additions & 0 deletions src/components/loader/data/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import Item from './item';
import { CONTENT } from 'utils/constants';
import './index.scss';

const Data = ({ data }) => {

return (
<div className="data-wrapper">
{CONTENT.map((item) => (
<Item
icon={item}
key={item}
value={data[item]}
/>
))}
</div>
);
};

export default Data;
24 changes: 24 additions & 0 deletions src/components/loader/data/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import 'src/styles/icons';
@import 'src/styles/sizes';

.data-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
overflow-x: hidden;
overflow-y: auto;

.item {
box-sizing: border-box;
color: var(--loader-color);
display: flex;
font-size: xx-large;
font-weight: var(--font-weight-semi-bold);
padding: $padding;
opacity: .5;
}

.loaded {
opacity: 1;
}
}
34 changes: 34 additions & 0 deletions src/components/loader/data/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import './index.scss';

const propTypes = {
icon: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string,
]),
};

const defaultProps = {
icon: '',
value: false,
};

const Item = ({
icon,
value,
}) => {

return (
<div className={cx('item', { loaded: value })}>
<div className={`icon-${icon}`} />
</div>
);
};

Item.propTypes = propTypes;
Item.defaultProps = defaultProps;

export default Item;
27 changes: 19 additions & 8 deletions src/components/loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ import {
useIntl,
} from 'react-intl';
import config from 'config';
//import Data from './data';
import Dots from './dots';
import Error from 'components/error';
import Player from 'components/player';
import { build } from 'utils/builder';
import { ID } from 'utils/constants';
import {
ERROR,
ID,
} from 'utils/constants';
import {
buildFileURL,
getFileName,
getFileType,
// getLoadedData,
} from 'utils/data';
import {
getLayout,
Expand All @@ -29,7 +34,7 @@ const intlMessages = defineMessages({
},
});

const initError = (recordId) => recordId ? null : config.error['NOT_FOUND'];
const initError = (recordId) => recordId ? null : ERROR.BAD_REQUEST;

const Loader = ({ match }) => {
const intl = useIntl();
Expand All @@ -40,7 +45,7 @@ const Loader = ({ match }) => {
const started = useRef(false);
const time = useRef(getTime());

const [error, setError] = useState(initError(recordId));
const [error, setError] = useState(initError(recordId.current));
const [loaded, setLoaded] = useState(false);

const fetchFile = (file) => {
Expand All @@ -59,7 +64,7 @@ const Loader = ({ match }) => {
case 'xml':
return response.text();
default:
setError(config.error['BAD_REQUEST']);
setError(ERROR.BAD_REQUEST);
return null;
}
} else {
Expand All @@ -71,8 +76,8 @@ const Loader = ({ match }) => {
if (content) logger.debug(ID.LOADER, 'builded', file);
data.current[getFileName(file)] = content;
update();
}).catch(error => setError(config.error['BAD_REQUEST']));
}).catch(error => setError(config.error['NOT_FOUND']));
}).catch(error => setError(ERROR.BAD_REQUEST));
}).catch(error => setError(ERROR.NOT_FOUND));
};

const fetchMedia = () => {
Expand All @@ -96,7 +101,7 @@ const Loader = ({ match }) => {
update();
} else {
// TODO: Handle audio medias
setError(config.error['NOT_FOUND']);
setError(ERROR.NOT_FOUND);
}
});
};
Expand Down Expand Up @@ -140,7 +145,13 @@ const Loader = ({ match }) => {
className="loader-wrapper"
id={ID.LOADER}
>
<Dots />
<div className="loader-top" />
<div className="loader-middle">
<Dots />
</div>
<div className="loader-bottom">
{/*<Data data={getLoadedData(data.current)} />*/}
</div>
</div>
);
};
Expand Down
13 changes: 13 additions & 0 deletions src/components/loader/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,23 @@ $dots-wrapper-width: 100px;
.loader-wrapper {
background-color: var(--loader-background-color);
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
}

.loader-top,
.loader-middle,
.loader-bottom {
display: flex;
height: 100%;
}

.loader-bottom {
align-items: flex-start;
justify-content: center;
}

.dots-wrapper {
margin: auto;
text-align: center;
Expand Down
28 changes: 10 additions & 18 deletions src/components/modals/about/body.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import Item from './item';
import { ID } from 'utils/constants';
import {
CONTENT,
ID,
} from 'utils/constants';
import './index.scss';

const CONTENT = [
ID.USERS,
ID.PRESENTATION,
ID.CHAT,
ID.POLLS,
ID.QUESTIONS,
ID.EXTERNAL_VIDEOS,
ID.NOTES,
ID.SCREENSHARE,
ID.CAPTIONS,
];

const propTypes = {
content: PropTypes.object,
users: PropTypes.number,
Expand All @@ -30,18 +21,19 @@ const Body = ({
content,
users,
}) => {
const data = {
...content,
users,
};

return (
<div className="about-body">
<Item
icon={ID.USERS}
key={ID.USERS}
value={users}
/>
{CONTENT.map((item) => (
<Item
icon={item}
key={item}
value={data[item]}
value={content[item]}
/>
))}
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/presentation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ const areEqual = (prevProps, nextProps) => {

if (prevProps.currentPanzoomIndex !== nextProps.currentPanzoomIndex) return false;

if (prevProps.currentSlideIndex !== nextProps.currentSlideIndex) return false;

if (!isEqual(prevProps.draws, nextProps.draws)) return false;

if (!isEqual(prevProps.drawsInterval, nextProps.drawsInterval)) return false;
Expand Down
4 changes: 2 additions & 2 deletions src/components/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Route,
Switch,
} from 'react-router-dom';
import { error } from 'config';
import { ERROR } from 'utils/constants';
import Error from './error';
import Loader from './loader';

Expand All @@ -17,7 +17,7 @@ const Router = () => {
path="/:recordId"
component={Loader}
/>
<Route render={() => <Error code={error['NOT_FOUND']} />} />
<Route render={() => <Error code={ERROR.NOT_FOUND} />} />
</Switch>
</BrowserRouter>
);
Expand Down
13 changes: 0 additions & 13 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@
"swap": true,
"thumbnails": true
},
"error": {
"BAD_REQUEST": 400,
"UNAUTHORIZED": 401,
"PAYMENT_REQUIRED": 402,
"FORBIDDEN": 403,
"NOT_FOUND": 404,
"METHOD_NOT_ALLOWED": 405,
"NOT_ACCEPTABLE": 406,
"PROXY_AUTHENTICATION_REQUIRED": 407,
"REQUEST_TIMEOUT": 408,
"CONFLICT": 409,
"GONE": 410
},
"files": {
"data": {
"alternates": "presentation_text.json",
Expand Down
27 changes: 27 additions & 0 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ const BUILD = process.env.REACT_APP_BBB_PLAYBACK_BUILD;
const MEDIA_ROOT_URL = process.env.REACT_APP_MEDIA_ROOT_URL;
const NO_ROUTER = process.env.REACT_APP_NO_ROUTER;

const ERROR = {
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
PAYMENT_REQUIRED: 402,
FORBIDDEN: 403,
NOT_FOUND: 404,
METHOD_NOT_ALLOWED: 405,
NOT_ACCEPTABLE: 406,
PROXY_AUTHENTICATION_REQUIRED: 407,
REQUEST_TIMEOUT: 408,
CONFLICT: 409,
GONE: 410,
};

const ID = {
ABOUT: 'about',
ALTERNATES: 'alternates',
Expand Down Expand Up @@ -29,6 +43,17 @@ const ID = {
VIDEO: 'video',
};

const CONTENT = [
ID.PRESENTATION,
ID.CHAT,
ID.POLLS,
ID.QUESTIONS,
ID.EXTERNAL_VIDEOS,
ID.NOTES,
ID.SCREENSHARE,
ID.CAPTIONS,
];

const LAYOUT = {
CONTENT: 'content',
DISABLED: 'disabled',
Expand Down Expand Up @@ -73,6 +98,8 @@ const ROUTER = getRouter();

export {
BUILD,
CONTENT,
ERROR,
ID,
LAYOUT,
MEDIA_ROOT_URL,
Expand Down
24 changes: 24 additions & 0 deletions src/utils/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
hasPresentation,
hasProperty,
isCurrent,
isDefined,
isEmpty,
isEnabled,
isVisible,
Expand Down Expand Up @@ -225,6 +226,28 @@ const getFileName = file => file.split('.').shift();

const getFileType = file => file.split('.').pop();

const getLoadedData = data => {
const captions = getData(data, ID.CAPTIONS);
const chat = getData(data, ID.CHAT);
const notes = getData(data, ID.NOTES);
const polls = getData(data, ID.POLLS);
const externalVideos = getData(data, ID.EXTERNAL_VIDEOS);
const screenshare = getData(data, ID.SCREENSHARE);
const shapes = getData(data, ID.SHAPES);

const loadedData = {
captions: isDefined(captions),
chat: isDefined(chat),
notes: isDefined(notes),
polls: isDefined(polls),
externalVideos: isDefined(externalVideos),
presentation: isDefined(shapes),
screenshare: isDefined(screenshare),
};

return loadedData;
};

const getPercentage = (value, total) => {
if (total === 0) return 0;

Expand Down Expand Up @@ -317,6 +340,7 @@ export {
getDraws,
getFileName,
getFileType,
getLoadedData,
getMessageType,
getPercentage,
getPollLabel,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/data/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const isCurrent = (data, index, time) => {
return current;
};

const isDefined = data => typeof data !== 'undefined';

const isEmpty = data => {
const isArray = isValid('array', data);
const isString = isValid('string', data);
Expand Down Expand Up @@ -171,6 +173,7 @@ export {
isActive,
isContentVisible,
isCurrent,
isDefined,
isEmpty,
isEnabled,
isEqual,
Expand Down

0 comments on commit a0e64f9

Please sign in to comment.