:JSON;
use strict;
use warnings;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use base 'Catalyst::View::JSON';
use JSON qw();
__PACKAGE__->config( 'expose_stash' => 'json_data', );
sub encode_json
$c->response->status(403);
$c->detach();
return;
}
my $encoder = JSON::MaybeXS->new(
utf8 => 1,
allow_blessed => 1,
convert_blesse
::Manoc::View::JSON
=head1 VERSION
version 2.99.4
=head1 SYNOPSIS
sub list_js : Chained('object_list') : PathPart('js') : Args(0) {
my ( $self, $c ) = @_;
$c->stash( json_data => \@my_l
JSON;
#ABSTRACT: Plugin to add .json vmethod to TT values.
use strict;
use warnings;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use Template::Plugin;
use base 'Template::Plugin';
use JSON;
sub json
{
my $self = shift;
my $o = shift;
return JSON->new->convert_blessed(1)->encode($o);
}
1;
# Local Variables:
# mode: cperl
# indent-tabs-mode: nil
# cperl-indent-level: 4
# cperl-inde
ME
App::Manoc::View::TT::Plugin::JSON - Plugin to add .json vmethod to TT values.
=head1 VERSION
version 2.99.4
=head1 DESCRIPTION
This plugin provides a C<.json> vmethod to all value types when
class => 'ManocDB::VlanRange',
form_class => 'App::Manoc::Form::VlanRange',
json_columns => [qw(id lansegment name description)],
object_list => {
order_by => [ 'lan
::Server',
form_class => 'App::Manoc::Form::Server',
view_object_perm => undef,
json_columns => [ 'id', 'name' ],
find_object_options => { prefetch => { installed_sw_pkgs =>
server->update();
$response->{success} = 1;
}
$c->stash( json_data => $response );
$c->forward('View::JSON');
}
__PACKAGE__->meta->make_immutable;
1;
# Local Variables:
# mode:
';
$result->{message} = 'command not found';
}
$c->stash( json_data => $result );
$c->forward('View::JSON');
}
sub get_form_success_url {
my ( $self, $c ) = @_;
my $act
return ( $filter, $attr );
}
sub datatable_row {
my ( $self, $c, $row ) = @_;
my $json_data = {
inventory => $row->inventory,
vendor => $row->vendor,
mod
$json_data->{workstation} = {
hostname => $wks->name,
href => $c->uri_for_action( 'workstation/view', [ $wks->id ] )->as_string,
};
}
return $json_data
Manoc::ControllerRole::CommonCRUD" => { -excludes => ["list"] },
"App::Manoc::ControllerRole::JSONView";
use namespace::autoclean;
__PACKAGE__->config(
action => {
setup => {
=> $_->id,
name => $_->name
}, @ifaces;
$c->stash( json_data => \@data );
$c->forward('View::JSON');
}
sub view : Chained('object') : PathPart('') : Args(0) {
my ( $s
S
=over 4
=item *
App::Manoc::ControllerRole::CommonCRUD
=item *
App::Manoc::ControllerRole::JSONView
=back
=head1 ACTIONS
=head2 populate
For interfaces batch creation
=head2 list_uncabled_
{},
),
name => $_->name
}, @ifaces;
$c->stash( json_data => \@data );
$c->forward('View::JSON');
}
__PACKAGE__->meta->make_immutable;
1;
# Local Variables:
# mode: cp
S
=over 4
=item *
App::Manoc::ControllerRole::CommonCRUD
=item *
App::Manoc::ControllerRole::JSONView
=back
=head1 ACTIONS
=head2 cabling
=head2 list_uncabled_js
=head1 AUTHORS
=over 4
=it
lt => 1 );
# has_field validation_json => ( type => 'Hidden', element_attr => { disabled => 'disabled' } );
# sub default_validation_json { shift->as_escaped_json }
sub html_attributes {
my (
autoclean;
BEGIN { extends 'Catalyst::Controller'; }
use App::Manoc::Utils::Validate;
has use_json_boolean => (
is => 'ro',
isa => 'Bool',
default => 0,
);
sub begin : Priva
or API input');
}
}
sub end : Private {
my ( $self, $c ) = @_;
my $expose_stash = 'json_data';
# don't change the http status code if already set elsewhere
unless ( $c->res->st
lding API response status=200");
my $data = $c->stash->{api_response_data} || $c->stash->{json_data};
$c->stash->{$expose_stash} = $data;
}
elsif ( $c->res->status == 401 ) {
class => 'ManocDB::Vlan',
form_class => 'App::Manoc::Form::Vlan',
json_columns => [ 'id', 'name', 'description' ],
view_object_perm => undef,
object_l
return ( $filter, $attr );
}
sub datatable_row {
my ( $self, $c, $row ) = @_;
my $json_data = {
hostname => $row->hostname,
os => $row->os,
href => $c
$json_data->{hardware} = {
label => $hw->label,
href => $c->manoc_uri_for_object("hw"),
location => $hw->display_location
};
}
return $json_
ommonCRUD
=item *
App::Manoc::ControllerRole::JQDatatable
=item *
App::Manoc::ControllerRole::JSONView
=item *
App::Manoc::ControllerRole::CSVView
=back
=head1 ACTIONS
=head2 create
Override
orm};
my $process_status = $form->is_valid;
my $json_data = {};
$json_data->{form_ok} = $process_status ? 1 : 0;
$json_data->{status} = $process_status ? 'success' : 'error'
$form->item_id;
$json_data->{message} = $self->object_updated_message;
$json_data->{redirect} = $self->get_form_success_url($c)->as_string;
$json_data->{object_id} = $form
->item_id;
$form->item->can('label') and
$json_data->{object_label} = $form->item->label;
}
elsif ( $c->stash->{object_form_ajax_add_html} ) {
my $template_name =
package App::Manoc::ControllerRole::JSONEdit;
#ABSTRACT: Role for adding JSON support for object edit and creation
use Moose::Role;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use namespace::autoclean;
e_form_json_response');
}
sub edit_js : Chained('object') : PathPart('edit/js') : Args(0) {
my ( $self, $c ) = @_;
$c->forward('object_form_edit');
$c->forward('prepare_form_json_respon
my $json_data = {};
$json_data->{form_ok} = $success;
if ( !$success ) {
$json_data->{errors} = $c->stash->{form_delete_error} || "";
}
$c->stash( current_view => 'JSON' );
package App::Manoc::ControllerRole::JSONView;
#ABSTRACT: Role for adding JSON support for view and view list
use Moose::Role;
our $VERSION = '2.99.4'; ##TRIAL VERSION
use namespace::autoclean;
use
equires 'serialize_objects';
sub prepare_json_object {
my ( $self, $c, $row ) = @_;
return $self->serialize_object( $c, $row );
}
sub prepare_json_objects {
my ( $self, $c, $rows ) = @
json_data => $self->prepare_json_object( $c, $c->stash->{object} ),
current_view => 'JSON'
);
}
sub object_list_js : Private {
my ( $self, $c ) = @_;
$c->stash(
json
_column('vendor')->all();
$c->log->error("data=@data");
$c->stash( json_data => \@data );
$c->forward('View::JSON');
}
sub models_js : Chained('base') : PathPart('models/js') : Args(0) {
distinct => 1
}
)->get_column('model')->all();
$c->stash( json_data => \@data );
$c->forward('View::JSON');
}
sub get_form_process_params {
my ( $self, $c, %params ) = @_;
=head2 delete
=head2 decommission
=head2 restore
=head2 vendors_js
Get a list of vendors in JSON, to be used in form autocomplete.
=head2 models_js
Get a list of models optionally filtered by
d") and
return ( $first->padded cmp padded_ipaddr("$second") );
return -1;
}
sub TO_JSON {
shift->_stringify();
}
__PACKAGE__->meta->make_immutable;
1;
# Local Variables:
# mode: c
address
Return the address in unpadded form. Automatically called by stringification.
=head2 TO_JSON
Convert to string
=head1 SYNOSPIS
my $addr = App::Manoc::IPAddress::IPv4->new('10.1.100.1');
Edit warehouse',
create_page_title => 'New warehouse',
view_object_perm => undef,
json_columns => [ 'id', 'name' ],
object_list_options => {
prefetch => 'building',
th
"App::Manoc::ControllerRole::CommonCRUD",
"App::Manoc::ControllerRole::JSONView" => { -excludes => 'get_json_object', },
"App::Manoc::ControllerRole::CSVView";
use Text::Diff;
use App
ce',
form_class => 'App::Manoc::Form::Device::Edit',
view_object_perm => undef,
json_columns => [ 'id', 'name' ],
object_list_options => {
prefetch => [ { 'rack' =>
device->update();
$response->{success} = 1;
}
$c->stash( json_data => $response );
$c->forward('View::JSON');
}
sub ifacecreate : Chained('object') : PathPart('ifacecreate') : A
ommonCRUD' => { -excludes => 'delete_object' },
'App::Manoc::ControllerRole::JSONView' => { -excludes => 'get_json_object', };
use App::Manoc::Form::Rack;
__PACKAGE__->config(
# define Pat
Rack',
form_class => 'App::Manoc::Form::Rack',
view_object_perm => undef,
json_columns => [ 'id', 'name' ],
object_list_options => {
prefetch => 'building',
return;
}
return $rack->delete;
}
sub get_json_object {
my ( $self, $c, $rack ) = @_;
my $r = $self->prepare_json_object( $c, $rack );
$r->{building} = {
id =>