audio-recordings.cgi: set upload status
on uploading and audio processing the status is updated
This commit is contained in:
@@ -1304,3 +1304,7 @@ CREATE TABLE `calcms_user_selected_events` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
ALTER TABLE `calcms`.`calcms_events`
|
||||
ADD COLUMN `upload_status` VARCHAR(45) NULL DEFAULT NULL AFTER `listen_key`;
|
||||
|
||||
|
||||
@@ -590,7 +590,7 @@ sub update_listen_key($$){
|
||||
|
||||
return undef unless defined $event->{event_id};
|
||||
return undef unless defined $event->{listen_key};
|
||||
print STDERR "set listen_key=$event->{listen_key} for ".$event->{start}." ".$event->{title}."\n";
|
||||
#print STDERR "set listen_key=$event->{listen_key} for ".$event->{start}." ".$event->{title}."\n";
|
||||
my $bindValues = [ $event->{listen_key}, $event->{event_id} ];
|
||||
|
||||
my $query = qq{
|
||||
@@ -602,6 +602,23 @@ sub update_listen_key($$){
|
||||
my $recordings = db::put( $dbh, $query, $bindValues );
|
||||
}
|
||||
|
||||
sub set_upload_status($$){
|
||||
my ($config, $event) = @_;
|
||||
|
||||
print STDERR "set upload_status=$event->{upload_status} for ".$event->{event_id}."\n";
|
||||
return undef unless defined $event->{event_id};
|
||||
return undef unless defined $event->{upload_status};
|
||||
my $bindValues = [ $event->{upload_status}, $event->{event_id}, $event->{upload_status} ];
|
||||
|
||||
my $query = qq{
|
||||
update calcms_events
|
||||
set upload_status=?
|
||||
where id=? and upload_status!=?;
|
||||
};
|
||||
my $dbh = db::connect($config);
|
||||
my $recordings = db::put( $dbh, $query, $bindValues );
|
||||
}
|
||||
|
||||
sub add_recordings($$$$) {
|
||||
my ($dbh, $config, $request, $events) = @_;
|
||||
|
||||
@@ -1086,6 +1103,7 @@ sub get_query($$$) {
|
||||
,e.disable_event_sync
|
||||
,e.episode
|
||||
,e.listen_key
|
||||
,e.upload_status
|
||||
};
|
||||
my $template = $params->{template} || '';
|
||||
|
||||
|
||||
@@ -135,20 +135,25 @@ sub uploadRecording {
|
||||
|
||||
if ( defined $fh ) {
|
||||
print STDERR "upload\n";
|
||||
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'uploading' });
|
||||
my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
|
||||
#$params->{duration} = $fileInfo->{duration};
|
||||
$params = updateDatabase( $config, $params, $user ) if $params->{error} eq '';
|
||||
if ($params->{error} eq ''){
|
||||
$params = updateDatabase( $config, $params, $user ) ;
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'uploaded' });
|
||||
}
|
||||
|
||||
} else {
|
||||
print STDERR "could not get file handle\n";
|
||||
$params->{error} .= 'Could not get file handle';
|
||||
}
|
||||
|
||||
if ( $params->{error} ne '' ) {
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'upload failed' });
|
||||
if ( $params->{error} =~ /limit/ ) {
|
||||
$params->{error} .=
|
||||
"audio file size is limited to "
|
||||
|
||||
@@ -732,7 +732,9 @@ sub showEventList {
|
||||
my $liveIcon = qq{<i class="fas fa-microphone-alt" title="$params->{loc}->{label_live}"></i>};
|
||||
my $draftIcon = qq{<i class="fas fa-drafting-compass" title="$params->{loc}->{label_draft}"></i>};
|
||||
my $archiveIcon = qq{<i class="fas fa-archive" title="$params->{loc}->{label_archived}"></i>};
|
||||
my $playoutIcon = qq{<i class="fas fa-play"></i>};
|
||||
my $playoutIcon = qq{<i class="fas fa-play"></i>};
|
||||
my $processingIcon = qq{<i class="fas fa-sync fa-spin"></i>};
|
||||
my $preparedIcon = qq{<i class="fas fa-play-circle"></i>};
|
||||
|
||||
my $out = '';
|
||||
$out = qq{
|
||||
@@ -840,9 +842,10 @@ sub showEventList {
|
||||
$draft = '-' if $draft eq '0';
|
||||
$draft = $draftIcon if $draft eq '1';
|
||||
|
||||
my $playout = $event->{playout} || '0';
|
||||
$playout = '-' if $playout eq '0';
|
||||
$playout = $playoutIcon if $playout eq '1';
|
||||
my $playout = '-';
|
||||
$playout = $processingIcon if $event->{upload_status} ne '';
|
||||
$playout = $preparedIcon if $event->{upload_status} eq 'done';
|
||||
$playout = $playoutIcon if $event->{playout} eq '1';
|
||||
|
||||
my $title = $event->{title};
|
||||
$title .= ': ' . $event->{user_title} if $event->{user_title} ne '';
|
||||
@@ -856,6 +859,7 @@ sub showEventList {
|
||||
my $file = $event->{file}
|
||||
? 'playout: ' . $event->{file} =~ s/\'/\'/gr
|
||||
: 'playout';
|
||||
my $playout_info = $file // $event->{upload_status} // '';
|
||||
|
||||
$out .=
|
||||
qq!<tr id="$id" class="$class" start="$event->{start}" >!
|
||||
@@ -872,7 +876,7 @@ sub showEventList {
|
||||
. qq!<td class="rerun">$rerun</td>!
|
||||
. qq!<td class="draft">$draft</td>!
|
||||
. qq!<td class="live">$live</td>!
|
||||
. qq!<td class="playout" title="$file">$playout</td>!
|
||||
. qq!<td class="playout" title="$playout_info">$playout</td>!
|
||||
. qq!<td class="archived">$archived</td>!
|
||||
. qq!<td>$event->{project_name} $other_studio</td>!
|
||||
. qq!<td>$event->{studio_name} $other_studio</td>!
|
||||
@@ -1527,16 +1531,27 @@ sub print_event {
|
||||
? 'playout: ' . $event->{file} =~ s/\'/\'/gr
|
||||
: 'playout';
|
||||
|
||||
my $playoutClass = qq{fas fa-play};
|
||||
my $processingClass = qq{fas fa-sync fa-spin};
|
||||
my $preparedClass = qq{fas fa-play-circle};
|
||||
|
||||
my $icons='';
|
||||
if ( exists $attr->{event} ){
|
||||
my $playout = '';
|
||||
if (exists $attr->{upload_status}){
|
||||
$playout = $processingClass if $attr->{upload_status} ne '';
|
||||
$playout = $preparedClass if $attr->{upload_status} eq 'done';
|
||||
}
|
||||
$playout = $playoutClass if exists $attr->{playout};
|
||||
|
||||
$icons.='<i class="fas fa-microphone-alt" title="live"></i>'
|
||||
if exists($attr->{live}) && exists($attr->{no_rerun});
|
||||
$icons.='<i class="fas fa-microphone-slash" title="preproduced"></i>'
|
||||
if exists($attr->{preproduced}) && exists($attr->{no_rerun});
|
||||
$icons.='<i class="fas fa-redo" title="rerun"></i>'
|
||||
if exists $attr->{rerun};
|
||||
$icons.=qq{<i class="fas fa-play" title="$file" onmouseenter="console.log('$file');"></i>}
|
||||
if exists $attr->{playout};
|
||||
$icons.=qq{<i class="$playout" title="$file" onmouseenter="console.log('$file');"></i>}
|
||||
if $playout;
|
||||
$icons.='<i class="fas fa-archive" title="archived"></i>'
|
||||
if exists $attr->{archived};
|
||||
}
|
||||
|
||||
@@ -115,13 +115,20 @@ sub uploadRecording {
|
||||
|
||||
if ( defined $fh ) {
|
||||
print STDERR "upload\n";
|
||||
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'uploading' });
|
||||
|
||||
my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
|
||||
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
|
||||
$params->{path} = $fileInfo->{path};
|
||||
$params->{size} = $fileInfo->{size};
|
||||
|
||||
$params = updateDatabase( $config, $params, $user ) if $params->{error} eq '';
|
||||
if ($params->{error} eq ''){
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'uploaded' });
|
||||
$params = updateDatabase( $config, $params, $user );
|
||||
}else{
|
||||
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'upload failed' });
|
||||
}
|
||||
} else {
|
||||
print STDERR "could not get file handle\n";
|
||||
$params->{error} .= 'Could not get file handle';
|
||||
|
||||
Reference in New Issue
Block a user