-
Automatic |
+
Auto |
+
Event Auto |
(beta) Tableau |
(beta) Planning |
Matchs |
diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html
index 3222ddf..dff76ea 100644
--- a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html
+++ b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html
@@ -6,7 +6,7 @@
{% include 'tournaments/broadcast/base_head.html' %}
-
+
Broadcast
@@ -43,7 +43,12 @@
prefixTitle: '',
retrieveData() {
fetch('/tournament/{{ tournament.id }}/broadcast/json/')
- .then(res => res.json())
+ .then(res => {
+ if (!res.ok) {
+ throw new Error(`HTTP ${res.status}: ${res.statusText}`);
+ }
+ return res.json();
+ })
.then((data) => {
this.paginatedMatches = this.paginate(data.matches, 8)
this.paginatedGroupStages = this.paginate(data.group_stages, 4)
@@ -56,6 +61,25 @@
this.active = 1; // Reset to the first page
}
})
+ .catch((error) => {
+ console.error('Error fetching tournament data:', error);
+
+ // If this tournament is in an iframe (part of event/club auto), notify parent
+ if (window.parent !== window) {
+ console.log('Notifying parent of tournament error');
+ window.parent.postMessage({
+ type: 'tournamentError',
+ tournamentId: '{{ tournament.id }}',
+ error: error.message
+ }, '*');
+ }
+
+ // Set empty data to prevent further errors
+ this.paginatedMatches = [];
+ this.paginatedGroupStages = [];
+ this.paginatedSummons = [];
+ this.paginatedRankings = [];
+ })
},
paginateSummons(array) {
let pageSize = 16
@@ -127,14 +151,18 @@
}, 15000)
},
pageCount() {
- return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length + this.paginatedRankings.length
+ return (this.paginatedMatches?.length || 0) + (this.paginatedGroupStages?.length || 0) + (this.paginatedSummons?.length || 0) + (this.paginatedRankings?.length || 0)
},
setPrefixTitle() {
- if (this.active < 1 + this.paginatedSummons.length) {
+ const summonsLength = this.paginatedSummons?.length || 0;
+ const matchesLength = this.paginatedMatches?.length || 0;
+ const groupStagesLength = this.paginatedGroupStages?.length || 0;
+
+ if (this.active < 1 + summonsLength) {
this.prefixTitle = 'Convocations'
- } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) {
+ } else if (this.active < 1 + summonsLength + matchesLength) {
this.prefixTitle = 'Matchs'
- } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) {
+ } else if (this.active < 1 + summonsLength + matchesLength + groupStagesLength) {
this.prefixTitle = 'Poules'
} else {
this.prefixTitle = 'Classement'
@@ -162,7 +190,7 @@
-
+
{% include 'tournaments/broadcast/broadcasted_summon.html' %}
@@ -170,25 +198,25 @@
-
+
-
+
{% include 'tournaments/broadcast/broadcasted_match.html' %}
-
+
-
+
{% include 'tournaments/broadcast/broadcasted_group_stage.html' %}
-
+
-
+
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
@@ -200,6 +228,7 @@
+
{% endif %}
+
+