release 2.011000
Squashed commit of the following: commit 3f1730957b6accbc11737e46c201453d7219d03e Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jul 29 08:01:59 2013 +0100 ready for 2.011000 commit e1873ca58375b458d9543576951f1003e1c28d35 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jul 28 00:02:20 2013 +0100 Find the RW snmp community string correctly now commit 039780bc66ca0d8b19767c38a21aa208feafeaf7 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jul 27 23:07:05 2013 +0100 User Management (for admins only) commit 213352d54ee8e71cbca5ae2c1c75696800c4216b Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jul 27 21:17:57 2013 +0100 Table headers float on the page when scrolling commit 598960e9141b0d9fc4f9a234a7d8fe02a81ba0f9 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jul 27 18:05:00 2013 +0100 Port Utilization report commit d25e41894476c74bee747e38960a277e2f5b2072 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jul 27 15:20:23 2013 +0100 Button to empty the job queue, and improve display when the queue is empty commit 18125d1a758b5707ab4c0ff8b65dfdd90dc32664 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jul 27 14:23:48 2013 +0100 Swap play/pause icons in jobqueue commit 9eead5328a127689701ac28d5bcf1cfa39edaf99 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jul 25 23:11:17 2013 +0100 Revert "No longer depend on Moo" This reverts commit 0a87ad4b410fa784bfbe823f3e6ede7c979144f3. Conflicts: Netdisco/Changes commit d0c31effa834201f1592c1fc3da9a6a689a3a43c Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jul 25 23:01:32 2013 +0100 REMOTE_USER is an env var, not an HTTP Header commit 0a87ad4b410fa784bfbe823f3e6ede7c979144f3 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jul 25 22:35:05 2013 +0100 No longer depend on Moo commit 7ccbb04e6f7c1701194d996baa557affcda48103 Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 24 23:44:42 2013 +0100 ready for 2.010004 commit 6314c5a054d56d7829797d37c6627b2cbccde4ab Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 24 23:41:51 2013 +0100 Navbar query box was being cleared sometimes under admin task panels commit 271a5d9db17b288aeff43ee29a6bbf753bf823de Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jul 24 00:03:05 2013 +0100 update TODO commit 3103f968a9fb128726ed929589137cb6011e2591 Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Jul 23 23:58:19 2013 +0100 ready for 2.010002 commit 0368df1dbdfe6d764eec05f2bf37587fff795995 Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Jul 23 23:17:17 2013 +0100 fix bugs in topo update code commit 43b7203ca3270dc2e02a097472179517087522d2 Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Jul 23 23:12:36 2013 +0100 fix FF bug with forms embedded in tables commit f86c5d7d3d8d293a781c2ec7dc7a18bfb3c8bf78 Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Jul 23 17:15:35 2013 +0100 Nullify unused schema changes commit 649e4c471d524013f87257e11fffa7789dccd01d Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 20 13:48:20 2013 +0100 version bump commit ac6ce399b2bd596444a629f24ddea5eca0fff56a Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 20 13:41:08 2013 +0100 Handle UTF-8 data in the device port remote_id commit c73b86c0204ddd98e9d27437028a7000d70338bf Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 20 13:35:32 2013 +0100 revert bytea conversion on remote_id commit a144f42cf93803882bb8492cd3ce3a8e5679d383 Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 23:09:50 2013 +0100 bump version for beta release commit 3b791c93d7d9b7358bf46f31e322a9b807823d9d Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 22:57:59 2013 +0100 Pass event param to all js functions which require it commit da38badef893fc1503a797a99c34504db71e7c20 Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 22:35:48 2013 +0100 Change data type on device_port remote_id to bytea commit 727237951a5576b476dee127b3cef777afb51df8 Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 10:52:28 2013 +0100 fix help message in netdisco-web-fg commit 25bc026dc5e0177cd3aa81c11cdace091eb68f36 Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Jun 17 08:16:56 2013 +0100 bump version for new release commit d4042f6e8db42c7a85df4dcf9690fec72ad2db69 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 18:27:52 2013 +0100 Job Queue page play/pause/refresh controls commit b6c9152516d7800409b7a73c5d0cdce6dd405492 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:50:06 2013 +0100 limit size of job queue table commit ac9e5feb8b774071fcf4423dd862dced74dee9e6 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:47:55 2013 +0100 update bugs link commit 9c0fb0e9aedc6297f4462c3cf88343f6d0df40b6 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:41:29 2013 +0100 update MANIFEST commit 7aaa2fff91ed2b1839bdbb79081d90ad3e144f47 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:40:35 2013 +0100 Fix Plack middleware config for Expiry commit 313e2cf014cf0da7cf85074e390ad394b28bf42d Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 17:23:00 2013 +0100 Support for delegated authentication with REMOTE_USER and X-REMOTE_USER commit 85e21f2bf296c4a5ca6b5afb5091694e56e3031f Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 14:24:08 2013 +0100 Add tooltip showing the job queue item logged status message commit 9b14f53ebed51eb46ea278807cfe8a2fbd28743c Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 13:43:26 2013 +0100 Increase default frequency of job queue polling to 2 seconds commit 6ba46818d8ab2100c652c8eb8e98bc6f5a54e273 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 12:57:43 2013 +0100 workaround for https://github.com/PerlDancer/Dancer/issues/935 commit c7a2d8a9d45716959bedbbb8db4cdd82a5950642 Author: Oliver Gorwits <oliver@cpan.org> Date: Sun Jun 16 11:54:18 2013 +0100 Fix hyperlinks when running behind reverse proxy on custom path commit 0620efa404bc25cb0a9ada5aa6f1b092d5c4d482 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 18:31:19 2013 +0100 update deploy docs commit 857b1c7aa0fe832f8948349eda5211eb38ba3099 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 18:16:50 2013 +0100 add note about compiler dependency commit 02a2ad6b2c52db9fbc1e24bc8888f658dc7084ad Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 17:44:29 2013 +0100 sort vlans, macs, ips in device port view commit 097bad77310728a98b261a2cfca4de7ab50be94b Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 16:32:20 2013 +0100 hint when calling web in fg without starman commit 6425d89ddb2b56129c610482134482d8f9455d40 Author: Oliver Gorwits <oliver@cpan.org> Date: Sat Jun 15 15:53:26 2013 +0100 macwalk and arpwalk refactored commit d527b9d05addc82fb38c84f6fea1aa5818fc68d5 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:27:34 2013 +0100 implement is_macsuckable and is_arpnipable commit 7af10ed313e25f5d99a22b53ba438225c2259069 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:17:39 2013 +0100 version bump commit 8ace3bf8fa48cf3e14bdf86fad5a4862aad50a4b Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:14:05 2013 +0100 tidy up user menu commit e6eef605c248471dbfe7ec62cd04d73d653523ca Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 22:02:52 2013 +0100 Add discoverall, macwalk, arpwalk items to the Admin Tasks menu commit 2631fabd1eccd8a3971e4762eebe57f406623bee Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 21:21:50 2013 +0100 remove length() which only became sane in 5.12 commit a7b7169070a58685cacde26a3b6d462e74be9928 Author: Oliver Gorwits <oliver@cpan.org> Date: Thu Jun 13 19:07:56 2013 +0100 Use DBIx::Class new collapsed query support when we can commit 77cddab8ba7033ccb1ecae257bafa4eef8f99f47 Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jun 12 17:26:47 2013 +0100 Database config simplified to only four essential settings commit 6ed0802bf2ab0fd898ce6945451b8ca6566ae551 Author: Oliver Gorwits <oliver@cpan.org> Date: Wed Jun 12 13:03:20 2013 +0100 Ask to set up guest user for Admin/Port Control rights in deploy script
This commit is contained in:
		| @@ -7,7 +7,7 @@ use 5.010_000; | ||||
