chg: [UI] Use quick click select for new generated authkey

pull/6586/head
Jakub Onderka 2020-11-15 10:49:13 +01:00
parent 035a7e99de
commit b7c01e262a
3 changed files with 14 additions and 19 deletions

View File

@ -8,8 +8,8 @@
</div>
<div class="modal-body modal-body-long">
<p><?= __('Please make sure that you note down the authkey below, this is the only time the authkey is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<p><?=__('MISP will use the first and the last 4 digit for identification purposes.')?></p>
<p><?= sprintf('%s: <span class="bold">%s</span>', __('Authkey'), h($entity['AuthKey']['authkey_raw'])) ?></p>
<p><?=__('MISP will use the first and the last 4 characters for identification purposes.')?></p>
<pre class="quickSelect"><?= h($entity['AuthKey']['authkey_raw']) ?></pre>
</div>
<div class="modal-footer">
<a href="<?= $referer ?>" class="btn btn-primary"><?= __('I have noted down my key, take me back now') ?></a>
@ -20,8 +20,8 @@
?>
<h4><?= __('Authkey created'); ?></h4>
<p><?= __('Please make sure that you note down the authkey below, this is the only time the authkey is shown in plain text, so make sure you save it. If you lose the key, simply remove the entry and generate a new one.'); ?></p>
<p><?=__('MISP will use the first and the last 4 digit for identification purposes.')?></p>
<p><?= sprintf('%s: <span class="bold">%s</span>', __('Authkey'), h($entity['AuthKey']['authkey_raw'])) ?></p>
<p><?=__('MISP will use the first and the last 4 characters for identification purposes.')?></p>
<pre class="quickSelect"><?= h($entity['AuthKey']['authkey_raw']) ?></pre>
<a href="<?= $referer ?>" class="btn btn-primary"><?= __('I have noted down my key, take me back now') ?></a>
<?php
}

View File

@ -67,9 +67,8 @@
array(
'name' => __('Authkey'),
'sort' => 'User.authkey',
'class' => 'bold',
'class' => 'bold quickSelect',
'data_path' => 'User.authkey',
'onClick' => 'quickSelect(this);',
'privacy' => 1,
'requirement' => empty(Configure::read('Security.advanced_authkeys'))
),

View File

@ -4697,14 +4697,6 @@ function checkNoticeList(type) {
}
function quickSelect(target) {
var range = document.createRange();
var selection = window.getSelection();
range.selectNodeContents(target);
selection.removeAllRanges();
selection.addRange(range);
}
$(document).ready(function() {
// Show popover for disabled input that contains `data-disabled-reason`.
$('input:disabled[data-disabled-reason]').popover("destroy").popover({
@ -4750,11 +4742,6 @@ $(document).ready(function() {
url: baseurl + '/admin/roles/set_default/' + (state ? id : ""),
});
});
// clicking on an element with this class will select all of its contents in a
// single click
$('.quickSelect').click(function() {
quickSelect(this);
});
$('.add_object_attribute_row').click(function() {
var template_id = $(this).data('template-id');
var object_relation = $(this).data('object-relation');
@ -4854,6 +4841,15 @@ $(document.body).on('keydown', 'textarea', function(e) {
}
});
// Clicking on an element with this class will select all of its contents in a single click
$(document.body).on('click', '.quickSelect', function() {
var range = document.createRange();
var selection = window.getSelection();
range.selectNodeContents(this);
selection.removeAllRanges();
selection.addRange(range);
});
function queryEventLock(event_id, user_org_id) {
if (tabIsActive) {
$.ajax({