##// END OF EJS Templates
auth-tokens: fix placeholder text
marcink -
r2084:61c96d88 default
parent child Browse files
Show More
@@ -1,180 +1,180 b''
1 1 <div class="panel panel-default">
2 2 <div class="panel-heading">
3 3 <h3 class="panel-title">${_('Authentication Tokens')}</h3>
4 4 </div>
5 5 <div class="panel-body">
6 6 <div class="apikeys_wrap">
7 7 <p>
8 8 ${_('Each token can have a role. Token with a role can be used only in given context, '
9 9 'e.g. VCS tokens can be used together with the authtoken auth plugin for git/hg/svn operations only.')}
10 10 </p>
11 11 <table class="rctable auth_tokens">
12 12 <tr>
13 13 <th>${_('Token')}</th>
14 14 <th>${_('Scope')}</th>
15 15 <th>${_('Description')}</th>
16 16 <th>${_('Role')}</th>
17 17 <th>${_('Expiration')}</th>
18 18 <th>${_('Action')}</th>
19 19 </tr>
20 20 %if c.user_auth_tokens:
21 21 %for auth_token in c.user_auth_tokens:
22 22 <tr class="${'expired' if auth_token.expired else ''}">
23 23 <td class="truncate-wrap td-authtoken">
24 24 <div class="user_auth_tokens truncate autoexpand">
25 25 <code>${auth_token.api_key}</code>
26 26 </div>
27 27 </td>
28 28 <td class="td">${auth_token.scope_humanized}</td>
29 29 <td class="td-wrap">${auth_token.description}</td>
30 30 <td class="td-tags">
31 31 <span class="tag disabled">${auth_token.role_humanized}</span>
32 32 </td>
33 33 <td class="td-exp">
34 34 %if auth_token.expires == -1:
35 35 ${_('never')}
36 36 %else:
37 37 %if auth_token.expired:
38 38 <span style="text-decoration: line-through">${h.age_component(h.time_to_utcdatetime(auth_token.expires))}</span>
39 39 %else:
40 40 ${h.age_component(h.time_to_utcdatetime(auth_token.expires))}
41 41 %endif
42 42 %endif
43 43 </td>
44 44 <td class="td-action">
45 45 ${h.secure_form(h.route_path('my_account_auth_tokens_delete'), method='POST', request=request)}
46 46 ${h.hidden('del_auth_token', auth_token.user_api_key_id)}
47 47 <button class="btn btn-link btn-danger" type="submit"
48 48 onclick="return confirm('${_('Confirm to remove this auth token: %s') % auth_token.token_obfuscated}');">
49 49 ${_('Delete')}
50 50 </button>
51 51 ${h.end_form()}
52 52 </td>
53 53 </tr>
54 54 %endfor
55 55 %else:
56 56 <tr><td><div class="ip">${_('No additional auth tokens specified')}</div></td></tr>
57 57 %endif
58 58 </table>
59 59 </div>
60 60
61 61 <div class="user_auth_tokens">
62 62 ${h.secure_form(h.route_path('my_account_auth_tokens_add'), method='POST', request=request)}
63 63 <div class="form form-vertical">
64 64 <!-- fields -->
65 65 <div class="fields">
66 66 <div class="field">
67 67 <div class="label">
68 68 <label for="new_email">${_('New authentication token')}:</label>
69 69 </div>
70 70 <div class="input">
71 71 ${h.text('description', class_='medium', placeholder=_('Description'))}
72 72 ${h.hidden('lifetime')}
73 73 ${h.select('role', '', c.role_options)}
74 74
75 75 % if c.allow_scoped_tokens:
76 76 ${h.hidden('scope_repo_id')}
77 77 % else:
78 78 ${h.select('scope_repo_id_disabled', '', ['Scopes available in EE edition'], disabled='disabled')}
79 79 % endif
80 80 </div>
81 81 <p class="help-block">
82 82 ${_('Repository scope works only with tokens with VCS type.')}
83 83 </p>
84 84 </div>
85 85 <div class="buttons">
86 86 ${h.submit('save',_('Add'),class_="btn")}
87 87 ${h.reset('reset',_('Reset'),class_="btn")}
88 88 </div>
89 89 </div>
90 90 </div>
91 91 ${h.end_form()}
92 92 </div>
93 93 </div>
94 94 </div>
95 95 <script>
96 96 $(document).ready(function(){
97 97
98 98 var select2Options = {
99 99 'containerCssClass': "drop-menu",
100 100 'dropdownCssClass': "drop-menu-dropdown",
101 101 'dropdownAutoWidth': true
102 102 };
103 103 $("#role").select2(select2Options);
104 104
105 105
106 106 var preloadData = {
107 107 results: [
108 108 % for entry in c.lifetime_values:
109 109 {id:${entry[0]}, text:"${entry[1]}"}${'' if loop.last else ','}
110 110 % endfor
111 111 ]
112 112 };
113 113
114 114 $("#lifetime").select2({
115 115 containerCssClass: "drop-menu",
116 116 dropdownCssClass: "drop-menu-dropdown",
117 117 dropdownAutoWidth: true,
118 118 data: preloadData,
119 placeholder: ${_('Select or enter expiration date')},
119 placeholder: "${_('Select or enter expiration date')}",
120 120 query: function(query) {
121 121 feedLifetimeOptions(query, preloadData);
122 122 }
123 123 });
124 124
125 125
126 126 var repoFilter = function(data) {
127 127 var results = [];
128 128
129 129 if (!data.results[0]) {
130 130 return data
131 131 }
132 132
133 133 $.each(data.results[0].children, function() {
134 134 // replace name to ID for submision
135 135 this.id = this.obj.repo_id;
136 136 results.push(this);
137 137 });
138 138
139 139 data.results[0].children = results;
140 140 return data;
141 141 };
142 142
143 143 $("#scope_repo_id_disabled").select2(select2Options);
144 144
145 145 $("#scope_repo_id").select2({
146 146 cachedDataSource: {},
147 147 minimumInputLength: 2,
148 148 placeholder: "${_('repository scope')}",
149 149 dropdownAutoWidth: true,
150 150 containerCssClass: "drop-menu",
151 151 dropdownCssClass: "drop-menu-dropdown",
152 152 formatResult: formatResult,
153 153 query: $.debounce(250, function(query){
154 154 self = this;
155 155 var cacheKey = query.term;
156 156 var cachedData = self.cachedDataSource[cacheKey];
157 157
158 158 if (cachedData) {
159 159 query.callback({results: cachedData.results});
160 160 } else {
161 161 $.ajax({
162 162 url: pyroutes.url('repo_list_data'),
163 163 data: {'query': query.term},
164 164 dataType: 'json',
165 165 type: 'GET',
166 166 success: function(data) {
167 167 data = repoFilter(data);
168 168 self.cachedDataSource[cacheKey] = data;
169 169 query.callback({results: data.results});
170 170 },
171 171 error: function(data, textStatus, errorThrown) {
172 172 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
173 173 }
174 174 })
175 175 }
176 176 })
177 177 });
178 178
179 179 });
180 180 </script>
@@ -1,176 +1,176 b''
1 1 <div class="panel panel-default">
2 2 <div class="panel-heading">
3 3 <h3 class="panel-title">${_('Authentication Tokens')}</h3>
4 4 </div>
5 5 <div class="panel-body">
6 6 <div class="apikeys_wrap">
7 7 <p>
8 8 ${_('Each token can have a role. Token with a role can be used only in given context, '
9 9 'e.g. VCS tokens can be used together with the authtoken auth plugin for git/hg/svn operations only.')}
10 10 </p>
11 11 <table class="rctable auth_tokens">
12 12 <tr>
13 13 <th>${_('Token')}</th>
14 14 <th>${_('Scope')}</th>
15 15 <th>${_('Description')}</th>
16 16 <th>${_('Role')}</th>
17 17 <th>${_('Expiration')}</th>
18 18 <th>${_('Action')}</th>
19 19 </tr>
20 20 %if c.user_auth_tokens:
21 21 %for auth_token in c.user_auth_tokens:
22 22 <tr class="${'expired' if auth_token.expired else ''}">
23 23 <td class="truncate-wrap td-authtoken"><div class="user_auth_tokens truncate autoexpand"><code>${auth_token.api_key}</code></div></td>
24 24 <td class="td">${auth_token.scope_humanized}</td>
25 25 <td class="td-wrap">${auth_token.description}</td>
26 26 <td class="td-tags">
27 27 <span class="tag disabled">${auth_token.role_humanized}</span>
28 28 </td>
29 29 <td class="td-exp">
30 30 %if auth_token.expires == -1:
31 31 ${_('never')}
32 32 %else:
33 33 %if auth_token.expired:
34 34 <span style="text-decoration: line-through">${h.age_component(h.time_to_utcdatetime(auth_token.expires))}</span>
35 35 %else:
36 36 ${h.age_component(h.time_to_utcdatetime(auth_token.expires))}
37 37 %endif
38 38 %endif
39 39 </td>
40 40 <td class="td-action">
41 41 ${h.secure_form(h.route_path('edit_user_auth_tokens_delete', user_id=c.user.user_id), method='POST', request=request)}
42 42 ${h.hidden('del_auth_token', auth_token.user_api_key_id)}
43 43 <button class="btn btn-link btn-danger" type="submit"
44 44 onclick="return confirm('${_('Confirm to remove this auth token: %s') % auth_token.token_obfuscated}');">
45 45 ${_('Delete')}
46 46 </button>
47 47 ${h.end_form()}
48 48 </td>
49 49 </tr>
50 50 %endfor
51 51 %else:
52 52 <tr><td><div class="ip">${_('No additional auth tokens specified')}</div></td></tr>
53 53 %endif
54 54 </table>
55 55 </div>
56 56
57 57 <div class="user_auth_tokens">
58 58 ${h.secure_form(h.route_path('edit_user_auth_tokens_add', user_id=c.user.user_id), method='POST', request=request)}
59 59 <div class="form form-vertical">
60 60 <!-- fields -->
61 61 <div class="fields">
62 62 <div class="field">
63 63 <div class="label">
64 64 <label for="new_email">${_('New authentication token')}:</label>
65 65 </div>
66 66 <div class="input">
67 67 ${h.text('description', class_='medium', placeholder=_('Description'))}
68 68 ${h.hidden('lifetime')}
69 69 ${h.select('role', '', c.role_options)}
70 70
71 71 % if c.allow_scoped_tokens:
72 72 ${h.hidden('scope_repo_id')}
73 73 % else:
74 74 ${h.select('scope_repo_id_disabled', '', ['Scopes available in EE edition'], disabled='disabled')}
75 75 % endif
76 76 </div>
77 77 <p class="help-block">
78 78 ${_('Repository scope works only with tokens with VCS type.')}
79 79 </p>
80 80 </div>
81 81 <div class="buttons">
82 82 ${h.submit('save',_('Add'),class_="btn")}
83 83 ${h.reset('reset',_('Reset'),class_="btn")}
84 84 </div>
85 85 </div>
86 86 </div>
87 87 ${h.end_form()}
88 88 </div>
89 89 </div>
90 90 </div>
91 91
92 92 <script>
93 93
94 94 $(document).ready(function(){
95 95 var select2Options = {
96 96 'containerCssClass': "drop-menu",
97 97 'dropdownCssClass': "drop-menu-dropdown",
98 98 'dropdownAutoWidth': true
99 99 };
100 100 $("#role").select2(select2Options);
101 101
102 102 var preloadData = {
103 103 results: [
104 104 % for entry in c.lifetime_values:
105 105 {id:${entry[0]}, text:"${entry[1]}"}${'' if loop.last else ','}
106 106 % endfor
107 107 ]
108 108 };
109 109
110 110 $("#lifetime").select2({
111 111 containerCssClass: "drop-menu",
112 112 dropdownCssClass: "drop-menu-dropdown",
113 113 dropdownAutoWidth: true,
114 114 data: preloadData,
115 placeholder: ${_('Select or enter expiration date')},
115 placeholder: "${_('Select or enter expiration date')}",
116 116 query: function(query) {
117 117 feedLifetimeOptions(query, preloadData);
118 118 }
119 119 });
120 120
121 121
122 122 var repoFilter = function(data) {
123 123 var results = [];
124 124
125 125 if (!data.results[0]) {
126 126 return data
127 127 }
128 128
129 129 $.each(data.results[0].children, function() {
130 130 // replace name to ID for submision
131 131 this.id = this.obj.repo_id;
132 132 results.push(this);
133 133 });
134 134
135 135 data.results[0].children = results;
136 136 return data;
137 137 };
138 138
139 139 $("#scope_repo_id_disabled").select2(select2Options);
140 140
141 141 $("#scope_repo_id").select2({
142 142 cachedDataSource: {},
143 143 minimumInputLength: 2,
144 144 placeholder: "${_('repository scope')}",
145 145 dropdownAutoWidth: true,
146 146 containerCssClass: "drop-menu",
147 147 dropdownCssClass: "drop-menu-dropdown",
148 148 formatResult: formatResult,
149 149 query: $.debounce(250, function(query){
150 150 self = this;
151 151 var cacheKey = query.term;
152 152 var cachedData = self.cachedDataSource[cacheKey];
153 153
154 154 if (cachedData) {
155 155 query.callback({results: cachedData.results});
156 156 } else {
157 157 $.ajax({
158 158 url: pyroutes.url('repo_list_data'),
159 159 data: {'query': query.term},
160 160 dataType: 'json',
161 161 type: 'GET',
162 162 success: function(data) {
163 163 data = repoFilter(data);
164 164 self.cachedDataSource[cacheKey] = data;
165 165 query.callback({results: data.results});
166 166 },
167 167 error: function(data, textStatus, errorThrown) {
168 168 alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
169 169 }
170 170 })
171 171 }
172 172 })
173 173 });
174 174
175 175 });
176 176 </script>
General Comments 0
You need to be logged in to leave comments. Login now