MT#6047 Implement system-wide field dev overview.

- Allows to search for macs
- Allows to delete devices on a global level, if needed
mr3.2.1
Andreas Granig 12 years ago
parent 9b9b4c0628
commit 315fe4bce9

@ -110,11 +110,35 @@ sub base :Chained('/') :PathPart('device') :CaptureArgs(0) {
{ name => 'config.version', search => 1, title => $c->loc('Configuration Version') },
]);
my $fielddev_rs = $c->model('DB')->resultset('autoprov_field_devices');
if($c->user->roles eq "subscriberadmin" || $c->user->roles eq "subscriber") {
$fielddev_rs = $fielddev_rs->search({
'device.reseller_id' => $c->user->voip_subscriber->contract->contact->reseller_id,
}, {
join => { 'profile' => { 'config' => 'device' } },
});
} elsif($c->user->roles eq "reseller") {
$fielddev_rs = $fielddev_rs->search({
'device.reseller_id' => $c->user->reseller_id
}, {
join => { 'profile' => { 'config' => 'device' } },
});
}
$c->stash->{fielddev_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => 'id', search => 1, title => $c->loc('#') },
{ name => 'identifier', search => 1, title => $c->loc('MAC Address / Identifier') },
{ name => 'profile.name', search => 1, title => $c->loc('Profile Name') },
{ name => 'contract.id', search => 1, title => $c->loc('Customer #') },
{ name => 'contract.contact.email', search => 1, title => $c->loc('Customer Email') },
]);
$c->stash(
devmod_rs => $devmod_rs,
devfw_rs => $devfw_rs,
devconf_rs => $devconf_rs,
devprof_rs => $devprof_rs,
fielddev_rs => $fielddev_rs,
template => 'device/list.tt',
);
}
@ -900,6 +924,14 @@ sub devprof_edit :Chained('devprof_base') :PathPart('edit') :Args(0) :Does(ACL)
);
}
sub dev_field_ajax :Chained('base') :PathPart('device/ajax') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
my ($self, $c) = @_;
my $resultset = $c->stash->{fielddev_rs};
NGCP::Panel::Utils::Datatables::process($c, $resultset, $c->stash->{fielddev_dt_columns});
$c->detach( $c->view("JSON") );
}
sub dev_field_config :Chained('/') :PathPart('device/autoprov/config') :Args() {
my ($self, $c, $id) = @_;

@ -171,5 +171,39 @@
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#device_details" href="#collapse_fielddev">[% c.loc('Deployed Devices') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_fielddev">
<div class="accordion-inner">
[%
helper.name = c.loc('Deployed Device');
helper.identifier = 'field_device';
helper.data = fielddev;
helper.dt_columns = fielddev_dt_columns;
helper.length_change = 1;
helper.ajax_uri = c.uri_for('/device/device/ajax');
UNLESS c.user.read_only;
helper.dt_buttons = [
{ name = c.loc('Delete'), uri = "/customer/' + full.contract_id + '/pbx/device/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
{ name = c.loc('Customer'), uri = "/customer/' + full.contract_id + '/details", class = 'btn-small btn-tertiary', icon = 'icon-user' },
];
ELSE;
helper.dt_buttons = [
{ name = c.loc('Customer'), uri = "/customer/' + full.contract_id + '/details", class = 'btn-small btn-tertiary', icon = 'icon-user' },
];
END;
PROCESS 'helpers/datatables.tt';
-%]
</div>
</div>
</div>
</div>
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save