noxoua / filament-activity-log

Add-on for simplified activity logging based on spatie package.
http://activity-log.noxo.app/
MIT License
64 stars 14 forks source link

todo #42

Open noxoua opened 10 months ago

noxoua commented 10 months ago
rahat1994 commented 10 months ago

Can I tackle items number 2 and 3?

noxoua commented 10 months ago

Can I tackle items number 2 and 3?

Of course, you can send a PR with a solution 👍

borex commented 7 months ago

As a todo, what do you think about displaying some property from subject instead of the ID for logged objects? I wanted to display the user name( or task title) in the activity list instead of the #id. So, I came up with the following code:

modified header.blade.php at line 80:

<span>#{{ $logger->getSubjectLabel($activity->subject) ?? $activity->subject_id }}</span>

modified UserLogger class:

...
class UserLogger extends Logger 
{
    public static ?string $model = User::class;

    public static function getLabel(): string | Htmlable | null
    {
        return UserResource::getModelLabel();
    }

    public static function getSubjectLabel($subject): string | Htmlable | null
    {
        return $subject?->name;
    }
...
}

I'm not sure if it's the best way of doing this, but it works for me. If you have time, please check it out and let me know if it's okay or how should I implement this feature. Maybe it can be added to the this package.

noxoua commented 7 months ago

@borex , thanks for your attention to the plugin 🙏 Your approach to display the user name or task title instead of the ID in the activity list seems effective for your specific case. But not all users of the plugin may need such a feature, so integrating it directly into the plugin might not be practical.

However, to adapt this solution for your needs, you can override/create the your-project/resources/views/vendor/filament-activity-log/list/header.blade.php file in your resources. This allows you to maintain this functionality without altering the main code of the plugin.

borex commented 6 months ago

@noxoua Thanks for your reply. I agree with what you are saying regarding other users, but the only thing that I don't like in my solution is overriding the header.blade.php file. In case this file gets modified in a newer version of the plugin I will need to keep track of it and reaply my changes again. If you would put the subject ID in a method that can be configured or overwritten then it would be much better to have the user display whatever value they want. Do you think that this could be a solution for this problem?

noxoua commented 6 months ago

@borex I rethought this and realized that you are right. Unfortunately, I don’t have enough time right now to implement this functionality. I’ll add it as soon as I can. or you can send PR. I think it's best to add a function to the logger class that all loggers extend.

noxoua commented 6 months ago

@borex added methods to the logger class - #66

borex commented 6 months ago

@noxoua Sorry, but I didn't had time to work on this. I have just checked out the new changes and it is very nice. Thank you for implementing it.

tonypartridge commented 3 months ago

@noxoua what about Encrypted values? Can you parse the casts?