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';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-08-03 09:24:38 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-12 10:00:28 +08:00
|
|
|
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-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
|
|
|
|
2017-09-22 08:18:15 +08:00
|
|
|
const changeWhiteboardMode = (multiUser) => {
|
|
|
|
makeCall('changeWhiteboardAccess', multiUser);
|
|
|
|
};
|
2017-08-03 09:24:38 +08:00
|
|
|
|
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 getMultiUserStatus = () => {
|
|
|
|
const data = WhiteboardMultiUser.findOne({ meetingId: Auth.meetingID });
|
2017-09-21 05:05:17 +08:00
|
|
|
return data ? data.multiUser : false;
|
2017-08-03 09:24:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const isPresenter = () => {
|
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
2017-09-21 05:05:17 +08:00
|
|
|
return currentUser ? currentUser.presenter : false;
|
2017-05-03 08:05:41 +08:00
|
|
|
};
|
|
|
|
|
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,
|
2017-06-17 10:32:41 +08:00
|
|
|
getTextShapeActiveId,
|
2017-08-03 09:24:38 +08:00
|
|
|
getMultiUserStatus,
|
|
|
|
isPresenter,
|
2017-04-20 02:27:00 +08:00
|
|
|
};
|