chg: [UI] Fix some bugs in user view

pull/6420/head
Jakub Onderka 2020-10-09 17:26:33 +02:00
parent 1f9737a052
commit ac3f2b11e5
7 changed files with 39 additions and 28 deletions

View File

@ -1,6 +1,6 @@
<table class="table table-striped table-hover table-condensed">
<tr>
<th><?php echo $this->Paginator->sort('id');?></th>
<th><?php echo $this->Paginator->sort('id', __('ID'));?></th>
<th><?php echo $this->Paginator->sort('org_ci', __('Org'));?></th>
<th><?php echo $this->Paginator->sort('role_id', __('Role'));?></th>
<th><?php echo $this->Paginator->sort('email');?></th>
@ -40,8 +40,8 @@
<td ondblclick="document.location ='<?php echo $this->Html->url(array('admin' => true, 'action' => 'view', $user['User']['id']), true);?>';">
<?php echo h($user['User']['email']); ?>&nbsp;
</td>
<td ondblclick="document.location ='<?php echo $this->Html->url(array('admin' => true, 'action' => 'view', $user['User']['id']), true);?>';" class="quickSelect <?php echo $user['Role']['perm_auth'] ? 'bold' : 'grey'; ?>">
<?php echo h($user['User']['authkey']); ?>&nbsp;
<td ondblclick="document.location ='<?php echo $this->Html->url(array('admin' => true, 'action' => 'view', $user['User']['id']), true);?>';" class="<?php echo $user['Role']['perm_auth'] ? 'bold' : 'grey'; ?>">
<span class="privacy-value quickSelect" data-hidden-value="<?= h($user['User']['authkey']) ?>">****************************************</span> <i class="privacy-toggle fas fa-eye useCursorPointer"></i>
</td>
<td class="short" ondblclick="document.location ='<?php echo $this->Html->url(array('admin' => true, 'action' => 'view', $user['User']['id']), true);?>';">
<?php echo $user['User']['autoalert']? __('Yes') : __('No'); ?>

View File

@ -21,8 +21,9 @@
$data = h($data);
if (!empty($field['privacy'])) {
$data = sprintf(
'<span class="privacy-value" data-hidden-value="%s">****************************************</span> <i class="privacy-toggle fas fa-eye useCursorPointer"></i>',
$data
'<span class="privacy-value quickSelect" data-hidden-value="%s">****************************************</span>&nbsp;<i class="privacy-toggle fas fa-eye useCursorPointer" title="%s"></i>',
$data,
__('Reveal hidden value')
);
}
}

View File

