make the branch authonly

This commit is contained in:
Oliver Gorwits
2019-03-17 20:08:06 +00:00
parent 33f94eac62
commit 46bc2c6feb
4 changed files with 9 additions and 145 deletions

View File

@@ -4,25 +4,13 @@ use Dancer ':syntax';
use Dancer::Plugin::Ajax;
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use Dancer::Plugin::Swagger;
use App::Netdisco::Web::Plugin;
register_device_tab({ tag => 'details', label => 'Details' });
# device details table
swagger_path {
description => 'Get properties and power details for a device.',
path => '/api/device/{identifier}/details',
tags => ['Devices'],
parameters => [
{ name => 'identifier', in => 'path', required => 1, type => 'string' },
],
responses => { default => { examples => {
'application/json' => { device => {}, power => {} },
} } },
},
get '/ajax/content/device/details' => require_login sub {
ajax '/ajax/content/device/details' => require_login sub {
my $q = param('q');
my $device = schema('netdisco')->resultset('Device')
->search_for_device($q) or send_error('Bad device', 400);
@@ -36,18 +24,10 @@ get '/ajax/content/device/details' => require_login sub {
= schema('netdisco')->resultset('DevicePower')
->search( { 'me.ip' => $device->ip } )->with_poestats->hri->all;
if (vars->{'is_api'}) {
content_type('application/json');
# TODO merge power into device details
# TODO remove sensitive data (community)
to_json { device => $results[0], power => \@power };
}
else {
content_type('text/html');
template 'ajax/device/details.tt', {
d => $results[0], p => \@power
}, { layout => undef };
}
content_type('text/html');
template 'ajax/device/details.tt', {
d => $results[0], p => \@power
}, { layout => undef };
};
1;