Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dan-hammond 6 posts 76 karma points
    Nov 30, 2017 @ 10:26
    dan-hammond
    0

    logResource not returning any results

    Hi all,

    I'm trying to set up a custom dashboard by following the Creating a Custom Dashboard tutorial linked below, but have run into a problem using logResource.

    https://our.umbraco.org/documentation/Tutorials/Creating-a-Custom-Dashboard/

    I'm having trouble getting any data back from logResource using either getUserLog or getLog with the type set to "save" and the date set to various dates between now and 2000. I always get back an empty array.

    I'm using code along these lines:

    logResource.getLog( "save", new Date() )
      .then( ( response ) => {
        console.log( response );
      } );
    

    There are no errors logged in the JavaScript console.

    I have published new documents, saved edits to existing documents, and tried creating a new user and running the same tests from that account. It seems that nothing is returned under any circumstances.

    I'm using the latest version of Umbraco.

    Does anyone have any suggestions on what else I can try?

    Thanks!

  • Marc Goodson 2141 posts 14324 karma points MVP 8x c-trib
    Nov 30, 2017 @ 21:55
    Marc Goodson
    0

    Hi Dan

    Which version of Umbraco? 7.7.6 ? (An issue with the logResource was fixed in 7.6.4 - http://issues.umbraco.org/issue/U4-9489)

    have you tried:

     logResource.getUserLog("save", new Date()).then(function (response) {
            console.log(response);
    

    });

    and do you have the logResource injected into the controller?

    angular.module("umbraco").controller("CustomWelcomeDashboardController", function ($scope, userService, logResource, entityResource) {
    

    if you post your whole controller implementation can see if I can spot anything / can see if there is an issue with logResource on the version you are using.

    regards

    Marc

  • dan-hammond 6 posts 76 karma points
    Dec 01, 2017 @ 08:23
    dan-hammond
    0

    Hi Marc,

    Thanks for taking the time to reply and offer some help!

    I am indeed running Umbraco 7.6.6, and have checked the umbraco.resources.js source file to confirm that I do have the fix.

    I have tried the code you suggested, and my controller does resemble the one you have provided:

        angular.module( "umbraco" ).controller( "CustomWelcomeDashboardController",
        function( $scope, userService, logResource, entityResource ) {
            $scope.LogEntries = [];
    
            userService.getCurrentUser().then( ( user ) => {
                $scope.UserName = user.name;
            } );
    
            logResource.getUserLog( "save", new Date() ).then( ( response ) => {
                console.log( response );
            } );
        }
    )
    

    However, since testing it this morning I'm no longer getting a blank array! Unfortunately, it's not returning the items I was hoping for.

    Yesterday afternoon I made some changes to some document types and data types, so this is being returned:

        (2) [{…}, {…}]
        0: {userId: 1, nodeId: 0, timestamp: "2017-11-30T16:11:01.42", logType: 1, comment: "Save DataTypeDefinition performed by user"}
        1: {userId: 1, nodeId: 16414, timestamp: "2017-11-30T15:58:42.723", logType: 1, comment: "Save DataTypeDefinition performed by user"}
        length: 2
        __proto__: Array(0)
    

    As you can see, the accompanying changes to content do not show in the list.

    Thanks again.

  • Marc Goodson 2141 posts 14324 karma points MVP 8x c-trib
    Dec 03, 2017 @ 12:05
    Marc Goodson
    0

    Hi Dan

    This is puzzling

    I span up a copy of 7.7.6 (when you say 'latest' 7.6.6 above you mean 7.7.6?)

    Copied across a completed version of tutorial, it works, cut and paste what you have above...

    enter image description here

    also works!

    enter image description here

    save update to content item and a media item, both appear on the dashboard...

    enter image description here

    and from your snapshot of the console.log output, you can see the dashboard is retrieving items from the userLog, for userId 1, but just the two updates to the DataTypes..

    So the issue does appear to be that when you are saving an updated content item, or media item, the log of that event isn't either being made, or isn't being retrieved by getUserLog.

    If it's not making it to the log, that must be a bug (but it's working fine for me in 7.6.6) if it's the second, then the other possibility is that the SinceDate (new Date()) bit or the UserId (the current user is used by getUserLog) is filtering these events out when retrieving the log?

    Make sure you hit save, instead of save and publish, see if that makes a difference? and see what new Date() is generating on your machine, have a look in the Audit Log (right click the content item you just saved, and choose Audit Trail, and see if the action was recorded there.,..)

    regards

    Marc

  • dan-hammond 6 posts 76 karma points
    Dec 04, 2017 @ 09:06
    dan-hammond
    0

    Hi Marc,

    Thanks once again for taking the time to reply. I do indeed mean version 7.7.6 and not 7.6.6 - apologies.

    Interestingly, it now appears to be working. I now have 247 items being returned by getLog(), and 3 items being returned by getUserLog(). I've not made any changes to the project since I previously commented, so I'm not really sure why it now works.

    The only thing that has changed is that my computer has been restarted as I had it powered off over the weekend.

    I did try fiddling with new Date() to set various dates in case that was the issue when troubleshooting, but that didn't seem to make a difference.

    Also, given that getLog() doesn't require a particular user ID, and that still didn't return anything, it can't be that which was preventing the results from being returned.

    Thank you very much for taking the time to investigate this! I only wish I could provide a better explanation of what actually broke or how restarting the machine fixed it.

Please Sign in or register to post replies

Write your reply to:

Draft