mirror of https://github.com/sipwise/www_admin.git
3.0-u-redesign
parent
673e05a857
commit
0afaa4f6ae
@ -0,0 +1,94 @@
|
||||
package admin::Controller::rrd;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Catalyst::Controller';
|
||||
use admin::Utils;
|
||||
use Data::Dumper;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
admin::Controller::rrd - Catalyst Controller
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Catalyst Controller.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head2 get
|
||||
|
||||
Serves rrd files
|
||||
|
||||
=cut
|
||||
|
||||
sub get : Local {
|
||||
my ( $self, $c ) = @_;
|
||||
|
||||
$c->log->debug('***rrd::get called');
|
||||
|
||||
my $path = $c->request->params->{path};
|
||||
my $rrd;
|
||||
|
||||
if($path and $c->model('Provisioning')->call_prov( $c, 'system', 'get_rrd',
|
||||
{path => $path}, \$rrd)) {
|
||||
$c->stash->{current_view} = 'Binary';
|
||||
$c->stash->{content_type} = 'application/octet-stream';
|
||||
$c->stash->{content} = $$rrd{content};
|
||||
return;
|
||||
}
|
||||
$c->response->redirect('/');
|
||||
}
|
||||
|
||||
sub end : ActionClass('RenderView') {
|
||||
my ( $self, $c ) = @_;
|
||||
|
||||
if(defined $c->stash->{current_view} and $c->stash->{current_view} eq 'Binary') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$c->stash->{current_view} = 'TT';
|
||||
unless($c->response->{status} =~ /^3/) { # only if not a redirect
|
||||
if(exists $c->session->{prov_error}) {
|
||||
$c->session->{messages}{prov_error} = $c->session->{prov_error};
|
||||
delete $c->session->{prov_error};
|
||||
}
|
||||
|
||||
if(exists $c->session->{messages}) {
|
||||
$c->stash->{messages} = $c->model('Provisioning')->localize($c, $c->session->{messages});
|
||||
delete $c->session->{messages};
|
||||
}
|
||||
}
|
||||
|
||||
$c->stash->{subscriber}{username} = $c->session->{user}{username};
|
||||
|
||||
return 1; # shouldn't matter
|
||||
}
|
||||
|
||||
=head1 BUGS AND LIMITATIONS
|
||||
|
||||
=over
|
||||
|
||||
=item none
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Provisioning model, Catalyst
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Andreas Granig <agranig@sipwise.com>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The rrd controller is Copyright (c) 2007-2010 Sipwise GmbH,
|
||||
Austria. All rights reserved.
|
||||
|
||||
=cut
|
||||
|
||||
1;
|
||||
@ -0,0 +1,53 @@
|
||||
package admin::View::Binary;
|
||||
|
||||
use strict;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
admin::View::Binary - TT View for binary data
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Binary View for admin. It will output binary data with the corresponding
|
||||
content-type header set.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
return bless {}, shift;
|
||||
}
|
||||
|
||||
sub process {
|
||||
my ( $self, $c ) = @_;
|
||||
|
||||
$c->response->content_type($c->stash->{content_type});
|
||||
$c->response->body($c->stash->{content});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
=head1 BUGS AND LIMITATIONS
|
||||
|
||||
=over
|
||||
|
||||
=item none I know.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Catalyst, admin
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Daniel Tiefnig <dtiefnig@sipwise.com>
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The Binary view is Copyright (c) 2007 Sipwise GmbH, Austria. All rights
|
||||
reserved.
|
||||
|
||||
=cut
|
||||
|
||||
# over and out
|
||||
1;
|
||||
Loading…
Reference in new issue