|
Lines 70-76
Link Here
|
| 70 |
[% CASE 'success_on_update' %] |
70 |
[% CASE 'success_on_update' %] |
| 71 |
<span>Identity provider updated successfully.</span> |
71 |
<span>Identity provider updated successfully.</span> |
| 72 |
[% CASE 'success_on_insert' %] |
72 |
[% CASE 'success_on_insert' %] |
| 73 |
<span>Identity provider added successfully.</span> |
73 |
<div>Identity provider added successfully.</div> |
|
|
74 |
<div>You will need to restart Koha for the provider to work.</div> |
| 74 |
[% CASE %] |
75 |
[% CASE %] |
| 75 |
<span>[% m.code | html %]</span> |
76 |
<span>[% m.code | html %]</span> |
| 76 |
[% END %] |
77 |
[% END %] |
|
Lines 82-257
Link Here
|
| 82 |
|
83 |
|
| 83 |
[% IF op == 'add_form' %] |
84 |
[% IF op == 'add_form' %] |
| 84 |
<h1>New identity provider</h1> |
85 |
<h1>New identity provider</h1> |
| 85 |
<form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post"> |
86 |
<div class="page-section"> |
| 86 |
<input type="hidden" name="op" value="add" /> |
87 |
<form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post"> |
| 87 |
<fieldset class="rows"> |
88 |
<input type="hidden" name="op" value="add" /> |
| 88 |
<ol> |
89 |
<fieldset class="rows"> |
| 89 |
<li> |
90 |
<ol> |
| 90 |
<label for="code" class="required">Code: </label> |
91 |
<li> |
| 91 |
<input type="text" name="code" id="code" size="60" class="required" required="required" /> |
92 |
<label for="code" class="required">Code: </label> |
| 92 |
<span class="required">Required</span> |
93 |
<input type="text" name="code" id="code" size="60" class="required" required="required" /> |
| 93 |
</li> |
94 |
<span class="required">Required</span> |
| 94 |
<li> |
95 |
<div class="hint">Code that identifies this provider. Only alphanumeric and "_" characters are allowed</div> |
| 95 |
<label for="description" class="required">Description: </label> |
96 |
</li> |
| 96 |
<input type="text" name="description" id="description" size="60" class="required" required="required" /> |
97 |
<li> |
| 97 |
<span class="required">Required</span> |
98 |
<label for="description" class="required">Description: </label> |
| 98 |
</li> |
99 |
<input type="text" name="description" id="description" size="60" class="required" required="required" /> |
| 99 |
<li> |
100 |
<span class="required">Required</span> |
| 100 |
<label for="protocol">Protocol: </label> |
101 |
<div class="hint">User friendly name of this provider</div> |
| 101 |
<select name="protocol" id="protocol"> |
102 |
</li> |
| 102 |
<option value="OAuth">OAuth</option> |
103 |
<li> |
| 103 |
<option value="OIDC">OIDC</option> |
104 |
<label for="protocol">Protocol: </label> |
| 104 |
<!-- Not implemented yet |
105 |
<select name="protocol" id="protocol"> |
| 105 |
<option value="LDAP">LDAP</option> |
106 |
<option value="OAuth">OAuth</option> |
| 106 |
<option value="CAS">CAS</option> |
107 |
<option value="OIDC">OIDC</option> |
| 107 |
--> |
108 |
<!-- Not implemented yet |
| 108 |
</select> |
109 |
<option value="LDAP">LDAP</option> |
| 109 |
</li> |
110 |
<option value="CAS">CAS</option> |
| 110 |
</ol> |
111 |
--> |
| 111 |
</fieldset> |
112 |
</select> |
| 112 |
|
113 |
<div class="hint">Choose the protocol this external identity provider uses</div> |
| 113 |
<fieldset class="rows"> |
114 |
</li> |
| 114 |
<ol> |
115 |
</ol> |
| 115 |
<li> |
116 |
</fieldset> |
| 116 |
<div> |
117 |
|
|
|
118 |
<fieldset class="rows"> |
| 119 |
<ol> |
| 120 |
<li> |
| 117 |
<label for="config" class="required json">Configuration: </label> |
121 |
<label for="config" class="required json">Configuration: </label> |
| 118 |
<textarea name="config" id="config" class="required"></textarea> |
122 |
<textarea name="config" id="config" class="required"></textarea> |
| 119 |
<span class="required">Required</span> |
123 |
<span class="required">Required</span> |
| 120 |
</div> |
124 |
<div class="hint">Provider's main configuration. <button class="more btn btn-ligth" data-target="config"><i class="fa fa-caret-down"></i> More</button></div> |
| 121 |
<div> |
125 |
<div class="hint more-config" style="display: none"> |
| 122 |
<label></label> |
126 |
<div>This configuration differs for each protocol.</div> |
| 123 |
<button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default OAuth configuration</button> |
127 |
<div>It is recommended to add the default configuration, and then replace with appropriate values</div> |
| 124 |
</div> |
128 |
</div> |
| 125 |
</li> |
129 |
<div class="hint"> |
| 126 |
<li> |
130 |
<button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default OAuth configuration</button> |
| 127 |
<div> |
131 |
</div> |
|
|
132 |
</li> |
| 133 |
<li> |
| 128 |
<label for="mapping" class="required json">Mapping: </label> |
134 |
<label for="mapping" class="required json">Mapping: </label> |
| 129 |
<textarea name="mapping" id="mapping" class="required"></textarea> |
135 |
<textarea name="mapping" id="mapping" class="required"></textarea> |
| 130 |
<span class="required">Required</span> |
136 |
<span class="required">Required</span> |
| 131 |
</div> |
137 |
<div class="hint">Map provider's result to Koha patron's fields. <button class="more btn btn-ligth" data-target="mapping"><i class="fa fa-caret-down"></i> More</button></div> |
| 132 |
<div> |
138 |
<div class="hint more-mapping" style="display: none"> |
| 133 |
<label></label> |
139 |
<div>It is recommended to add the default mapping, and then modify to suit this provider's response</div> |
| 134 |
<button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default OAuth mapping</button> |
140 |
<div>Keys represent Koha's fields, and values represent the keys in provider's result</div> |
| 135 |
</div> |
141 |
<div>For nested values in provider's results, you can use dot separation.</div> |
| 136 |
</li> |
142 |
<div>For example, <i>firstname: "users.0.name"</i> will match the 'name' attribute of the first object in the array named 'users', and place it in 'firstname' field</div> |
| 137 |
<li> |
143 |
<div>If you plan to use auto register feature, either <i>userid</i> or <i>cardnumber</i> must be present in this mapping</div> |
| 138 |
<label for="matchpoint" class="required">Matchpoint: </label> |
144 |
</div> |
| 139 |
<select name="matchpoint" id="matchpoint" class="required"> |
145 |
<div class="hint"> |
| 140 |
<option value="email">Email</option> |
146 |
<button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default OAuth mapping</button> |
| 141 |
<option value="userid">User id</option> |
147 |
</div> |
| 142 |
<option value="cardnumber">Card number</option> |
148 |
</li> |
| 143 |
</select> |
149 |
<li> |
| 144 |
<span class="required">Required</span> |
150 |
<label for="matchpoint">Matchpoint: </label> |
| 145 |
</li> |
151 |
<select name="matchpoint" id="matchpoint"> |
| 146 |
<li> |
152 |
<option value="email">Email</option> |
| 147 |
<label for="icon_url">Icon URL: </label> |
153 |
<option value="userid">User id</option> |
| 148 |
<input type="text" name="icon_url" id="icon_url" size="60" /> |
154 |
<option value="cardnumber">Card number</option> |
| 149 |
</li> |
155 |
</select> |
| 150 |
</ol> |
156 |
<div class="hint">Koha patron's field that will be used to match provider's user with Koha's</div> |
| 151 |
</fieldset> |
157 |
<div class="hint">It must be present in mapping</div> |
| 152 |
<fieldset class="action"> |
158 |
</li> |
| 153 |
<input type="submit" value="Submit" /> |
159 |
<li> |
| 154 |
<a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a> |
160 |
<label for="icon_url">Icon URL: </label> |
| 155 |
</fieldset> |
161 |
<input type="text" name="icon_url" id="icon_url" size="60" /> |
| 156 |
</form> |
162 |
</li> |
|
|
163 |
</ol> |
| 164 |
</fieldset> |
| 165 |
<fieldset class="action"> |
| 166 |
<input type="submit" value="Submit" /> |
| 167 |
<a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a> |
| 168 |
</fieldset> |
| 169 |
</form> |
| 170 |
</div> |
| 157 |
[% END %] |
171 |
[% END %] |
| 158 |
|
172 |
|
| 159 |
[% IF op == 'edit_form' %] |
173 |
[% IF op == 'edit_form' %] |
| 160 |
<h1>Edit identity provider</h1> |
174 |
<h1>Edit identity provider</h1> |
| 161 |
<form action="/cgi-bin/koha/admin/identity_providers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
175 |
<div class="page-section"> |
| 162 |
<input type="hidden" name="op" value="edit_save" /> |
176 |
<form action="/cgi-bin/koha/admin/identity_providers.pl" id="edit_save" name="edit_save" class="validated" method="post"> |
| 163 |
<input type="hidden" name="identity_provider_id" value="[%- identity_provider.identity_provider_id | html -%]" /> |
177 |
<input type="hidden" name="op" value="edit_save" /> |
| 164 |
<fieldset class="rows"> |
178 |
<input type="hidden" name="identity_provider_id" value="[%- identity_provider.identity_provider_id | html -%]" /> |
| 165 |
<ol> |
179 |
<fieldset class="rows"> |
| 166 |
<li> |
180 |
<ol> |
| 167 |
<label for="code" class="required">Code: </label> |
181 |
<li> |
| 168 |
<input type="text" name="code" id="code" size="60" class="required" required="required" value="[%- identity_provider.code | html -%]"/> |
182 |
<label for="code" class="required">Code: </label> |
| 169 |
<span class="required">Required</span> |
183 |
<input type="text" name="code" id="code" size="60" class="required" required="required" value="[%- identity_provider.code | html -%]"/> |
| 170 |
</li> |
184 |
<span class="required">Required</span> |
| 171 |
<li> |
185 |
<div class="hint">Code that identifies this provider. Only alphanumeric and "_" characters are allowed</div> |
| 172 |
<label for="description" class="required">Description: </label> |
186 |
</li> |
| 173 |
<input type="text" name="description" id="description" size="60" class="required" required="required" value="[%- identity_provider.description | html -%]"/> |
187 |
<li> |
| 174 |
<span class="required">Required</span> |
188 |
<label for="description" class="required">Description: </label> |
| 175 |
</li> |
189 |
<input type="text" name="description" id="description" size="60" class="required" required="required" value="[%- identity_provider.description | html -%]"/> |
| 176 |
<li> |
190 |
<span class="required">Required</span> |
| 177 |
<label for="protocol">Protocol: </label> |
191 |
<div class="hint">User friendly name of this provider</div> |
| 178 |
<select name="protocol" id="protocol"> |
192 |
</li> |
| 179 |
[% IF identity_provider.protocol == 'OAuth' %] |
193 |
<li> |
| 180 |
<option value="OAuth" selected="selected">OAuth</option> |
194 |
<label for="protocol">Protocol: </label> |
| 181 |
<option value="OIDC">OIDC</option> |
195 |
<select name="protocol" id="protocol"> |
| 182 |
<!-- Not implemented yet |
196 |
[% IF identity_provider.protocol == 'OAuth' %] |
| 183 |
<option value="LDAP">LDAP</option> |
197 |
<option value="OAuth" selected="selected">OAuth</option> |
| 184 |
<option value="CAS">CAS</option> |
198 |
<option value="OIDC">OIDC</option> |
| 185 |
--> |
199 |
<!-- Not implemented yet |
| 186 |
[% ELSE %] |
200 |
<option value="LDAP">LDAP</option> |
| 187 |
<option value="OAuth">OAuth</option> |
201 |
<option value="CAS">CAS</option> |
| 188 |
<option value="OIDC" selected="selected">OIDC</option> |
202 |
--> |
| 189 |
<!-- Not implemented yet |
203 |
[% ELSE %] |
| 190 |
<option value="LDAP">LDAP</option> |
204 |
<option value="OAuth">OAuth</option> |
| 191 |
<option value="CAS">CAS</option> |
205 |
<option value="OIDC" selected="selected">OIDC</option> |
| 192 |
--> |
206 |
<!-- Not implemented yet |
| 193 |
[% END %] |
207 |
<option value="LDAP">LDAP</option> |
| 194 |
</select> |
208 |
<option value="CAS">CAS</option> |
| 195 |
</li> |
209 |
--> |
| 196 |
</ol> |
210 |
[% END %] |
| 197 |
</fieldset> |
211 |
</select> |
| 198 |
|
212 |
<div class="hint">Choose the protocol this external identity provider uses</div> |
| 199 |
<fieldset class="rows"> |
213 |
</li> |
| 200 |
<ol> |
214 |
</ol> |
| 201 |
<li> |
215 |
</fieldset> |
| 202 |
<div> |
216 |
|
|
|
217 |
<fieldset class="rows"> |
| 218 |
<ol> |
| 219 |
<li> |
| 203 |
<label for="config" class="required json">Configuration: </label> |
220 |
<label for="config" class="required json">Configuration: </label> |
| 204 |
<textarea name="config" id="config" class="required">[%- identity_provider.config | html -%]</textarea> |
221 |
<textarea name="config" id="config" class="required">[%- identity_provider.config | html -%]</textarea> |
| 205 |
<span class="required">Required</span> |
222 |
<span class="required">Required</span> |
| 206 |
</div> |
223 |
<div class="hint">Provider's main configuration. <button class="more btn btn-ligth" data-target="config"><i class="fa fa-caret-down"></i> More</button></div> |
| 207 |
<div> |
224 |
<div class="hint more-config" style="display: none"> |
| 208 |
<label></label> |
225 |
<div>This configuration differs for each protocol.</div> |
| 209 |
<button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default [%- identity_provider.protocol | html -%] configuration</button> |
226 |
<div>It is recommended to add the default configuration, and then replace with appropriate values</div> |
| 210 |
</div> |
227 |
</div> |
| 211 |
</li> |
228 |
<div class="hint"> |
| 212 |
<li> |
229 |
<button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default [%- identity_provider.protocol | html -%] configuration</button> |
| 213 |
<div> |
230 |
</div> |
|
|
231 |
</li> |
| 232 |
<li> |
| 214 |
<label for="mapping" class="required json">Mapping: </label> |
233 |
<label for="mapping" class="required json">Mapping: </label> |
| 215 |
<textarea name="mapping" id="mapping" class="required">[%- identity_provider.mapping | html -%]</textarea> |
234 |
<textarea name="mapping" id="mapping" class="required">[%- identity_provider.mapping | html -%]</textarea> |
| 216 |
<span class="required">Required</span> |
235 |
<span class="required">Required</span> |
| 217 |
</div> |
236 |
<div class="hint">Map provider's result to Koha patron's fields. <button class="more btn btn-ligth" data-target="mapping"><i class="fa fa-caret-down"></i> More</button></div> |
| 218 |
<div> |
237 |
<div class="hint more-mapping" style="display: none"> |
| 219 |
<label></label> |
238 |
<div>It is recommended to add the default mapping, and then modify to suit this provider's response</div> |
| 220 |
<button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default [%- identity_provider.protocol | html -%] mapping</button> |
239 |
<div>Keys represent Koha's fields, and values represent the keys in provider's result</div> |
| 221 |
</div> |
240 |
<div>For nested values in provider's results, you can use dot separation.</div> |
| 222 |
</li> |
241 |
<div>For example, <i>firstname: "users.0.name"</i> will match the 'name' attribute of the first object in the array named 'users', and place it in 'firstname' field</div> |
| 223 |
<li> |
242 |
<div>If you plan to use auto register feature, either <i>userid</i> or <i>cardnumber</i> must be present in this mapping</div> |
| 224 |
<label for="matchpoint" class="required">matchpoint: </label> |
243 |
</div> |
| 225 |
<select name="matchpoint" id="matchpoint" class="required"> |
244 |
<div class="hint"> |
| 226 |
[%- IF identity_provider.matchpoint == 'email' -%] |
245 |
<button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default [%- identity_provider.protocol | html -%] mapping</button> |
| 227 |
<option value="email" selected="selected">Email</option> |
246 |
</div> |
| 228 |
[%- ELSE -%] |
247 |
</li> |
| 229 |
<option value="email">Email</option> |
248 |
<li> |
| 230 |
[%- END -%] |
249 |
<label for="matchpoint">matchpoint: </label> |
| 231 |
[%- IF identity_provider.matchpoint == 'userid' -%] |
250 |
<select name="matchpoint" id="matchpoint"> |
| 232 |
<option value="userid" selected="selected">User id</option> |
251 |
[%- IF identity_provider.matchpoint == 'email' -%] |
| 233 |
[%- ELSE -%] |
252 |
<option value="email" selected="selected">Email</option> |
| 234 |
<option value="userid">User id</option> |
253 |
[%- ELSE -%] |
| 235 |
[%- END -%] |
254 |
<option value="email">Email</option> |
| 236 |
[%- IF identity_provider.matchpoint == 'cardnumber' -%] |
255 |
[%- END -%] |
| 237 |
<option value="cardnumber" selected="selected">Card number</option> |
256 |
[%- IF identity_provider.matchpoint == 'userid' -%] |
| 238 |
[%- ELSE -%] |
257 |
<option value="userid" selected="selected">User id</option> |
| 239 |
<option value="cardnumber">Card number</option> |
258 |
[%- ELSE -%] |
| 240 |
[%- END -%] |
259 |
<option value="userid">User id</option> |
| 241 |
</select> |
260 |
[%- END -%] |
| 242 |
<span class="required">Required</span> |
261 |
[%- IF identity_provider.matchpoint == 'cardnumber' -%] |
| 243 |
</li> |
262 |
<option value="cardnumber" selected="selected">Card number</option> |
| 244 |
<li> |
263 |
[%- ELSE -%] |
| 245 |
<label for="icon_url">Icon URL: </label> |
264 |
<option value="cardnumber">Card number</option> |
| 246 |
<input type="text" name="icon_url" id="icon_url" size="60" value="[%- identity_provider.icon_url | html -%]"/> |
265 |
[%- END -%] |
| 247 |
</li> |
266 |
</select> |
| 248 |
</ol> |
267 |
<div class="hint">Koha patron's field that will be used to match provider's user with Koha's</div> |
| 249 |
</fieldset> |
268 |
<div class="hint">It must be present in mapping</div> |
| 250 |
<fieldset class="action"> |
269 |
</li> |
| 251 |
<input type="submit" value="Submit" /> |
270 |
<li> |
| 252 |
<a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a> |
271 |
<label for="icon_url">Icon URL: </label> |
| 253 |
</fieldset> |
272 |
<input type="text" name="icon_url" id="icon_url" size="60" value="[%- identity_provider.icon_url | html -%]"/> |
| 254 |
</form> |
273 |
</li> |
|
|
274 |
</ol> |
| 275 |
</fieldset> |
| 276 |
<fieldset class="action"> |
| 277 |
<input type="submit" value="Submit" /> |
| 278 |
<a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a> |
| 279 |
</fieldset> |
| 280 |
</form> |
| 281 |
</div> |
| 255 |
[% END %] |
282 |
[% END %] |
| 256 |
|
283 |
|
| 257 |
[% IF op == 'list' %] |
284 |
[% IF op == 'list' %] |
|
Lines 261-277
Link Here
|
| 261 |
</div> |
288 |
</div> |
| 262 |
|
289 |
|
| 263 |
<h1>Identity providers</h1> |
290 |
<h1>Identity providers</h1> |
| 264 |
|
291 |
<div class="page-section"> |
| 265 |
<table id="identity_providers"> |
292 |
<table id="identity_providers"> |
| 266 |
<thead> |
293 |
<thead> |
| 267 |
<tr> |
294 |
<tr> |
| 268 |
<th>Code</th> |
295 |
<th>Code</th> |
| 269 |
<th>Description</th> |
296 |
<th>Description</th> |
| 270 |
<th>Protocol</th> |
297 |
<th>Protocol</th> |
| 271 |
<th data-class-name="actions noExport">Actions</th> |
298 |
<th data-class-name="actions noExport">Actions</th> |
| 272 |
</tr> |
299 |
</tr> |
| 273 |
</thead> |
300 |
</thead> |
| 274 |
</table> |
301 |
</table> |
|
|
302 |
</div> |
| 275 |
[% END %] |
303 |
[% END %] |
| 276 |
|
304 |
|
| 277 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
305 |
<div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> |
|
Lines 397-410
Link Here
|
| 397 |
}); |
425 |
}); |
| 398 |
|
426 |
|
| 399 |
$.validator.addMethod('json', function(value, element) { |
427 |
$.validator.addMethod('json', function(value, element) { |
| 400 |
if (this.optional(element)) return true; |
428 |
if (this.optional(element) && value === '') return true; |
| 401 |
try { |
429 |
try { |
| 402 |
JSON.parse(value) |
430 |
JSON.parse(value) |
| 403 |
} catch (error) { |
431 |
} catch (error) { |
| 404 |
return false; |
432 |
return false; |
| 405 |
} |
433 |
} |
| 406 |
return true; |
434 |
return true; |
| 407 |
}, _('Not a valid JSON')); |
435 |
}, _("Not a valid JSON")); |
|
|
436 |
|
| 437 |
$.validator.addMethod('alphanum', function(value, element) { |
| 438 |
if (this.optional(element) && value === '') return true; |
| 439 |
return /^[a-zA-Z0-9_]+$/.test(value); |
| 440 |
}, _("Value must have alphanumeric characters or '_'")); |
| 408 |
|
441 |
|
| 409 |
$('#config, #mapping').each(function() { |
442 |
$('#config, #mapping').each(function() { |
| 410 |
$(this).rules('add', { |
443 |
$(this).rules('add', { |
|
Lines 413-418
Link Here
|
| 413 |
}); |
446 |
}); |
| 414 |
}); |
447 |
}); |
| 415 |
|
448 |
|
|
|
449 |
$('button.more').on('click', function(event) { |
| 450 |
event.preventDefault(); |
| 451 |
var target = $(this).hide().data('target'); |
| 452 |
$('.more-'+target).show(); |
| 453 |
}); |
| 454 |
|
| 455 |
$('#code').rules('add', { |
| 456 |
alphanum: true, |
| 457 |
required: true |
| 458 |
}); |
| 459 |
|
| 416 |
var defaults = { |
460 |
var defaults = { |
| 417 |
OIDC: { |
461 |
OIDC: { |
| 418 |
config: { |
462 |
config: { |
|
Lines 424-430
Link Here
|
| 424 |
mapping: { |
468 |
mapping: { |
| 425 |
email: "email", |
469 |
email: "email", |
| 426 |
given_name: "firstname", |
470 |
given_name: "firstname", |
| 427 |
family_name: "surname" |
471 |
family_name: "surname" |
| 428 |
} |
472 |
} |
| 429 |
}, |
473 |
}, |
| 430 |
OAuth: { |
474 |
OAuth: { |
|
Lines 439-463
Link Here
|
| 439 |
mapping: { |
483 |
mapping: { |
| 440 |
email: "email", |
484 |
email: "email", |
| 441 |
firstname: "given_name", |
485 |
firstname: "given_name", |
| 442 |
surname: "family_name" |
486 |
surname: "family_name" |
| 443 |
} |
487 |
} |
| 444 |
} |
488 |
} |
| 445 |
}; |
489 |
}; |
| 446 |
|
490 |
|
| 447 |
$('#protocol').on('change', function() { |
491 |
$('#protocol').on('change', function() { |
| 448 |
var protocol = $(this).val(); |
492 |
var protocol = $(this).val(); |
| 449 |
$('#default-config').html(_('Add default %s configuration').format(protocol)); |
493 |
$('#default-config').html(_("Add default %s configuration").format(protocol)); |
| 450 |
$('#default-mapping').html(_('Add default %s mapping').format(protocol)); |
494 |
$('#default-mapping').html(_("Add default %s mapping").format(protocol)); |
| 451 |
}); |
495 |
}); |
| 452 |
|
496 |
|
| 453 |
$('button.defaults').on('click', function(event) { |
497 |
$('button.defaults').on('click', function(event) { |
| 454 |
event.preventDefault(); |
498 |
event.preventDefault(); |
| 455 |
var target = $(this).data('defaultTarget'); |
499 |
var target = $(this).data('defaultTarget'); |
| 456 |
if($('#'+target).html() !== '' && !confirm(_('Are you sure you want to replace current %s contents?').format(target))) { |
500 |
if($('#'+target).val() !== '' && !confirm(_("Are you sure you want to replace current %s contents?").format(target))) { |
| 457 |
return; |
501 |
return; |
| 458 |
} |
502 |
} |
| 459 |
var protocol = $('#protocol').val(); |
503 |
var protocol = $('#protocol').val(); |
| 460 |
$('#'+target).html(JSON.stringify(defaults[protocol][target], null, 2)); |
504 |
$('#'+target).val(JSON.stringify(defaults[protocol][target], null, 2)); |
| 461 |
}) |
505 |
}) |
| 462 |
}); |
506 |
}); |
| 463 |
</script> |
507 |
</script> |