Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
/**
16
 * JS actions.
17
 *
18
 * @module      mod_bigbluebuttonbn/actions
19
 * @copyright   2021 Blindside Networks Inc
20
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21
 */
22
 
23
import {endMeeting as requestEndMeeting} from './repository';
24
import {
25
    exception as displayException,
26
    saveCancel,
27
} from 'core/notification';
28
import {notifySessionEnded} from './events';
29
import {getString} from 'core/str';
30
 
31
const confirmedPromise = (title, question, saveLabel) => new Promise(resolve => {
32
    saveCancel(title, question, saveLabel, resolve);
33
});
34
 
35
const registerEventListeners = () => {
36
    document.addEventListener('click', e => {
37
        const actionButton = e.target.closest('.bbb-btn-action[data-action="end"]');
38
        if (!actionButton) {
39
            return;
40
        }
41
 
42
        e.preventDefault();
43
 
44
        const bbbId = actionButton.dataset.bbbId;
45
        const groupId = actionButton.dataset.groupId ? actionButton.dataset.groupId : 0;
46
 
47
        confirmedPromise(
48
            getString('end_session_confirm_title', 'mod_bigbluebuttonbn'),
49
            getString('end_session_confirm', 'mod_bigbluebuttonbn'),
50
            getString('yes', 'moodle')
51
        )
52
        .then(() => requestEndMeeting(bbbId, groupId))
53
        .then(() => {
54
            notifySessionEnded(bbbId, groupId);
55
 
56
            return;
57
        })
58
        .catch(displayException);
59
    });
60
};
61
 
62
let listening = false;
63
if (!listening) {
64
    registerEventListeners();
65
    listening = true;
66
}