diff --git a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm index d3b7f9eded..b6adfd4ec9 100644 --- a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm +++ b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm @@ -218,6 +218,7 @@ sub POST :Allow { $sset = $schema->resultset('voip_cf_source_sets')->create({ name => $resource->{name}, + mode => $resource->{mode}, subscriber_id => $subscriber->id, }); for my $s ( @{$resource->{sources}} ) { diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index 4dbbeeb8be..cd26d675b9 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -661,12 +661,14 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) { } my @sources = (); my $sset_name = undef; + my $sset_mode = undef; if($map->source_set) { @sources = map { { $_->get_columns } } $map->source_set->voip_cf_sources->all; foreach my $s(@sources) { $s->{as_string} = $s->{source}; } $sset_name = $map->source_set->name; + $sset_mode = $map->source_set->mode; } push @{ $cfs->{$type} }, { destinations => \@dset, @@ -674,7 +676,8 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) { periods => \@tset, tset_name => $tset_name, sources => \@sources, - sset_name => $sset_name }; + sset_name => $sset_name, + sset_mode => $sset_mode }; } } $c->stash(cf_destinations => $cfs); @@ -1588,7 +1591,7 @@ sub preferences_callforward_sourceset :Chained('base') :PathPart('preferences/so foreach my $s(@sources) { $s->{as_string} = $s->{source}; } - push @sets, { name => $set->name, id => $set->id, sources => \@sources }; + push @sets, { name => $set->name, mode => $set->mode, id => $set->id, sources => \@sources }; } } } @@ -1634,6 +1637,7 @@ sub preferences_callforward_sourceset_create :Chained('base') :PathPart('prefere if(@fields) { my $set = $prov_subscriber->voip_cf_source_sets->create({ name => $form->field('name')->value, + mode => $form->field('mode')->value, }); foreach my $src(@fields) { my $s = $src->field('source')->value; @@ -1708,6 +1712,7 @@ sub preferences_callforward_sourceset_edit :Chained('preferences_callforward_sou my $params; unless($posted) { $params->{name} = $set->name; + $params->{mode} = $set->mode; my @sources; for my $src($set->voip_cf_sources->all) { push @sources, { @@ -1752,6 +1757,9 @@ sub preferences_callforward_sourceset_edit :Chained('preferences_callforward_sou if($form->field('name')->value ne $set->name) { $set->update({name => $form->field('name')->value}); } + if($form->field('mode')->value ne $set->mode) { + $set->update({mode => $form->field('mode')->value}); + } $set->voip_cf_sources->delete_all; foreach my $src(@fields) { diff --git a/lib/NGCP/Panel/Form/CFSourceSetAPI.pm b/lib/NGCP/Panel/Form/CFSourceSetAPI.pm index 5b352fdfe1..03390658f1 100644 --- a/lib/NGCP/Panel/Form/CFSourceSetAPI.pm +++ b/lib/NGCP/Panel/Form/CFSourceSetAPI.pm @@ -27,6 +27,19 @@ has_field 'name' => ( }, ); +has_field 'mode' => ( + type => 'Select', + options => [ + {value => 'whitelist', label => 'whitelist'}, + {value => 'blacklist', label => 'blacklist'}, + ], + required => 1, + element_attr => { + rel => ['tooltip'], + title => ['The source set mode'] + }, +); + has_field 'sources' => ( type => 'Repeatable', element_attr => { diff --git a/lib/NGCP/Panel/Form/CallforwardSourceSet.pm b/lib/NGCP/Panel/Form/CallforwardSourceSet.pm index 5c0f3c6a6f..3cbcfbc6cb 100644 --- a/lib/NGCP/Panel/Form/CallforwardSourceSet.pm +++ b/lib/NGCP/Panel/Form/CallforwardSourceSet.pm @@ -21,6 +21,19 @@ has_field 'name' => ( }, ); +has_field 'mode' => ( + type => 'Select', + options => [ + {value => 'whitelist', label => 'whitelist'}, + {value => 'blacklist', label => 'blacklist'}, + ], + required => 1, + element_attr => { + rel => ['tooltip'], + title => ['The source set mode'] + }, +); + has_field 'source' => ( type => 'Repeatable', setup_for_js => 1, @@ -69,7 +82,7 @@ has_field 'source_add' => ( has_block 'fields' => ( tag => 'div', class => [qw(modal-body)], - render_list => [qw(name source source_add)], + render_list => [qw(name mode source source_add)], ); has_field 'save' => ( diff --git a/lib/NGCP/Panel/Role/API/CFSourceSets.pm b/lib/NGCP/Panel/Role/API/CFSourceSets.pm index ade3da6c0c..930af99e26 100644 --- a/lib/NGCP/Panel/Role/API/CFSourceSets.pm +++ b/lib/NGCP/Panel/Role/API/CFSourceSets.pm @@ -125,6 +125,7 @@ sub update_item { try { $item->update({ name => $resource->{name}, + mode => $resource->{mode}, subscriber_id => $subscriber->id, })->discard_changes; $item->voip_cf_sources->delete; diff --git a/lib/NGCP/Panel/Role/API/CallForwards.pm b/lib/NGCP/Panel/Role/API/CallForwards.pm index 59872bf379..1f4096caa9 100644 --- a/lib/NGCP/Panel/Role/API/CallForwards.pm +++ b/lib/NGCP/Panel/Role/API/CallForwards.pm @@ -348,7 +348,8 @@ sub _contents_from_cfm { push @sources, {$source->get_inflated_columns}; delete @{$sources[-1]}{'source_set_id', 'id'}; } - return {times => \@times, destinations => \@destinations, sources => \@sources}; + return {times => \@times, destinations => \@destinations, + sources => \@sources, sources_mode => $sourceset_item->mode}; } 1; diff --git a/share/templates/subscriber/preferences.tt b/share/templates/subscriber/preferences.tt index 10d95684b9..75fd189d7c 100644 --- a/share/templates/subscriber/preferences.tt +++ b/share/templates/subscriber/preferences.tt @@ -185,7 +185,7 @@ $( document ).ready(function() { [% c.loc('all sources'); %] [% jdx = jdx + 1 %] [% ELSE -%] - [% maps.sset_name -%] + [% maps.sset_name -%] ([% maps.sset_mode -%]) [% sset_unique_id = cf.type _ idx _ jdx _ maps.id _ 's' -%] [% modal_header_dynamic(m.header = c.loc('Sourceset "[_1]" Details', maps.sset_name), m.id=sset_unique_id) %] @@ -988,6 +988,7 @@ $( document ).ready(function() { [% c.loc('Name') %] + [% c.loc('Mode') %] [% c.loc('Values') %] @@ -996,6 +997,7 @@ $( document ).ready(function() { [% FOREACH set IN cf_source_sets -%] [% set.name %] + [% set.mode %] [% FOREACH source IN set.sources -%] [% source.as_string %]