web interface: reorder input fields in certificate search page
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / htdocs / service / workflow / search_instances.html
blob2b91acea76ba43a5f483dac1d20ee118d8e594e8
1 <%args>
2 $type => undef
3 $context_key => undef
4 $context_value => undef
5 $notitle => undef
6 $certificate_link => undef
7 $limit => 20
8 $start => 1
9 $page => undef
10 $show_custom_columns => undef
11 @custom_columns => ()
12 </%args>
13 <%init>
14 my @search_context;
15 if (defined $context_key && defined $context_value) {
16 if (! ref $context_key) {
17 $context_key = [ $context_key ];
19 if (! ref $context_value) {
20 $context_value = [ $context_value ];
22 for (my $i = 0; $i < scalar @{$context_key}; $i++) {
23 $context_value->[$i] =~ s/\*/%/g;
25 if ($context_key->[$i] ne '') {
26 push @search_context, {
27 KEY => $context_key->[$i],
28 VALUE => $context_value->[$i],
33 </%init>
34 % my $msg;
35 % my $nr_of_results;
36 % if (scalar @search_context > 0 || exists $m->request_args()->{'__submit'}) {
37 % my $params = {
38 % 'CONTEXT' => \@search_context,
39 % };
40 % if ($type) {
41 % $params->{TYPE} = $type,
42 % }
43 % $nr_of_results = $context->{client}->send_receive_command_msg(
44 % 'search_workflow_instances_count',
45 % $params,
46 % )->{PARAMS};
47 % $params->{LIMIT} = $limit,
48 % my $page_info = $m->comp('/lib/paging.mhtml',
49 % totalEntries => $nr_of_results,
50 % entriesPerPage => $limit,
51 % page => $page,
52 % start => $start,
53 % url => $context->{menu}->get_root() . '/service/workflow/search_instances.html',
54 % additional_params => {
55 % 'context_key' => $context_key,
56 % 'context_value' => $context_value,
57 % }
58 % );
59 % if (defined $page_info) {
60 % $params->{START} = $page_info->first - 1;
61 % }
62 % if ($params->{START} == -1) {
63 % $params->{START} = 1;
64 % }
65 % $msg = $context->{client}->send_receive_command_msg
66 % (
67 % "search_workflow_instances",
68 % $params,
69 % );
70 % }
71 % if (defined $nr_of_results) { # SEARCH RESULT
72 % if (! $notitle) {
73 <h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_RESULT_TITLE') %></h1>
74 % }
75 % if ($nr_of_results <= 0) { # NO INSTANCES
76 <p><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_NO_RESULTS') %></p>
77 % } else { # INSTANCES FOUND
78 <table>
79 <tr>
80 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_TYPE') %></th>
81 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SERIAL') %></th>
82 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_STATE') %></th>
83 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_LAST_UPDATE') %></th>
85 % # add custom columns
86 % foreach my $custom_column ( @custom_columns ) {
88 % # map field to i18n identifier
89 <th><% $m->comp('/lib/field_to_i18n.mhtml', 'field' => $custom_column) %></th>
91 % }
93 </tr>
94 % foreach my $instance (@{$msg->{PARAMS}}) # @{$msg->{PARAMS}})
95 % {
96 <tr>
97 <td><% i18nGettext($instance->{'WORKFLOW.WORKFLOW_TYPE'}) %></td>
98 <td><a href="<% $context->{menu}->get_root() %>/service/workflow/show_instance.html?type=<% $instance->{'WORKFLOW.WORKFLOW_TYPE'} %>;id=<% $instance->{'WORKFLOW.WORKFLOW_SERIAL'} %>;<% $context->{menu}->get_link_params() %>"><% $instance->{'WORKFLOW.WORKFLOW_SERIAL'} %></a></td>
99 <td><% i18nGettext($instance->{'WORKFLOW.WORKFLOW_STATE'}) %>
100 % 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')) {
101 % # we have a CSR workflow with a potential certificate
102 <& '/service/workflow/link_to_cert_by_csr_id.mhtml',
103 id => $instance->{'WORKFLOW.WORKFLOW_SERIAL'},
104 label => '(' . i18nGettext('I18N_OPENXPKI_HTML_MASON_DOWNLOAD_CERTIFICATE') . ')',
107 </td>
108 <td><% $instance->{'WORKFLOW.WORKFLOW_LAST_UPDATE'} %></td>
110 % # fill custom columns
111 % foreach my $custom_column ( @custom_columns ) {
112 % my $workflow_info = $context->{client}->send_receive_command_msg('get_workflow_info', { ID => $instance->{'WORKFLOW.WORKFLOW_SERIAL'} } );
114 % # fetch the data to be displayed in the custom column
115 % my $custom_column_data = $workflow_info->{PARAMS}->{WORKFLOW}->{CONTEXT}->{$custom_column};
117 <td><% $m->comp('/lib/display_field.mhtml', 'field' => $custom_column_data ) %></td>
121 </tr>
122 % } # END FOREACH
123 </table>
124 % } # END IF INSTANCES FOUND
125 % } # END IF SEARCH RESULTS
126 % else { # SEARCH FORM
127 % #### TODO: get all possible context keys (for type) from DB
128 <h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_TITLE') %></h1>
130 <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_DESCRIPTION') %>
131 </p>
132 <& /service/open_form.mhtml &>
133 % my $msg = $context->{client}->send_receive_command_msg ("list_workflow_titles");
134 <table>
135 <!-- TODO: input field for types -->
136 <tr>
137 <td>
138 <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_WORKFLOW_TYPE') %>
139 </td>
140 <td>
141 <script type="text/javascript">
142 <!--
143 function reloadType(type) {
144 search = window.location.search;
145 s_no_type = search.replace(/;type=.*$/, "");
146 window.location.search=s_no_type + ";type=" + type;
149 </script>
150 <select name="type" onchange="reloadType(this.value)">
151 <option value=""><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_WORKFLOW_TYPE_ANY') %></option>
152 % foreach my $a_type (keys %{$msg->{PARAMS}}) {
153 % if ($a_type eq $type) {
154 <option value="<% $a_type %>" selected><% i18nGettext($a_type) %></option>
156 % else {
157 <option value="<% $a_type %>"><% i18nGettext($a_type) %></option>
160 </select>
161 </td>
162 </tr>
163 </table>
164 <table>
165 <tr>
166 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_KEY') %></th>
167 <th><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_FORM_VALUE') %></th>
168 </tr>
169 <tr>
170 % if (!defined $type) {
171 % $type = '';
173 % my $keys_msg = $context->{client}->send_receive_command_msg
175 % "list_context_keys",
177 % 'WORKFLOW_TYPE' => $type
178 % },
179 % );
180 <td>
181 <select name="context_key">
182 <option value=""></option>
183 % my @i18n_keys = ();
184 % # create array of [ translated context key, I18N_KEY ]
185 % if (exists $keys_msg->{PARAMS}) {
186 % foreach my $key (@{$keys_msg->{PARAMS}}) {
187 % push @i18n_keys, [ $m->scomp('/lib/field_to_i18n.mhtml',
188 % 'field' => $key),
189 % $key ];
192 % # output sorted by translated keys
193 % foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
194 <option value="<% $key->[1] %>"><% $key->[0] %></option>
196 </select>
197 </td>
198 <td><& /lib/html/input.mhtml, 'name' => "context_value" &></td>
199 </tr>
200 <tr>
201 <td>
202 <select name="context_key">
203 <option value=""></option>
204 % foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
205 <option value="<% $key->[1] %>"><% $key->[0] %></option>
207 </select>
208 </td>
209 <td><& /lib/html/input.mhtml, 'name' => "context_value" &></td>
210 </tr>
211 <tr>
212 <td>
213 <select name="context_key">
214 <option value=""></option>
215 % foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
216 <option value="<% $key->[1] %>"><% $key->[0] %></option>
218 </select>
219 </td>
220 <td><& /lib/html/input.mhtml, 'name' => "context_value" &></td>
221 </tr>
222 <tr>
223 <td>
224 <select name="context_key">
225 <option value=""></option>
226 % foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @i18n_keys) {
227 <option value="<% $key->[1] %>"><% $key->[0] %></option>
229 </select>
230 </td>
231 <td><& /lib/html/input.mhtml, 'name' => "context_value" &></td>
232 </tr>
233 </table>
236 % if (not $show_custom_columns) {
237 <p><a href="<% $context->{menu}->get_root() %>/service/workflow/search_instances.html?<% $context->{menu}->get_link_params() %>;type=<% $type %>;id=<% $msg->{PARAMS}->{WORKFLOW}->{ID} %>;show_custom_columns=1"><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_SHOW_CUSTOM_RESULT_COLUMNS') %></a></p>
239 % else { # SHOW CUSTOM COLUMNS
241 <table>
242 <tr>
243 <th>
244 <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SEARCH_INSTANCES_CUSTOM_RESULT_COLUMNS') %>
245 </th>
246 </tr>
247 <tr>
248 <td>
249 <select name="custom_columns" multiple="multiple">
251 % my @result_column_choices;
252 % foreach my $key (@{$keys_msg->{PARAMS}}) {
253 % push @result_column_choices, [ $m->scomp('/lib/field_to_i18n.mhtml', 'field' => $key), $key ];
256 % foreach my $key (sort {lc($a->[0]) cmp lc($b->[0])} @result_column_choices) {
257 <option value="<% $key->[1] %>"><% $key->[0] %></option>
260 </select>
261 </td>
262 </tr>
263 </table>
265 % } # END IF SHOW CUSTOM COLUMNS
267 <& /service/send_form.mhtml &>
268 <& /service/close_form.mhtml &>
269 % } # END IF SEARCH FORM