bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/settings/service.js
2017-10-10 19:08:51 -03:00

38 lines
905 B
JavaScript

import Users from '/imports/api/2.0/users';
import Captions from '/imports/api/2.0/captions';
import Auth from '/imports/ui/services/auth';
import _ from 'lodash';
import Settings from '/imports/ui/services/settings';
const getClosedCaptionLocales = () => {
// list of unique locales in the Captions Collection
const locales = _.uniq(Captions.find({}, {
sort: { locale: 1 },
fields: { locale: true },
}).fetch().map(obj => obj.locale), true);
return locales;
};
const getUserRoles = () => {
const user = Users.findOne({
userId: Auth.userID,
});
return user.role;
};
const updateSettings = (obj) => {
Object.keys(obj).forEach(k => (Settings[k] = obj[k]));
Settings.save();
};
const getAvailableLocales = () => fetch('/html5client/locales').then(locales => locales.json());
export {
getClosedCaptionLocales,
getUserRoles,
updateSettings,
getAvailableLocales,
};