@ -41,7 +41,7 @@
),
'fields' => array(
array(
'name' => __('Id'),
'name' => __('ID'),
'sort' => 'id',
'class' => 'short',
'data_path' => 'User.id'
@ -65,11 +65,10 @@
'data_path' => 'User.email'
),
array(
'name' => __('authkey'),
'name' => __('Authkey'),
'sort' => 'User.authkey',
'class' => 'bold quickSelect',
'class' => 'bold',
'data_path' => 'User.authkey',
'onClick' => 'quickSelect(this);',
'privacy' => 1
),
array(

View File

@ -3,11 +3,11 @@ $buttonAddStatus = $isAclAdd ? 'button_on':'button_off';
$mayModify = ($isSiteAdmin || ($isAdmin && ($user['User']['org_id'] == $me['org_id'])));
$buttonModifyStatus = $mayModify ? 'button_on':'button_off';
$table_data = array();
$table_data[] = array('key' => __('Id'), 'value' => $user['User']['id']);
$table_data[] = array('key' => __('ID'), 'value' => $user['User']['id']);
$table_data[] = array(
'key' => __('Email'),
'html' => sprintf(
'%s <a class="icon-envelope" href="%s/admin/users/quickEmail/%s"></a>',
'%s <a class="fas fa-envelope" style="color: black" href="%s/admin/users/quickEmail/%s"></a>',
h($user['User']['email']),
$baseurl,
h($user['User']['id'])
@ -26,11 +26,11 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
$table_data[] = array('key' => __('Autoalert'), 'boolean' => $user['User']['autoalert']);
$table_data[] = array('key' => __('Contactalert'), 'boolean' => $user['User']['contactalert']);
$authkey_data = sprintf(
'<a onclick="requestAPIAccess();" style="cursor:pointer;"></a>',
'<a onclick="requestAPIAccess();" style="cursor:pointer;">%s</a>',
__('Request API access')
);
$authkey_data = sprintf(
'<span class="quickSelect">%s</span>%s',
'<span class="privacy-value quickSelect authkey" data-hidden-value="%s">****************************************</span> <i class="privacy-toggle fas fa-eye useCursorPointer"></i>%s',
h($user['User']['authkey']),
sprintf(
' (%s)',
@ -52,11 +52,14 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
)
);
}
$table_data[] = array('key' => __('Invited By'), 'value' => empty($user2['User']['email']) ? 'N/A' : $user2['User']['email']);
$table_data[] = array(
'key' => __('Invited By'),
'html' => empty($user2['User']['email']) ? 'N/A' : sprintf('<a href="%s/admin/users/view/%s">%s</a>', h($user2['User']['id']), h($user2['User']['email'])),
);
$org_admin_data = array();
foreach ($user['User']['orgAdmins'] as $orgAdminId => $orgAdminEmail) {
$org_admin_data[] = sprintf(
'<a href="%s/admin/users/view/%s">%s</a><a class="icon-envelope" href="%s/admin/users/quickEmail/%s"></a><br />',
'<a href="%s/admin/users/view/%s">%s</a> <a class="fas fa-envelope" style="color: black" href="%s/admin/users/quickEmail/%s"></a>',
$baseurl,
h($orgAdminId),
h($orgAdminEmail),
@ -64,10 +67,10 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
h($orgAdminId)
);
}
$table_data[] = array('key' => __('Org_admin'), 'html' => implode('<br />', $org_admin_data));
$table_data[] = array('key' => __('Org admin'), 'html' => implode('<br>', $org_admin_data));
$table_data[] = array('key' => __('NIDS Start SID'), 'value' => $user['User']['nids_sid']);
$table_data[] = array('key' => __('Terms accepted'), 'boolean' => $user['User']['termsaccepted']);
$table_data[] = array('key' => __('Password change'), 'boolean' => $user['User']['change_pw']);
$table_data[] = array('key' => __('Must change password'), 'boolean' => $user['User']['change_pw']);
$table_data[] = array(
'key' => __('GnuPG key'),
'element' => 'genericElements/key',
@ -92,7 +95,10 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
'element_params' => array('key' => $user['User']['certif_public']),
);
}
$table_data[] = array('key' => __('Newsread'), 'html' => $user['User']['newsread'] ? date('Y/m/d H:i:s', h($user['User']['newsread'])) : __('N/A'));
$table_data[] = array(
'key' => __('News read at'),
'value' => $user['User']['newsread'] ? date('Y-m-d H:i:s', $user['User']['newsread']) : __('N/A')
);
$table_data[] = array(
'key' => __('Disabled'),
'class' => empty($user['User']['disabled']) ? '' : 'background-red',
@ -106,7 +112,7 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
'<div class="users view row-fluid"><div class="span8" style="margin:0px;">%s%s</div>%s</div>%s',
sprintf(
'<h2>%s</h2>%s',
__('User'),
__('User %s', h($user['User']['email'])),
$this->element('genericElements/viewMetaTable', array('table_data' => $table_data))
),
sprintf(
@ -123,15 +129,15 @@ $buttonModifyStatus = $mayModify ? 'button_on':'button_off';
);
?>
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$.ajax({
url: '<?php echo $baseurl . "/events/index/searchemail:" . urlencode(h($user['User']['email'])); ?>',
type:'GET',
beforeSend: function (XMLHttpRequest) {
beforeSend: function () {
$(".loading").show();
},
error: function(){
$('#userEvents').html(__('An error has occurred, please reload the page.'));
$('#userEvents').html('An error has occurred, please reload the page.');
},
success: function(response){
$('#userEvents').html(response);

View File

@ -1,18 +1,18 @@
<?php
$table_data = array();
$table_data[] = array('key' => __('Id'), 'value' => $user['User']['id']);
$table_data[] = array('key' => __('ID'), 'value' => $user['User']['id']);
$table_data[] = array('key' => __('Email'), 'value' => $user['User']['email']);
$table_data[] = array('key' => __('Organisation'), 'value' => $user['Organisation']['name']);
$table_data[] = array('key' => __('Role'), 'html' => $this->Html->link($user['Role']['name'], array('controller' => 'roles', 'action' => 'view', $user['Role']['id'])));
$table_data[] = array('key' => __('Autoalert'), 'boolean' => $user['User']['autoalert']);
$table_data[] = array('key' => __('Contactalert'), 'boolean' => $user['User']['contactalert']);
$authkey_data = sprintf(
'<a onclick="requestAPIAccess();" style="cursor:pointer;"></a>',
'<a onclick="requestAPIAccess();" style="cursor:pointer;">%s</a>',
__('Request API access')
);
if ($user['Role']['perm_auth']) {
$authkey_data = sprintf(
'<span class="quickSelect">%s</span>%s',
'<span class="privacy-value quickSelect authkey" data-hidden-value="%s">****************************************</span> <i class="privacy-toggle fas fa-eye useCursorPointer"></i>%s',
h($user['User']['authkey']),
(Configure::read('MISP.disableUserSelfManagement') && !$isAdmin) ? '' :
sprintf(
@ -56,7 +56,7 @@
'<div class="users view"><div class="row-fluid"><div class="span8" style="margin:0px;">%s</div></div>%s</div>%s',
sprintf(
'<h2>%s</h2>%s',
__('User'),
__('User %s', h($user['User']['email'])),
$this->element('genericElements/viewMetaTable', array('table_data' => $table_data))
),
sprintf(
@ -66,4 +66,4 @@
),
$this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'globalActions', 'menuItem' => 'view'))
);
?>

View File

@ -2620,3 +2620,8 @@ table tr:hover .down-expand-button {
font-size: 100%;
width: 45em;
}
.authkey {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
font-size: 11px;
}

View File

@ -4684,7 +4684,7 @@ $(document).ready(function() {
setHomePage();
});
$('.privacy-toggle').on('click', function() {
$(document.body).on('click', '.privacy-toggle', function() {
var $this = $(this);
var $privacy_target = $this.parent().find('.privacy-value');
if ($this.hasClass('fa-eye')) {