Skip to content
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

Patch/audio component #375

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Patch/audio component #375

wants to merge 4 commits into from

Conversation

keving17
Copy link
Contributor

Addresses Issues #362 and #361 about moving audio players and transcripts to their own separate component rather than finding elements by ID and updating them as data was retrieved from s3 and Watson API.

This adds two new components to DynamicTable.js: AudioPlayerComponent and TranscriptComponent which update the table as data is returned.

@keving17
Copy link
Contributor Author

I tested this locally. Everything works fine except for a minor visual bug when the table first loads up. That can be fixed by adjusting the window size slightly. More details in Issue #376

Copy link
Contributor

@kevinrobinson kevinrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keving17 This looks great! One question here is how the awesome cleanup in this PR would impact other older analyses.

return (
<div id={this.state.audioID+"-transcript"}>Transcript: "{this.state.transcript}"</div>
// <div id={audioID+"-transcript"}>Transcript: "{results.transcript}"</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover comment

@@ -344,12 +230,105 @@ export default class DynamicHeightTableColumn extends React.PureComponent {
dataKey="responseText"
label="Response"
disableSort = {false}
cellDataGetter={({ dataKey , rowData }) => rowData.json[dataKey] || (this._getAudioUrl(rowData) && <div>{this._loadAudioPlayer(this._getAudioID(this._getAudioUrl(rowData)))} {this._loadTranscript(this._getAudioID(this._getAudioUrl(rowData)))} </div>)}
cellRenderer= {this._wrappingCellRendererAgain}
cellDataGetter={({ dataKey , rowData }) => rowData.json[dataKey] || (this._getAudioUrl(rowData) && <div><AudioPlayerComponent audioID={this._getAudioID(this._getAudioUrl(rowData))} token={this.props.token} /> <TranscriptComponent audioID={this._getAudioID(this._getAudioUrl(rowData))} token={this.props.token}/> </div>)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot in one line :) maybe make a method that cellDataGetter can call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

// For looking at raw events and sessions. Hover to reveal more sensitive data.
renderEventsTable(json) {
const {analysisKey} = this.props;
if (analysisKey === 'HMTCA') return this.renderHmtcaTable(json);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's simplifying, but also that it's removing some code that is used to analyze other data besides the scenarios you've been focused on. Can you say more about how removing this code impacts viewing data for other sessions or scenarios?

If removing this would break those, let's leave this code and add a branching to use the new awesome view where it works and for older analyses use this old code. Or if it didn't really work before this change to look at the older analyses, then I think it's fine to remove this and just add a comment linking back to an older commit to point future folks in a helpful direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So those stopped working once I stopped using the renderEventsTable() function and switched to using react virtualized. Are you saying to leave a comment in the actual code about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I think it's fine to break these older scenarios to make the awesome improvements you've made. I'd suggest just adding comment that says something like "for analysis of other scenarios, look at (this URL in the git history)" as a helpful pointer for future folks.

}

class AudioPlayerComponent extends React.Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Can you move AudioPlayerComponent and TranscriptComponent into their own files? They're now nicely self-contained which simplifies the table code quite a bit but also could be re-used if other folks are making other kinds of analysis. In the same file here they're a bit hidden away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@keving17
Copy link
Contributor Author

So overall, this PR should not change any of the behavior since commit a3ffebd where I fixed up some problems with using react-virtualized. I only create and move the AudioPlayerComponent and TranscriptComponent outside of the constructor for the data table and clean up some leftover code from when I switched over to react-virtualized.

@keving17
Copy link
Contributor Author

If things look ok to you @kevinrobinson , I can merge this.

@kevinrobinson
Copy link
Contributor

@keving17 sounds great, 🚢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants