Skip to content

Commit

Permalink
Merge pull request #5474 from avalonmediasystem/conversion
Browse files Browse the repository at this point in the history
Display message when item is converting
  • Loading branch information
masaball authored Nov 27, 2023
2 parents ca5b3e6 + f61e42d commit c9ffa8d
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 101 deletions.
193 changes: 95 additions & 98 deletions app/javascript/components/Ramp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const Ramp = ({
share,
timeline,
playlist,
in_progress,
cdl,
has_files,
has_transcripts
Expand Down Expand Up @@ -122,110 +121,108 @@ const Ramp = ({
return (
<IIIFPlayer manifestUrl={manifestUrl}>
<Row className="ramp--all-components">
{!in_progress &&
<Col sm={8}>
{ (cdl.enabled && !cdl.can_stream)
? (<div dangerouslySetInnerHTML={{ __html: cdl.embed }} />)
: ( <React.Fragment>
{ master_files_count > 0 &&
<React.Fragment>
<MediaPlayer enableFileDownload={false} />
<div className="ramp--rails-title">
{ <div className="object-title" dangerouslySetInnerHTML={{ __html: title.content }} /> }
</div>
<div className="ramp--rails-content">
<Col className="ramp-button-group-1">
{ timeline.canCreate &&
<button
id="timelineBtn"
className="btn btn-outline mr-1 text-nowrap"
type="button"
data-toggle="modal"
data-target="#timelineModal"
aria-expanded="false"
aria-controls="timelineModal"
disabled={true}
>
Create Timeline
</button>
}
{ share.canShare &&
<button
className="btn btn-outline mr-1 text-nowrap"
type="button"
data-toggle="collapse"
data-target="#shareResourcePanel"
aria-expanded="false"
aria-controls="shareResourcePanel"
id="shareBtn"
>
<i className="fa fa-share-alt"></i>
Share
</button>
}
{ playlist.canCreate &&
<button className="btn btn-outline text-nowrap mr-1"
id="addToPlaylistBtn"
type="button"
data-toggle="collapse"
data-target="#addToPlaylistPanel"
aria-expanded="false"
aria-controls="addToPlaylistPanel"
disabled={true}
>
{/* Static SVG image in /app/assets/images/add_to_playlist_icon.svg */}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-293 386 24 24" xmlSpace="preserve">
<path className="st1" fill="currentColor" d="M-279,395h-12v2h12V395z M-279,391h-12v2h12V391z M-275,399v-4h-2v4h-4v2h4v4h2v-4h4v-2H-275z M-291,401h8v-2h-8V401z"/>
</svg>
Add to Playlist
</button>
}
</Col>
{ has_structure &&
<Col className="ramp-button-group-2">
<button
className="btn btn-outline expand-collapse-toggle-button expanded"
id="expand_all_btn"
onClick={handleCollapseExpand}
ref={expandCollapseBtnRef}
>
<ExpandCollapseArrow />
{isClosed ? ' Expand' : ' Close'} {master_files_count > 1 ? `${master_files_count} Sections` : 'Section'}
</button>
</Col>
<Col sm={8}>
{ (cdl.enabled && !cdl.can_stream)
? (<div dangerouslySetInnerHTML={{ __html: cdl.embed }} />)
: ( <React.Fragment>
{ master_files_count > 0 &&
<React.Fragment>
<MediaPlayer enableFileDownload={false} />
<div className="ramp--rails-title">
{ <div className="object-title" dangerouslySetInnerHTML={{ __html: title.content }} /> }
</div>
<div className="ramp--rails-content">
<Col className="ramp-button-group-1">
{ timeline.canCreate &&
<button
id="timelineBtn"
className="btn btn-outline mr-1 text-nowrap"
type="button"
data-toggle="modal"
data-target="#timelineModal"
aria-expanded="false"
aria-controls="timelineModal"
disabled={true}
>
Create Timeline
</button>
}
</div>
<Row className="mx-0">
<Col>
<div dangerouslySetInnerHTML={{ __html: timeline.content}} />
</Col>
<Col md={12} lg={12} sm={12} className="px-0">
<div className="collapse" id="addToPlaylistPanel">
<div className="card card-body" dangerouslySetInnerHTML={{ __html: playlist.tab }} />
</div>
</Col>
<Col md={12} lg={12} sm={12} className="px-0">
<div className="collapse" id="shareResourcePanel">
<div className="share-tabs" dangerouslySetInnerHTML={{ __html: share.content }} />
</div>
{ share.canShare &&
<button
className="btn btn-outline mr-1 text-nowrap"
type="button"
data-toggle="collapse"
data-target="#shareResourcePanel"
aria-expanded="false"
aria-controls="shareResourcePanel"
id="shareBtn"
>
<i className="fa fa-share-alt"></i>
Share
</button>
}
{ playlist.canCreate &&
<button className="btn btn-outline text-nowrap mr-1"
id="addToPlaylistBtn"
type="button"
data-toggle="collapse"
data-target="#addToPlaylistPanel"
aria-expanded="false"
aria-controls="addToPlaylistPanel"
disabled={true}
>
{/* Static SVG image in /app/assets/images/add_to_playlist_icon.svg */}
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="-293 386 24 24" xmlSpace="preserve">
<path className="st1" fill="currentColor" d="M-279,395h-12v2h12V395z M-279,391h-12v2h12V391z M-275,399v-4h-2v4h-4v2h4v4h2v-4h4v-2H-275z M-291,401h8v-2h-8V401z"/>
</svg>
Add to Playlist
</button>
}
</Col>
{ has_structure &&
<Col className="ramp-button-group-2">
<button
className="btn btn-outline expand-collapse-toggle-button expanded"
id="expand_all_btn"
onClick={handleCollapseExpand}
ref={expandCollapseBtnRef}
>
<ExpandCollapseArrow />
{isClosed ? ' Expand' : ' Close'} {master_files_count > 1 ? `${master_files_count} Sections` : 'Section'}
</button>
</Col>
</Row>
<StructuredNavigation />
</React.Fragment>
}
</React.Fragment>
)
}
</Col>
}
<Col sm={ (in_progress || master_files_count == 0) ? 12 : 4}>
}
</div>
<Row className="mx-0">
<Col>
<div dangerouslySetInnerHTML={{ __html: timeline.content}} />
</Col>
<Col md={12} lg={12} sm={12} className="px-0">
<div className="collapse" id="addToPlaylistPanel">
<div className="card card-body" dangerouslySetInnerHTML={{ __html: playlist.tab }} />
</div>
</Col>
<Col md={12} lg={12} sm={12} className="px-0">
<div className="collapse" id="shareResourcePanel">
<div className="share-tabs" dangerouslySetInnerHTML={{ __html: share.content }} />
</div>
</Col>
</Row>
<StructuredNavigation />
</React.Fragment>
}
</React.Fragment>
)
}
</Col>
<Col sm={ (master_files_count == 0) ? 12 : 4}>
{ cdl.enabled && <div dangerouslySetInnerHTML={{ __html: cdl.destroy }}/> }
<Tabs>
<Tab eventKey="details" title="Details">
<MetadataDisplay showHeading={false} displayTitle={false}/>
</Tab>
{ (cdl.can_stream && master_files_count != 0 && !in_progress && has_transcripts) &&
{ (cdl.can_stream && master_files_count != 0 && has_transcripts) &&
<Tab eventKey="transcripts" title="Transcripts">
<Transcript
playerID="iiif-media-player"
Expand Down
10 changes: 10 additions & 0 deletions app/models/iiif_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def placeholder_content
height: 720,
type: 'Image',
format: 'image/jpeg')
elsif section_processing?(@master_file)
IIIFManifest::V3::DisplayContent.new(nil,
label: I18n.t('media_object.conversion_msg'),
type: 'Text',
format: 'text/plain')
else
support_email = Settings.email.support
IIIFManifest::V3::DisplayContent.new(nil,
Expand Down Expand Up @@ -116,6 +121,11 @@ def stream_urls
end
end

def section_processing?(master_file)
encode_gid = "gid://ActiveEncode/#{master_file.encoder_class}/#{master_file.workflow_id}"
ActiveEncode::EncodeRecord.find_by(global_id: encode_gid).state.to_s.upcase != 'COMPLETED'
end

def supplemental_captions_transcripts
files = master_file.supplemental_files(tag: 'caption') + master_file.supplemental_files(tag: 'transcript')
files += [master_file.captions] if master_file.captions.present? && master_file.captions.persisted?
Expand Down
3 changes: 1 addition & 2 deletions app/views/media_objects/_item_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Unless required by applicable law or agreed to in writing, software distributed
<% end %>
<% end %>
</div>
<div class="<%= in_progress || !@currentStream ? 'col-sm-4' : 'col-sm-12' %>">
<div class="col-sm-12">
<%= react_component("Ramp",
{
base_url: request.protocol+request.host_with_port,
Expand All @@ -49,7 +49,6 @@ Unless required by applicable law or agreed to in writing, software distributed
share: { canShare: (will_partial_list_render? :share), content: lending_enabled?(@media_object) ? (render('share') if can_stream) : render('share') },
timeline: { canCreate: (current_ability.can? :create, Timeline), content: lending_enabled?(@media_object) ? (render('timeline') if can_stream) : render('timeline') },
playlist: { canCreate: (current_ability.can? :create, Playlist), tab: render('add_to_playlist') },
in_progress: in_progress,
cdl: { enabled: lending_enabled?(@media_object), can_stream: can_stream, embed: render('embed_checkout'), destroy: render('destroy_checkout') },
has_files: @media_object.supplemental_files.present? || @media_object.sections_with_files.present?,
has_transcripts: @media_object.sections_with_files(tag: 'transcript').present?
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ en:
empty_share_link: ""
empty_share_link_notice: "After processing has started the embedded link will be available."
empty_share_section_permalink_notice: "After processing has started the section link will be available."
conversion_msg: "This item is still processing. Please check back later."
cdl:
checkout_message: "<p>Borrow this item to access media resources.</p>"
not_available_message: "<p>This resource is currently checked out by another user. </br></br> This item is due to be returned on </br><span data-utc-time='%{time}' />.</p>"
Expand Down
18 changes: 17 additions & 1 deletion spec/models/iiif_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
end

context 'when master file does not have derivatives' do
let(:master_file) { FactoryBot.build(:master_file, media_object: media_object) }
let(:master_file) { FactoryBot.build(:master_file, :completed_processing, media_object: media_object) }

it 'has format' do
expect(subject.format).to eq "text/plain"
Expand All @@ -172,6 +172,22 @@
expect(subject.label).to eq I18n.t('errors.missing_derivatives_error') % [Settings.email.support, Settings.email.support]
end
end

context 'when master file is processing' do
let(:master_file) { FactoryBot.build(:master_file, media_object: media_object) }

it 'has format' do
expect(subject.format).to eq "text/plain"
end

it 'has type' do
expect(subject.type).to eq "Text"
end

it 'has label' do
expect(subject.label).to eq I18n.t('media_object.conversion_msg')
end
end
end

describe 'Supplemental file handling' do
Expand Down

0 comments on commit c9ffa8d

Please sign in to comment.