You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-panel/lib/NGCP/Panel/Widget/Plugin/SubscriberCallsOverview.pm

54 lines
1.1 KiB

package NGCP::Panel::Widget::Plugin::SubscriberCallsOverview;
use Moose::Role;
has 'template' => (
is => 'ro',
isa => 'Str',
default => 'widgets/subscriber_calls_overview.tt'
);
has 'type' => (
is => 'ro',
isa => 'Str',
default => 'dashboard_widgets',
);
has 'priority' => (
is => 'ro',
isa => 'Int',
default => 10,
);
around handle => sub {
my ($foo, $self, $c) = @_;
my $out_rs = $c->model('DB')->resultset('cdr')->search({
source_user_id => $c->user->uuid,
});
my $in_rs = $c->model('DB')->resultset('cdr')->search({
destination_user_id => $c->user->uuid,
});
my $calls_rs = $out_rs->union($in_rs)->search(undef, {
order_by => { -desc => 'me.start_time' },
})->slice(0, 9);
$c->stash(
calls => $calls_rs,
);
return;
};
sub filter {
my ($self, $c, $type) = @_;
return $self if(
$type eq $self->type &&
($c->user_in_realm('subscriber') || $c->user_in_realm('subscriberadmin')) &&
ref $c->controller eq 'NGCP::Panel::Controller::Dashboard'
);
return;
}
1;
# vim: set tabstop=4 expandtab: