%args>
$type => undef
$context_key => undef
$context_value => undef
$notitle => undef
$certificate_link => undef
$limit => 20
$start => 1
$page => undef
$show_custom_columns => undef
$custom_columns_filter => undef
@custom_columns => ()
%args>
<%init>
my @search_context;
if (defined $context_key && defined $context_value) {
if (! ref $context_key) {
$context_key = [ $context_key ];
}
if (! ref $context_value) {
$context_value = [ $context_value ];
}
for (my $i = 0; $i < scalar @{$context_key}; $i++) {
$context_value->[$i] =~ s/\*/%/g;
if ($context_key->[$i] ne '') {
push @search_context, {
KEY => $context_key->[$i],
VALUE => $context_value->[$i],
OPERATOR => 'LIKE'
};
}
}
}
%init>
% my $msg;
% my $nr_of_results;
% if (scalar @search_context > 0 || exists $m->request_args()->{'__submit'}) {
% my $params = {
% 'CONTEXT' => \@search_context,
% };
% if ($type) {
% $params->{TYPE} = $type,
% }
% $nr_of_results = $context->{client}->send_receive_command_msg(
% 'search_workflow_instances_count',
% $params,
% )->{PARAMS};
% $params->{LIMIT} = $limit,
% my $page_info = $m->comp('/lib/paging.mhtml',
% totalEntries => $nr_of_results,
% entriesPerPage => $limit,
% page => $page,
% start => $start,
% url => $context->{menu}->get_root() . '/service/workflow/search_instances.html',
% additional_params => {
% 'context_key' => $context_key,
% 'context_value' => $context_value,
% }
% );
% if (defined $page_info) {
% $params->{START} = $page_info->first - 1;
% }
% if ($params->{START} == -1) {
% $params->{START} = 1;
% }
% $msg = $context->{client}->send_receive_command_msg
% (
% "search_workflow_instances",
% $params,
% );
% }
% if (defined $nr_of_results) { # SEARCH RESULT
% if (! $notitle) {
<% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_RESULT_TITLE') %>
% }
% if ($nr_of_results <= 0) { # NO INSTANCES
<% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_NO_RESULTS') %>
% } else { # INSTANCES FOUND
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_TYPE') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SERIAL') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_STATE') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_LAST_UPDATE') %>
%
% # add custom columns
% foreach my $custom_column ( @custom_columns ) {
%
% # map field to i18n identifier
<% $m->comp('/lib/field_to_i18n.mhtml', 'field' => $custom_column) %>
%
% }
%
% foreach my $instance (@{$msg->{PARAMS}}) # @{$msg->{PARAMS}})
% {
<% i18nGettext($instance->{'WORKFLOW.WORKFLOW_TYPE'}) %>
<% $instance->{'WORKFLOW.WORKFLOW_SERIAL'} %>
<% i18nGettext($instance->{'WORKFLOW.WORKFLOW_STATE'}) %>
% if ($certificate_link && $instance->{'WORKFLOW.WORKFLOW_TYPE'} eq 'I18N_OPENXPKI_WF_TYPE_CERTIFICATE_SIGNING_REQUEST' && ($instance->{'WORKFLOW.WORKFLOW_STATE'} eq 'SUCCESS' || $instance->{'WORKFLOW.WORKFLOW_STATE'} eq 'CHECK_CHILD_FINISHED')) {
% # we have a CSR workflow with a potential certificate
<& '/service/workflow/link_to_cert_by_csr_id.mhtml',
id => $instance->{'WORKFLOW.WORKFLOW_SERIAL'},
label => '(' . i18nGettext('I18N_OPENXPKI_HTML_MASON_DOWNLOAD_CERTIFICATE') . ')',
&>
% }
<% $instance->{'WORKFLOW.WORKFLOW_LAST_UPDATE'} %>
%
% # fill custom columns
% foreach my $custom_column ( @custom_columns ) {
% my $workflow_info = $context->{client}->send_receive_command_msg('get_workflow_info', { ID => $instance->{'WORKFLOW.WORKFLOW_SERIAL'} } );
%
% # fetch the data to be displayed in the custom column
% my $custom_column_data = $workflow_info->{PARAMS}->{WORKFLOW}->{CONTEXT}->{$custom_column};
%
<% $m->comp('/lib/display_field.mhtml', 'column' => $custom_column, 'field' => $custom_column_data, 'filter' => $custom_columns_filter ) %>
%
% }
%
% } # END FOREACH
% } # END IF INSTANCES FOUND
% } # END IF SEARCH RESULTS
% else { # SEARCH FORM
% #### TODO: get all possible context keys (for type) from DB
<% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_TITLE') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_DESCRIPTION') %>
<& /service/open_form.mhtml &>
% my $msg = $context->{client}->send_receive_command_msg ("list_workflow_titles");
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_WORKFLOW_TYPE') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_WORKFLOW_TYPE_ANY') %>
% foreach my $a_type (keys %{$msg->{PARAMS}}) {
% if ($a_type eq $type) {
<% i18nGettext($a_type) %>
% }
% else {
<% i18nGettext($a_type) %>
% }
% }
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_KEY') %>
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_VALUE') %>
% if (!defined $type) {
% $type = '';
% }
% my $keys_msg = $context->{client}->send_receive_command_msg
% (
% "list_context_keys",
% {
% 'WORKFLOW_TYPE' => $type
% },
% );
% my @i18n_keys = ();
% # create array of [ translated context key, I18N_KEY ]
% if (exists $keys_msg->{PARAMS}) {
% foreach my $key (@{$keys_msg->{PARAMS}}) {
% push @i18n_keys, [ $m->scomp('/lib/field_to_i18n.mhtml',
% 'field' => $key),
% $key ];
% }
% }
% # output sorted by translated keys
% foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
<% $key->[0] %>
% }
<& /lib/html/input.mhtml, 'name' => "context_value" &>
% foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
<% $key->[0] %>
% }
<& /lib/html/input.mhtml, 'name' => "context_value" &>
% foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
<% $key->[0] %>
% }
<& /lib/html/input.mhtml, 'name' => "context_value" &>
% foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
<% $key->[0] %>
% }
<& /lib/html/input.mhtml, 'name' => "context_value" &>
%
% if (not $show_custom_columns) {
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_SHOW_CUSTOM_RESULT_COLUMNS') %>
% }
% else { # SHOW CUSTOM COLUMNS
%
<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_CUSTOM_RESULT_COLUMNS') %>
%
% my @result_column_choices;
% foreach my $key (@{$keys_msg->{PARAMS}}) {
% push @result_column_choices, [ $m->scomp('/lib/field_to_i18n.mhtml', 'field' => $key), $key ];
% }
%
% foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @result_column_choices) {
<% $key->[0] %>
% }
%
%
% } # END IF SHOW CUSTOM COLUMNS
%
<& /service/send_form.mhtml &>
<& /service/close_form.mhtml &>
% } # END IF SEARCH FORM