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

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-08-03 06:55:20 +08:00
import SlideControls from './component.jsx';
import AuthSingleton from '/imports/ui/services/auth/index.js';
import Users from '/imports/api/users';
import Slides from '/imports/api/slides';
2016-08-06 02:39:24 +08:00
import { callServer } from '/imports/ui/services/api/index.js';
2016-08-03 06:55:20 +08:00
let getSlideData = (params) => {
const { currentSlideNum, presentationId } = params;
2016-08-06 02:39:24 +08:00
// Get userId and meetingId
2016-08-03 06:55:20 +08:00
const userId = AuthSingleton.getCredentials().requesterUserId;
const meetingId = AuthSingleton.getCredentials().meetingId;
2016-08-06 02:39:24 +08:00
// Find the user object of this specific meeting and userid
const userIsPresenter = Users.findOne({
2016-08-03 06:55:20 +08:00
meetingId: meetingId,
userId: userId,
2016-08-06 02:39:24 +08:00
}).user.presenter;
2016-08-03 06:55:20 +08:00
2016-08-06 02:39:24 +08:00
// Get total number of slides in this presentation
2016-08-03 06:55:20 +08:00
const numberOfSlides = Slides.find({
meetingId: meetingId,
presentationId: presentationId,
}).fetch().length;
return {
2016-08-06 02:39:24 +08:00
userIsPresenter: userIsPresenter,
2016-08-03 06:55:20 +08:00
numberOfSlides: numberOfSlides,
};
};
2016-08-06 02:39:24 +08:00
const previousSlide = (currentSlideNum) => {
if (currentSlideNum > 1) {
callServer('switchSlideMessage', currentSlideNum - 1);
2016-08-06 02:39:24 +08:00
}
};
const nextSlide = (currentSlideNum, numberOfSlides) => {
if (currentSlideNum < numberOfSlides) {
callServer('switchSlideMessage', currentSlideNum + 1);
2016-08-06 02:39:24 +08:00
}
};
const skipToSlide = (event) => {
const requestedSlideNum = event.target.value;
callServer('switchSlideMessage', requestedSlideNum);
2016-08-06 02:39:24 +08:00
};
2016-08-03 06:55:20 +08:00
export default {
getSlideData,
2016-08-06 02:39:24 +08:00
nextSlide,
previousSlide,
skipToSlide,
2016-08-03 06:55:20 +08:00
};