diff --git a/install/create.sql b/install/create.sql index 369f74d..81ab307 100644 --- a/install/create.sql +++ b/install/create.sql @@ -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`; + diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 9054ed4..e5bea6c 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -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} || ''; diff --git a/website/agenda/planung/audio-recordings.cgi b/website/agenda/planung/audio-recordings.cgi index 940b963..7ee2f8e 100755 --- a/website/agenda/planung/audio-recordings.cgi +++ b/website/agenda/planung/audio-recordings.cgi @@ -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 " diff --git a/website/agenda/planung/calendar.cgi b/website/agenda/planung/calendar.cgi index 5d0442c..1f3033b 100755 --- a/website/agenda/planung/calendar.cgi +++ b/website/agenda/planung/calendar.cgi @@ -732,7 +732,9 @@ sub showEventList { my $liveIcon = qq{}; my $draftIcon = qq{}; my $archiveIcon = qq{}; - my $playoutIcon = qq{}; + my $playoutIcon = qq{}; + my $processingIcon = qq{}; + my $preparedIcon = qq{}; 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!! @@ -872,7 +876,7 @@ sub showEventList { . qq!$rerun! . qq!$draft! . qq!$live! - . qq!$playout! + . qq!$playout! . qq!$archived! . qq!$event->{project_name} $other_studio! . qq!$event->{studio_name} $other_studio! @@ -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.='' if exists($attr->{live}) && exists($attr->{no_rerun}); $icons.='' if exists($attr->{preproduced}) && exists($attr->{no_rerun}); $icons.='' if exists $attr->{rerun}; - $icons.=qq{} - if exists $attr->{playout}; + $icons.=qq{} + if $playout; $icons.='' if exists $attr->{archived}; } diff --git a/website/agenda/planung/upload-audio-recordings.cgi b/website/agenda/planung/upload-audio-recordings.cgi index 14c8e8b..13991cd 100644 --- a/website/agenda/planung/upload-audio-recordings.cgi +++ b/website/agenda/planung/upload-audio-recordings.cgi @@ -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';