Add waiting room to create programming groups (#1919)

Co-authored-by: Sebastian Serth <Sebastian.Serth@hpi.de>
This commit is contained in:
Kira Grammel
2023-09-21 15:07:10 +02:00
committed by GitHub
parent 1dfc306e76
commit 9f837412c7
15 changed files with 174 additions and 48 deletions

View File

@@ -3,10 +3,9 @@ $(document).on('turbolinks:load', function () {
if ($.isController('programming_groups') && window.location.pathname.includes('programming_groups/new')) {
const matching_page = $('#matching');
const exercise_id = matching_page.data('exercise-id');
const specific_channel = { channel: "PgMatchingChannel", exercise_id: exercise_id};
App.pg_matching = App.cable.subscriptions.create({
channel: "PgMatchingChannel", exercise_id: exercise_id
}, {
App.pg_matching = App.cable.subscriptions.create(specific_channel, {
connected() {
// Called when the subscription is ready for use on the server
},
@@ -23,8 +22,17 @@ $(document).on('turbolinks:load', function () {
window.location.reload();
}
break;
case 'joined_pg':
if (ProgrammingGroups.contains_own_user(data.users)) {
window.location.reload();
}
break;
}
},
waiting_for_match() {
this.perform('waiting_for_match');
}
});
}
});

View File

@@ -20,6 +20,10 @@ var ProgrammingGroups = {
is_other_session: function (other_session_id) {
return this.session_id !== other_session_id;
},
contains_own_user: function (users) {
return users.find(e => ProgrammingGroups.is_other_user(e) === false) !== undefined
}
};
$(document).on('turbolinks:load', function () {
@@ -35,4 +39,12 @@ $(document).on('turbolinks:load', function () {
new bootstrap.Modal(modal).show();
}
}
const join_pair_button = $('.join_programming_pair');
if (join_pair_button.isPresent()) {
join_pair_button.on('click', function() {
App.pg_matching?.waiting_for_match();
CodeOceanEditor.showSpinner(join_pair_button);
});
}
});