| use File::ShareDir 'dist_dir'; | ||||
| use Path::Class; | ||||
|  | ||||
| our $VERSION = '2.010004'; | ||||
| our $VERSION = '2.011000'; | ||||
|  | ||||
| BEGIN { | ||||
|   if (not ($ENV{DANCER_APPDIR} || '') | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use base 'DBIx::Class::Schema'; | ||||
|  | ||||
| __PACKAGE__->load_namespaces; | ||||
|  | ||||
| our $VERSION = 23; # schema version used for upgrades, keep as integer | ||||
| our $VERSION = 24; # schema version used for upgrades, keep as integer | ||||
|  | ||||
| use Path::Class; | ||||
| use File::Basename; | ||||
|   | ||||
| @@ -65,6 +65,8 @@ __PACKAGE__->add_columns( | ||||
|   { data_type => "integer", is_nullable => 1 }, | ||||
|   "snmp_comm", | ||||
|   { data_type => "text", is_nullable => 1 }, | ||||
|   "snmp_comm_rw", | ||||
|   { data_type => "text", is_nullable => 1 }, | ||||
|   "snmp_class", | ||||
|   { data_type => "text", is_nullable => 1 }, | ||||
|   "vtp_domain", | ||||
|   | ||||
| @@ -0,0 +1,46 @@ | ||||
| package App::Netdisco::DB::Result::Virtual::PortUtilization; | ||||
|  | ||||
| use strict; | ||||
| use warnings; | ||||
|  | ||||
| use base 'DBIx::Class::Core'; | ||||
|  | ||||
| __PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | ||||
|  | ||||
| __PACKAGE__->table('port_utilization'); | ||||
| __PACKAGE__->result_source_instance->is_virtual(1); | ||||
| __PACKAGE__->result_source_instance->view_definition(<<ENDSQL | ||||
|  SELECT d.dns AS dns, d.ip as ip, | ||||
|      sum(CASE WHEN (dp.type != 'propVirtual') THEN 1 ELSE 0 END) as port_count, | ||||
|      sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin = 'up' AND dp.up = 'up') THEN 1 ELSE 0 END) as ports_in_use, | ||||
|      sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin != 'up') THEN 1 ELSE 0 END) as ports_shutdown, | ||||
|      sum(CASE WHEN (dp.type != 'propVirtual' AND dp.up_admin = 'up' AND dp.up != 'up') THEN 1 ELSE 0 END) as ports_free | ||||
|    FROM device d LEFT JOIN device_port dp | ||||
|      ON d.ip = dp.ip | ||||
|    GROUP BY d.dns, d.ip | ||||
|    ORDER BY d.dns, d.ip | ||||
| ENDSQL | ||||
| ); | ||||
|  | ||||
| __PACKAGE__->add_columns( | ||||
|   'dns' => { | ||||
|     data_type => 'text', | ||||
|   }, | ||||
|   'ip' => { | ||||
|     data_type => 'inet', | ||||
|   }, | ||||
|   'port_count' => { | ||||
|     data_type => 'integer', | ||||
|   }, | ||||
|   'ports_in_use' => { | ||||
|     data_type => 'integer', | ||||
|   }, | ||||
|   'ports_shutdown' => { | ||||
|     data_type => 'integer', | ||||
|   }, | ||||
|   'ports_free' => { | ||||
|     data_type => 'integer', | ||||
|   }, | ||||
| ); | ||||
|  | ||||
| 1; | ||||
| @@ -511,12 +511,16 @@ sub with_port_count { | ||||
|     ->search_rs($cond, $attrs) | ||||
|     ->search({}, | ||||
|       { | ||||
|         '+columns' => { port_count => | ||||
|           $rs->result_source->schema->resultset('DevicePort') | ||||
|             ->search( | ||||
|               { 'dp.ip' => { -ident => 'me.ip' } }, | ||||
|               { alias => 'dp' } | ||||
|             )->count_rs->as_query | ||||
|         '+columns' => { | ||||
|           port_count => | ||||
|             $rs->result_source->schema->resultset('DevicePort') | ||||
|               ->search( | ||||
|                 { | ||||
|                   'dp.ip' => { -ident => 'me.ip' }, | ||||
|                   'dp.type' => { '!=' => 'propVirtual' }, | ||||
|                 }, | ||||
|                 { alias => 'dp' } | ||||
|               )->count_rs->as_query, | ||||
|         }, | ||||
|       }); | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,5 @@ | ||||
| BEGIN; | ||||
|  | ||||
| ALTER TABLE device ADD COLUMN snmp_comm_rw text; | ||||
|  | ||||
| COMMIT; | ||||
| @@ -101,8 +101,9 @@ Value: Boolean. Default: C<false>. | ||||
|  | ||||
| Enable this if Netdisco is running within another web server such as Apache, | ||||
| and you want that server to handle user authentication. Normally the | ||||
| authenticated username will automatically be set in the C<REMOTE_USER> HTTP | ||||
| Header. See L<Dancer::Deployment/Running from Apache> for further details. | ||||
| authenticated username will automatically be set in the C<REMOTE_USER> | ||||
| environment variable. See L<Dancer::Deployment/Running from Apache> for | ||||
| further details. | ||||
|  | ||||
| =head3 C<trust_x_remote_user> | ||||
|  | ||||
| @@ -110,8 +111,8 @@ Value: Boolean. Default: C<false>. | ||||
|  | ||||
| Enable this if you proxy requests to Netdisco via another web server such as | ||||
| Apache, and you want that server to handle user authentication. You need to | ||||
| configure the authorized username to be passed in the C<X-REMOTE_USER> HTTP | ||||
| Header. For example with Apache: | ||||
| configure the authorized username to be passed from the frontend environment | ||||
| to Netdisco in the C<X-REMOTE_USER> HTTP Header. For example with Apache: | ||||
|  | ||||
|  RequestHeader unset X-REMOTE_USER | ||||
|  RequestHeader set X-REMOTE_USER "%{REMOTE_USER}e" env=REMOTE_USER | ||||
|   | ||||
| @@ -75,6 +75,16 @@ To delegate user authentication to Apache, use the C<trust_remote_user> or | ||||
| C<trust_x_remote_user> settings. See L<App::Netdisco::Manual::Configuration> | ||||
| for more details. | ||||
|  | ||||
| =head1 SSL Support | ||||
|  | ||||
| There is no SSL support in the built-in web server. This is because it's not | ||||
| straightforward to support all the SSL options, and using port 443 requires | ||||
| root privilege, which the Netdisco application should not have. | ||||
|  | ||||
| You are instead recommended to run C<netdisco-web> behind a reverse proxy as | ||||
| described elsewhere in this document. Apache can easily act as an SSL reverse | ||||
| proxy. | ||||
|  | ||||
| =head1 SQL and HTTP Trace | ||||
|  | ||||
| For SQL debugging try the following commands: | ||||
|   | ||||
| @@ -21,8 +21,8 @@ the more verbose C<plugins/DBIC> setting which was there before: | ||||
|    user: 'someuser' | ||||
|    pass: 'somepass' | ||||
|  | ||||
| Also, the C<REMOTE_USER> and C<X-REMOTE_USER> environment variables are now | ||||
| supported for delegating authentication to another web server. See the | ||||
| Also, the C<REMOTE_USER> environment variable and C<X-REMOTE_USER> HTTP Header | ||||
| are now supported for delegating authentication to another web server. See the | ||||
| Deployment and Configuration documentation for further details. | ||||
|  | ||||
| =head1 2.008000 | ||||
|   | ||||
| @@ -90,6 +90,9 @@ sub _snmp_connect_generic { | ||||
|   unshift @communities, $device->snmp_comm | ||||
|     if defined $device->snmp_comm | ||||
|        and defined $comm_type and $comm_type eq 'community'; | ||||
|   unshift @communities, $device->snmp_comm_rw | ||||
|     if defined $device->snmp_comm_rw | ||||
|        and defined $comm_type and $comm_type eq 'community_rw'; | ||||
|  | ||||
|   my $info = undef; | ||||
|   VERSION: foreach my $ver (@versions) { | ||||
| @@ -101,8 +104,13 @@ sub _snmp_connect_generic { | ||||
|           COMMUNITY: foreach my $comm (@communities) { | ||||
|               next unless $comm; | ||||
|  | ||||
|               $info = _try_connect($ver, $class, $comm, \%snmp_args) | ||||
|                 and last VERSION; | ||||
|               $info = _try_connect($ver, $class, $comm, \%snmp_args); | ||||
|  | ||||
|               if ($comm_type eq 'community_rw') { | ||||
|                   _try_write($info, $comm, $device) or next COMMUNITY; | ||||
|               } | ||||
|  | ||||
|               last VERSION if $info; | ||||
|           } | ||||
|       } | ||||
|   } | ||||
| @@ -110,6 +118,25 @@ sub _snmp_connect_generic { | ||||
|   return $info; | ||||
| } | ||||
|  | ||||
| sub _try_write { | ||||
|   my ($info, $comm, $device) = @_; | ||||
|   my $happy = 0; | ||||
|  | ||||
|   try { | ||||
|       debug sprintf '[%s] try_write with comm: %s', $device->ip, $comm; | ||||
|       $info->clear_cache; | ||||
|       my $rv = $info->set_location( $info->location ); | ||||
|       $device->update({snmp_comm_rw => $comm}) | ||||
|         if $device->in_storage; | ||||
|       $happy = 1 if $rv; | ||||
|   } | ||||
|   catch { | ||||
|       debug $_; | ||||
|   }; | ||||
|  | ||||
|   return $happy; | ||||
| } | ||||
|  | ||||
| sub _try_connect { | ||||
|   my ($ver, $class, $comm, $snmp_args) = @_; | ||||
|   my $info = undef; | ||||
| @@ -154,7 +181,7 @@ sub _build_mibdirs { | ||||
|  | ||||
| sub _get_mibdirs_content { | ||||
|   my $home = shift; | ||||
|   warning 'Netdisco SNMP work will be slow - loading ALL MIBs. Consider setting mibdirs.'; | ||||
|   # warning 'Netdisco SNMP work will be slow - loading ALL MIBs. Consider setting mibdirs.'; | ||||
|   my @list = map {s|$home/||; $_} grep {-d} glob("$home/*"); | ||||
|   return \@list; | ||||
| } | ||||
|   | ||||
| @@ -10,8 +10,8 @@ hook 'before' => sub { | ||||
|         if (setting('trust_x_remote_user') and scalar request->header('X-REMOTE_USER')) { | ||||
|             session(user => scalar request->header('X-REMOTE_USER')); | ||||
|         } | ||||
|         elsif (setting('trust_remote_user') and scalar request->header('REMOTE_USER')) { | ||||
|             session(user => scalar request->header('REMOTE_USER')); | ||||
|         elsif (setting('trust_remote_user') and $ENV{REMOTE_USER}) { | ||||
|             session(user => $ENV{REMOTE_USER}); | ||||
|         } | ||||
|         elsif (setting('no_auth')) { | ||||
|             session(user => 'guest'); | ||||
|   | ||||
| @@ -21,6 +21,14 @@ ajax '/ajax/control/admin/jobqueue/del' => sub { | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| ajax '/ajax/control/admin/jobqueue/delall' => sub { | ||||
|     send_error('Forbidden', 403) unless var('user')->admin; | ||||
|  | ||||
|     schema('netdisco')->txn_do(sub { | ||||
|       my $device = schema('netdisco')->resultset('Admin')->delete; | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| ajax '/ajax/content/admin/jobqueue' => sub { | ||||
|     send_error('Forbidden', 403) unless var('user')->admin; | ||||
|  | ||||
|   | ||||
							
								
								
									
										80
									
								
								Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Users.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/Users.pm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| package App::Netdisco::Web::Plugin::AdminTask::Users; | ||||
|  | ||||
| use Dancer ':syntax'; | ||||
| use Dancer::Plugin::Ajax; | ||||
| use Dancer::Plugin::DBIC; | ||||
|  | ||||
| use App::Netdisco::Web::Plugin; | ||||
| use Digest::MD5 (); | ||||
|  | ||||
| register_admin_task({ | ||||
|   tag => 'users', | ||||
|   label => 'User Management', | ||||
| }); | ||||
|  | ||||
| sub _sanity_ok { | ||||
|     return 0 unless var('user') and var('user')->admin; | ||||
|  | ||||
|     return 0 unless param('username') | ||||
|       and param('username') =~ m/^[[:print:]]+$/ | ||||
|       and param('username') !~ m/[[:space:]]/; | ||||
|  | ||||
|     return 1; | ||||
| } | ||||
|  | ||||
| ajax '/ajax/control/admin/users/add' => sub { | ||||
|     send_error('Bad Request', 400) unless _sanity_ok(); | ||||
|  | ||||
|     schema('netdisco')->txn_do(sub { | ||||
|       my $user = schema('netdisco')->resultset('User') | ||||
|         ->create({ | ||||
|           username => param('username'), | ||||
|           password => Digest::MD5::md5_hex(param('password')), | ||||
|           fullname => param('fullname'), | ||||
|           port_control => (param('port_control') ? \'true' : \'false'), | ||||
|           admin => (param('admin') ? \'true' : \'false'), | ||||
|         }); | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| ajax '/ajax/control/admin/users/del' => sub { | ||||
|     send_error('Bad Request', 400) unless _sanity_ok(); | ||||
|  | ||||
|     schema('netdisco')->txn_do(sub { | ||||
|       schema('netdisco')->resultset('User') | ||||
|         ->find({username => param('username')})->delete; | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| ajax '/ajax/control/admin/users/update' => sub { | ||||
|     send_error('Bad Request', 400) unless _sanity_ok(); | ||||
|  | ||||
|     schema('netdisco')->txn_do(sub { | ||||
|       my $user = schema('netdisco')->resultset('User') | ||||
|         ->find({username => param('username')}); | ||||
|       return unless $user; | ||||
|  | ||||
|       $user->update({ | ||||
|         ((param('password') ne '********') | ||||
|           ? (password => Digest::MD5::md5_hex(param('password'))) | ||||
|           : ()), | ||||
|         fullname => param('fullname'), | ||||
|         port_control => (param('port_control') ? \'true' : \'false'), | ||||
|         admin => (param('admin') ? \'true' : \'false'), | ||||
|       }); | ||||
|     }); | ||||
| }; | ||||
|  | ||||
| ajax '/ajax/content/admin/users' => sub { | ||||
|     send_error('Forbidden', 403) unless var('user')->admin; | ||||
|  | ||||
|     my $set = schema('netdisco')->resultset('User') | ||||
|       ->search(undef, { order_by => [qw/fullname username/]}); | ||||
|  | ||||
|     content_type('text/html'); | ||||
|     template 'ajax/admintask/users.tt', { | ||||
|       results => $set, | ||||
|     }, { layout => undef }; | ||||
| }; | ||||
|  | ||||
| true; | ||||
| @@ -0,0 +1,25 @@ | ||||
| package App::Netdisco::Web::Plugin::Report::PortUtilization; | ||||
|  | ||||
| use Dancer ':syntax'; | ||||
| use Dancer::Plugin::Ajax; | ||||
| use Dancer::Plugin::DBIC; | ||||
|  | ||||
| use App::Netdisco::Web::Plugin; | ||||
|  | ||||
| register_report({ | ||||
|   category => 'Device', | ||||
|   tag => 'portutilization', | ||||
|   label => 'Port Utilization', | ||||
| }); | ||||
|  | ||||
| ajax '/ajax/content/report/portutilization' => sub { | ||||
|     return unless schema('netdisco')->resultset('Device')->count; | ||||
|     my $set = schema('netdisco')->resultset('Virtual::PortUtilization'); | ||||
|  | ||||
|     content_type('text/html'); | ||||
|     template 'ajax/report/portutilization.tt', { | ||||
|       results => $set, | ||||
|     }, { layout => undef }; | ||||
| }; | ||||
|  | ||||
| true; | ||||
		Reference in New Issue
	
	Block a user