-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added missing API integrations
- Loading branch information
1 parent
1cea61e
commit 5cb96a4
Showing
7 changed files
with
287 additions
and
13 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
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,86 @@ | ||
import { API_BASE_URL } from './api'; | ||
|
||
export async function fetchComponents(dashId) { | ||
const endpoint = `${API_BASE_URL}/dashboards/${dashId}/components`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Could not fetch dashboard components'); | ||
} | ||
|
||
return await response.json(); | ||
} | ||
|
||
export async function createComponent(dashId, data) { | ||
const endpoint = `${API_BASE_URL}/dashboards/${dashId}/components`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Could not create a component'); | ||
} | ||
|
||
return await response.json(); | ||
} | ||
|
||
export async function updateComponent(dashId, compId, data) { | ||
const endpoint = `${API_BASE_URL}/dashboards/${dashId}/components/${compId}`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Could not create a component'); | ||
} | ||
|
||
return await response.json(); | ||
} | ||
|
||
export async function deleteComponent(dashId, compId) { | ||
const endpoint = `${API_BASE_URL}/dashboards/${dashId}/components/${compId}`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: 'DELETE', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Could not delete a component'); | ||
} | ||
} | ||
|
||
export async function runComponent(dashId, compId) { | ||
const endpoint = `${API_BASE_URL}/dashboards/${dashId}/components/${compId}`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Could not run component'); | ||
} | ||
|
||
return await response.json(); | ||
} |
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
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