-
Notifications
You must be signed in to change notification settings - Fork 12
Fix: adds real audiodevice type #488
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
Draft
Saelmala
wants to merge
7
commits into
feat/ingest-page
Choose a base branch
from
fix-add-real-audiodevice-type
base: feat/ingest-page
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ce4060f
feat: ingest-page and restructure of components to be more general
malmen237 2c3f032
fix: updated code-comments
malmen237 a95ab4a
fix: updated broken solution
malmen237 701f114
feat: added logic and the real ingest-endpoints to the api
malmen237 d9592ea
feat: added text on empty-devicelist and minor fix
malmen237 837019b
chore: changes ingest-name to ingest-label for consistency
malmen237 aaf7383
fix: add real device type
Saelmala 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,5 +48,6 @@ module.exports = { | |
| { allowConstantExport: true }, | ||
| ], | ||
| "no-console": "off", | ||
| "no-underscore-dangle": "off", | ||
| }, | ||
| }; | ||
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,43 @@ export type TBasicProductionResponse = { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| lines: TLine[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type TAudioDevice = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxInputChannels: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxOutputChannels: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultSampleRate: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultLowInputLatency: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultLowOutputLatency: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultHighInputLatency: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultHighOutputLatency: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| isInput: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| isOutput: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| hostApiName: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| label?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type TSavedIngest = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ipAddress: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceOutput: TAudioDevice[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceInput: TAudioDevice[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type TEditIngest = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _id: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| label?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceOutput?: TAudioDevice; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceInput?: TAudioDevice; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type TListIngestResponse = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ingests: TSavedIngest[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| offset: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| limit: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| totalItems: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type TListProductionsResponse = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| productions: TBasicProductionResponse[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| offset: 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -291,4 +328,60 @@ export const API = { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchIngestList: (): Promise<TListIngestResponse> => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchRequest<TListIngestResponse>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${API_URL}ingest`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "GET", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| createIngest: async (data: { label: string; ipAddress: string }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchRequest<boolean>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${API_URL}ingest/`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: data.label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ipAddress: data.ipAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetchIngest: (id: number): Promise<TSavedIngest> => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchRequest<TSavedIngest>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${API_URL}ingest/${id}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "GET", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| updateIngest: async (data: TEditIngest) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchRequest<TEditIngest>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${API_URL}ingest/${data._id}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "PATCH", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Content-Type": "application/json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: JSON.stringify({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: data.label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceOutput: data.deviceOutput, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deviceInput: data.deviceInput, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| deleteIngest: async (id: string): Promise<string> => | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleFetchRequest<string>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${API_URL}ingest/${id}`, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "DELETE", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(API_KEY ? { Authorization: `Bearer ${API_KEY}` } : {}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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
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
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,25 @@ | ||
| import styled from "@emotion/styled"; | ||
| import { SecondaryButton } from "../form-elements/form-elements"; | ||
|
|
||
| export const ButtonsWrapper = styled.div` | ||
| display: flex; | ||
| justify-content: flex-end; | ||
| margin: 1rem 0 1rem 0; | ||
| `; | ||
|
|
||
| export const DeleteButton = styled(SecondaryButton)` | ||
| display: flex; | ||
| align-items: center; | ||
| background: #d15c5c; | ||
| color: white; | ||
|
|
||
| &:disabled { | ||
| background: #ab5252; | ||
| } | ||
| `; | ||
|
|
||
| export const SpinnerWrapper = styled.div` | ||
| position: relative; | ||
| width: 2rem; | ||
| height: 2rem; | ||
| `; |
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
92 changes: 92 additions & 0 deletions
92
src/components/ingests-page/add-ingest-modal/add-ingest-form.tsx
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,92 @@ | ||
| import { SubmitHandler, useForm } from "react-hook-form"; | ||
| import { useEffect, useState } from "react"; | ||
| import { useSubmitOnEnter } from "../../../hooks/use-submit-form-enter-press"; | ||
| import { ButtonWrapper } from "../../generic-components"; | ||
| import { FormInput } from "../../form-elements/form-elements"; | ||
| import { FormItem } from "../../user-settings-form/form-item"; | ||
| import { FormWrapper, SubmitButton } from "../ingest-components"; | ||
| import { useCreateIngest } from "./use-create-ingest"; | ||
| import { Spinner } from "../../loader/loader"; | ||
| import { SpinnerWrapper } from "../../delete-button/delete-button-components"; | ||
|
|
||
| type FormValues = { | ||
| ingestLabel: string; | ||
| ipAddress: string; | ||
| }; | ||
|
|
||
| type AddIngestFormProps = { | ||
| onSave?: () => void; | ||
| }; | ||
|
|
||
| export const AddIngestForm = ({ onSave }: AddIngestFormProps) => { | ||
| const [createIngest, setCreateIngest] = useState<FormValues | null>(null); | ||
| const { | ||
| formState: { errors, isValid }, | ||
| register, | ||
| handleSubmit, | ||
| } = useForm<FormValues>({ | ||
| resetOptions: { | ||
| keepDirtyValues: true, // user-interacted input will be retained | ||
| keepErrors: true, // input errors will be retained with value update | ||
| }, | ||
| }); | ||
|
|
||
| const { loading, success } = useCreateIngest({ createIngest }); | ||
|
|
||
| useEffect(() => { | ||
| if (success) { | ||
| setCreateIngest(null); | ||
| if (onSave) onSave(); | ||
| } | ||
| }, [success, onSave]); | ||
|
|
||
| const onSubmit: SubmitHandler<FormValues> = (data) => { | ||
| setCreateIngest(data); | ||
| }; | ||
|
|
||
| useSubmitOnEnter<FormValues>({ | ||
| handleSubmit, | ||
| submitHandler: onSubmit, | ||
| shouldSubmitOnEnter: true, | ||
| }); | ||
|
|
||
| return ( | ||
| <FormWrapper> | ||
| <FormItem label="Name" fieldName="ingestLabel" errors={errors}> | ||
| <FormInput | ||
| // eslint-disable-next-line | ||
| {...register(`ingestLabel`, { | ||
| required: "Ingest name is required", | ||
| minLength: 1, | ||
| })} | ||
| placeholder="Name for Ingest" | ||
| /> | ||
| </FormItem> | ||
| <FormItem label="Server IP Address" fieldName="ipAddress" errors={errors}> | ||
| <FormInput | ||
| // eslint-disable-next-line | ||
| {...register(`ipAddress`, { | ||
| required: "IP address is required", | ||
| minLength: 1, | ||
| })} | ||
| placeholder="192.168.1.1" | ||
| /> | ||
| </FormItem> | ||
| <ButtonWrapper> | ||
| <SubmitButton | ||
| type="button" | ||
| disabled={!isValid} | ||
| onClick={handleSubmit(onSubmit)} | ||
| shouldSubmitOnEnter | ||
| > | ||
| Add Ingest | ||
| {loading && ( | ||
| <SpinnerWrapper> | ||
| <Spinner className="production-list" /> | ||
| </SpinnerWrapper> | ||
| )} | ||
| </SubmitButton> | ||
| </ButtonWrapper> | ||
| </FormWrapper> | ||
| ); | ||
| }; |
21 changes: 21 additions & 0 deletions
21
src/components/ingests-page/add-ingest-modal/ingest-form.tsx
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,21 @@ | ||
| import { FC } from "react"; | ||
| import { DisplayContainerHeader } from "../../landing-page/display-container-header"; | ||
| import { ResponsiveFormContainer } from "../../generic-components"; | ||
| import { AddIngestForm } from "./add-ingest-form"; | ||
|
|
||
| interface IngestFormModalProps { | ||
| className?: string; | ||
| onSave?: () => void; | ||
| } | ||
|
|
||
| export const IngestFormModal: FC<IngestFormModalProps> = (props) => { | ||
| const { className, onSave } = props; | ||
|
|
||
| return ( | ||
| <ResponsiveFormContainer className={className}> | ||
| <DisplayContainerHeader>Add New Ingest</DisplayContainerHeader> | ||
|
|
||
| <AddIngestForm onSave={onSave} /> | ||
| </ResponsiveFormContainer> | ||
| ); | ||
| }; |
24 changes: 24 additions & 0 deletions
24
src/components/ingests-page/add-ingest-modal/use-create-ingest.tsx
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,24 @@ | ||
| import { API } from "../../../api/api"; | ||
| import { useRequest } from "../../../hooks/use-request"; | ||
|
|
||
| type FormValues = { | ||
| ingestLabel: string; | ||
| ipAddress: string; | ||
| }; | ||
|
|
||
| export const useCreateIngest = ({ | ||
| createIngest, | ||
| }: { | ||
| createIngest: FormValues | null; | ||
| }) => { | ||
| return useRequest<{ label: string; ipAddress: string }, boolean>({ | ||
| params: createIngest | ||
| ? { | ||
| label: createIngest.ingestLabel, | ||
| ipAddress: createIngest.ipAddress, | ||
| } | ||
| : null, | ||
| apiCall: API.createIngest, | ||
| errorMessage: (i) => `Failed to create ingest: ${i.label}`, | ||
| }); | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label?: string;or
label: string;