From 60f3d3abc7dca3cb2a2558d6495e2a35e8f53bec Mon Sep 17 00:00:00 2001 From: Darren Satkunas Date: Wed, 21 Aug 2019 17:34:04 -0400 Subject: [PATCH] (web admin) add front end markup to admin (back end) rename choose_access_duration to set_access_durations to match current set_access_duration --- .../PacketFence/Controller/Activate/Email.pm | 14 +++++----- ...html => sponsor_set_access_durations.html} | 4 +-- .../Base/Form/Authentication/Action.pm | 6 ++--- .../src/components/pfFieldTypeValue.vue | 5 +++- .../globals/configuration/pfConfiguration.js | 14 ++++++++++ .../pfConfigurationAuthenticationSources.js | 27 ++++++++++++++++--- .../root/static.alt/src/globals/pfField.js | 5 ++++ lib/pf/Authentication/constants.pm | 12 ++++----- lib/pf/web/guest.pm | 2 +- 9 files changed, 66 insertions(+), 23 deletions(-) rename html/captive-portal/templates/activation/{sponsor_choose_access_duration.html => sponsor_set_access_durations.html} (86%) diff --git a/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm b/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm index 5d4d0caea71d..6249d9867f73 100644 --- a/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm +++ b/html/captive-portal/lib/captiveportal/PacketFence/Controller/Activate/Email.pm @@ -124,11 +124,11 @@ sub login : Private { ); } -=head2 choose_access_duration +=head2 set_access_durations =cut -sub choose_access_duration : Private { +sub set_access_durations : Private { my ( $self, $c ) = @_; if ( $c->has_errors ) { $c->stash->{txt_auth_error} = join(' ', grep { ref ($_) eq '' } @{$c->error}); @@ -136,7 +136,7 @@ sub choose_access_duration : Private { } $c->stash( title => "Choose the access duration", - template => $pf::web::guest::SPONSOR_CHOOSE_ACCESS_DURATION_TEMPLATE, + template => $pf::web::guest::SPONSOR_SET_ACCESS_DURATIONS_TEMPLATE, ); } @@ -190,13 +190,13 @@ sub doSponsorRegistration : Private { $self->showError($c,"does not have permission to sponsor a user"); $c->detach('login'); } - if ($values->{$Actions::CHOOSE_ACCESS_DURATION}) { + if ($values->{$Actions::SET_ACCESS_DURATIONS}) { if ($request->param("access_duration")) { pf::activation::set_unregdate('sponsor',$activation_record->{'activation_code'}, pf::config::access_duration($request->param("access_duration"))); } else { - my @options_duration = map { { value => $_, label => $_ } } split(',', $values->{$Actions::CHOOSE_ACCESS_DURATION}); - $c->stash->{choose_access_duration} = \@options_duration; - $c->detach('choose_access_duration'); + my @options_duration = map { { value => $_, label => $_ } } split(',', $values->{$Actions::SET_ACCESS_DURATIONS}); + $c->stash->{set_access_durations} = \@options_duration; + $c->detach('set_access_durations'); } } } diff --git a/html/captive-portal/templates/activation/sponsor_choose_access_duration.html b/html/captive-portal/templates/activation/sponsor_set_access_durations.html similarity index 86% rename from html/captive-portal/templates/activation/sponsor_choose_access_duration.html rename to html/captive-portal/templates/activation/sponsor_set_access_durations.html index d581376f7e65..3e1e80209335 100644 --- a/html/captive-portal/templates/activation/sponsor_choose_access_duration.html +++ b/html/captive-portal/templates/activation/sponsor_set_access_durations.html @@ -3,12 +3,12 @@
- [% IF choose_access_duration.size > 1 %] + [% IF set_access_durations.size > 1 %]
diff --git a/html/pfappserver/lib/pfappserver/Base/Form/Authentication/Action.pm b/html/pfappserver/lib/pfappserver/Base/Form/Authentication/Action.pm index 4c90d182253c..bc395ec62ade 100644 --- a/html/pfappserver/lib/pfappserver/Base/Form/Authentication/Action.pm +++ b/html/pfappserver/lib/pfappserver/Base/Form/Authentication/Action.pm @@ -61,13 +61,13 @@ our %ACTION_FIELD_OPTIONS = ( type => 'Hidden', default => '1' }, - $Actions::CHOOSE_ACCESS_DURATION => { + $Actions::SET_ACCESS_DURATIONS => { type => 'Select', do_label => 0, wrapper => 0, multiple => 1, element_class => ['chzn-select'], - element_attr => {'data-placeholder' => 'Click to add a access duration'}, + element_attr => {'data-placeholder' => 'Click to add an access duration'}, options_method => \&options_durations, }, $Actions::SET_ACCESS_LEVEL => { @@ -76,7 +76,7 @@ our %ACTION_FIELD_OPTIONS = ( wrapper => 0, multiple => 1, element_class => ['chzn-select'], - element_attr => {'data-placeholder' => 'Click to add a access right'}, + element_attr => {'data-placeholder' => 'Click to add an access right'}, options_method => \&options_access_level, }, $Actions::SET_TENANT_ID => { diff --git a/html/pfappserver/root/static.alt/src/components/pfFieldTypeValue.vue b/html/pfappserver/root/static.alt/src/components/pfFieldTypeValue.vue index 8a06aa70415f..c182a1d1f5e3 100644 --- a/html/pfappserver/root/static.alt/src/components/pfFieldTypeValue.vue +++ b/html/pfappserver/root/static.alt/src/components/pfFieldTypeValue.vue @@ -25,7 +25,7 @@ - + { + return { + label: i18n.t('Associated Sources'), + text: i18n.t('Sources that will be associated with this source (For the Sponsor)'), + fields: [ + { + key: 'sources', + component: pfFormChosen, + attrs: pfConfigurationAttributesFromMeta(meta, 'sources'), + validators: pfConfigurationValidatorsFromMeta(meta, 'sources', i18n.t('Sources')) + } + ] + } + }, sp_cert_path: ({ options: { meta = {} } } = {}) => { return { label: i18n.t('Path to Service Provider cert (x509)'), @@ -2318,6 +2338,7 @@ export const pfConfigurationAuthenticationSourceViewFields = (context) => { fields: [ pfConfigurationAuthenticationSourceFields.id(context), pfConfigurationAuthenticationSourceFields.description(context), + pfConfigurationAuthenticationSourceFields.sources(context), pfConfigurationAuthenticationSourceFields.allow_localdomain(context), pfConfigurationAuthenticationSourceFields.banned_domains(context), pfConfigurationAuthenticationSourceFields.allowed_domains(context), diff --git a/html/pfappserver/root/static.alt/src/globals/pfField.js b/html/pfappserver/root/static.alt/src/globals/pfField.js index 39c1f35f35db..a2cf887216d6 100644 --- a/html/pfappserver/root/static.alt/src/globals/pfField.js +++ b/html/pfappserver/root/static.alt/src/globals/pfField.js @@ -19,6 +19,7 @@ export const pfFieldType = { /* Promise based field types */ ADMINROLE: 'adminrole', DURATION: 'duration', + DURATIONS: 'durations', OPTIONS: 'options', REALM: 'realm', ROLE: 'role', @@ -43,6 +44,10 @@ pfFieldTypeValues[pfFieldType.DURATION] = ({ $store }) => { $store.dispatch('config/getBaseGuestsAdminRegistration') return $store.getters['config/accessDurationsList'] } +pfFieldTypeValues[pfFieldType.DURATIONS] = ({ $store }) => { + $store.dispatch('config/getBaseGuestsAdminRegistration') + return $store.getters['config/accessDurationsList'] +} pfFieldTypeValues[pfFieldType.OPTIONS] = ({ field }) => { let options = [] if (field === undefined) { diff --git a/lib/pf/Authentication/constants.pm b/lib/pf/Authentication/constants.pm index d42993c7a0b7..4082bb946d5b 100644 --- a/lib/pf/Authentication/constants.pm +++ b/lib/pf/Authentication/constants.pm @@ -147,7 +147,7 @@ Constants related to actions rules. package Actions; -=item MARK_AS_SPONSOR, CHOOSE_ACCESS_DURATION, SET_ACCESS_LEVEL, SET_ROLE, SET_ACCESS_DURATION, SET_UNREG_DATE SET_TIME_BALANCE, SET_BANDWIDTH_BALANCE +=item MARK_AS_SPONSOR, SET_ACCESS_LEVEL, SET_ROLE, SET_ACCESS_DURATION, SET_ACCESS_DURATIONS, SET_UNREG_DATE SET_TIME_BALANCE, SET_BANDWIDTH_BALANCE Available actions @@ -158,10 +158,10 @@ Readonly::Scalar our $SET_ACCESS_LEVEL => "set_access_level"; Readonly::Scalar our $SET_TENANT_ID => "set_tenant_id"; Readonly::Scalar our $SET_ROLE => "set_role"; Readonly::Scalar our $SET_ACCESS_DURATION => "set_access_duration"; +Readonly::Scalar our $SET_ACCESS_DURATIONS => "set_access_durations"; Readonly::Scalar our $SET_UNREG_DATE => "set_unreg_date"; Readonly::Scalar our $SET_TIME_BALANCE => "set_time_balance"; Readonly::Scalar our $SET_BANDWIDTH_BALANCE => "set_bandwidth_balance"; -Readonly::Scalar our $CHOOSE_ACCESS_DURATION => "choose_access_duration"; =item ACTIONS List of available actions @@ -170,7 +170,7 @@ List of available actions Readonly::Hash our %ACTIONS => ( $Rules::AUTH => [ $SET_ROLE, $SET_ACCESS_DURATION, $SET_UNREG_DATE, $SET_TIME_BALANCE, $SET_BANDWIDTH_BALANCE ], - $Rules::ADMIN => [ $SET_ACCESS_LEVEL, $MARK_AS_SPONSOR, $SET_TENANT_ID, $CHOOSE_ACCESS_DURATION ], + $Rules::ADMIN => [ $SET_ACCESS_LEVEL, $MARK_AS_SPONSOR, $SET_TENANT_ID, $SET_ACCESS_DURATIONS ], ); Readonly::Hash our %ACTION_CLASS_TO_TYPE => ( @@ -183,7 +183,7 @@ Readonly::Hash our %ACTION_CLASS_TO_TYPE => ( $SET_ACCESS_LEVEL => $Rules::ADMIN, $SET_TENANT_ID => $Rules::ADMIN, $MARK_AS_SPONSOR => $Rules::ADMIN, - $CHOOSE_ACCESS_DURATION => $Rules::ADMIN, + $SET_ACCESS_DURATIONS => $Rules::ADMIN, ); Readonly::Hash our %ALLOWED_ACTIONS => ( @@ -197,17 +197,17 @@ Readonly::Hash our %ALLOWED_ACTIONS => ( }, $SET_TIME_BALANCE => {$SET_TIME_BALANCE => 1}, $SET_BANDWIDTH_BALANCE => {$SET_BANDWIDTH_BALANCE => 1}, - $CHOOSE_ACCESS_DURATION => {$CHOOSE_ACCESS_DURATION => 1}, + $SET_ACCESS_DURATIONS => {$SET_ACCESS_DURATIONS => 1}, ); Readonly::Hash our %MAPPED_ACTIONS => ( $MARK_AS_SPONSOR => $MARK_AS_SPONSOR, $SET_ACCESS_LEVEL => $SET_ACCESS_LEVEL, - $CHOOSE_ACCESS_DURATION => $CHOOSE_ACCESS_DURATION, $SET_TENANT_ID => $SET_TENANT_ID, $SET_ROLE => $SET_ROLE, $SET_UNREG_DATE => $SET_UNREG_DATE, $SET_ACCESS_DURATION => $SET_UNREG_DATE, + $SET_ACCESS_DURATIONS => $SET_ACCESS_DURATIONS, ); =back diff --git a/lib/pf/web/guest.pm b/lib/pf/web/guest.pm index fdbd38c7d8fb..fb356c5df09d 100644 --- a/lib/pf/web/guest.pm +++ b/lib/pf/web/guest.pm @@ -66,7 +66,7 @@ our $VERSION = 1.41; our $SPONSOR_CONFIRMED_TEMPLATE = "activation/sponsor_accepted.html"; our $SPONSOR_LOGIN_TEMPLATE = "activation/sponsor_login.html"; -our $SPONSOR_CHOOSE_ACCESS_DURATION_TEMPLATE = "activation/sponsor_choose_access_duration.html"; +our $SPONSOR_SET_ACCESS_DURATIONS_TEMPLATE = "activation/sponsor_set_access_durations.html"; # flag used in URLs Readonly our $GUEST_REGISTRATION => "guest-register";