diff --git a/lib/NGCP/Panel/Controller/Header.pm b/lib/NGCP/Panel/Controller/Header.pm
index 615f757ba3..1432edd9d9 100644
--- a/lib/NGCP/Panel/Controller/Header.pm
+++ b/lib/NGCP/Panel/Controller/Header.pm
@@ -270,6 +270,16 @@ sub rules_list :Chained('set_base') :PathPart('rules') :CaptureArgs(0) {
order_by => { -asc => 'priority' },
});
$c->stash(rules_rs => $rules_rs);
+
+ $c->stash->{rule_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
+ { name => 'priority', search => 0, title => $c->loc('Priority') },
+ { name => 'id', search => 1, title => $c->loc('#') },
+ { name => 'name', search => 1, title => $c->loc('Name') },
+ { name => 'description', search => 1, title => $c->loc('Description') },
+ { name => 'stopper', search => 1, title => $c->loc('Stopper') },
+ { name => 'enabled', search => 1, title => $c->loc('Enabled') },
+ ]);
+
$c->stash(rules_uri => $c->uri_for_action("/header/rules_root", [$c->req->captures->[0]]));
$c->stash(template => 'header/rules_list.tt');
@@ -323,6 +333,13 @@ sub rules_root :Chained('rules_list') :PathPart('') :Args(0) {
return;
}
+sub rules_ajax :Chained('rules_list') :PathPart('ajax') :Args(0) {
+ my ($self, $c) = @_;
+ my $rs = $c->stash->{rules_rs};
+ NGCP::Panel::Utils::Datatables::process($c, $rs, $c->stash->{rule_dt_columns});
+ $c->detach( $c->view("JSON") );
+}
+
sub rules_base :Chained('rules_list') :PathPart('') :CaptureArgs(1) {
my ($self, $c, $rule_id) = @_;
@@ -456,8 +473,21 @@ sub conditions_list :Chained('rules_base') :PathPart('conditions') :CaptureArgs(
my ( $self, $c ) = @_;
my $conditions_rs = $c->stash->{rule_result}->conditions;
+
$c->stash(conditions_rs => $conditions_rs);
+ $c->stash->{condition_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
+ { name => 'id', search => 1, title => $c->loc('#') },
+ { name => 'match_type', search => 1, title => $c->loc('Match') },
+ { name => 'match_part', search => 1, title => $c->loc('Part') },
+ { name => 'match_name', search => 1, title => $c->loc('Name') },
+ { name => 'expression', search => 1, title => $c->loc('Expression') },
+ { name => 'value_type', search => 1, title => $c->loc('Type') },
+ { name => 'c_values', search => 0, title => $c->loc('Values') },
+ { name => 'c_rwr_set', search => 0, title => $c->loc('Rewrite Rule Set') },
+ { name => 'enabled', search => 1, title => $c->loc('Enabled') },
+ ]);
+
$c->stash(conditions_uri => $c->uri_for_action("/header/conditions_root", $c->req->captures));
$c->stash(template => 'header/conditions_list.tt');
@@ -469,26 +499,36 @@ sub conditions_root :Chained('conditions_list') :PathPart('') :Args(0) {
my $conditions_rs = $c->stash->{conditions_rs};
- my @conditions = ();
+ $c->stash(conditions => [ $conditions_rs->all ] );
- foreach my $condition ($conditions_rs->all) {
- my $row = { $condition->get_inflated_columns };
- @{$row->{values}} = map { $_->value } $condition->values->all;
- push @conditions, $row;
- if ($row->{rwr_set_id}) {
- my $rwr_set = { $condition->rwr_set->get_inflated_columns };
- $row->{rwr_set} = $rwr_set->{name};
- my $dp_id = $row->{rwr_dp_id} // 0;
- ($row->{rwr_dp}) =
- grep { $_ =~ /_dpid/ && $rwr_set->{$_} eq $dp_id }
- keys %{$rwr_set};
- }
- }
-
- $c->stash(conditions => \@conditions);
return;
}
+sub conditions_ajax :Chained('conditions_list') :PathPart('rules_ajax') :Args(0) {
+ my ($self, $c) = @_;
+ my $rs = $c->stash->{conditions_rs};
+ NGCP::Panel::Utils::Datatables::process($c, $rs, $c->stash->{condition_dt_columns}, sub {
+ my $item = shift;
+ my %cols = $item->get_inflated_columns;
+ my ($c_rwr_set, $c_rwr_dp) = ('','');
+ if ($cols{rwr_set_id}) {
+ my %rwr_set = $item->rwr_set->get_inflated_columns;
+ $c_rwr_set = $rwr_set{name};
+ my $dp_id = $cols{rwr_dp_id} // 0;
+ ($c_rwr_dp) =
+ grep { $_ =~ /_dpid/ && $rwr_set{$_} eq $dp_id }
+ keys %rwr_set;
+ $c_rwr_dp =~ s/_dpid$//;
+ }
+ return (
+ expression => ($cols{expression_negation} ? ' ! ' : ' ') . $cols{expression},
+ c_values => join("
", map { $_->value } $item->values->all) // '',
+ c_rwr_set => $c_rwr_set ? "$c_rwr_set ($c_rwr_dp)" : '',
+ );
+ });
+ $c->detach( $c->view("JSON") );
+}
+
sub conditions_base :Chained('conditions_list') :PathPart('') :CaptureArgs(1) {
my ($self, $c, $condition_id) = @_;
@@ -695,6 +735,18 @@ sub actions_list :Chained('rules_base') :PathPart('actions') :CaptureArgs(0) {
});
$c->stash(actions_rs => $actions_rs);
+ $c->stash->{action_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
+ { name => 'priority', search => 0, title => $c->loc('Priority') },
+ { name => 'id', search => 1, title => $c->loc('#') },
+ { name => 'header', search => 1, title => $c->loc('Header') },
+ { name => 'header_part', search => 1, title => $c->loc('Part') },
+ { name => 'action_type', search => 1, title => $c->loc('Type') },
+ { name => 'value_part', search => 1, title => $c->loc('Value Part') },
+ { name => 'value', search => 1, title => $c->loc('Value') },
+ { name => 'c_rwr_set', search => 0, title => $c->loc('Rewrite Rule Set') },
+ { name => 'enabled', search => 1, title => $c->loc('Enabled') },
+ ]);
+
$c->stash(actions_uri => $c->uri_for_action("/header/actions_root", $c->req->captures));
$c->stash(template => 'header/actions_list.tt');
@@ -744,25 +796,34 @@ sub actions_root :Chained('actions_list') :PathPart('') :Args(0) {
}
}
- my @actions = ();
+ $c->stash(actions => [ $actions_rs->all ]);
- foreach my $action ($actions_rs->all) {
- my $row = { $action->get_inflated_columns };
- push @actions, $row;
- if ($row->{rwr_set_id}) {
- my $rwr_set = { $action->rwr_set->get_inflated_columns };
- $row->{rwr_set} = $rwr_set->{name};
- my $dp_id = $row->{rwr_dp_id} // 0;
- ($row->{rwr_dp}) =
- grep { $_ =~ /_dpid/ && $rwr_set->{$_} eq $dp_id }
- keys %{$rwr_set};
- }
- }
-
- $c->stash(actions => \@actions);
return;
}
+sub actions_ajax :Chained('actions_list') :PathPart('rules_ajax') :Args(0) {
+ my ($self, $c) = @_;
+ my $rs = $c->stash->{actions_rs};
+ NGCP::Panel::Utils::Datatables::process($c, $rs, $c->stash->{action_dt_columns}, sub {
+ my $item = shift;
+ my %cols = $item->get_inflated_columns;
+ my ($c_rwr_set, $c_rwr_dp) = ('','');
+ if ($cols{rwr_set_id}) {
+ my %rwr_set = $item->rwr_set->get_inflated_columns;
+ $c_rwr_set = $rwr_set{name};
+ my $dp_id = $cols{rwr_dp_id} // 0;
+ ($c_rwr_dp) =
+ grep { $_ =~ /_dpid/ && $rwr_set{$_} eq $dp_id }
+ keys %rwr_set;
+ $c_rwr_dp =~ s/_dpid$//;
+ }
+ return (
+ c_rwr_set => $c_rwr_set ? "$c_rwr_set ($c_rwr_dp)" : '',
+ );
+ });
+ $c->detach( $c->view("JSON") );
+}
+
sub actions_base :Chained('actions_list') :PathPart('') :CaptureArgs(1) {
my ($self, $c, $action_id) = @_;
diff --git a/share/templates/header/actions_edit.tt b/share/templates/header/actions_edit.tt
deleted file mode 100644
index 4b8c7a0dd9..0000000000
--- a/share/templates/header/actions_edit.tt
+++ /dev/null
@@ -1,88 +0,0 @@
-[% site_config.title = c.loc('Header Rules for [_1]', set_result.name) -%]
-
-
- | [% c.loc('Name') %] | -[% c.loc('Description') %] | -- |
---|---|---|---|
- - - - - - - | -[% r.name %] | -[% r.description %] | -
- [% UNLESS c.user.read_only -%]
-
- [%- FILTER null;
- backuritmp=c.req.uri;
- backuritmp.query_param_delete('back');
- backuritmp.query_param_delete('move');
- backuritmp.query_param_delete('where');
- END;
- %]
-
- [% c.loc('Edit') %]
-
-
- [% c.loc('Conditions') %]
-
-
- [% c.loc('Actions') %]
-
-
- [% c.loc('Delete') %]
-
-
- [% END -%]
- |
-
- | [% c.loc('Header') %] | -[% c.loc('Part') %] | -[% c.loc('Type') %] | -[% c.loc('Value Part') %] | -[% c.loc('Value') %] | -[% c.loc('Rewrite Rule Set') %] | -[% c.loc('Rewrite Rules') %] | -[% c.loc('Enabled') %] | -- |
---|---|---|---|---|---|---|---|---|---|
- [% IF action != actions.first %] - - - - [% END %] - [% IF action != actions.last %] - - - - [% END %] - | -[% action.header %] | -[% action.header_part %] | -[% action.action_type %] | -[% action.value_part %] | -[% action.value %] | -[% action.rwr_set %] | -[% action.rwr_dp %] | -[% action.enabled %] | -
- [% UNLESS c.user.read_only -%]
-
- [%- FILTER null;
- backuritmp=c.req.uri;
- backuritmp.query_param_delete('back');
- backuritmp.query_param_delete('move');
- backuritmp.query_param_delete('where');
- END;
- %]
-
- [% c.loc('Edit') %]
-
-
- [% c.loc('Delete') %]
-
-
- [% END -%]
- |
-
[% c.loc('Match') %] | -[% c.loc('Part') %] | -[% c.loc('Name') %] | -[% c.loc('Expression') %] | -[% c.loc('Type') %] | -[% c.loc('Values') %] | -[% c.loc('Rewrite Rule Set') %] | -[% c.loc('Rewrite Rules') %] | -[% c.loc('Enabled') %] | -- |
---|---|---|---|---|---|---|---|---|---|
[% condition.match_type %] | -[% condition.match_part %] | -[% condition.match_name %] | -[% IF condition.expression_negation %] ! [% END %][% condition.expression %] | -[% condition.value_type %] | -[% condition.values.join(' ') %] |
- [% condition.rwr_set %] | -[% condition.rwr_dp %] | -[% condition.enabled %] | -- [% UNLESS c.user.read_only -%] - - [% END -%] - | -
- | [% c.loc('Name') %] | -[% c.loc('Direction') %] | -[% c.loc('Description') %] | -[% c.loc('Stopper') %] | -[% c.loc('Enabled') %] | -- |
---|---|---|---|---|---|---|
- [% IF r != rules.first %] - - - - [% END %] - [% IF r != rules.last %] - - - - [% END %] - | -[% r.name %] | -[% r.direction %] | -[% r.description %] | -[% r.stopper %] | -[% r.enabled %] | -
- [% UNLESS c.user.read_only -%]
-
- [%- FILTER null;
- backuritmp=c.req.uri;
- backuritmp.query_param_delete('back');
- backuritmp.query_param_delete('move');
- backuritmp.query_param_delete('where');
- END;
- %]
-
- [% c.loc('Edit') %]
-
-
- [% c.loc('Conditions') %]
-
-
- [% c.loc('Actions') %]
-
-
- [% c.loc('Delete') %]
-
-
- [% END -%]
- |
-