2017-06-08 04:45:49 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2017-05-03 08:05:41 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-08-03 09:24:38 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2018-09-22 00:42:00 +08:00
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
2017-04-20 02:27:00 +08:00
|
|
|
|
2017-09-21 05:05:17 +08:00
|
|
|
const DRAW_SETTINGS = 'drawSettings';
|
2020-09-18 18:30:27 +08:00
|
|
|
const PALM_REJECTION_MODE = 'palmRejectionMode';
|
2018-09-22 03:42:39 +08:00
|
|
|
const WHITEBOARD_TOOLBAR = Meteor.settings.public.whiteboard.toolbar;
|
2017-09-21 05:05:17 +08:00
|
|
|
|
|
|
|
const makeSetter = key => (value) => {
|
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
|
|
|
if (drawSettings) {
|
|
|
|
drawSettings[key] = value;
|
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const undoAnnotation = (whiteboardId) => {
|
|
|
|
makeCall('undoAnnotation', whiteboardId);
|
|
|
|
};
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const clearWhiteboard = (whiteboardId) => {
|
|
|
|
makeCall('clearWhiteboard', whiteboardId);
|
|
|
|
};
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2020-09-18 18:30:27 +08:00
|
|
|
const changeWhiteboardMode = (multiUser, whiteboardId) => {
|
|
|
|
makeCall('changeWhiteboardAccess', multiUser, whiteboardId);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getCurrentPalmRejectionMode = () => Storage.getItem(PALM_REJECTION_MODE);
|
|
|
|
|
|
|
|
const setInitialPalmRejectionMode = (palmRejectionMode) => {
|
|
|
|
const _palmRejectionMode = Storage.getItem(PALM_REJECTION_MODE);
|
|
|
|
if (!_palmRejectionMode) {
|
|
|
|
Storage.setItem(PALM_REJECTION_MODE, palmRejectionMode);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const setPalmRejectionMode = (palmRejectionMode) => {
|
|
|
|
Storage.setItem(PALM_REJECTION_MODE, palmRejectionMode);
|
|
|
|
};
|
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setInitialWhiteboardToolbarValues = (tool, thickness, color, fontSize, textShape) => {
|
|
|
|
const _drawSettings = Storage.getItem(DRAW_SETTINGS);
|
|
|
|
if (!_drawSettings) {
|
|
|
|
const drawSettings = {
|
|
|
|
whiteboardAnnotationTool: tool,
|
|
|
|
whiteboardAnnotationThickness: thickness,
|
|
|
|
whiteboardAnnotationColor: color,
|
|
|
|
textFontSize: fontSize,
|
|
|
|
textShape,
|
|
|
|
};
|
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
|
|
|
}
|
|
|
|
};
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const getCurrentDrawSettings = () => Storage.getItem(DRAW_SETTINGS);
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setFontSize = makeSetter('textFontSize');
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setTool = makeSetter('whiteboardAnnotationTool');
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setThickness = makeSetter('whiteboardAnnotationThickness');
|
2017-06-17 10:32:41 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setColor = makeSetter('whiteboardAnnotationColor');
|
2017-09-06 06:55:18 +08:00
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const setTextShapeObject = makeSetter('textShape');
|
2017-04-20 02:27:00 +08:00
|
|
|
|
2017-06-17 10:32:41 +08:00
|
|
|
const getTextShapeActiveId = () => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
|
|
|
return drawSettings ? drawSettings.textShape.textShapeActiveId : '';
|
2017-08-03 09:24:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const isPresenter = () => {
|
2019-08-30 00:26:07 +08:00
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { presenter: 1 } });
|
2017-09-21 05:05:17 +08:00
|
|
|
return currentUser ? currentUser.presenter : false;
|
2017-05-03 08:05:41 +08:00
|
|
|
};
|
|
|
|
|
2018-09-22 00:42:00 +08:00
|
|
|
const filterAnnotationList = () => {
|
2019-07-25 01:04:46 +08:00
|
|
|
const multiUserPenOnly = getFromUserSettings('bbb_multi_user_pen_only', WHITEBOARD_TOOLBAR.multiUserPenOnly);
|
2021-03-05 06:26:25 +08:00
|
|
|
const amIPresenter = isPresenter();
|
2018-09-22 00:42:00 +08:00
|
|
|
|
2018-09-22 03:42:39 +08:00
|
|
|
let filteredAnnotationList = WHITEBOARD_TOOLBAR.tools;
|
2018-09-22 00:42:00 +08:00
|
|
|
|
2021-03-05 06:26:25 +08:00
|
|
|
if (!amIPresenter && multiUserPenOnly) {
|
2018-09-22 00:42:00 +08:00
|
|
|
filteredAnnotationList = [{
|
|
|
|
icon: 'pen_tool',
|
|
|
|
value: 'pencil',
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2019-07-25 01:04:46 +08:00
|
|
|
const presenterTools = getFromUserSettings('bbb_presenter_tools', WHITEBOARD_TOOLBAR.presenterTools);
|
2021-03-05 06:26:25 +08:00
|
|
|
if (amIPresenter && Array.isArray(presenterTools)) {
|
2018-09-22 03:42:39 +08:00
|
|
|
filteredAnnotationList = WHITEBOARD_TOOLBAR.tools.filter(el =>
|
|
|
|
presenterTools.includes(el.value));
|
|
|
|
}
|
|
|
|
|
2019-07-25 01:04:46 +08:00
|
|
|
const multiUserTools = getFromUserSettings('bbb_multi_user_tools', WHITEBOARD_TOOLBAR.multiUserTools);
|
2021-03-05 06:26:25 +08:00
|
|
|
if (!amIPresenter && !multiUserPenOnly && Array.isArray(multiUserTools)) {
|
2018-09-22 03:42:39 +08:00
|
|
|
filteredAnnotationList = WHITEBOARD_TOOLBAR.tools.filter(el =>
|
|
|
|
multiUserTools.includes(el.value));
|
|
|
|
}
|
|
|
|
|
2018-09-22 00:42:00 +08:00
|
|
|
return filteredAnnotationList;
|
|
|
|
};
|
|
|
|
|
2017-04-20 02:27:00 +08:00
|
|
|
export default {
|
2017-09-22 08:18:15 +08:00
|
|
|
undoAnnotation,
|
|
|
|
clearWhiteboard,
|
2020-09-18 18:30:27 +08:00
|
|
|
changeWhiteboardMode,
|
|
|
|
getCurrentPalmRejectionMode,
|
|
|
|
setInitialPalmRejectionMode,
|
|
|
|
setPalmRejectionMode,
|
2017-09-22 08:18:15 +08:00
|
|
|
setInitialWhiteboardToolbarValues,
|
|
|
|
getCurrentDrawSettings,
|
|
|
|
setFontSize,
|
|
|
|
setTool,
|
|
|
|
setThickness,
|
|
|
|
setColor,
|
|
|
|
setTextShapeObject,
|
2017-06-17 10:32:41 +08:00
|
|
|
getTextShapeActiveId,
|
2017-08-03 09:24:38 +08:00
|
|
|
isPresenter,
|
2018-09-22 00:42:00 +08:00
|
|
|
filterAnnotationList,
|
2017-04-20 02:27:00 +08:00
|
|
|
};
|