View | Details | Raw Unified | Return to bug 20568
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt (-69 / +88 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patrons &rsaquo; API Keys</title>
4
<title>Koha &rsaquo; Patrons &rsaquo; API Keys</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 8-87 Link Here
8
[% INCLUDE 'patron-search.inc' %]
9
[% INCLUDE 'patron-search.inc' %]
9
10
10
<div id="breadcrumbs">
11
<div id="breadcrumbs">
11
  <a href="/cgi-bin/koha/mainpage.pl">Home</a>
12
    <a href="/cgi-bin/koha/mainpage.pl">Home</a>
12
  &rsaquo;
13
    &rsaquo;
13
  <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
14
    <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
14
  &rsaquo;
15
    &rsaquo;
15
  API Keys for [% INCLUDE 'patron-title.inc' %]
16
    API Keys for [% INCLUDE 'patron-title.inc' %]
16
</div>
17
</div>
17
18
18
<div id="doc3" class="yui-t2">
19
<div id="doc3" class="yui-t2">
19
  <div id="bd">
20
    <div id="bd">
20
    <div id="yui-main">
21
        <div id="yui-main">
21
      <div class="yui-b">
22
            <div class="yui-b">
22
        [% INCLUDE 'members-toolbar.inc' %]
23
                [% INCLUDE 'members-toolbar.inc' %]
23
24
24
        <h1>API keys for [% INCLUDE 'patron-title.inc' %]</h1>
25
                <h1>API keys for [% INCLUDE 'patron-title.inc' %]</h1>
25
        <div>
26
                <form id="add-api-key" action="/cgi-bin/koha/members/apikeys.pl" method="post" style="display:none">
26
          <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
27
                    <input type="hidden" name="patron_id" value="[% patron.id %]" />
27
            <input type="hidden" name="patron_id" value="[% patron.id %]">
28
                    <input type="hidden" name="op" value="generate" />
28
            <input type="hidden" name="op" value="generate">
29
                    <fieldset class="brief">
29
            <label for="description">Description: </label>
30
                        <legend>Generate new key</legend>
30
            <input type="text" name="description">
31
                        <ol>
31
            <button class="btn btn-default btn-sm" type="submit"><i class="fa fa-plus"></i> Generate a new key</span></button>
32
                            <li>
32
          </form>
33
                                <label for="description">Description: </label>
33
        </div>
34
                                <input type="text" name="description" />
34
35
                                <input type="submit" value="Save" />
35
        <br/>
36
                                <a href="#" class="cancel toggle_element" data-element="#add-api-key">Cancel</a>
37
                            </li>
38
                        </ol>
39
                    </fieldset>
40
                </form>
36
41
37
        <div id="keys">
42
                <div id="keys">
38
        [% IF api_keys && api_keys.size > 0 %]
43
                    [% IF api_keys && api_keys.size > 0 %]
39
          <table>
44
                        <p>
40
            <thead>
45
                            <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new key</button>
41
              <tr>
46
                        </p>
42
                <th>Description</th>
47
                        <table>
43
                <th>Key</th>
48
                            <thead>
44
                <th>Active</th>
49
                                <tr>
45
                <th>Actions</th>
50
                                    <th>Description</th>
46
              </tr>
51
                                    <th>Key</th>
47
            </thead>
52
                                    <th>Active</th>
48
            <tbody>
53
                                    <th>Actions</th>
49
              [% FOREACH key IN api_keys %]
54
                                </tr>
50
                <tr>
55
                            </thead>
51
                  <td>[% key.description %]</td>
56
                            <tbody>
52
                  <td>[% key.value %]</td>
57
                                [% FOREACH key IN api_keys %]
53
                  <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
58
                                    <tr>
54
                  <td>
59
                                        <td>[% key.description %]</td>
55
                    <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
60
                                        <td>[% key.value %]</td>
56
                      <input type="hidden" name="patron_id" value="[% patron.id %]">
61
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
57
                      <input type="hidden" name="key" value="[% key.value %]">
62
                                        <td>
58
                      <input type="hidden" name="op" value="delete">
63
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
59
                      <button class="btn btn-default btn-sm" type="submit">Delete</button>
64
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
60
                    </form>
65
                                                <input type="hidden" name="key" value="[% key.value %]" />
61
                    <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
66
                                                <input type="hidden" name="op" value="delete" />
62
                      <input type="hidden" name="patron_id" value="[% patron.id %]">
67
                                                <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button>
63
                      <input type="hidden" name="key" value="[% key.value %]">
68
                                            </form>
64
                      [% IF key.active %]
69
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
65
                        <input type="hidden" name="op" value="revoke">
70
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
66
                        <button class="btn btn-default btn-sm" type="submit">Revoke</button>
71
                                                <input type="hidden" name="key" value="[% key.value %]" />
67
                      [% ELSE %]
72
                                                [% IF key.active %]
68
                        <input type="hidden" name="op" value="activate">
73
                                                    <input type="hidden" name="op" value="revoke" />
69
                        <button class="btn btn-default btn-sm" type="submit">Activate</button>
74
                                                    <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
70
                      [% END %]
75
                                                [% ELSE %]
71
                    </form>
76
                                                    <input type="hidden" name="op" value="activate" />
72
                  </td>
77
                                                    <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button>
73
                </tr>
78
                                                [% END %]
74
              [% END %]
79
                                            </form>
75
            </tbody>
80
                                        </td>
76
          </table>
81
                                    </tr>
77
        [% ELSE %]
82
                                [% END %]
78
            <span class="warn">No keys defined for the current patron.</span>
83
                            </tbody>
79
        [% END %]
84
                        </table>
85
                    [% ELSE %]
86
                        <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new key</div>
87
                    [% END %]
88
                </div>
89
            </div>
90
        </div>
91
        <div class="yui-b">
92
            [% INCLUDE 'circ-menu.inc' %]
80
        </div>
93
        </div>
81
      </div>
82
    </div>
83
    <div class="yui-b">
84
      [% INCLUDE 'circ-menu.inc' %]
85
    </div>
94
    </div>
86
  </div>
95
96
[% MACRO jsinclude BLOCK %]
97
        <script>
98
            $(document).ready(function(){
99
                $(".delete").on("click", function(e){
100
                    return confirmDelete(_("Are you sure you want to delete this key?"));
101
                });
102
            });
103
        </script>
104
[% END %]
105
87
[% INCLUDE 'intranet-bottom.inc' %]
106
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt (-53 / +71 lines)
Lines 10-19 Link Here
10
    <ul class="breadcrumb">
10
    <ul class="breadcrumb">
11
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
11
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
12
        <li>
12
        <li>
13
          <a href="/cgi-bin/koha/opac-user.pl">
13
            <a href="/cgi-bin/koha/opac-user.pl">
14
            [% INCLUDE 'patron-title.inc' category_type=patron.category.category_type firstname=patron.firstname surname=patron.surname othernames=patron.othernames %]
14
                [% INCLUDE 'patron-title.inc' category_type=patron.category.category_type firstname=patron.firstname surname=patron.surname othernames=patron.othernames %]
15
          </a>
15
            </a>
16
          <span class="divider">&rsaquo;</span>
16
            <span class="divider">&rsaquo;</span>
17
        </li>
17
        </li>
18
        <li><a href="/cgi-bin/koha/opac-apikeys.pl">Your API keys</a></li>
18
        <li><a href="/cgi-bin/koha/opac-apikeys.pl">Your API keys</a></li>
19
    </ul>
19
    </ul>
Lines 27-87 Link Here
27
            </div>
27
            </div>
28
            <div class="span10">
28
            <div class="span10">
29
                <div id="apikeys" class="maincontent">
29
                <div id="apikeys" class="maincontent">
30
                  <h1>Your API keys</h1>
30
                    <h1>Your API keys</h1>
31
                  <div>
31
                    <p>
32
                    <form action="/cgi-bin/koha/opac-apikeys.pl" method="post">
32
                        <button id="show-api-form" style="display:none" class="btn btn-default btn-sm" type="button"><i class="fa fa-plus"></i> Generate new key</button>
33
                        <input type="hidden" name="patron_id" value="[% patron.id %]">
33
                    </p>
34
                        <input type="hidden" name="op" value="generate">
34
                    <form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post">
35
                        <label for="description">Description: </label>
35
                        <fieldset>
36
                        <input type="text" name="description">
36
                            <legend>Generate new key</legend>
37
                        <button class="btn btn-default btn-sm" type="submit"><i class="fa fa-plus"></i> Generate a new key</span></button>
37
                            <input type="hidden" name="patron_id" value="[% patron.id %]" />
38
                            <input type="hidden" name="op" value="generate" />
39
                            <label for="description">Description: </label>
40
                            <input type="text" name="description" />
41
                        </fieldset>
42
                        <fieldset class="action">
43
                            <button class="btn btn-default btn-sm" type="submit">Save</button> <a href="#" style="display:none" class="cancel cancel-api-key">Cancel</a>
44
                        </fieldset>
38
                    </form>
45
                    </form>
39
                  </div>
46
                    [% IF api_keys && api_keys.size > 0 %]
40
                  [% IF api_keys && api_keys.size > 0 %]
47
                        <table class="table table-bordered table-striped">
41
                    <table class="table table-bordered table-striped">
48
                            <thead>
42
                      <thead>
49
                                <tr>
43
                        <tr>
50
                                    <th>Description</th>
44
                          <th>Description</th>
51
                                    <th>Key</th>
45
                          <th>Key</th>
52
                                    <th>Active</th>
46
                          <th>Active</th>
53
                                    <th>Actions</th>
47
                          <th>Actions</th>
54
                                </tr>
48
                        </tr>
55
                            </thead>
49
                      </thead>
56
                            <tbody>
50
                      <tbody>
57
                                [% FOREACH key IN api_keys %]
51
                        [% FOREACH key IN api_keys %]
58
                                    <tr>
52
                          <tr>
59
                                        <td>[% key.description %]</td>
53
                            <td>[% key.description %]</td>
60
                                        <td>[% key.value %]</td>
54
                            <td>[% key.value %]</td>
61
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
55
                            <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
62
                                        <td>
56
                            <td>
63
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
57
                              <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
64
                                                <input type="hidden" name="key" value="[% key.value %]" />
58
                                <input type="hidden" name="key" value="[% key.value %]">
65
                                                <input type="hidden" name="op" value="delete" />
59
                                <input type="hidden" name="op" value="delete">
66
                                                <button class="btn btn-link btn-xs delete-key" type="submit"><i class="fa fa-trash"></i> Delete</button>
60
                                <button class="btn btn-default btn-sm" type="submit">Delete</button>
67
                                            </form>
61
                              </form>
68
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
62
                              <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
69
                                                <input type="hidden" name="key" value="[% key.value %]" />
63
                                <input type="hidden" name="key" value="[% key.value %]">
70
                                                [% IF key.active %]
64
                                [% IF key.active %]
71
                                                    <input type="hidden" name="op" value="revoke" />
65
                                  <input type="hidden" name="op" value="revoke">
72
                                                    <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
66
                                  <button class="btn btn-default btn-sm" type="submit">Revoke</button>
73
                                                [% ELSE %]
67
                                [% ELSE %]
74
                                                    <input type="hidden" name="op" value="activate" />
68
                                  <input type="hidden" name="op" value="activate">
75
                                                    <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-play"></i> Activate</button>
69
                                  <button class="btn btn-default btn-sm" type="submit">Activate</button>
76
                                                [% END %]
77
                                            </form>
78
                                        </td>
79
                                    </tr>
70
                                [% END %]
80
                                [% END %]
71
                              </form>
81
                            </tbody>
72
                            </td>
82
                        </table>
73
                          </tr>
83
                    [% ELSE %]
74
                        [% END %]
84
                        <p>No keys defined for the current patron.</p>
75
                      </tbody>
85
                    [% END %]
76
                    </table>
77
                  [% ELSE %]
78
                    <span class="warn">No keys defined for the current patron.</span>
79
                  [% END %]
80
                </div> <!-- /#apikeys -->
86
                </div> <!-- /#apikeys -->
81
            </div> <!-- /.span10 -->
87
            </div> <!-- /.span10 -->
82
        </div> <!-- /.row-fluid -->
88
        </div> <!-- /.row-fluid -->
83
    </div> <!-- /.container-fluid -->
89
    </div> <!-- /.container-fluid -->
84
</div> <!-- /#main -->
90
</div> <!-- /#main -->
85
91
86
[% BLOCK jsinclude %][% END %]
92
[% BLOCK jsinclude %]
93
    <script>
94
        $(document).ready(function(){
95
            $("#add-api-key, #show-api-form, .cancel-api-key").toggle();
96
            $("#show-api-form, .cancel-api-key").on("click", function(){
97
                $("#add-api-key, #show-api-form").toggle();
98
            });
99
            $(".delete-key").on("click", function(){
100
                return confirm(_("Are you sure you want to delete this key?"));
101
            });
102
        });
103
    </script>
104
[% END %]
87
[% INCLUDE 'opac-bottom.inc' %]
105
[% INCLUDE 'opac-bottom.inc' %]
(-)a/opac/opac-apikeys.pl (-2 / +1 lines)
Lines 40-46 my $patron_id = $loggedinuser; Link Here
40
my $patron = Koha::Patrons->find( $patron_id );
40
my $patron = Koha::Patrons->find( $patron_id );
41
41
42
if ( not defined $patron
42
if ( not defined $patron
43
    or C4::Context->preference('AllowPatronsManageAPIKeysInOPAC') )
43
    or !C4::Context->preference('AllowPatronsManageAPIKeysInOPAC') )
44
{
44
{
45
    # patron_id invalid -> exit
45
    # patron_id invalid -> exit
46
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");    # escape early
46
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");    # escape early
47
- 

Return to bug 20568