-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge with automation service
- Loading branch information
Showing
18 changed files
with
1,291 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import axios from 'axios'; | ||
import type { | ||
Automation, | ||
AutomationBlueprint, | ||
AutomationBlueprintDTO, | ||
AutomationDTO, | ||
AutomationOutput, | ||
AutomationSettings, | ||
} from 'ontime-types'; | ||
|
||
import { apiEntryUrl } from './constants'; | ||
|
||
const automationsPath = `${apiEntryUrl}/automations`; | ||
|
||
/** | ||
* HTTP request to get the automations settings | ||
*/ | ||
export async function getAutomationSettings(): Promise<AutomationSettings> { | ||
const res = await axios.get(automationsPath); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to edit the automations settings | ||
*/ | ||
export async function editAutomationSettings( | ||
automationSettings: Partial<AutomationSettings>, | ||
): Promise<AutomationSettings> { | ||
const res = await axios.post(automationsPath, automationSettings); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to create a new automation | ||
*/ | ||
export async function addAutomation(automation: AutomationDTO): Promise<Automation> { | ||
const res = await axios.post(`${automationsPath}/automation`, automation); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to update an automation | ||
*/ | ||
export async function editAutomation(id: string, automation: Automation): Promise<Automation> { | ||
const res = await axios.put(`${automationsPath}/automation/${id}`, automation); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to delete an automation | ||
*/ | ||
export function deleteAutomation(id: string): Promise<void> { | ||
return axios.delete(`${automationsPath}/automation/${id}`); | ||
} | ||
|
||
/** | ||
* HTTP request to create a new blueprint | ||
*/ | ||
export async function addBlueprint(blueprint: AutomationBlueprintDTO): Promise<AutomationBlueprint> { | ||
const res = await axios.post(`${automationsPath}/blueprint`, blueprint); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to update a blueprint | ||
*/ | ||
export async function editBlueprint(id: string, blueprint: AutomationBlueprint): Promise<AutomationBlueprint> { | ||
const res = await axios.put(`${automationsPath}/blueprint/${id}`, blueprint); | ||
return res.data; | ||
} | ||
|
||
/** | ||
* HTTP request to delete a blueprint | ||
*/ | ||
export function deleteBlueprint(id: string): Promise<void> { | ||
return axios.delete(`${automationsPath}/blueprint/${id}`); | ||
} | ||
|
||
/** | ||
* HTTP request to test automation output | ||
* The return is irrelevant as we care for the resolution of the promise | ||
*/ | ||
export async function testOutput(output: AutomationOutput): Promise<void> { | ||
return axios.post(automationsPath, output); | ||
} |
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
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
5 changes: 5 additions & 0 deletions
5
...client/src/features/app-settings/panel/automations-panel/AutomationManagement.module.scss
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,5 @@ | ||
.list { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 3rem; | ||
} |
36 changes: 36 additions & 0 deletions
36
apps/client/src/features/app-settings/panel/automations-panel/AutomationPanel.tsx
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,36 @@ | ||
import useScrollIntoView from '../../../../common/hooks/useScrollIntoView'; | ||
import useAutomationSettings from '../../../../common/hooks-query/useAutomationSettings'; | ||
import type { PanelBaseProps } from '../../panel-list/PanelList'; | ||
import * as Panel from '../../panel-utils/PanelUtils'; | ||
|
||
import AutomationSettingsForm from './AutomationSettingsForm'; | ||
import AutomationsList from './AutomationsList'; | ||
import BlueprintsList from './BlueprintsList'; | ||
|
||
export default function AutomationPanel({ location }: PanelBaseProps) { | ||
const { data } = useAutomationSettings(); | ||
const settingsRef = useScrollIntoView<HTMLDivElement>('settings', location); | ||
const blueprintsRef = useScrollIntoView<HTMLDivElement>('blueprints', location); | ||
const automationRef = useScrollIntoView<HTMLDivElement>('automations', location); | ||
|
||
return ( | ||
<> | ||
<Panel.Header>Automation</Panel.Header> | ||
<Panel.Section> | ||
<div ref={settingsRef}> | ||
<AutomationSettingsForm | ||
enabledAutomations={data.enabledAutomations} | ||
enabledOscIn={data.enabledOscIn} | ||
oscPortIn={data.oscPortIn} | ||
/> | ||
</div> | ||
<div ref={blueprintsRef}> | ||
<BlueprintsList blueprints={data.blueprints} /> | ||
</div> | ||
<div ref={automationRef}> | ||
<AutomationsList automations={data.automations} blueprints={data.blueprints} /> | ||
</div> | ||
</Panel.Section> | ||
</> | ||
); | ||
} |
Oops, something went wrong.