-
Notifications
You must be signed in to change notification settings - Fork 14
[OGUI-1298] Add button to cancel ongoing query request #3482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graduta
merged 6 commits into
dev
from
feature/ILG/OGUI-1298/add-button-to-cance-query-request
Jun 2, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3d093e2
Refactor command logs for query and live buttons to use same remoteda…
graduta 5381814
Add button and mechanism for canceling query from front-end
graduta 0e978c6
Add tests for cancel query button
graduta a5213b5
Apply fixes as per 3/4 comments
graduta bff6a36
Remove unused-code condition
graduta 52f61a4
Fix as per GH recommendation
graduta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { fetchClient } from '/js/src/index.js'; | ||
|
|
||
| /** | ||
| * Send a request to an endpoint, and extract the response. If errors occurred, return an error containing a message. | ||
| * | ||
| * The endpoint is expected to follow some conventions: | ||
| * - If request is valid but no data was sent as response, it must return a 204 | ||
| * - If an error occurred on the backend: | ||
| * - request can be status ok with {message: string} body describing the error | ||
| * - or request can be status error with or without body that contains a message field describing the error | ||
| * - If request is valid and data is sent as response, it must return a json with the expected data | ||
| * @param {string} endpoint - the remote endpoint to send request to | ||
| * @param {RequestInit} options - the request options, see {@link fetch } native function | ||
| * (method, headers, body, abort.signal, etc.) | ||
| * @returns {Promise<Resolve<object>.Error<{message: string}>>} resolve with the result or reject with the error message | ||
| */ | ||
| export const jsonFetch = async (endpoint, options) => { | ||
| try { | ||
| const response = await fetchClient(endpoint, options); | ||
| if (response.status === 204) { | ||
| return null; | ||
| } | ||
|
|
||
| const result = await response.json(); | ||
|
|
||
| if (response.ok) { | ||
| return result; | ||
| } | ||
|
|
||
| const serverMessage = result && typeof result.message === 'string' | ||
| ? result.message | ||
| : null; | ||
|
|
||
| throw new Error(serverMessage || `Request failed with status ${response.status}`); | ||
| } catch (error) { | ||
| if (error && typeof error.message === 'string') { | ||
| throw error; | ||
| } | ||
| throw new Error('Parsing result from server failed', { cause: error }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /** | ||
| * @license | ||
| * Copyright CERN and copyright holders of ALICE O2. This software is | ||
| * distributed under the terms of the GNU General Public License v3 (GPL | ||
| * Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * See http://alice-o2.web.cern.ch/license for full licensing information. | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import { jsonFetch } from './jsonFetch.js'; | ||
|
|
||
| /** | ||
| * Build and send a POST request to a remote endpoint, and extract the response. | ||
| * @param {string} endpoint - the remote endpoint to send request to | ||
| * @param {RequestInit} options - the request options, see {@link fetch } native function | ||
| * (method, headers, body, abort.signal, etc.) | ||
| * @returns {Promise<Resolve<object>.Error<{message: string}>>} resolve with the result or reject with the error | ||
| */ | ||
| export const jsonPost = async (endpoint, options = {}) => { | ||
| if (options.body && typeof options.body === 'object') { | ||
| options.body = JSON.stringify(options.body); | ||
| } | ||
| try { | ||
| const result = await jsonFetch(endpoint, { | ||
| method: 'POST', | ||
| headers: { | ||
| Accept: 'application/json', | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| ...options, | ||
| }); | ||
| return result; | ||
| } catch (error) { | ||
| return Promise.reject({ message: error.message || error }); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.