Implement voicemail table.

Listening to WAV49 doesn't seem to work out of the box with a normal
linux player, probably we need to transcode GSM?
agranig/1_0_subfix
Andreas Granig 12 years ago
parent b4d294af12
commit da4170c2a6

@ -1293,6 +1293,12 @@ sub master :Chained('base') :PathPart('details') :CaptureArgs(0) {
{ name => "start_time", search_from_epoch => 1, search_to_epoch => 1, title => "Start Time" },
{ name => "duration", search => 1, title => "Duration" },
]);
$c->stash->{vm_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => "id", search => 1, title => "#" },
{ name => "callerid", search => 1, title => "Caller" },
{ name => "origtime", search_from_epoch => 1, search_to_epoch => 1, title => "Time" },
{ name => "duration", search => 1, title => "Duration" },
]);
$c->stash(
template => 'subscriber/master.tt',
@ -1306,6 +1312,7 @@ sub details :Chained('master') :PathPart('') :Args(0) {
sub ajax_calls :Chained('master') :PathPart('calls/ajax') :Args(0) {
my ($self, $c) = @_;
# CDRs
my $out_rs = $c->model('DB')->resultset('cdr')->search({
source_user_id => $c->stash->{subscriber}->uuid,
});
@ -1313,12 +1320,63 @@ sub ajax_calls :Chained('master') :PathPart('calls/ajax') :Args(0) {
destination_user_id => $c->stash->{subscriber}->uuid,
});
my $rs = $out_rs->union($in_rs);
NGCP::Panel::Utils::Datatables::process($c, $rs, $c->stash->{calls_dt_columns});
$c->detach( $c->view("JSON") );
}
sub ajax_voicemails :Chained('master') :PathPart('voicemails/ajax') :Args(0) {
my ($self, $c) = @_;
my $vm_rs = $c->model('DB')->resultset('voicemail_spool')->search({
mailboxuser => $c->stash->{subscriber}->uuid,
});
NGCP::Panel::Utils::Datatables::process($c, $vm_rs, $c->stash->{vm_dt_columns});
$c->detach( $c->view("JSON") );
}
sub voicemail :Chained('master') :PathPart('voicemail') :CaptureArgs(1) {
my ($self, $c, $vm_id) = @_;
my $rs = $c->model('DB')->resultset('voicemail_spool')->search({
mailboxuser => $c->stash->{subscriber}->uuid,
id => $vm_id,
});
unless($rs->first) {
$c->log->error("no such voicemail file with id '$vm_id' for uuid ".$c->stash->{subscriber}->uuid);
$c->flash(messages => [{type => 'error', text => 'No such voicemail file to play'}]);
$c->response->redirect($c->uri_for_action('/subscriber/details', [$c->req->captures->[0]]));
return;
}
$c->stash->{voicemail} = $rs->first;
}
sub play_voicemail :Chained('voicemail') :PathPart('play') :Args(0) {
my ($self, $c) = @_;
my $file = $c->stash->{voicemail};
# TODO: doesn't properly play wav49!
$c->response->header('Content-Disposition' => 'attachment; filename="'.$file->msgnum.'.wav"');
$c->response->content_type('audio/x-wav');
$c->response->body($file->recording);
}
sub delete_voicemail :Chained('voicemail') :PathPart('delete') :Args(0) {
my ($self, $c) = @_;
try {
$c->stash->{voicemail}->delete;
$c->flash(messages => [{type => 'success', text => 'Successfully deleted voicemail'}]);
} catch($e) {
$c->log->error("failed to delete voicemail message: $e");
$c->flash(messages => [{type => 'error', text => 'Failed to delete voicemail'}]);
}
$c->response->redirect($c->uri_for_action('/subscriber/details', [$c->req->captures->[0]]));
}
=head1 AUTHOR
Andreas Granig,,,

@ -45,7 +45,8 @@ sub process {
my $from_date = $c->request->params->{sSearch_0} // "";
my $to_date = $c->request->params->{sSearch_1} // "";
my $parser = DateTime::Format::Strptime->new(
pattern => '%Y-%m-%d %H:%M',
#pattern => '%Y-%m-%d %H:%M',
pattern => '%Y-%m-%d',
);
if($from_date) {
$from_date = $parser->parse_datetime($from_date);

@ -163,8 +163,25 @@
</div>
<div class="accordion-body collapse" id="collapse_voicemail">
<div class="accordion-inner">
[%
helper.name = 'Voicemails';
helper.column_sort = 'origtime';
helper.dt_columns = vm_dt_columns;
[% # render vm DT here %]
helper.close_target = close_target;
helper.create_flag = create_flag;
helper.edit_flag = edit_flag;
helper.form_object = form;
helper.ajax_uri = c.uri_for_action('/subscriber/ajax_voicemails', [c.req.captures.0]);
helper.dt_buttons = [
{ name = 'Play', uri = "details/voicemail/'+full.id+'/play", class = 'btn-small btn-tertiary', icon = 'icon-play' },
{ name = 'Delete', uri = "details/voicemail/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
];
PROCESS 'helpers/datatables.tt';
%]
</div>
</div>
</div>

Loading…
Cancel
Save