Skip to content

Commit

Permalink
Add missing flash message box to /tests page
Browse files Browse the repository at this point in the history
This page can have flash messages created by ajax events.
  • Loading branch information
asdil12 committed Sep 12, 2024
1 parent 91960ca commit 71192da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions assets/javascripts/openqa.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function setupForAll() {
});
}

function getCSRFToken() {
return document.querySelector('meta[name="csrf-token"]').content;

Check failure on line 27 in assets/javascripts/openqa.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹` with `··`
}

Check failure on line 28 in assets/javascripts/openqa.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Delete `⏎`


function makeFlashElement(text) {
return typeof text === 'string' ? '<span>' + text + '</span>' : text;
}
Expand Down
20 changes: 20 additions & 0 deletions assets/javascripts/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ function changeJobPrio(jobId, delta, linkElement) {
}

var newPrio = currentPrio + delta;

/*

Check failure on line 195 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Insert `··`
$.ajax({
url: urlWithBase('/api/v1/jobs/' + jobId + '/prio?prio=' + newPrio),
method: 'POST',
Expand All @@ -201,6 +203,24 @@ function changeJobPrio(jobId, delta, linkElement) {
addFlash('danger', 'Unable to set the priority value of job ' + jobId + '.');
}
});
*/

fetch(urlWithBase('/api/v1/jobs/' + jobId + '/prio?prio=' + newPrio), {
method: 'POST',

Check failure on line 209 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹··method:·'POST',` with `····method:·'POST'`
//headers: {'X-CSRF-TOKEN': getCSRFToken()}

Check failure on line 210 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹` with `··`
})
.then(response => {
if (response.status == 200)

Check failure on line 213 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹··if·(response.status·==·200)⏎·······` with `······if·(response.status·==·200)`
prioValueElement.text(newPrio);
else {

Check failure on line 215 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹` with `····`
console.warn("response");

Check failure on line 216 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹↹console.warn("response"` with `········console.warn('response'`
addFlash('danger', 'Unable to set the priority value of job ' + jobId + '.');
}

Check failure on line 218 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹` with `····`
})
.catch(error => {

Check failure on line 220 in assets/javascripts/tests.js

View workflow job for this annotation

GitHub Actions / Lint JavaScript code (using Node version 20)

Replace `↹` with `····`
console.log(error);
addFlash('danger', 'Unable to set the priority value of job ' + jobId + ': ' . error);
});
}

function renderTestSummary(data) {
Expand Down
4 changes: 4 additions & 0 deletions templates/webapi/test/list.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
renderTestLists();
% end

<div id="flash-messages">
%= include 'layouts/flash_messages';
</div>

<div>
<h2 id="running_jobs_heading">Running jobs</h2>
<table id="running" class="display table table-striped" style="width: 100%">
Expand Down

0 comments on commit 71192da

Please sign in to comment.