-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'to-redux-toolkit-recordingDetails' of Arnei/opencast-ad…
…min-interface into admin-ui-picard Pull request #258 Modernize redux: recordingDetailsSlice
- Loading branch information
Showing
14 changed files
with
130 additions
and
155 deletions.
There are no files selected for viewing
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
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
9 changes: 6 additions & 3 deletions
9
app/src/components/recordings/partials/wizards/GeneralDetailsTab.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
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,15 @@ | ||
import RecordingsActionCell from "../../components/recordings/partials/RecordingsActionCell"; | ||
import RecordingsNameCell from "../../components/recordings/partials/RecordingsNameCell"; | ||
import RecordingsStatusCell from "../../components/recordings/partials/RecordingsStatusCell"; | ||
import RecordingsUpdateCell from "../../components/recordings/partials/RecordingsUpdateCell"; | ||
|
||
/** | ||
* This map contains the mapping between the template strings above and the corresponding react component. | ||
* This helps to render different templates of cells more dynamically | ||
*/ | ||
export const recordingsTemplateMap = { | ||
RecordingsActionCell: RecordingsActionCell, | ||
RecordingsNameCell: RecordingsNameCell, | ||
RecordingsStatusCell: RecordingsStatusCell, | ||
RecordingsUpdateCell: RecordingsUpdateCell, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { RootState } from "../store"; | ||
|
||
/** | ||
* This file contains selectors regarding details of a certain recording/capture agent | ||
*/ | ||
export const getRecordingDetails = (state: any) => state.recordingDetails; | ||
export const getRecordingDetails = (state: RootState) => state.recordingDetails; |
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,83 @@ | ||
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit' | ||
import axios from 'axios'; | ||
|
||
/** | ||
* This file contains redux reducer for actions affecting the state of a recording/capture agent | ||
*/ | ||
export interface RecordingDetails { | ||
name: string, | ||
status: string, | ||
update: string, | ||
url: string, | ||
capabilities: { key: string, value: string }[], | ||
configuration: { key: string, value: string }[], | ||
inputs: { id: string, value: string }[], | ||
} | ||
|
||
interface RecordingDetailsState extends RecordingDetails { | ||
statusRecordingDetails: 'uninitialized' | 'loading' | 'succeeded' | 'failed', | ||
errorRecordingDetails: SerializedError | null, | ||
} | ||
|
||
// Initial state of recording details in redux store | ||
const initialState: RecordingDetailsState = { | ||
statusRecordingDetails: 'uninitialized', | ||
errorRecordingDetails: null, | ||
name: "", | ||
status: "", | ||
update: "", | ||
url: "", | ||
capabilities: [], | ||
configuration: [], | ||
inputs: [], | ||
}; | ||
|
||
// fetch details of certain recording from server | ||
export const fetchRecordingDetails = createAsyncThunk('recordingDetails/fetchRecordingDetails', async (name: any, { getState }) => { | ||
// Just make the async request here, and return the response. | ||
// This will automatically dispatch a `pending` action first, | ||
// and then `fulfilled` or `rejected` actions based on the promise. | ||
const res = await axios.get(`/admin-ng/capture-agents/${name}`); | ||
return res.data; | ||
}); | ||
|
||
const recordingDetailsSlice = createSlice({ | ||
name: 'recordingDetails', | ||
initialState, | ||
reducers: {}, | ||
// These are used for thunks | ||
extraReducers: builder => { | ||
builder | ||
.addCase(fetchRecordingDetails.pending, (state) => { | ||
state.statusRecordingDetails = 'loading'; | ||
}) | ||
.addCase(fetchRecordingDetails.fulfilled, (state, action: PayloadAction<{ | ||
Name: RecordingDetailsState["name"], | ||
Status: RecordingDetailsState["status"], | ||
Update: RecordingDetailsState["update"], | ||
URL: RecordingDetailsState["url"], | ||
capabilities: RecordingDetailsState["capabilities"], | ||
configuration: RecordingDetailsState["configuration"], | ||
inputs: RecordingDetailsState["inputs"], | ||
}>) => { | ||
state.statusRecordingDetails = 'succeeded'; | ||
const recordingDetails = action.payload; | ||
state.name = recordingDetails.Name; | ||
state.status = recordingDetails.Status; | ||
state.update = recordingDetails.Update; | ||
state.url = recordingDetails.URL; | ||
state.capabilities = recordingDetails.capabilities; | ||
state.configuration = recordingDetails.configuration; | ||
state.inputs = recordingDetails.inputs; | ||
}) | ||
.addCase(fetchRecordingDetails.rejected, (state, action) => { | ||
state.statusRecordingDetails = 'failed'; | ||
state.errorRecordingDetails = action.error; | ||
}); | ||
} | ||
}); | ||
|
||
// export const {} = recordingDetailsSlice.actions; | ||
|
||
// Export the slice reducer as the default export | ||
export default recordingDetailsSlice.reducer; |
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.