JustArchiNET / ArchiSteamFarm

C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
Apache License 2.0
11.24k stars 1.05k forks source link

Implemented native web GUI support for plugins inside the ASF IPC. Closes #2876 #2877

Closed fazelukario closed 1 year ago

fazelukario commented 1 year ago

Checklist

Changes

New functionality

Added native web GUI support for custom plugins inside the ASF IPC

Changed functionality

None

Removed functionality

None

Additional info

ref #2876

JustArchi commented 1 year ago

Also, remove ASF-ui change from this PR, looks like a mistake on your part.

fazelukario commented 1 year ago

Also, remove ASF-ui change from this PR, looks like a mistake on your part.

Yes, seems visual studio git module f*cked up.

fazelukario commented 1 year ago

I still don't like how we hardcode /plugins into a path and make assumption on it based on the name of the parent directory. I can have plugins/MyPlugin/static/www2 and want to host it under /admin for example.

If we can't make it work generically, then we need new plugin interface that exposes to us under what path it wants its www served.

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

  • string PhysicalPath which defaults to www.
  • string WebPath which defaults to /.

Then we should change existing code to firstly, evaluate only IWebInterface plugins (rather than all), evaluate if Path.Combine() for assembly location and PhysicalPath exists, if yes, add default and static files under WebPath.

Okay, I'll try to do that today.

Rudokhvist commented 1 year ago

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

If we are adding new interface, maybe we should add some indication for ASF-ui after all, like fazelukario suggested before? Maybe add some field to /Api/Plugins endpoint, like implements with array of implemented interfaces? Or just a bool "haswebui" for IWebInterface only.

JustArchi commented 1 year ago

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

If we are adding new interface, maybe we should add some indication for ASF-ui after all, like fazelukario suggested before? Maybe add some field to /Api/Plugins endpoint, like implements with array of implemented interfaces? Or just a bool "haswebui" for IWebInterface only.

In standalone PR, one thing at a time, we don't need to do 1000 things at a time, that'll be standalone follow-up enhancement (if we determine it wanted).

But yes, it's good idea to expose plugins and their WebPaths to ASF-ui.

fazelukario commented 1 year ago

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

If we are adding new interface, maybe we should add some indication for ASF-ui after all, like fazelukario suggested before? Maybe add some field to /Api/Plugins endpoint, like implements with array of implemented interfaces? Or just a bool "haswebui" for IWebInterface only.

We don't need this, since /API/Plugins already fills this need with the ability to serialize additional properties, so ASF-ui can simply check if the WebPath property exists and use it.

fazelukario commented 1 year ago

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

  • string PhysicalPath which defaults to www.
  • string WebPath which defaults to /.

@JustArchi Didn't quite understand how I can make an interface with optional values with defaults, maybe you mean abstract class like OfficialPlugin?

JustArchi commented 1 year ago

Plugin interface should be probably named IWebInterface, inherit from IPlugin and require implementation of two properties, both optional:

  • string PhysicalPath which defaults to www.
  • string WebPath which defaults to /.

@JustArchi Didn't quite understand how I can make an interface with optional values with defaults, maybe you mean abstract class like OfficialPlugin?

https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/ https://learn.microsoft.com/dotnet/csharp/advanced-topics/interface-implementation/default-interface-methods-versions

JustArchi commented 1 year ago

@Abrynos @Ryzhehvost feel free to review.

fazelukario commented 1 year ago

@JustArchi @Abrynos @Ryzhehvost Done with feedback, feel free to review.

Rudokhvist commented 1 year ago

LGTM. IWebInterface should probably have self-documentation comments for properties, but that's not a show-stopper.

fazelukario commented 1 year ago

LGTM. IWebInterface should probably have self-documentation comments for properties, but that's not a show-stopper.

Yes, I forgot about this, but I think it would be better if @JustArchi documented this as I'm not very good at writing user friendly documentation.

JustArchi commented 1 year ago

Enough of chit-chat, time to merge that in!

Thanks again :trophy: