Skip to content

Commit

Permalink
Fixes accessLevel not defined error
Browse files Browse the repository at this point in the history
  • Loading branch information
mrharpo committed Dec 12, 2024
1 parent 09a5b68 commit b09b751
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 44 deletions.
84 changes: 40 additions & 44 deletions app/classes/aapbRecordHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ export function handleAapbRecordGroup(aapbRecordGroup, key) {
// this func is where we split by whitespace v
var guids = parseAapbRecordGroup(aapbRecordGroup.value.guids)

// preserve these flags' effect for each aapb_record_group
var showThumbnail = aapbRecordGroup.value.show_thumbnail
var showTitle = aapbRecordGroup.value.show_title

return (
<AAPBRecords
guids={guids}
startTime={aapbRecordGroup.value.start_time}
endTime={aapbRecordGroup.value.end_time}
showThumbnail={showThumbnail}
showTitle={showTitle}
showThumbnail={aapbRecordGroup.value.show_thumbnail}
showTitle={aapbRecordGroup.value.show_title}
accessLevel={aapbRecordGroup.value.access_level}
embedPlayer={true}
specialCollections={
Expand Down Expand Up @@ -74,16 +70,16 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
inst = [inst]
}
// Find all proxies
let proxies = inst.find(i => i.instantiationGenerations == 'Proxy')
let proxies = inst.find((i) => i.instantiationGenerations == 'Proxy')
if (proxies) {
// proxytome proxytome proxytome proxytome
if (!(proxies instanceof Array)) {
proxies = [proxies]
}
// Get the aspect ratio of the essence tracks
let ets = proxies.map(proxy =>
let ets = proxies.map((proxy) =>
proxy.instantiationEssenceTrack.map(
track => track.essenceTrackAspectRatio
(track) => track.essenceTrackAspectRatio
)
)
for (let aspect of ets) {
Expand All @@ -97,9 +93,13 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
}
}
}

this.setState({ guid: hyphenGuid, pbcore: record, wide: isWide, mediaType: this.mediaType(record) })

this.setState({
guid: hyphenGuid,
pbcore: record,
wide: isWide,
mediaType: this.mediaType(record),
})
}

mediaType(pbcore: PBCore) {
Expand Down Expand Up @@ -166,7 +166,7 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
<iframe
className={iframeClasses}
src={url}
frameBorder="0"
frameBorder='0'
allowFullScreen={true}
/>
</a>
Expand All @@ -180,9 +180,9 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
let titleBar
if (this.props.showTitle) {
titleBar = (
<div className="shade-bar">
<div className='shade-bar'>
<a href={`https://americanarchive.org/catalog/${this.state.guid}`}>
{ this.aapbTitle(this.state.pbcore) }
{this.aapbTitle(this.state.pbcore)}
</a>
</div>
)
Expand All @@ -191,11 +191,11 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
let thumbnail
if (this.props.showThumbnail) {
let mt = this.state.mediaType
if (mt == "Moving Image") {
if (mt == 'Moving Image') {
// check here for digitized? if not show VIDEO THUMB
var ci_pbi =
this.state.pbcore.pbcoreDescriptionDocument.pbcoreIdentifier.find(
pbi => pbi.source == 'Sony Ci'
(pbi) => pbi.source == 'Sony Ci'
)
if (ci_pbi && ci_pbi.text) {
thumbnail = {
Expand All @@ -207,7 +207,7 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
backgroundImage: `url(/VIDEO_SMALL.png)`,
}
}
} else if(mt == "Sound") {
} else if (mt == 'Sound') {
// AUDIO THUMB
thumbnail = {
backgroundImage: `url(/AUDIO_SMALL.png)`,
Expand All @@ -220,9 +220,9 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
}

let playButton
if(this.state.mediaType){
if (this.state.mediaType) {
playButton = (
<div className="blue-circle">
<div className='blue-circle'>
<div />
</div>
)
Expand All @@ -235,28 +235,25 @@ export class AAPBRecord extends Component<AAPBRecordProps> {
this.state.wide
)
} else {

if (this.props.embedPlayer) {
recordBlock = (
<a
style={thumbnail}
className="content-aapbblock"
onClick={() => this.setState({ showEmbed: true })}
>
{ titleBar }
{ playButton }
className='content-aapbblock'
onClick={() => this.setState({ showEmbed: true })}>
{titleBar}
{playButton}
</a>
)
} else {
// fake video player
recordBlock = (
<a
style={thumbnail}
className="content-aapbblock"
href={this.aapbCatalogURL(this.state.guid)}
>
{ titleBar }
{ playButton }
className='content-aapbblock'
href={this.aapbCatalogURL(this.state.guid)}>
{titleBar}
{playButton}
</a>
)
}
Expand All @@ -279,21 +276,16 @@ export class AAPBRecords extends Component<AAPBRecordBlockProps> {
}

async componentDidMount() {
var accessLevel = "online"
if(this.props.accessLevel){
accessLevel = this.props.accessLevel
}

this.setState({ aapb_host: window.ENV.AAPB_HOST }, async () => {
var data
if (this.props.specialCollections) {
// fetch actual number of records from this special collection search
data = await fetch(
// this endpoint takes a bare solr query within each filter option (q, fq, etc.), NOT BLACKLIGHT URL PARAMS
`${window.ENV.AAPB_HOST}/api.json?fq=special_collections:${this.props.specialCollections} AND access_types:${accessLevel}&sort=title+asc&rows=0`
// this endpoint takes a bare solr query within each filter option (q, fq, etc.), NOT BLACKLIGHT URL PARAMS
`${window.ENV.AAPB_HOST}/api.json?fq=special_collections:${this.props.specialCollections} AND access_types:${this.props.accessLevel}&sort=title+asc&rows=0`
)
.then(response => response.json())
.catch(error => console.error(error))
.then((response) => response.json())
.catch((error) => console.error(error))
}
if (data) {
this.setState({ numRecords: parseInt(data['response']['numFound']) })
Expand All @@ -312,18 +304,19 @@ export class AAPBRecords extends Component<AAPBRecordBlockProps> {
showTitle={this.state.showTitle}
startTime={this.props.startTime}
endTime={this.props.endTime}
accessLevel={this.props.accessLevel}
specialCollections={this.props.specialCollections}
/>
)
})

var recordsSearchLink = `${this.state.aapb_host}/catalog`
if (this.props.specialCollections) {
recordsSearchLink += `?f[special_collections][]=${this.props.specialCollections}&sort=title+asc&f[access_types][]=${accessLevel}`
recordsSearchLink += `?f[special_collections][]=${this.props.specialCollections}&sort=title+asc&f[access_types][]=${this.props.accessLevel}`
}
var msg
if(this.state.numRecords > 0){
if(this.state.numRecords == 1){
if (this.state.numRecords > 0) {
if (this.state.numRecords == 1) {
msg = `View on AAPB >`
} else {
msg = `View all ${this.state.numRecords} on AAPB >`
Expand All @@ -332,9 +325,12 @@ export class AAPBRecords extends Component<AAPBRecordBlockProps> {
msg = `View more on AAPB >`
}
return (
<div className="aapb-records">
<div className='aapb-records'>
{aapbRecords}
<a target="_blank" className="aapb-records-seemore" href={recordsSearchLink}>
<a
target='_blank'
className='aapb-records-seemore'
href={recordsSearchLink}>
{msg}
</a>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/types/aapb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type AAPBRecordProps = {
embedPlayer: boolean
startTime: string
endTime: string
accessLevel: string
}

export type AAPBRecordState = {
Expand Down

0 comments on commit b09b751

Please sign in to comment.