2016-07-11 21:45:24 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2016-05-14 00:17:00 +08:00
|
|
|
|
2016-07-06 00:47:40 +08:00
|
|
|
/* TODO: Will be pretty sweet if we return a promise from the callServer function */
|
2016-05-14 00:17:00 +08:00
|
|
|
function callServer(name) {
|
2016-05-14 00:31:06 +08:00
|
|
|
if (!name || !(typeof (name) === 'string' || name instanceof String) || name.length === 0 ||
|
|
|
|
!name.trim() || /^\s*$/.test(name)) {
|
2016-05-13 00:10:20 +08:00
|
|
|
console.error(`serverCall: invalid function name '${name}'`);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-17 22:23:00 +08:00
|
|
|
const credentials = Auth.credentials;
|
2016-05-13 00:10:20 +08:00
|
|
|
|
2016-05-14 00:17:00 +08:00
|
|
|
// slice off the first element. That is the function name but we already have that.
|
2016-05-19 03:26:51 +08:00
|
|
|
const args = Array.prototype.slice.call(arguments, 1);
|
2016-05-13 00:10:20 +08:00
|
|
|
Meteor.call(name, credentials, ...args);
|
|
|
|
};
|
|
|
|
|
2017-04-28 21:47:07 +08:00
|
|
|
function logClient(logLevel) {
|
|
|
|
const credentials = Auth.credentials;
|
|
|
|
check(logLevel, String);
|
|
|
|
const args = Array.prototype.slice.call(arguments, 0);
|
|
|
|
const userInfo = window.navigator;
|
|
|
|
|
|
|
|
args.push({
|
|
|
|
systemProps: {
|
|
|
|
language: userInfo.language,
|
|
|
|
userAgent: userInfo.userAgent,
|
|
|
|
screenSize: { width: screen.width, height: screen.height },
|
|
|
|
windowSize: { width: window.innerWidth, height: window.innerHeight },
|
|
|
|
bbbVersion: Meteor.settings.public.app.bbbServerVersion,
|
|
|
|
location: window.location.href,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Meteor.call('logClient', logLevel, credentials, ...args);
|
|
|
|
};
|
|
|
|
|
2016-05-13 00:10:20 +08:00
|
|
|
export {
|
2017-04-28 21:47:07 +08:00
|
|
|
logClient,
|
2016-05-13 00:10:20 +08:00
|
|
|
callServer,
|
|
|
|
};
|