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-06-17 10:32:41 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-05-02 05:34:24 +08:00
|
|
|
|
2017-09-21 05:05:17 +08:00
|
|
|
const DRAW_SETTINGS = 'drawSettings';
|
|
|
|
|
2017-05-02 05:34:24 +08:00
|
|
|
const sendAnnotation = (annotation) => {
|
2017-06-08 04:45:49 +08:00
|
|
|
makeCall('sendAnnotation', annotation);
|
2017-05-02 05:34:24 +08:00
|
|
|
};
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
const getWhiteboardToolbarValues = () => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
|
|
|
if (!drawSettings) {
|
|
|
|
return {};
|
2017-06-03 07:40:52 +08:00
|
|
|
}
|
2017-09-21 05:05:17 +08:00
|
|
|
|
|
|
|
const {
|
|
|
|
whiteboardAnnotationTool,
|
|
|
|
whiteboardAnnotationThickness,
|
|
|
|
whiteboardAnnotationColor,
|
|
|
|
textFontSize,
|
|
|
|
textShape,
|
|
|
|
} = drawSettings;
|
|
|
|
|
|
|
|
return {
|
|
|
|
tool: whiteboardAnnotationTool,
|
|
|
|
thickness: whiteboardAnnotationThickness,
|
|
|
|
color: whiteboardAnnotationColor,
|
|
|
|
textFontSize,
|
|
|
|
textShapeValue: textShape.textShapeValue ? textShape.textShapeValue : '',
|
|
|
|
textShapeActiveId: textShape.textShapeActiveId ? textShape.textShapeActiveId : '',
|
|
|
|
};
|
2017-05-03 08:05:41 +08:00
|
|
|
};
|
|
|
|
|
2017-08-24 11:35:34 +08:00
|
|
|
const resetTextShapeSession = () => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
2017-08-19 10:47:31 +08:00
|
|
|
if (drawSettings) {
|
2017-06-17 10:32:41 +08:00
|
|
|
drawSettings.textShape.textShapeValue = '';
|
2017-08-24 11:35:34 +08:00
|
|
|
drawSettings.textShape.textShapeActiveId = '';
|
2017-09-21 05:05:17 +08:00
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
2017-06-17 10:32:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const setTextShapeActiveId = (id) => {
|
2017-09-21 05:05:17 +08:00
|
|
|
const drawSettings = Storage.getItem(DRAW_SETTINGS);
|
2017-08-19 10:47:31 +08:00
|
|
|
if (drawSettings) {
|
2017-08-24 11:35:34 +08:00
|
|
|
drawSettings.textShape.textShapeActiveId = id;
|
2017-09-21 05:05:17 +08:00
|
|
|
Storage.setItem(DRAW_SETTINGS, drawSettings);
|
2017-06-17 10:32:41 +08:00
|
|
|
}
|
2017-06-11 10:21:37 +08:00
|
|
|
};
|
|
|
|
|
2017-08-19 10:47:31 +08:00
|
|
|
const getCurrentUserId = () => Auth.userID;
|
|
|
|
|
|
|
|
|
2017-05-02 05:34:24 +08:00
|
|
|
export default {
|
|
|
|
sendAnnotation,
|
2017-05-03 08:05:41 +08:00
|
|
|
getWhiteboardToolbarValues,
|
2017-06-17 10:32:41 +08:00
|
|
|
setTextShapeActiveId,
|
2017-08-24 11:35:34 +08:00
|
|
|
resetTextShapeSession,
|
2017-08-19 10:47:31 +08:00
|
|
|
getCurrentUserId,
|
2017-05-02 05:34:24 +08:00
|
|
|
};
|