bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/whiteboard/whiteboard-toolbar/service.js

85 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-06-08 04:45:49 +08:00
import { makeCall } from '/imports/ui/services/api';
import Storage from '/imports/ui/services/storage/session';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user/';
2017-04-20 02:27:00 +08:00
2017-09-21 05:05:17 +08:00
const DRAW_SETTINGS = 'drawSettings';
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-09-22 08:18:15 +08:00
const clearWhiteboard = (whiteboardId) => {
makeCall('clearWhiteboard', whiteboardId);
};
2017-09-22 08:18:15 +08:00
const changeWhiteboardMode = (multiUser) => {
makeCall('changeWhiteboardAccess', multiUser);
};
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-09-22 08:18:15 +08:00
const getCurrentDrawSettings = () => Storage.getItem(DRAW_SETTINGS);
2017-09-22 08:18:15 +08:00
const setFontSize = makeSetter('textFontSize');
2017-09-22 08:18:15 +08:00
const setTool = makeSetter('whiteboardAnnotationTool');
2017-09-22 08:18:15 +08:00
const setThickness = makeSetter('whiteboardAnnotationThickness');
2017-09-22 08:18:15 +08:00
const setColor = makeSetter('whiteboardAnnotationColor');
2017-09-22 08:18:15 +08:00
const setTextShapeObject = makeSetter('textShape');
2017-04-20 02:27:00 +08:00
const getTextShapeActiveId = () => {
2017-09-21 05:05:17 +08:00
const drawSettings = Storage.getItem(DRAW_SETTINGS);
return drawSettings ? drawSettings.textShape.textShapeActiveId : '';
};
const getMultiUserStatus = () => {
const data = WhiteboardMultiUser.findOne({ meetingId: Auth.meetingID });
2017-09-21 05:05:17 +08:00
return data ? data.multiUser : false;
};
const isPresenter = () => {
const currentUser = Users.findOne({ userId: Auth.userID });
2017-09-21 05:05:17 +08:00
return currentUser ? currentUser.presenter : false;
};
2017-04-20 02:27:00 +08:00
export default {
2017-09-22 08:18:15 +08:00
undoAnnotation,
clearWhiteboard,
changeWhiteboardMode,
setInitialWhiteboardToolbarValues,
getCurrentDrawSettings,
setFontSize,
setTool,
setThickness,
setColor,
setTextShapeObject,
getTextShapeActiveId,
getMultiUserStatus,
isPresenter,
2017-04-20 02:27:00 +08:00
};