This commit is contained in:
Ilya Tregubov 2022-11-24 10:59:29 +03:00
commit 3c36928805
8 changed files with 40 additions and 46 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,10 @@
define("mod_bigbluebuttonbn/roomupdater",["exports","core/templates","core/notification","./repository"],(function(_exports,_templates,_notification,_repository){var obj;
define("mod_bigbluebuttonbn/roomupdater",["exports","core/pending","core/templates","core/notification","./repository"],(function(_exports,_pending,_templates,_notification,_repository){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
/**
* JS room updater.
*
* @module mod_bigbluebuttonbn/roomupdater
* @copyright 2021 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.updateRoom=_exports.stop=_exports.start=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj};let timerReference=null,timerRunning=!1,pollInterval=0,pollIntervalFactor=1;const resetValues=()=>{timerRunning=!1,timerReference=null,pollInterval=0,pollIntervalFactor=1};_exports.start=interval=>{resetValues(),timerRunning=!0,pollInterval=interval,poll()};_exports.stop=()=>{timerReference&&clearTimeout(timerReference),resetValues()};const poll=()=>{timerRunning&&pollInterval&&updateRoom().then((updateOk=>(updateOk||(pollIntervalFactor=pollIntervalFactor<10?pollIntervalFactor+1:10),timerReference=setTimeout((()=>poll()),pollInterval*pollIntervalFactor),!0))).catch()},updateRoom=function(){let updatecache=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const bbbRoomViewElement=document.getElementById("bigbluebuttonbn-room-view");if(!bbbRoomViewElement)return Promise.resolve(!1);const bbbId=bbbRoomViewElement.dataset.bbbId,groupId=bbbRoomViewElement.dataset.groupId;return(0,_repository.getMeetingInfo)(bbbId,groupId,updatecache).then((data=>(data.haspresentations=!(!data.presentations||!data.presentations.length),_templates.default.renderForPromise("mod_bigbluebuttonbn/room_view",data)))).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.replaceNode(bbbRoomViewElement,html,js)})).then((()=>!0)).catch((ex=>((0,_notification.exception)(ex),!1)))};_exports.updateRoom=updateRoom}));
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.updateRoom=_exports.stop=_exports.start=void 0,_pending=_interopRequireDefault(_pending),_templates=_interopRequireDefault(_templates);let timerReference=null,timerRunning=!1,pollInterval=0,pollIntervalFactor=1;const resetValues=()=>{timerRunning=!1,timerReference=null,pollInterval=0,pollIntervalFactor=1};_exports.start=interval=>{resetValues(),timerRunning=!0,pollInterval=interval,poll()};_exports.stop=()=>{timerReference&&clearTimeout(timerReference),resetValues()};const poll=()=>{timerRunning&&pollInterval&&updateRoom().then((updateOk=>(updateOk||(pollIntervalFactor=pollIntervalFactor<10?pollIntervalFactor+1:10),timerReference=setTimeout((()=>poll()),pollInterval*pollIntervalFactor),!0))).catch()},updateRoom=function(){let updatecache=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const bbbRoomViewElement=document.getElementById("bigbluebuttonbn-room-view");if(null===bbbRoomViewElement)return Promise.resolve(!1);const bbbId=bbbRoomViewElement.dataset.bbbId,groupId=bbbRoomViewElement.dataset.groupId,pendingPromise=new _pending.default("mod_bigbluebuttonbn/roomupdater:updateRoom");return(0,_repository.getMeetingInfo)(bbbId,groupId,updatecache).then((data=>(data.haspresentations=!(!data.presentations||!data.presentations.length),_templates.default.renderForPromise("mod_bigbluebuttonbn/room_view",data)))).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.replaceNode(bbbRoomViewElement,html,js)})).then((()=>pendingPromise.resolve())).catch(_notification.exception)};_exports.updateRoom=updateRoom}));
//# sourceMappingURL=roomupdater.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"roomupdater.min.js","sources":["../src/roomupdater.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JS room updater.\n *\n * @module mod_bigbluebuttonbn/roomupdater\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Templates from \"core/templates\";\nimport {exception as displayException} from 'core/notification';\nimport {getMeetingInfo} from './repository';\n\nlet timerReference = null;\nlet timerRunning = false;\nlet pollInterval = 0;\nlet pollIntervalFactor = 1;\nconst MAX_POLL_INTERVAL_FACTOR = 10;\n\nconst resetValues = () => {\n timerRunning = false;\n timerReference = null;\n pollInterval = 0;\n pollIntervalFactor = 1;\n};\n\n/**\n * Start the information poller.\n * @param {Number} interval interval in miliseconds between each poll action.\n */\nexport const start = (interval) => {\n resetValues();\n timerRunning = true;\n pollInterval = interval;\n poll();\n};\n\n/**\n * Stop the room updater.\n */\nexport const stop = () => {\n if (timerReference) {\n clearTimeout(timerReference);\n }\n resetValues();\n};\n\n/**\n * Start the information poller.\n */\nconst poll = () => {\n if (!timerRunning || !pollInterval) {\n // The poller has been stopped.\n return;\n }\n updateRoom()\n .then((updateOk) => {\n if (!updateOk) {\n pollIntervalFactor = (pollIntervalFactor < MAX_POLL_INTERVAL_FACTOR) ?\n pollIntervalFactor + 1 : MAX_POLL_INTERVAL_FACTOR;\n // We make sure if there is an error that we do not try too often.\n }\n timerReference = setTimeout(() => poll(), pollInterval * pollIntervalFactor);\n return true;\n })\n .catch();\n};\n\n/**\n * Update the room information.\n *\n * @param {boolean} [updatecache=false] should we update cache\n * @returns {Promise}\n */\nexport const updateRoom = (updatecache = false) => {\n const bbbRoomViewElement = document.getElementById('bigbluebuttonbn-room-view');\n if (!bbbRoomViewElement) {\n return Promise.resolve(false);\n }\n const bbbId = bbbRoomViewElement.dataset.bbbId;\n const groupId = bbbRoomViewElement.dataset.groupId;\n return getMeetingInfo(bbbId, groupId, updatecache)\n .then(data => {\n // Just make sure we have the right information for the template.\n data.haspresentations = !!(data.presentations && data.presentations.length);\n return Templates.renderForPromise('mod_bigbluebuttonbn/room_view', data);\n })\n .then(({html, js}) => Templates.replaceNode(bbbRoomViewElement, html, js))\n .then(() => true)\n .catch((ex) => {\n displayException(ex);\n return false;\n });\n};\n"],"names":["timerReference","timerRunning","pollInterval","pollIntervalFactor","resetValues","interval","poll","clearTimeout","updateRoom","then","updateOk","setTimeout","catch","updatecache","bbbRoomViewElement","document","getElementById","Promise","resolve","bbbId","dataset","groupId","data","haspresentations","presentations","length","Templates","renderForPromise","_ref","html","js","replaceNode","ex"],"mappings":";;;;;;;uLA2BIA,eAAiB,KACjBC,cAAe,EACfC,aAAe,EACfC,mBAAqB,QAGnBC,YAAc,KAChBH,cAAe,EACfD,eAAiB,KACjBE,aAAe,EACfC,mBAAqB,kBAOHE,WAClBD,cACAH,cAAe,EACfC,aAAeG,SACfC,sBAMgB,KACZN,gBACAO,aAAaP,gBAEjBI,qBAMEE,KAAO,KACJL,cAAiBC,cAItBM,aACKC,MAAMC,WACEA,WACDP,mBAAsBA,mBAzCL,GA0CbA,mBAAqB,EA1CR,IA6CrBH,eAAiBW,YAAW,IAAML,QAAQJ,aAAeC,qBAClD,KAEVS,SASIJ,WAAa,eAACK,0EACjBC,mBAAqBC,SAASC,eAAe,iCAC9CF,0BACMG,QAAQC,SAAQ,SAErBC,MAAQL,mBAAmBM,QAAQD,MACnCE,QAAUP,mBAAmBM,QAAQC,eACpC,8BAAeF,MAAOE,QAASR,aACjCJ,MAAKa,OAEFA,KAAKC,oBAAsBD,KAAKE,gBAAiBF,KAAKE,cAAcC,QAC7DC,mBAAUC,iBAAiB,gCAAiCL,SAEtEb,MAAKmB,WAACC,KAACA,KAADC,GAAOA,gBAAQJ,mBAAUK,YAAYjB,mBAAoBe,KAAMC,OACrErB,MAAK,KAAM,IACXG,OAAOoB,iCACaA,KACV"}
{"version":3,"file":"roomupdater.min.js","sources":["../src/roomupdater.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * JS room updater.\n *\n * @module mod_bigbluebuttonbn/roomupdater\n * @copyright 2021 Blindside Networks Inc\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\nimport Templates from \"core/templates\";\nimport {exception as displayException} from 'core/notification';\nimport {getMeetingInfo} from './repository';\n\nlet timerReference = null;\nlet timerRunning = false;\nlet pollInterval = 0;\nlet pollIntervalFactor = 1;\nconst MAX_POLL_INTERVAL_FACTOR = 10;\n\nconst resetValues = () => {\n timerRunning = false;\n timerReference = null;\n pollInterval = 0;\n pollIntervalFactor = 1;\n};\n\n/**\n * Start the information poller.\n * @param {Number} interval interval in miliseconds between each poll action.\n */\nexport const start = (interval) => {\n resetValues();\n timerRunning = true;\n pollInterval = interval;\n poll();\n};\n\n/**\n * Stop the room updater.\n */\nexport const stop = () => {\n if (timerReference) {\n clearTimeout(timerReference);\n }\n resetValues();\n};\n\n/**\n * Start the information poller.\n */\nconst poll = () => {\n if (!timerRunning || !pollInterval) {\n // The poller has been stopped.\n return;\n }\n updateRoom()\n .then((updateOk) => {\n if (!updateOk) {\n pollIntervalFactor = (pollIntervalFactor < MAX_POLL_INTERVAL_FACTOR) ?\n pollIntervalFactor + 1 : MAX_POLL_INTERVAL_FACTOR;\n // We make sure if there is an error that we do not try too often.\n }\n timerReference = setTimeout(() => poll(), pollInterval * pollIntervalFactor);\n return true;\n })\n .catch();\n};\n\n/**\n * Update the room information.\n *\n * @param {boolean} [updatecache=false] should we update cache\n * @returns {Promise}\n */\nexport const updateRoom = (updatecache = false) => {\n const bbbRoomViewElement = document.getElementById('bigbluebuttonbn-room-view');\n if (bbbRoomViewElement === null) {\n return Promise.resolve(false);\n }\n\n const bbbId = bbbRoomViewElement.dataset.bbbId;\n const groupId = bbbRoomViewElement.dataset.groupId;\n\n const pendingPromise = new Pending('mod_bigbluebuttonbn/roomupdater:updateRoom');\n\n return getMeetingInfo(bbbId, groupId, updatecache)\n .then(data => {\n // Just make sure we have the right information for the template.\n data.haspresentations = !!(data.presentations && data.presentations.length);\n return Templates.renderForPromise('mod_bigbluebuttonbn/room_view', data);\n })\n .then(({html, js}) => Templates.replaceNode(bbbRoomViewElement, html, js))\n .then(() => pendingPromise.resolve())\n .catch(displayException);\n};\n"],"names":["timerReference","timerRunning","pollInterval","pollIntervalFactor","resetValues","interval","poll","clearTimeout","updateRoom","then","updateOk","setTimeout","catch","updatecache","bbbRoomViewElement","document","getElementById","Promise","resolve","bbbId","dataset","groupId","pendingPromise","Pending","data","haspresentations","presentations","length","Templates","renderForPromise","_ref","html","js","replaceNode","displayException"],"mappings":";;;;;;;iNA4BIA,eAAiB,KACjBC,cAAe,EACfC,aAAe,EACfC,mBAAqB,QAGnBC,YAAc,KAChBH,cAAe,EACfD,eAAiB,KACjBE,aAAe,EACfC,mBAAqB,kBAOHE,WAClBD,cACAH,cAAe,EACfC,aAAeG,SACfC,sBAMgB,KACZN,gBACAO,aAAaP,gBAEjBI,qBAMEE,KAAO,KACJL,cAAiBC,cAItBM,aACKC,MAAMC,WACEA,WACDP,mBAAsBA,mBAzCL,GA0CbA,mBAAqB,EA1CR,IA6CrBH,eAAiBW,YAAW,IAAML,QAAQJ,aAAeC,qBAClD,KAEVS,SASIJ,WAAa,eAACK,0EACjBC,mBAAqBC,SAASC,eAAe,gCACxB,OAAvBF,0BACOG,QAAQC,SAAQ,SAGrBC,MAAQL,mBAAmBM,QAAQD,MACnCE,QAAUP,mBAAmBM,QAAQC,QAErCC,eAAiB,IAAIC,iBAAQ,qDAE5B,8BAAeJ,MAAOE,QAASR,aACjCJ,MAAKe,OAEFA,KAAKC,oBAAsBD,KAAKE,gBAAiBF,KAAKE,cAAcC,QAC7DC,mBAAUC,iBAAiB,gCAAiCL,SAEtEf,MAAKqB,WAACC,KAACA,KAADC,GAAOA,gBAAQJ,mBAAUK,YAAYnB,mBAAoBiB,KAAMC,OACrEvB,MAAK,IAAMa,eAAeJ,YAC1BN,MAAMsB"}

View File

@ -99,6 +99,9 @@ const getTableNode = tableSelector => document.querySelector(tableSelector);
const fetchRecordingData = tableSelector => {
const tableNode = getTableNode(tableSelector);
if (tableNode === null) {
return Promise.resolve(false);
}
if (tableNode.dataset.importMode) {
return repository.fetchRecordingsToImport(
@ -225,7 +228,7 @@ const getDataTableFunctions = (tableId, searchFormId, dataTable) => {
modal.show();
return modal;
}).catch(Notification.exception)
}).catch(displayException)
).then((proceed) =>
proceed ? repository.updateRecording(payload) : () => null
);
@ -292,9 +295,8 @@ const getDataTableFunctions = (tableId, searchFormId, dataTable) => {
requestAction(clickedLink)
.then(refreshTableData)
.catch(displayException)
.then(iconPromise.resolve)
.catch();
.catch(displayException);
}
};
@ -405,7 +407,10 @@ const setupDatatable = (tableId, searchFormId, response) => {
* @param {String} searchFormId The Id of the relate.
*/
export const init = (tableId, searchFormId) => {
const pendingPromise = new Pending('mod_bigbluebuttonbn/recordings:init');
fetchRecordingData(tableId)
.then(response => setupDatatable(tableId, searchFormId, response))
.then(() => pendingPromise.resolve())
.catch(displayException);
};

View File

@ -21,6 +21,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
import Pending from 'core/pending';
import Templates from "core/templates";
import {exception as displayException} from 'core/notification';
import {getMeetingInfo} from './repository';
@ -88,11 +89,15 @@ const poll = () => {
*/
export const updateRoom = (updatecache = false) => {
const bbbRoomViewElement = document.getElementById('bigbluebuttonbn-room-view');
if (!bbbRoomViewElement) {
if (bbbRoomViewElement === null) {
return Promise.resolve(false);
}
const bbbId = bbbRoomViewElement.dataset.bbbId;
const groupId = bbbRoomViewElement.dataset.groupId;
const pendingPromise = new Pending('mod_bigbluebuttonbn/roomupdater:updateRoom');
return getMeetingInfo(bbbId, groupId, updatecache)
.then(data => {
// Just make sure we have the right information for the template.
@ -100,9 +105,6 @@ export const updateRoom = (updatecache = false) => {
return Templates.renderForPromise('mod_bigbluebuttonbn/room_view', data);
})
.then(({html, js}) => Templates.replaceNode(bbbRoomViewElement, html, js))
.then(() => true)
.catch((ex) => {
displayException(ex);
return false;
});
.then(() => pendingPromise.resolve())
.catch(displayException);
};

View File

@ -36,16 +36,17 @@ Feature: bigbluebuttonbn instance
And I should see "Recordings"
Scenario: Add a Recording Only activity and check that no live session settings are available for this instance type
Given I am on the "Test course" "course" page logged in as "admin"
And I am on "Test course" course homepage with editing mode on
When I turn editing mode on
And I change window size to "large"
And I add a "BigBlueButton" to section "1"
When I select "Recordings only" from the "Instance type" singleselect
And I select "Recordings only" from the "Instance type" singleselect
Then I should not see "Lock settings"
Scenario Outline: Add an activity and check that required settings are available for the three types of instance types
When I turn editing mode on
And I change window size to "large"
And I add a "BigBlueButton" to section "1"
And I select "<type>" from the "Instance type" singleselect
And I select "<type>" from the "Instance type" singleselect
Then I should see "Restrict access"
Examples:

View File

@ -24,36 +24,25 @@ Feature: The recording can be managed through the room page
| RoomRecordings | Recording 3 | Description 3 | 0 |
| RoomRecordings | Recording 4 | Description 4 | 1 |
@javascript
Scenario: Recordings are not listed until the server informs that they are available
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
And I should not see "Recording 3"
When the BigBlueButtonBN server has sent recording ready notifications
And I reload the page
And I should see "Recording 3"
@javascript
Scenario: Recordings are not listed until we can fetch their metadata, then they are listed
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
# Recording 3 will be fetched and metadata will be present so, we will see it.
And I should not see "Recording 3"
And I should not see "Recording 4"
When the BigBlueButtonBN server has sent recording ready notifications
And I reload the page
Then I should see "Recording 3"
And I should not see "Recording 4"
@javascript
Scenario: I can see the recordings related to an activity
Given the BigBlueButtonBN server has sent recording ready notifications
When I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
And "Recording 1" "table_row" should exist
And "Recording 2" "table_row" should exist
And "Recording 3" "table_row" should not exist
And "Recording 4" "table_row" should not exist
# Recording 3 will be fetched and metadata will be present so, we will see it.
When the BigBlueButtonBN server has sent recording ready notifications
And I run the scheduled task "mod_bigbluebuttonbn\task\check_pending_recordings"
And I reload the page
Then "Recording 1" "table_row" should exist
And "Recording 2" "table_row" should exist
And "Recording 3" "table_row" should exist
And "Recording 4" "table_row" should not exist
@javascript
Scenario: I can rename the recording
Given the BigBlueButtonBN server has sent recording ready notifications
And I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
When I set the field "Edit name" in the "Recording 1" "table_row" to "Recording with an updated name 1"
Then I should see "Recording with an updated name 1"
And I should see "Recording 2"
@ -63,8 +52,7 @@ Feature: The recording can be managed through the room page
@javascript
Scenario: I can set a new description for this recording
Given the BigBlueButtonBN server has sent recording ready notifications
And I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
When I set the field "Edit description" in the "Recording 1" "table_row" to "This is a new recording description 1"
Then I should see "This is a new recording description 1"
And I should see "Description 2" in the "Recording 2" "table_row"
@ -74,10 +62,8 @@ Feature: The recording can be managed through the room page
@javascript
Scenario: I can delete a recording
Given the BigBlueButtonBN server has sent recording ready notifications
And I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
Given I am on the "RoomRecordings" "bigbluebuttonbn activity" page logged in as admin
When I click on "a[data-action='delete']" "css_element" in the "Recording 1" "table_row"
And I wait until the page is ready
And I click on "OK" "button" in the "Confirm" "dialogue"
Then I should not see "Recording 1"
And I should see "Recording 2"