Support from Acquia helps fund testing for Drupal Acquia logo

Comments

VBN created an issue. See original summary.

VBN’s picture

Any information?

star-szr’s picture

Version: 8.x-1.0 » 8.x-1.x-dev
Component: Documentation » Code
Category: Support request » Feature request
Related issues: +#1402266: Login History Views integration

@VBN there's no views integration right now for the 8.x version. The 7.x version has a patch for this. I haven't looked at the Views API in D8 to know how/similar different it may be. Patches are welcome :)

DarkstarTom’s picture

I was very interested in this module until I found there was no views integration. Please add this, thanks!

gnuget’s picture

Status: Active » Needs review
FileSize
2.65 KB

Here a patch with the integration.

Prashant.c’s picture

Status: Needs review » Needs work
FileSize
87.54 KB

@gnuget

Great initiative, your patch applies cleanly but it does not seem to be working.
It does not create new group in the views called "Login History" therefore fields are also not available in the views.

Module version : 8.x-1.x
Drupal core version: 8.6.x

Prashant.c’s picture

Status: Needs work » Needs review
FileSize
111.24 KB
2.64 KB
463 bytes

@gnuget

Nice work..!!

Sorry my bad i was testing without clearing the cache :).

I tested it again and it works fine, group is also created while creating the view and fields are also available and working fine.
I have made changes to the views group name changing it to Login History the patch for consistency purpose and more clarification for the developers/users while creating views for Login history.

Thanks.

gnuget’s picture

Hi.

I just reused the same comments from the D7 version thanks for improvement.

If it worked for you, can you please change the status to RTBC?

Thanks!

nkoporec’s picture

Tested the patch, although the patch works as described there is coding standard issues.It's common practice that all views hooks should be implemented in views.inc file.Applying a new patch which moves the code in views.inc file.

Janez Zibelnik’s picture

Tested the patch provided by @nkoporec. Works as expected.

gnuget’s picture

It is almost ready, just needs an extra empty line at the end of the file.

+  return $data;
+}
\ No newline at end of file
Prashant.c’s picture

@gnuget

Please make the change then we can put the issue into RTBC and wait for the maintainers of the module for their review and commit.

johnnydarkko’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.54 KB
270 bytes

Here's a reroll of the patch from #9 with the coding standards fix suggested in #11.
Updating the status to RTBC as requested in #12.

brooke_heaton’s picture

I'm a bit confused on this patch. I have a view of users and want to display their login history however I:

  1. Do not see the ability to add Login History fields
  2. Do not see the ability to add a relationship to Login History

Am I doing something wrong, or is the views integration limited to just login data?

brooke_heaton’s picture

Ok, so I think we really need to add a relationship handler to this module. It should be possible to add a Relationship to Login History when displaying users. I'm not sure if we need a full plugin here or just a hook_views_data_alter like thus:

/**
 * Implements hook_views_data_alter().
 */
function login_history_views_data_alter(array &$data)
{
  $data['users']['login_history'] = [
    'title' => t('Logins'),
    'help' => t('Relate a user to historical logins'),
    'relationship' => [
      'id' => 'standard',
      'group' => 'Login History',
      'base' => 'login_history',
      'base field' => 'uid',
      'relationship field' => 'uid',
      'handler' => 'standard',
      'label' => t('Logins'),
      'field' => 'uid'
    ],
  ];
}
KapilV’s picture

Issue tags: +views integration
jcnventura’s picture

RTBC++

  • johnnydarkko authored 7333a23 on 8.x-1.x
    Issue #2727711 by Prashant.c, johnnydarkko, gnuget, nkoporec, jcnventura...
jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.