audio-recordings.cgi: set upload status

on uploading and audio processing the status is updated
This commit is contained in:
Milan
2021-02-05 22:53:56 +01:00
parent 696b964dfa
commit 7ffc6914b9
5 changed files with 60 additions and 11 deletions

View File

@@ -1304,3 +1304,7 @@ CREATE TABLE `calcms_user_selected_events` (
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */; /*!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`;

View File

@@ -590,7 +590,7 @@ sub update_listen_key($$){
return undef unless defined $event->{event_id}; return undef unless defined $event->{event_id};
return undef unless defined $event->{listen_key}; 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 $bindValues = [ $event->{listen_key}, $event->{event_id} ];
my $query = qq{ my $query = qq{
@@ -602,6 +602,23 @@ sub update_listen_key($$){
my $recordings = db::put( $dbh, $query, $bindValues ); 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($$$$) { sub add_recordings($$$$) {
my ($dbh, $config, $request, $events) = @_; my ($dbh, $config, $request, $events) = @_;
@@ -1086,6 +1103,7 @@ sub get_query($$$) {
,e.disable_event_sync ,e.disable_event_sync
,e.episode ,e.episode
,e.listen_key ,e.listen_key
,e.upload_status
}; };
my $template = $params->{template} || ''; my $template = $params->{template} || '';

View File

@@ -135,20 +135,25 @@ sub uploadRecording {
if ( defined $fh ) { if ( defined $fh ) {
print STDERR "upload\n"; 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} ); my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error}; $params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
$params->{path} = $fileInfo->{path}; $params->{path} = $fileInfo->{path};
$params->{size} = $fileInfo->{size}; $params->{size} = $fileInfo->{size};
#$params->{duration} = $fileInfo->{duration}; #$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 { } else {
print STDERR "could not get file handle\n"; print STDERR "could not get file handle\n";
$params->{error} .= 'Could not get file handle'; $params->{error} .= 'Could not get file handle';
} }
if ( $params->{error} ne '' ) { if ( $params->{error} ne '' ) {
events::set_upload_status($config, {event_id=>$params->{event_id}, upload_status=>'upload failed' });
if ( $params->{error} =~ /limit/ ) { if ( $params->{error} =~ /limit/ ) {
$params->{error} .= $params->{error} .=
"audio file size is limited to " "audio file size is limited to "

View File

@@ -733,6 +733,8 @@ sub showEventList {
my $draftIcon = qq{<i class="fas fa-drafting-compass" title="$params->{loc}->{label_draft}"></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 $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 = ''; my $out = '';
$out = qq{ $out = qq{
@@ -840,9 +842,10 @@ sub showEventList {
$draft = '-' if $draft eq '0'; $draft = '-' if $draft eq '0';
$draft = $draftIcon if $draft eq '1'; $draft = $draftIcon if $draft eq '1';
my $playout = $event->{playout} || '0'; my $playout = '-';
$playout = '-' if $playout eq '0'; $playout = $processingIcon if $event->{upload_status} ne '';
$playout = $playoutIcon if $playout eq '1'; $playout = $preparedIcon if $event->{upload_status} eq 'done';
$playout = $playoutIcon if $event->{playout} eq '1';
my $title = $event->{title}; my $title = $event->{title};
$title .= ': ' . $event->{user_title} if $event->{user_title} ne ''; $title .= ': ' . $event->{user_title} if $event->{user_title} ne '';
@@ -856,6 +859,7 @@ sub showEventList {
my $file = $event->{file} my $file = $event->{file}
? 'playout: ' . $event->{file} =~ s/\'/\&apos;/gr ? 'playout: ' . $event->{file} =~ s/\'/\&apos;/gr
: 'playout'; : 'playout';
my $playout_info = $file // $event->{upload_status} // '';
$out .= $out .=
qq!<tr id="$id" class="$class" start="$event->{start}" >! qq!<tr id="$id" class="$class" start="$event->{start}" >!
@@ -872,7 +876,7 @@ sub showEventList {
. qq!<td class="rerun">$rerun</td>! . qq!<td class="rerun">$rerun</td>!
. qq!<td class="draft">$draft</td>! . qq!<td class="draft">$draft</td>!
. qq!<td class="live">$live</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 class="archived">$archived</td>!
. qq!<td>$event->{project_name} $other_studio</td>! . qq!<td>$event->{project_name} $other_studio</td>!
. qq!<td>$event->{studio_name} $other_studio</td>! . qq!<td>$event->{studio_name} $other_studio</td>!
@@ -1527,16 +1531,27 @@ sub print_event {
? 'playout: ' . $event->{file} =~ s/\'/\&apos;/gr ? 'playout: ' . $event->{file} =~ s/\'/\&apos;/gr
: 'playout'; : 'playout';
my $playoutClass = qq{fas fa-play};
my $processingClass = qq{fas fa-sync fa-spin};
my $preparedClass = qq{fas fa-play-circle};
my $icons=''; my $icons='';
if ( exists $attr->{event} ){ 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>' $icons.='<i class="fas fa-microphone-alt" title="live"></i>'
if exists($attr->{live}) && exists($attr->{no_rerun}); if exists($attr->{live}) && exists($attr->{no_rerun});
$icons.='<i class="fas fa-microphone-slash" title="preproduced"></i>' $icons.='<i class="fas fa-microphone-slash" title="preproduced"></i>'
if exists($attr->{preproduced}) && exists($attr->{no_rerun}); if exists($attr->{preproduced}) && exists($attr->{no_rerun});
$icons.='<i class="fas fa-redo" title="rerun"></i>' $icons.='<i class="fas fa-redo" title="rerun"></i>'
if exists $attr->{rerun}; if exists $attr->{rerun};
$icons.=qq{<i class="fas fa-play" title="$file" onmouseenter="console.log('$file');"></i>} $icons.=qq{<i class="$playout" title="$file" onmouseenter="console.log('$file');"></i>}
if exists $attr->{playout}; if $playout;
$icons.='<i class="fas fa-archive" title="archived"></i>' $icons.='<i class="fas fa-archive" title="archived"></i>'
if exists $attr->{archived}; if exists $attr->{archived};
} }

View File

@@ -116,12 +116,19 @@ sub uploadRecording {
if ( defined $fh ) { if ( defined $fh ) {
print STDERR "upload\n"; 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} ); my $fileInfo = uploadFile( $config, $fh, $params->{event_id}, $user, $params->{upload} );
$params->{error} .= $fileInfo->{error} if defined $fileInfo->{error}; $params->{error} .= $fileInfo->{error} if defined $fileInfo->{error};
$params->{path} = $fileInfo->{path}; $params->{path} = $fileInfo->{path};
$params->{size} = $fileInfo->{size}; $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 { } else {
print STDERR "could not get file handle\n"; print STDERR "could not get file handle\n";
$params->{error} .= 'Could not get file handle'; $params->{error} .= 'Could not get file handle';