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-08-03 09:24:38 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import WhiteboardMultiUser from '/imports/api/2.0/whiteboard-multi-user/';
|
2017-04-20 02:27:00 +08:00
|
|
|
|
2017-06-17 10:32:41 +08:00
|
|
|
const actions = {
|
|
|
|
undoAnnotation: (whiteboardId) => {
|
|
|
|
makeCall('undoAnnotation', whiteboardId);
|
|
|
|
},
|
|
|
|
|
|
|
|
clearWhiteboard: (whiteboardId) => {
|
|
|
|
makeCall('clearWhiteboard', whiteboardId);
|
|
|
|
},
|
|
|
|
|
2017-08-03 09:24:38 +08:00
|
|
|
changeWhiteboardMode: (multiUser) => {
|
|
|
|
makeCall('changeWhiteboardAccess', multiUser);
|
|
|
|
},
|
|
|
|
|
2017-09-06 06:55:18 +08:00
|
|
|
setInitialWhiteboardToolbarValues: (tool, thickness, color, fontSize, textShape) => {
|
|
|
|
const _drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (!_drawSettings) {
|
|
|
|
const drawSettings = {
|
|
|
|
whiteboardAnnotationTool: tool,
|
|
|
|
whiteboardAnnotationThickness: thickness,
|
|
|
|
whiteboardAnnotationColor: color,
|
|
|
|
textFontSize: fontSize,
|
|
|
|
textShape,
|
|
|
|
};
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
2017-06-17 10:32:41 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setTool: (tool) => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.whiteboardAnnotationTool = tool;
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setThickness: (thickness) => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.whiteboardAnnotationThickness = thickness;
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setColor: (color) => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.whiteboardAnnotationColor = color;
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setFontSize: (fontSize) => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.textFontSize = fontSize;
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-09-06 06:55:18 +08:00
|
|
|
getCurrentDrawSettings: () => Storage.getItem('drawSettings'),
|
|
|
|
|
2017-06-17 10:32:41 +08:00
|
|
|
setTextShapeObject: (textShape) => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.textShape = textShape;
|
|
|
|
Storage.setItem('drawSettings', JSON.stringify(drawSettings));
|
|
|
|
}
|
|
|
|
},
|
2017-04-22 02:01:52 +08:00
|
|
|
};
|
2017-04-20 02:27:00 +08:00
|
|
|
|
2017-06-17 10:32:41 +08:00
|
|
|
const getTextShapeActiveId = () => {
|
2017-08-03 09:24:38 +08:00
|
|
|
const drawSettings = Storage.getItem('drawSettings');
|
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
return drawSettings.textShape.textShapeActiveId;
|
|
|
|
}
|
2017-08-03 09:24:38 +08:00
|
|
|
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
const getMultiUserStatus = () => {
|
|
|
|
const data = WhiteboardMultiUser.findOne({ meetingId: Auth.meetingID });
|
|
|
|
|
|
|
|
if (data) {
|
|
|
|
return data.multiUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
const isPresenter = () => {
|
|
|
|
const currentUser = Users.findOne({ userId: Auth.userID });
|
|
|
|
|
2017-08-19 10:47:31 +08:00
|
|
|
if (currentUser) {
|
|
|
|
return currentUser.presenter;
|
2017-08-03 09:24:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2017-05-03 08:05:41 +08:00
|
|
|
};
|
|
|
|
|
2017-04-20 02:27:00 +08:00
|
|
|
export default {
|
2017-06-17 10:32:41 +08:00
|
|
|
actions,
|
|
|
|
getTextShapeActiveId,
|
2017-08-03 09:24:38 +08:00
|
|
|
getMultiUserStatus,
|
|
|
|
isPresenter,
|
2017-04-20 02:27:00 +08:00
|
|
|
};
|