Fix subscriber login and add basic widgets.

agranig/peering-route
Andreas Granig 12 years ago
parent 5160759f38
commit 06fc0fa4dd

@ -77,16 +77,23 @@ sub index :Path Form {
$realm);
} elsif($realm eq 'subscriber') {
# TODO: check for lock status?
my ($u, $d) = split /\@/, $user;
unless($d) {
$d = $c->req->uri->host;
}
my $authrs = $c->model('DB')->resultset('provisioning_voip_subscribers')->search({
webusername => $u,
webpassword => $pass,
'domain.domain' => $d,
}, {
join => 'domain',
});
$res = $c->authenticate(
{
webusername => $user,
webusername => $u,
webpassword => $pass,
'dbix_class' => {
searchargs => [{
-and => [
webusername => $user,
],
}],
resultset => $authrs
}
},
$realm);

@ -0,0 +1,53 @@
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:

@ -0,0 +1,50 @@
package NGCP::Panel::Widget::Plugin::SubscriberVmOverview;
use Moose::Role;
has 'template' => (
is => 'ro',
isa => 'Str',
default => 'widgets/subscriber_vm_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 $rs = $c->model('DB')->resultset('voicemail_spool')->search({
mailboxuser => $c->user->uuid,
dir => { -like => '%/INBOX' },
}, {
order_by => { -desc => 'me.origtime' },
})->slice(0, 9);
$c->stash(
vmails => $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:

@ -9,7 +9,14 @@
<div id="top-nav">
<ul class="pull-right">
<li><i class="icon-user"></i> Logged in as [% c.user.login %]</li>
<li>
<i class="icon-user"></i> Logged in as
[% IF c.user_in_realm('admin') || c.user_in_realm('reseller') -%]
[% c.user.login %]
[% ELSE -%]
[% c.user.webusername %]@[% c.user.domain.domain %]
[% END -%]
</li>
<li><a href="[% c.uri_for('/logout') %]">Logout</a></li>
</ul>
</div> <!-- /#top-nav -->

@ -0,0 +1,51 @@
[% USE Math -%]
<div class="plan-container">
<div class="plan">
<div class="plan-header">
<div class="plan-title">Call List</div>
<div class="plan-price">
<span>[% calls.count %]</span>
<span class="term">Recent Calls</span>
</div>
</div>
<div class="plan-features">
<ul>
[% IF calls.count == 0 -%]
<li>No calls yet</li>
[% ELSE -%]
[% FOR call IN calls.all -%]
<li>
<div class="row-fluid">
[% IF call.source_user_id == c.user.uuid -%]
<span class="span1">
[% IF call.call_status == "ok" -%]
<i class="icon-circle-arrow-right" style="color:green"></i>
[% ELSE -%]
<i class="icon-circle-arrow-up" style="color:red"></i>
[% END -%]
</span>
<span class="span4">[% call.destination_user_in %]</span>
[% ELSE -%]
<span class="span1">
[% IF call.call_status == "ok" -%]
<i class="icon-circle-arrow-left" style="color:green"></i>
[% ELSE -%]
<i class="icon-circle-arrow-down" style="color:red"></i>
[% END -%]
</span>
<span class="span4">[% call.clir ? "anonymous" : call.source_cli %]</span>
[% END -%]
<span class="span3">[% call.start_time -%]</span>
<span class="span1">[% Math.int(call.duration) -%]s</span>
</div>
</li>
[% END -%]
[% END -%]
</ul>
</div>
<div class="plan-actions">
<a href="[% c.uri_for('/subscriber') %]" class="btn">View Call List</a>
</div>
</div>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -0,0 +1,38 @@
[% USE Math -%]
<div class="plan-container">
<div class="plan">
<div class="plan-header">
<div class="plan-title">Voicebox Messages</div>
<div class="plan-price">
<span>[% vmails.count %]</span>
<span class="term">New Messages</span>
</div>
</div>
<div class="plan-features">
<ul>
[% IF vmails.count == 0 -%]
<li>No new messages</li>
[% ELSE -%]
[% FOR vmail IN vmails.all -%]
<li>
<div class="row-fluid">
<span class="span1">
<a href="#" alt="listen">
<i class="icon-volume-up" style="color:green"></i>
</a>
</span>
<span class="span4">[% vmail.callerid -%]</span>
<span class="span3">[% vmail.origtime -%]</span>
<span class="span1">[% vmail.duration -%]s</span>
</div>
</li>
[% END -%]
[% END -%]
</ul>
</div>
<div class="plan-actions">
<a href="[% c.uri_for('/subscriber') %]" class="btn">View Call List</a>
</div>
</div>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]
Loading…
Cancel
Save