This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new a1da322 [OPENMEETINGS-2000] moving JS code to npm
a1da322 is described below
commit a1da322e93e860fa79274fdd5771e18dbc7d1f3d
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Thu Dec 24 16:23:45 2020 +0700
[OPENMEETINGS-2000] moving JS code to npm
---
openmeetings-web/src/main/front/chat/src/chat.js | 2 +-
.../src/main/front/room/src/quick-poll.js | 60 +++++
openmeetings-web/src/main/front/room/src/room.js | 296 +--------------------
.../src/main/front/room/src/user-list.js | 249 +++++++++++++++++
4 files changed, 320 insertions(+), 287 deletions(-)
diff --git a/openmeetings-web/src/main/front/chat/src/chat.js
b/openmeetings-web/src/main/front/chat/src/chat.js
index 097f900..24f74f1 100644
--- a/openmeetings-web/src/main/front/chat/src/chat.js
+++ b/openmeetings-web/src/main/front/chat/src/chat.js
@@ -483,7 +483,7 @@ function _typingActivity(uid, active) {
if (!c) {
return;
}
- const u = Room.getClient(uid).find('.typing-activity');
+ const u = c.find('.typing-activity');
if (!u) {
return;
}
diff --git a/openmeetings-web/src/main/front/room/src/quick-poll.js
b/openmeetings-web/src/main/front/room/src/quick-poll.js
new file mode 100644
index 0000000..66422a5
--- /dev/null
+++ b/openmeetings-web/src/main/front/room/src/quick-poll.js
@@ -0,0 +1,60 @@
+/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
+const UserList = require('./user-list');
+
+function _setQuickPollRights() {
+ const close = $('#quick-vote .close-btn');
+ if (close.length === 1) {
+ if (UserList.hasRight(['PRESENTER'])) {
+ close.show();
+ if (typeof(close.data('bs.confirmation')) === 'object')
{
+ return;
+ }
+ close
+ .confirmation({
+ confirmationEvent: 'bla'
+ , onConfirm: function() {
+ quickPollAction('close');
+ }
+ });
+ } else {
+ close.hide();
+ }
+ }
+}
+function _update(obj) {
+ if (obj.started) {
+ let qv = $('#quick-vote');
+ if (qv.length === 0) {
+ const wbArea = $('.room-block .wb-block');
+ qv = OmUtil.tmpl('#quick-vote-template', 'quick-vote');
+ wbArea.append(qv);
+ }
+ const pro = qv.find('.control.pro')
+ , con = qv.find('.control.con');
+ if (obj.voted) {
+ pro.removeClass('clickable').off();
+ con.removeClass('clickable').off();
+ } else {
+ pro.addClass('clickable').off().click(function() {
+ quickPollAction('vote', true);
+ });
+ con.addClass('clickable').off().click(function() {
+ quickPollAction('vote', false);
+ });
+ }
+ pro.find('.badge').text(obj.pros);
+ con.find('.badge').text(obj.cons);
+ _setQuickPollRights();
+ } else {
+ const qv = $('#quick-vote');
+ if (qv.length === 1) {
+ qv.remove();
+ }
+ }
+ OmUtil.tmpl('#quick-vote-template', 'quick-vote');
+}
+
+module.exports = {
+ update: _update
+ , setRights: _setQuickPollRights
+};
\ No newline at end of file
diff --git a/openmeetings-web/src/main/front/room/src/room.js
b/openmeetings-web/src/main/front/room/src/room.js
index 030f456..5ce9675 100644
--- a/openmeetings-web/src/main/front/room/src/room.js
+++ b/openmeetings-web/src/main/front/room/src/room.js
@@ -4,6 +4,8 @@ const VideoManager = require('./video-manager');
const Sharer = require('./sharer');
const Activities = require('./activities');
const SipDialer = require('./sip-dialer');
+const UserList = require('./user-list');
+const QuickPoll = require('./quick-poll');
const sbSide = Settings.isRtl ? 'right' : 'left';
let options, menuHeight, sb, dock, noSleep;
@@ -42,6 +44,7 @@ function _init(_options) {
VideoManager.init();
Activities.init();
Sharer.init();
+ UserList.init(options);
_setSize();
}
function __dockSetMode(mode) {
@@ -218,268 +221,6 @@ function _showClipboard(txt) {
]
});
}
-function _hasRight(_inRights, _ref) {
- const ref = _ref || options.rights;
- let _rights;
- if (Array.isArray(_inRights)) {
- _rights = _inRights;
- } else {
- if ('SUPER_MODERATOR' === _inRights) {
- return ref.includes(_inRights);
- }
- _rights = [_inRights];
- }
- const rights = ['SUPER_MODERATOR', 'MODERATOR', ..._rights];
- for (let i = 0; i < rights.length; ++i) {
- if (ref.includes(rights[i])) {
- return true;
- }
- }
- return false;
-}
-function _setQuickPollRights() {
- const close = $('#quick-vote .close-btn');
- if (close.length === 1) {
- if (_hasRight(['PRESENTER'])) {
- close.show();
- if (typeof(close.data('bs.confirmation')) === 'object')
{
- return;
- }
- close
- .confirmation({
- confirmationEvent: 'bla'
- , onConfirm: function() {
- quickPollAction('close');
- }
- });
- } else {
- close.hide();
- }
- }
-}
-function _quickPoll(obj) {
- if (obj.started) {
- let qv = $('#quick-vote');
- if (qv.length === 0) {
- const wbArea = $('.room-block .wb-block');
- qv = OmUtil.tmpl('#quick-vote-template', 'quick-vote');
- wbArea.append(qv);
- }
- const pro = qv.find('.control.pro')
- , con = qv.find('.control.con');
- if (obj.voted) {
- pro.removeClass('clickable').off();
- con.removeClass('clickable').off();
- } else {
- pro.addClass('clickable').off().click(function() {
- quickPollAction('vote', true);
- });
- con.addClass('clickable').off().click(function() {
- quickPollAction('vote', false);
- });
- }
- pro.find('.badge').text(obj.pros);
- con.find('.badge').text(obj.cons);
- _setQuickPollRights();
- } else {
- const qv = $('#quick-vote');
- if (qv.length === 1) {
- qv.remove();
- }
- }
- OmUtil.tmpl('#quick-vote-template', 'quick-vote');
-}
-function __activityAVIcon(elem, selector, predicate, onfunc, disabledfunc) {
- let icon = elem.find(selector);
- if (predicate()) {
- icon.show();
- const on = onfunc()
- , disabled = disabledfunc();
- if (disabled) {
- icon.addClass('disabled');
- } else {
- icon.removeClass('disabled');
- if (on) {
- icon.addClass('enabled');
- } else {
- icon.removeClass('enabled');
- }
- }
- icon.attr('title', icon.data(on ? 'on' :'off'));
- } else {
- icon.hide();
- }
-}
-function __activityIcon(elem, selector, predicate, action, confirm) {
- let icon = elem.find(selector);
- if (predicate()) {
- if (icon.length === 0) {
- icon = OmUtil.tmpl('#user-actions-stub ' + selector);
- elem.append(icon);
- }
- icon.off();
- if (confirm) {
- icon.confirmation('dispose');
- icon.confirmation(confirm)
- } else {
- icon.click(action);
- }
- } else {
- icon.hide();
- }
-}
-function __rightIcon(c, elem, rights, selector, predicate) {
- const self = c.uid === options.uid
- , hasRight = _hasRight(rights, c.rights);
- let icon = elem.find(selector);
- if (predicate() && !_hasRight('SUPER_MODERATOR', c.rights) && (
- (self && options.questions && !hasRight)
- || (!self && _hasRight('MODERATOR'))
- )) {
- if (icon.length === 0) {
- icon = OmUtil.tmpl('#user-actions-stub ' + selector);
- elem.append(icon);
- }
- if (hasRight) {
- icon.addClass('granted');
- } else {
- icon.removeClass('granted')
- }
- icon.attr('title', icon.data(self ? 'request' : (hasRight ?
'revoke' : 'grant')));
- icon.off().click(function() {
- OmUtil.roomAction({action: 'toggleRight', right:
rights[0], uid: c.uid});
- });
- } else {
- icon.remove();
- }
-}
-function __rightAudioIcon(c, elem) {
- __rightIcon(c, elem, ['AUDIO'], '.right.audio', () => true);
-}
-function __rightVideoIcon(c, elem) {
- __rightIcon(c, elem, ['VIDEO'], '.right.camera', () =>
!options.audioOnly);
-}
-function __rightOtherIcons(c, elem) {
- __rightIcon(c, elem, ['PRESENTER'], '.right.presenter', () =>
!options.interview && $('.wb-area').is(':visible'));
- __rightIcon(c, elem, ['WHITEBOARD', 'PRESENTER'], '.right.wb', () =>
!options.interview && $('.wb-area').is(':visible'));
- __rightIcon(c, elem, ['SHARE'], '.right.screen-share', () => true);
//FIXME TODO getRoomPanel().screenShareAllowed()
- __rightIcon(c, elem, ['REMOTE_CONTROL'], '.right.remote-control', () =>
true); //FIXME TODO getRoomPanel().screenShareAllowed()
- __rightIcon(c, elem, ['MODERATOR'], '.right.moderator', () => true);
-}
-function __setStatus(c, le) {
- const status = le.find('.user-status')
- , mode = c.level == 5 ? 'mod' : (c.level == 3 ? 'wb' : 'user');
- status.removeClass('mod wb user');
- status.attr('title', status.data(mode)).addClass(mode);
- le.data('level', c.level);
-}
-function __updateCount() {
- $('#room-sidebar-users-tab
.user-count').text($('#room-sidebar-tab-users .user-list .users
.user.entry').length);
-}
-function __sortUserList() {
- const container = $('#room-sidebar-tab-users .user-list .users');
- container.find('.user.entry').sort((_u1, _u2) => {
- const u1 = $(_u1)
- , u2 = $(_u2);
- return u2.data('level') - u1.data('level') ||
u1.attr('title').localeCompare(u2.attr('title'));
- }).appendTo(container);
-}
-function _addClient(_clients) {
- if (!options) {
- return; //too early
- }
- const clients = Array.isArray(_clients) ? _clients : [_clients];
- clients.forEach(c => {
- const self = c.uid === options.uid;
- let le = Room.getClient(c.uid);
- if (le.length === 0) {
- le = OmUtil.tmpl('#user-entry-stub', 'user' + c.uid);
- le.attr('id', 'user' + c.uid)
- .attr('data-userid', c.user.id)
- .attr('data-uid', c.uid);
- if (self) {
- le.addClass('current');
- }
- $('#room-sidebar-tab-users .user-list
.users').append(le);
- }
- _updateClient(c);
- });
- __updateCount();
- __sortUserList();
-}
-function _updateClient(c) {
- if (!options) {
- return; //too early
- }
- const self = c.uid === options.uid
- , le = Room.getClient(c.uid)
- , hasAudio = VideoUtil.hasMic(c)
- , hasVideo = VideoUtil.hasCam(c)
- , speaks = le.find('.audio-activity');
- if (le.length === 0) {
- return;
- }
- __setStatus(c, le);
- if (hasVideo || hasAudio) {
- if (le.find('.restart').length === 0) {
-
le.prepend(OmUtil.tmpl('#user-av-restart').click(function () {
- VideoManager.refresh(c.uid);
- }));
- }
- } else {
- le.find('.restart').remove();
- }
- speaks.hide().removeClass('clickable').attr('title',
speaks.data('speaks')).off();
- if (hasAudio) {
- speaks.show();
- if(_hasRight('MUTE_OTHERS')) {
- speaks.addClass('clickable').click(function () {
- VideoManager.clickMuteOthers(c.uid);
- }).attr('title', speaks.attr('title') +
speaks.data('mute'));
- }
- }
- le.attr('title', c.user.displayName)
- .css('background-image', 'url(' + c.user.pictureUri + ')')
- .find('.user.name').text(c.user.displayName);
-
- if (c.user.id !== -1) {
- const actions = le.find('.user.actions');
- __rightVideoIcon(c, actions);
- __rightAudioIcon(c, actions);
- __rightOtherIcons(c, actions);
- __activityIcon(actions, '.kick'
- , () => !self && _hasRight('MODERATOR') &&
!_hasRight('SUPER_MODERATOR', c.rights)
- , null
- , {
- confirmationEvent: 'om-kick'
- , placement: Settings.isRtl ? 'left' : 'right'
- , onConfirm: () => OmUtil.roomAction({action:
'kick', uid: c.uid})
- });
- __activityIcon(actions, '.private-chat'
- , () => options.userId !== c.user.id &&
$('#chatPanel').is(':visible')
- , function() {
- Chat.addTab('chatTab-u' + c.user.id,
c.user.displayName);
- Chat.open();
- $('#chatMessage .wysiwyg-editor').click();
- });
- }
- if (self) {
- options.rights = c.rights;
- _setQuickPollRights();
- options.activities = c.activities;
- const header = $('#room-sidebar-tab-users .header');
- __rightVideoIcon(c, header);
- __activityAVIcon(header, '.activity.cam', () =>
!options.audioOnly && _hasRight('VIDEO')
- , () => hasVideo
- , () => Settings.load().video.cam < 0);
- __rightAudioIcon(c, header);
- __activityAVIcon(header, '.activity.mic', () =>
_hasRight('AUDIO')
- , () => hasAudio
- , () => Settings.load().video.mic < 0);
- __rightOtherIcons(c, header);
- }
- VideoManager.update(c)
-}
module.exports = {
init: _init
@@ -492,31 +233,14 @@ module.exports = {
, load: _load
, unload: _unload
, showClipboard: _showClipboard
- , quickPoll: _quickPoll
- , hasRight: _hasRight
+ , quickPoll: QuickPoll.update
+ , hasRight: UserList.hasRight
, setCssVar: function(key, val) {
($('.main.room')[0]).style.setProperty(key, val);
}
- , addClient: _addClient
- , updateClient: function(c) {
- _updateClient(c);
- __sortUserList();
- }
- , removeClient: function(uid) {
- Room.getClient(uid).remove();
- __updateCount();
- }
- , removeOthers: function() {
- const selfUid = Room.getOptions().uid;
- $('.user-list .user.entry').each(function() {
- const c = $(this);
- if (c.data('uid') !== selfUid) {
- c.remove();
- }
- });
- __updateCount();
- }
- , getClient: function(uid) {
- return $('#user' + uid);
- }
+ , addClient: UserList.addClient
+ , updateClient: UserList.updateClient
+ , removeClient: UserList.removeClient
+ , removeOthers: UserList.removeOthers
+ , getClient: UserList.getClient
};
diff --git a/openmeetings-web/src/main/front/room/src/user-list.js
b/openmeetings-web/src/main/front/room/src/user-list.js
new file mode 100644
index 0000000..66169e6
--- /dev/null
+++ b/openmeetings-web/src/main/front/room/src/user-list.js
@@ -0,0 +1,249 @@
+/* Licensed under the Apache License, Version 2.0 (the "License")
http://www.apache.org/licenses/LICENSE-2.0 */
+const VideoManager = require('./video-manager');
+const QuickPoll = require('./quick-poll');
+
+let options;
+
+function _hasRight(_inRights, _ref) {
+ const ref = _ref || options.rights;
+ let _rights;
+ if (Array.isArray(_inRights)) {
+ _rights = _inRights;
+ } else {
+ if ('SUPER_MODERATOR' === _inRights) {
+ return ref.includes(_inRights);
+ }
+ _rights = [_inRights];
+ }
+ const rights = ['SUPER_MODERATOR', 'MODERATOR', ..._rights];
+ for (let i = 0; i < rights.length; ++i) {
+ if (ref.includes(rights[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function __activityAVIcon(elem, selector, predicate, onfunc, disabledfunc) {
+ let icon = elem.find(selector);
+ if (predicate()) {
+ icon.show();
+ const on = onfunc()
+ , disabled = disabledfunc();
+ if (disabled) {
+ icon.addClass('disabled');
+ } else {
+ icon.removeClass('disabled');
+ if (on) {
+ icon.addClass('enabled');
+ } else {
+ icon.removeClass('enabled');
+ }
+ }
+ icon.attr('title', icon.data(on ? 'on' :'off'));
+ } else {
+ icon.hide();
+ }
+}
+function __activityIcon(elem, selector, predicate, action, confirm) {
+ let icon = elem.find(selector);
+ if (predicate()) {
+ if (icon.length === 0) {
+ icon = OmUtil.tmpl('#user-actions-stub ' + selector);
+ elem.append(icon);
+ }
+ icon.off();
+ if (confirm) {
+ icon.confirmation('dispose');
+ icon.confirmation(confirm)
+ } else {
+ icon.click(action);
+ }
+ } else {
+ icon.hide();
+ }
+}
+function __rightIcon(c, elem, rights, selector, predicate) {
+ const self = c.uid === options.uid
+ , hasRight = _hasRight(rights, c.rights);
+ let icon = elem.find(selector);
+ if (predicate() && !_hasRight('SUPER_MODERATOR', c.rights) && (
+ (self && options.questions && !hasRight)
+ || (!self && _hasRight('MODERATOR'))
+ )) {
+ if (icon.length === 0) {
+ icon = OmUtil.tmpl('#user-actions-stub ' + selector);
+ elem.append(icon);
+ }
+ if (hasRight) {
+ icon.addClass('granted');
+ } else {
+ icon.removeClass('granted')
+ }
+ icon.attr('title', icon.data(self ? 'request' : (hasRight ?
'revoke' : 'grant')));
+ icon.off().click(function() {
+ OmUtil.roomAction({action: 'toggleRight', right:
rights[0], uid: c.uid});
+ });
+ } else {
+ icon.remove();
+ }
+}
+function __rightAudioIcon(c, elem) {
+ __rightIcon(c, elem, ['AUDIO'], '.right.audio', () => true);
+}
+function __rightVideoIcon(c, elem) {
+ __rightIcon(c, elem, ['VIDEO'], '.right.camera', () =>
!options.audioOnly);
+}
+function __rightOtherIcons(c, elem) {
+ __rightIcon(c, elem, ['PRESENTER'], '.right.presenter', () =>
!options.interview && $('.wb-area').is(':visible'));
+ __rightIcon(c, elem, ['WHITEBOARD', 'PRESENTER'], '.right.wb', () =>
!options.interview && $('.wb-area').is(':visible'));
+ __rightIcon(c, elem, ['SHARE'], '.right.screen-share', () => true);
//FIXME TODO getRoomPanel().screenShareAllowed()
+ __rightIcon(c, elem, ['REMOTE_CONTROL'], '.right.remote-control', () =>
true); //FIXME TODO getRoomPanel().screenShareAllowed()
+ __rightIcon(c, elem, ['MODERATOR'], '.right.moderator', () => true);
+}
+function __setStatus(c, le) {
+ const status = le.find('.user-status')
+ , mode = c.level == 5 ? 'mod' : (c.level == 3 ? 'wb' : 'user');
+ status.removeClass('mod wb user');
+ status.attr('title', status.data(mode)).addClass(mode);
+ le.data('level', c.level);
+}
+function __updateCount() {
+ $('#room-sidebar-users-tab
.user-count').text($('#room-sidebar-tab-users .user-list .users
.user.entry').length);
+}
+function __sortUserList() {
+ const container = $('#room-sidebar-tab-users .user-list .users');
+ container.find('.user.entry').sort((_u1, _u2) => {
+ const u1 = $(_u1)
+ , u2 = $(_u2);
+ return u2.data('level') - u1.data('level') ||
u1.attr('title').localeCompare(u2.attr('title'));
+ }).appendTo(container);
+}
+
+
+function _getClient(uid) {
+ return $('#user' + uid);
+}
+function _addClient(_clients) {
+ if (!options) {
+ return; //too early
+ }
+ const clients = Array.isArray(_clients) ? _clients : [_clients];
+ clients.forEach(c => {
+ const self = c.uid === options.uid;
+ let le = _getClient(c.uid);
+ if (le.length === 0) {
+ le = OmUtil.tmpl('#user-entry-stub', 'user' + c.uid);
+ le.attr('id', 'user' + c.uid)
+ .attr('data-userid', c.user.id)
+ .attr('data-uid', c.uid);
+ if (self) {
+ le.addClass('current');
+ }
+ $('#room-sidebar-tab-users .user-list
.users').append(le);
+ }
+ _updateClient(c);
+ });
+ __updateCount();
+ __sortUserList();
+}
+function _updateClient(c) {
+ if (!options) {
+ return; //too early
+ }
+ const self = c.uid === options.uid
+ , le = _getClient(c.uid)
+ , hasAudio = VideoUtil.hasMic(c)
+ , hasVideo = VideoUtil.hasCam(c)
+ , speaks = le.find('.audio-activity');
+ if (le.length === 0) {
+ return;
+ }
+ __setStatus(c, le);
+ if (hasVideo || hasAudio) {
+ if (le.find('.restart').length === 0) {
+
le.prepend(OmUtil.tmpl('#user-av-restart').click(function () {
+ VideoManager.refresh(c.uid);
+ }));
+ }
+ } else {
+ le.find('.restart').remove();
+ }
+ speaks.hide().removeClass('clickable').attr('title',
speaks.data('speaks')).off();
+ if (hasAudio) {
+ speaks.show();
+ if(_hasRight('MUTE_OTHERS')) {
+ speaks.addClass('clickable').click(function () {
+ VideoManager.clickMuteOthers(c.uid);
+ }).attr('title', speaks.attr('title') +
speaks.data('mute'));
+ }
+ }
+ le.attr('title', c.user.displayName)
+ .css('background-image', 'url(' + c.user.pictureUri + ')')
+ .find('.user.name').text(c.user.displayName);
+
+ if (c.user.id !== -1) {
+ const actions = le.find('.user.actions');
+ __rightVideoIcon(c, actions);
+ __rightAudioIcon(c, actions);
+ __rightOtherIcons(c, actions);
+ __activityIcon(actions, '.kick'
+ , () => !self && _hasRight('MODERATOR') &&
!_hasRight('SUPER_MODERATOR', c.rights)
+ , null
+ , {
+ confirmationEvent: 'om-kick'
+ , placement: Settings.isRtl ? 'left' : 'right'
+ , onConfirm: () => OmUtil.roomAction({action:
'kick', uid: c.uid})
+ });
+ __activityIcon(actions, '.private-chat'
+ , () => options.userId !== c.user.id &&
$('#chatPanel').is(':visible')
+ , function() {
+ Chat.addTab('chatTab-u' + c.user.id,
c.user.displayName);
+ Chat.open();
+ $('#chatMessage .wysiwyg-editor').click();
+ });
+ }
+ if (self) {
+ options.rights = c.rights;
+ QuickPoll.setRights();
+ options.activities = c.activities;
+ const header = $('#room-sidebar-tab-users .header');
+ __rightVideoIcon(c, header);
+ __activityAVIcon(header, '.activity.cam', () =>
!options.audioOnly && _hasRight('VIDEO')
+ , () => hasVideo
+ , () => Settings.load().video.cam < 0);
+ __rightAudioIcon(c, header);
+ __activityAVIcon(header, '.activity.mic', () =>
_hasRight('AUDIO')
+ , () => hasAudio
+ , () => Settings.load().video.mic < 0);
+ __rightOtherIcons(c, header);
+ }
+ VideoManager.update(c)
+}
+
+module.exports = {
+ init: function(opts) {
+ options = opts;
+ }
+ , hasRight: _hasRight
+ , addClient: _addClient
+ , updateClient: function(c) {
+ _updateClient(c);
+ __sortUserList();
+ }
+ , removeClient: function(uid) {
+ _getClient(uid).remove();
+ __updateCount();
+ }
+ , removeOthers: function() {
+ const selfUid = options.uid;
+ $('.user-list .user.entry').each(function() {
+ const c = $(this);
+ if (c.data('uid') !== selfUid) {
+ c.remove();
+ }
+ });
+ __updateCount();
+ }
+ , getClient: _getClient
+};