-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* suport dark mode and editor theming from dev tools * remove sql editor theme, add session check * update snapshots * minor fixes * fix import * fix job query url * update poll interval to 2000 --------- (cherry picked from commit 937ff30) Signed-off-by: Shenoy Pratik <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2269d1d
commit 0f5673a
Showing
20 changed files
with
357 additions
and
529 deletions.
There are no files selected for viewing
This file contains 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 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,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
import { CoreStart } from '../../../../src/core/public'; | ||
import { | ||
ASYNC_QUERY_ENDPOINT, | ||
ASYNC_QUERY_JOB_ENDPOINT, | ||
ASYNC_QUERY_SESSION_ID, | ||
POLL_INTERVAL_MS, | ||
} from '../constants'; | ||
|
||
export const setAsyncSessionId = (value: string | null) => { | ||
if (value === null) sessionStorage.removeItem(ASYNC_QUERY_SESSION_ID); | ||
else sessionStorage.setItem(ASYNC_QUERY_SESSION_ID, value); | ||
}; | ||
|
||
export const getAsyncSessionId = () => { | ||
return sessionStorage.getItem(ASYNC_QUERY_SESSION_ID); | ||
}; | ||
|
||
export const getJobId = (query: {}, http: CoreStart['http'], callback) => { | ||
http | ||
.post(ASYNC_QUERY_ENDPOINT, { | ||
body: JSON.stringify({ ...query, sessionId: getAsyncSessionId() ?? undefined }), | ||
}) | ||
.then((res) => { | ||
const id = res.data.resp.queryId; | ||
setAsyncSessionId(_.get(res.data.resp, 'sessionId', null)); | ||
callback(id); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
export const pollQueryStatus = (id: string, http: CoreStart['http'], callback) => { | ||
http | ||
.get(ASYNC_QUERY_JOB_ENDPOINT + id) | ||
.then((res) => { | ||
const status = res.data.resp.status.toLowerCase(); | ||
if ( | ||
status === 'pending' || | ||
status === 'running' || | ||
status === 'scheduled' || | ||
status === 'waiting' | ||
) { | ||
setTimeout(() => pollQueryStatus(id, http, callback), POLL_INTERVAL_MS); | ||
} else if (status === 'failed') { | ||
callback([]); | ||
} else if (status === 'success') { | ||
const results = _.get(res.data.resp, 'datarows'); | ||
callback(results); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
callback([]); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains 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.