Libra-1995 commited on
Commit
af87529
·
1 Parent(s): 31dc0f1

feat: update register alert

Browse files
Files changed (1) hide show
  1. competitions/templates/index.html +126 -126
competitions/templates/index.html CHANGED
@@ -9,13 +9,102 @@
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
10
  <link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.css" rel="stylesheet" />
11
  <script>
12
- document.addEventListener('DOMContentLoaded', function () {
13
- function showSubmissionModal() {
14
- const modal = document.getElementById('submission-modal');
15
- modal.classList.add('flex');
16
- modal.classList.remove('hidden');
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
 
 
 
 
 
 
 
19
  function hideSubmissionModal() {
20
  const modal = document.getElementById('submission-modal');
21
  modal.classList.remove('flex');
@@ -119,96 +208,6 @@
119
  // fetchAndDisplayLeaderboard('private');
120
  // }
121
 
122
- function fetchAndDisplaySubmissions() {
123
- const apiEndpoint = '/my_submissions';
124
- const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
125
- articleLoadingSpinner.classList.remove('hidden');
126
-
127
- const requestOptions = {
128
- method: 'POST',
129
- headers: {
130
- 'Content-Type': 'application/json',
131
- }
132
- };
133
-
134
- fetch(apiEndpoint, requestOptions)
135
- .then(response => {
136
- if (!response.ok) {
137
- throw new Error('Network response was not ok');
138
- }
139
- return response.json();
140
- })
141
- .then(data => {
142
- const contentDiv = document.getElementById('content');
143
- const teamNameDiv = `
144
- <div class="flex items-center">
145
- <input type="text" name="team_name" id="team_name" class="mt-1 mb-1 block me-2" value="${data.response.team_name}">
146
- <button id="updateTeamNameButton" type="button" class="confirm text-white bg-green-600 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center me-2">Update Team Name</button>
147
- </div>`;
148
- // console.log(data.response.submissions);
149
- // contentDiv.innerHTML = marked.parse(data.response.submission_text) + data.response.submissions;
150
- if (data.response.submissions && data.response.submissions.length > 0 && data.response.error.length == 0) {
151
- // Start building the table HTML
152
- let tableHTML = teamNameDiv;
153
- tableHTML += '<table border="1"><tr><th width: 17%;>Datetime</th><th style="width: 40%;">Submission ID</th><th style="width: 20%;">Score</th><th style="width: 8%;">Status</th><th style="width: 15%;">Error Code</th></tr>';
154
-
155
- // Iterate over each submission and add it to the table
156
- data.response.submissions.forEach(submission => {
157
- logFileLink = submission.log_file_url === "" ? "" : `<a href="${submission.log_file_url}" target="_blank">log_file.txt</a>`;
158
- tableHTML += `<tr>
159
- <td>${submission.datetime}</td>
160
- <td>${submission.submission_id}</td>
161
- <td>${submission.score}</td>
162
- <td>${submission.status}</td>
163
- <td>${submission.error_message} <br> ${logFileLink}</td>
164
- </tr>`;
165
- });
166
-
167
- // Close the table HTML and set it as the content
168
- tableHTML += '</table>';
169
- // add a text field which displays team name and a button to update team name
170
- contentDiv.innerHTML = marked.parse(data.response.submission_text) + tableHTML;
171
- document.getElementById('updateSelectedSubmissionsButton').addEventListener('click', function () {
172
- updateSelectedSubmissions();
173
- });
174
- } else {
175
- // Display message if there are no submissions
176
- contentDiv.innerHTML = teamNameDiv + marked.parse(data.response.submission_text) + marked.parse(data.response.error);
177
- }
178
- document.getElementById('updateTeamNameButton').addEventListener('click', function () {
179
- updateTeamName();
180
- });
181
- articleLoadingSpinner.classList.add('hidden');
182
- })
183
- .catch(error => {
184
- console.error('There was a problem with the fetch operation:', error);
185
- articleLoadingSpinner.classList.add('hidden');
186
- });
187
- }
188
-
189
- function fetchAndDisplaySubmissionInfo() {
190
- const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
191
- articleLoadingSpinner.classList.remove('hidden');
192
- fetch('/submission_info')
193
- .then(response => {
194
- if (!response.ok) {
195
- throw new Error('Network response was not ok');
196
- }
197
- return response.json(); // Parse the JSON response
198
- })
199
- .then(data => {
200
- // Populate the 'content' div with the HTML from the response
201
- const contentDiv = document.getElementById('content');
202
- contentDiv.innerHTML = marked.parse(data.response);
203
- addTargetBlankToLinks();
204
- articleLoadingSpinner.classList.add('hidden');
205
- })
206
- .catch(error => {
207
- console.error('There has been a problem with your fetch operation:', error);
208
- articleLoadingSpinner.classList.add('hidden');
209
- });
210
- }
211
-
212
  function fetchAndDisplayTeamInfo() {
213
  const apiEndpoint = '/team_info';
214
  const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
@@ -296,9 +295,6 @@
296
  const datasetLink = document.getElementById('dataset');
297
  // const publicLBLink = document.getElementById('public_lb');
298
  // const privateLBLink = document.getElementById('private_lb');
299
- const newSubmission = document.getElementById('new_submission');
300
- const mySubmissions = document.getElementById('my_submissions');
301
- const submissionInfo = document.getElementById('submission_info');
302
  const rulesLink = document.getElementById('rules');
303
  const leaderBoardLink = document.getElementById('leaderboard');
304
 
@@ -327,19 +323,6 @@
327
  // event.preventDefault(); // Prevent the default link behavior
328
  // fetchAndDisplayPrivateLeaderboard(); // Fetch and display info on click
329
  // });
330
-
331
- newSubmission.addEventListener('click', function (event) {
332
- event.preventDefault(); // Prevent the default link behavior
333
- showSubmissionModal(); // Fetch and display info on click
334
- });
335
- mySubmissions.addEventListener('click', function (event) {
336
- event.preventDefault(); // Prevent the default link behavior
337
- fetchAndDisplaySubmissions(); // Fetch and display info on click
338
- });
339
- submissionInfo.addEventListener('click', function (event) {
340
- event.preventDefault(); // Prevent the default link behavior
341
- fetchAndDisplaySubmissionInfo(); // Fetch and display info on click
342
- });
343
  rulesLink.addEventListener('click', function (event) {
344
  event.preventDefault(); // Prevent the default link behavior
345
  fetchAndDisplayRules(); // Fetch and display info on click
@@ -371,6 +354,9 @@
371
 
372
  function checkOAuth() {
373
  var url = "/login_status";
 
 
 
374
  makeApiRequest(url, function ({is_login, is_admin, is_registered, is_white_team}) {
375
  const registerRemoveStyle = ["pointer-events-none", "text-gray-400", "cursor-not-allowed"];
376
  const registerNewStyle = ["ext-gray-900", "hover:bg-gray-100"]
@@ -384,19 +370,33 @@
384
  if (is_admin) {
385
  document.getElementById("admin").classList.remove("hidden");
386
  }
387
- if (is_registered) {
388
- document.getElementById("submission_info").classList.remove(...registerRemoveStyle);
389
- document.getElementById("submission_info").classList.add(...registerNewStyle);
390
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  if (is_login && !is_registered) {
392
  document.getElementById("registerButton").style.display = "block";
393
  }
394
- if (is_white_team) {
395
- document.getElementById("my_submissions").classList.remove(...registerRemoveStyle);
396
- document.getElementById("my_submissions").classList.add(...registerNewStyle);
397
- document.getElementById("new_submission").classList.remove(...registerRemoveStyle);
398
- document.getElementById("new_submission").classList.add(...registerNewStyle);
399
- }
400
  });
401
  }
402
  window.onload = checkOAuth;
@@ -486,17 +486,17 @@
486
  <ul id="submissions-dropdown" class="py-2 space-y-2">
487
  <li>
488
  <a href="#" id="submission_info"
489
- class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group pointer-events-none text-gray-400 cursor-not-allowed">Submission
490
  information</a>
491
  </li>
492
  <li>
493
  <a href="#" id="my_submissions"
494
- class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group pointer-events-none text-gray-400 cursor-not-allowed">My
495
  submissions</a>
496
  </li>
497
  <li>
498
  <a href="#" id="new_submission"
499
- class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group pointer-events-none text-gray-400 cursor-not-allowed">New
500
  submission</a>
501
  </li>
502
  </ul>
@@ -581,7 +581,7 @@
581
  {% endif %}
582
  {% if competition_type == 'script' %}
583
  <div class="form-group">
584
- <label for="hub_model" class="text-sm font-medium text-gray-700">Hub model
585
  </label>
586
  <input type="text" name="hub_model" id="hub_model"
587
  class="mt-1 block w-full border border-gray-300 px-3 py-1.5 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
 
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
10
  <link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.css" rel="stylesheet" />
11
  <script>
12
+ function fetchAndDisplaySubmissionInfo() {
13
+ const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
14
+ articleLoadingSpinner.classList.remove('hidden');
15
+ fetch('/submission_info')
16
+ .then(response => {
17
+ if (!response.ok) {
18
+ throw new Error('Network response was not ok');
19
+ }
20
+ return response.json(); // Parse the JSON response
21
+ })
22
+ .then(data => {
23
+ // Populate the 'content' div with the HTML from the response
24
+ const contentDiv = document.getElementById('content');
25
+ contentDiv.innerHTML = marked.parse(data.response);
26
+ addTargetBlankToLinks();
27
+ articleLoadingSpinner.classList.add('hidden');
28
+ })
29
+ .catch(error => {
30
+ console.error('There has been a problem with your fetch operation:', error);
31
+ articleLoadingSpinner.classList.add('hidden');
32
+ });
33
+ }
34
+
35
+ function fetchAndDisplaySubmissions() {
36
+ const apiEndpoint = '/my_submissions';
37
+ const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
38
+ articleLoadingSpinner.classList.remove('hidden');
39
+
40
+ const requestOptions = {
41
+ method: 'POST',
42
+ headers: {
43
+ 'Content-Type': 'application/json',
44
+ }
45
+ };
46
+
47
+ fetch(apiEndpoint, requestOptions)
48
+ .then(response => {
49
+ if (!response.ok) {
50
+ throw new Error('Network response was not ok');
51
+ }
52
+ return response.json();
53
+ })
54
+ .then(data => {
55
+ const contentDiv = document.getElementById('content');
56
+ const teamNameDiv = `
57
+ <div class="flex items-center">
58
+ <input type="text" name="team_name" id="team_name" class="mt-1 mb-1 block me-2" value="${data.response.team_name}">
59
+ <button id="updateTeamNameButton" type="button" class="confirm text-white bg-green-600 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center me-2">Update Team Name</button>
60
+ </div>`;
61
+ // console.log(data.response.submissions);
62
+ // contentDiv.innerHTML = marked.parse(data.response.submission_text) + data.response.submissions;
63
+ if (data.response.submissions && data.response.submissions.length > 0 && data.response.error.length == 0) {
64
+ // Start building the table HTML
65
+ let tableHTML = teamNameDiv;
66
+ tableHTML += '<table border="1"><tr><th width: 17%;>Datetime</th><th style="width: 40%;">Submission ID</th><th style="width: 20%;">Score</th><th style="width: 8%;">Status</th><th style="width: 15%;">Error</th></tr>';
67
+
68
+ // Iterate over each submission and add it to the table
69
+ data.response.submissions.forEach(submission => {
70
+ tableHTML += `<tr>
71
+ <td>${submission.datetime}</td>
72
+ <td>${submission.submission_id}</td>
73
+ <td>${submission.score}</td>
74
+ <td>${submission.status}</td>
75
+ <td>${submission.error_message}</td>
76
+ </tr>`;
77
+ });
78
+
79
+ // Close the table HTML and set it as the content
80
+ tableHTML += '</table>';
81
+ // add a text field which displays team name and a button to update team name
82
+ contentDiv.innerHTML = marked.parse(data.response.submission_text) + tableHTML;
83
+ document.getElementById('updateSelectedSubmissionsButton').addEventListener('click', function () {
84
+ updateSelectedSubmissions();
85
+ });
86
+ } else {
87
+ // Display message if there are no submissions
88
+ contentDiv.innerHTML = teamNameDiv + marked.parse(data.response.submission_text) + marked.parse(data.response.error);
89
+ }
90
+ document.getElementById('updateTeamNameButton').addEventListener('click', function () {
91
+ updateTeamName();
92
+ });
93
+ articleLoadingSpinner.classList.add('hidden');
94
+ })
95
+ .catch(error => {
96
+ console.error('There was a problem with the fetch operation:', error);
97
+ articleLoadingSpinner.classList.add('hidden');
98
+ });
99
+ }
100
 
101
+ function showSubmissionModal() {
102
+ const modal = document.getElementById('submission-modal');
103
+ modal.classList.add('flex');
104
+ modal.classList.remove('hidden');
105
+ }
106
+
107
+ document.addEventListener('DOMContentLoaded', function () {
108
  function hideSubmissionModal() {
109
  const modal = document.getElementById('submission-modal');
110
  modal.classList.remove('flex');
 
208
  // fetchAndDisplayLeaderboard('private');
209
  // }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  function fetchAndDisplayTeamInfo() {
212
  const apiEndpoint = '/team_info';
213
  const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
 
295
  const datasetLink = document.getElementById('dataset');
296
  // const publicLBLink = document.getElementById('public_lb');
297
  // const privateLBLink = document.getElementById('private_lb');
 
 
 
298
  const rulesLink = document.getElementById('rules');
299
  const leaderBoardLink = document.getElementById('leaderboard');
300
 
 
323
  // event.preventDefault(); // Prevent the default link behavior
324
  // fetchAndDisplayPrivateLeaderboard(); // Fetch and display info on click
325
  // });
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  rulesLink.addEventListener('click', function (event) {
327
  event.preventDefault(); // Prevent the default link behavior
328
  fetchAndDisplayRules(); // Fetch and display info on click
 
354
 
355
  function checkOAuth() {
356
  var url = "/login_status";
357
+ const submissionInfo = document.getElementById('submission_info');
358
+ const mySubmissions = document.getElementById('my_submissions');
359
+ const newSubmission = document.getElementById('new_submission');
360
  makeApiRequest(url, function ({is_login, is_admin, is_registered, is_white_team}) {
361
  const registerRemoveStyle = ["pointer-events-none", "text-gray-400", "cursor-not-allowed"];
362
  const registerNewStyle = ["ext-gray-900", "hover:bg-gray-100"]
 
370
  if (is_admin) {
371
  document.getElementById("admin").classList.remove("hidden");
372
  }
373
+ submissionInfo.addEventListener('click', function (event) {
374
+ event.preventDefault(); // Prevent the default link behavior
375
+ if (is_registered) {
376
+ fetchAndDisplaySubmissionInfo(); // Fetch and display info on click
377
+ } else {
378
+ alert(`You need to register to access the "Submission Information."`)
379
+ }
380
+ });
381
+ mySubmissions.addEventListener('click', function (event) {
382
+ event.preventDefault(); // Prevent the default link behavior
383
+ if (is_white_team) {
384
+ fetchAndDisplaySubmissions(); // Fetch and display info on click
385
+ } else {
386
+ alert(`Access to the "Submit" will be granted after we manually review your registration. This process usually takes up to 24 hours.`)
387
+ }
388
+ });
389
+ newSubmission.addEventListener('click', function (event) {
390
+ event.preventDefault(); // Prevent the default link behavior
391
+ if (is_white_team) {
392
+ showSubmissionModal(); // Show the submission modal
393
+ } else {
394
+ alert(`Access to the "Submit" will be granted after we manually review your registration. This process usually takes up to 24 hours.`)
395
+ }
396
+ });
397
  if (is_login && !is_registered) {
398
  document.getElementById("registerButton").style.display = "block";
399
  }
 
 
 
 
 
 
400
  });
401
  }
402
  window.onload = checkOAuth;
 
486
  <ul id="submissions-dropdown" class="py-2 space-y-2">
487
  <li>
488
  <a href="#" id="submission_info"
489
+ class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">Submission
490
  information</a>
491
  </li>
492
  <li>
493
  <a href="#" id="my_submissions"
494
+ class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">My
495
  submissions</a>
496
  </li>
497
  <li>
498
  <a href="#" id="new_submission"
499
+ class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">New
500
  submission</a>
501
  </li>
502
  </ul>
 
581
  {% endif %}
582
  {% if competition_type == 'script' %}
583
  <div class="form-group">
584
+ <label for="hub_model" class="text-sm font-medium text-gray-700">Hub Model
585
  </label>
586
  <input type="text" name="hub_model" id="hub_model"
587
  class="mt-1 block w-full border border-gray-300 px-3 py-1.5 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"