Add API configuration
This commit is contained in:
parent
7a81bbaec6
commit
e97720bc24
9 changed files with 23 additions and 4 deletions
|
@ -19,6 +19,7 @@ import { IMessage } from '../../Interfaces/IMessage';
|
|||
import { DISABLE_API } from '../../utils/default';
|
||||
import { UseWorker, UseAsync } from './UseWorker';
|
||||
import { FindContainerById } from '../../utils/itertools';
|
||||
import { IAPIConfiguration } from '../../Interfaces/IAPIConfiguration';
|
||||
|
||||
export interface IUIProps {
|
||||
selectedContainer: IContainerModel | undefined
|
||||
|
@ -28,6 +29,7 @@ export interface IUIProps {
|
|||
availableContainers: IAvailableContainer[]
|
||||
availableSymbols: IAvailableSymbol[]
|
||||
categories: ICategory[]
|
||||
apiConfiguration: IAPIConfiguration | undefined
|
||||
selectContainer: (containerId: string) => void
|
||||
deleteContainer: (containerId: string) => void
|
||||
onPropertyChange: (key: string, value: string | number | boolean | number[], type?: PropertyType) => void
|
||||
|
@ -73,11 +75,13 @@ export function UI(props: IUIProps): JSX.Element {
|
|||
if (window.Worker && !DISABLE_API) {
|
||||
UseWorker(
|
||||
props.current,
|
||||
props.apiConfiguration?.apiGetFeedbackUrl,
|
||||
setMessages
|
||||
);
|
||||
} else if (!DISABLE_API) {
|
||||
UseAsync(
|
||||
props.current,
|
||||
props.apiConfiguration?.apiGetFeedbackUrl,
|
||||
setMessages
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ const myWorker = window.Worker && new Worker('workers/message_worker.js');
|
|||
|
||||
export function UseWorker(
|
||||
state: IHistoryState,
|
||||
configurationUrl: string | undefined,
|
||||
setMessages: React.Dispatch<React.SetStateAction<IMessage[]>>): void {
|
||||
React.useEffect(() => {
|
||||
// use webworker for the stringify to avoid freezing
|
||||
|
@ -30,6 +31,7 @@ export function UseWorker(
|
|||
}
|
||||
export function UseAsync(
|
||||
state: IHistoryState,
|
||||
configurationUrl: string | undefined,
|
||||
setMessages: React.Dispatch<React.SetStateAction<IMessage[]>>): void {
|
||||
React.useEffect(() => {
|
||||
const request: IGetFeedbackRequest = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue