<h1>
  <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_KEY_LIST_TITLE') %>
</h1>
<p>
  <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_API_KEY_LIST_DESCRIPTION') %>
</p>
<table id="table_list">
  <tr>
    <th><% i18nGettext('I18N_OPENXPKI_SECRET_LABEL') %></th>
    <th><% i18nGettext('I18N_OPENXPKI_SECRET_STATUS') %></th>
    <th><% i18nGettext('I18N_OPENXPKI_SECRET_ACTION') %></th>
  </tr>
<%perl>
  foreach my $secret (sort keys %secrets)
  {
    print "  <tr>\n";
    print "    <td>".i18nGettext($secrets{$secret}->{LABEL})."</td>\n";
    if ($secrets{$secret}->{STATUS})
    {
        print "    <td>".i18nGettext('I18N_OPENXPKI_SECRET_COMPLETE')."</td>\n";
        print "    <td>\n";
        $m->comp ('/lib/html/a.mhtml',
                  'target' => "clear_secret.html",
                  'params' => [["secret", $secret]],
                  'label'  => i18nGettext('I18N_OPENXPKI_SECRET_LOGOUT_LINK_LABEL'));
        print "    </td>\n";
    } else {
        print "    <td>".i18nGettext('I18N_OPENXPKI_SECRET_INCOMPLETE')."</td>\n";
        print "    <td>\n";
        $m->comp ('/lib/html/a.mhtml',
                  'target' => "set_secret.html",
                  'params' => [["secret", $secret], ["type", $secrets{$secret}->{TYPE}]],
                  'label'  => i18nGettext('I18N_OPENXPKI_SECRET_LOGIN_LINK_LABEL'));
        print "    </td>\n";
    }
    print "  </tr>\n";
  }
</%perl>
</table>

<%init>
  my $msg  = $context->{client}->send_receive_command_msg ("get_secrets");
  my %secrets = ();
  foreach my $secret (keys %{$msg->{PARAMS}})
  {
    my $msg_s = $context->{client}->send_receive_command_msg ("is_secret_complete",
                    {SECRET => $secret});
    $secrets{$secret}->{STATUS} = $msg_s->{PARAMS};
    $secrets{$secret}->{LABEL}  = $msg->{PARAMS}->{$secret}->{LABEL};
    $secrets{$secret}->{TYPE}   = $msg->{PARAMS}->{$secret}->{TYPE};
  }
</%init>
