Jump to content

Emby.web.genericedit nuget missing?


bakes82

Recommended Posts

In the sample sdk projects the GenericEditDemo has a reference to a nuget thats not published so it wont compile, also the "templates" and docs dont talk about generating any UI stuff which I assume this generic edit demo is trying to simplify? @softworkz

Link to comment
Share on other sites

14 hours ago, bakes82 said:

In the sample sdk projects the GenericEditDemo has a reference to a nuget thats not published so it wont compile, also the "templates" and docs dont talk about generating any UI stuff which I assume this generic edit demo is trying to simplify? @softworkz

@bakes82- This project had accidentally slipped into the release SDK. GenericEdit is only supported in the beta server and with the beta SDK: https://betadev.emby.media/

Sorry for the confusion!

Link to comment
Share on other sites

@softworkzI got it compile with the .38.  Is there a way to select multi folders/file?  I didnt want to make a custom select, when it seems like it would just be easier to extend the Folder/File pickers?

Link to comment
Share on other sites

6 minutes ago, bakes82 said:

Is there a way to select multi folders/file? 

Not from the picker. But you could create a list/repeated sub-view to which you can always add one more empty element which would allow to add another file (by opening the picker again).

Edited by softworkz
Link to comment
Share on other sites

The path would be something like this:

  • From the "Child Option" class, remove the title and the "Import Mode" selection
  • Apply the Emby SDK Reference: AutoPostBackAttribute to the file path property, so you get a server roundtrip on each change
  • At the server, change the items of the collection, so you provide always one additional (empty) item ("Child Option")
Link to comment
Share on other sites

I just noticed that there's a bug at the client side for which it doesn't dynamically change the item count.

But here's an example for how it's supposed to work. Based in the example project,....

Change ChildOptionExample to this:

namespace EmbyPluginUiDemo.Model
{
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;

    using Emby.Web.GenericEdit;

    using MediaBrowser.Model.Attributes;
    using IEditableObject = MediaBrowser.Model.GenericEdit.IEditableObject;

    public class ChildOptionExample : EditableOptionsBase
    {
        public override string EditorTitle => "";

        [DisplayName("")]
        [EditFilePicker]
        [AutoPostBack("PostBack", nameof(File))]
        public string File { get; set; }
    }

    public class ChildOptionExampleCollection : 
        List<ChildOptionExample>,
        IEditableObjectCollection,
        IEnumerable<ChildOptionExample>,
        IEnumerable
    {
        public ChildOptionExampleCollection()
        {
        }

        public ChildOptionExampleCollection(IEnumerable<ChildOptionExample> collection)
            : base(collection)
        {
        }

        public ChildOptionExampleCollection(int capacity)
            : base(capacity)
        {
        }

        IEnumerator<IEditableObject> IEnumerable<IEditableObject>.GetEnumerator() => (IEnumerator<IEditableObject>) this.GetEnumerator();
        IEnumerator<ChildOptionExample> IEnumerable<ChildOptionExample>.GetEnumerator() => (IEnumerator<ChildOptionExample>) this.GetEnumerator();

        IEnumerator IEnumerable.GetEnumerator() => (IEnumerator) this.GetEnumerator();
    }

}

 

Change NestingPageView to this:

namespace EmbyPluginUiDemo.UI.Nesting
{
    using System.Threading.Tasks;
    using Emby.Media.Common.Extensions;
    using EmbyPluginUiDemo.Model;
    using EmbyPluginUiDemo.UIBaseClasses.Views;

    using MediaBrowser.Model.Plugins;
    using MediaBrowser.Model.Plugins.UI.Views;

    internal class NestingPageView : PluginPageView
    {
        public NestingPageView(PluginInfo pluginInfo)
        : base(pluginInfo.Id)
        {
            this.ContentData = new NestingUI();
        }

        public NestingUI NestingUI => this.ContentData as NestingUI;

        public override bool IsCommandAllowed(string commandKey)
        {
            if (commandKey == "PostBack")
            {
                return true;
            }

            return base.IsCommandAllowed(commandKey);
        }

        public override Task<IPluginUIView> RunCommand(string itemId, string commandId, string data)
        {
            if (commandId == "PostBack")
            {
                this.NestingUI.Collection.RemoveAll(e => ((ChildOptionExample)e).File.IsNullOrEmpty());
                this.NestingUI.Collection.Add(new ChildOptionExample());
                return Task.FromResult((IPluginUIView)this);
            }

            return base.RunCommand(itemId, commandId, data);
        }
    }
}

 

And in NestingUI, change the Collection property to this:

 

        [DisplayName("Dynamic Collection of Child Options")]
        public ChildOptionExampleCollection Collection { get; set; } = new ChildOptionExampleCollection
                                                                   {
                                                                       new ChildOptionExample(),
                                                                   };

 

I'll try to get the client issue fixed asap.

Link to comment
Share on other sites

The visibility toggle on  Enum DisplayName titles seems broken

 

        [DisplayName("The list id from MDBList website")]
        [Description("This is found by hovering over the \"Create your Movie Filter\" button and looking at the ?list= parameter in the URL.")]
        [Required]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public int ListId { get; set; }
        
        [DisplayName("Type of items in the list")]
        [Required]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public ChannelListMediaType ListMediaType { get; set; }

        [DisplayName("Rating of channel")]
        [Required]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public ChannelParentalRating ChannelRating { get; set; } = ChannelParentalRating.Adult;


image.png.7cdb85236bda8e1298ab2654c337734d.png

Link to comment
Share on other sites

21 minutes ago, bakes82 said:

The visibility toggle on  Enum DisplayName titles seems broken

Ah, right, the structure of the select element has changed. It will be fixed in the next update.

Thanks

Link to comment
Share on other sites

@softworkzIm not sure if this is related to the nuget version, but the plugin values dont seem to persist on UI, unless you restart the server.  IE I check a box, press save, the UI says saved, refresh the screen, box is unchcked, restart server, value on ui is now checked.

I tested this on the plugin demo and my plug.  Maybe its just late for me but something seems up

Link to comment
Share on other sites

7 hours ago, bakes82 said:

@softworkzIm not sure if this is related to the nuget version, but the plugin values dont seem to persist on UI, unless you restart the server.  IE I check a box, press save, the UI says saved, refresh the screen, box is unchcked, restart server, value on ui is now checked.

I tested this on the plugin demo and my plug.  Maybe its just late for me but something seems up

Which page of the demo plugin did you try with?

It works for me on the first tab at least:

image.png.cf93360845107600a342ff2f47c1ee90.png

 

When I change the checkboxes and refresh the page without saving, I get the check states from before.
When I change the checkboxes and save, then refresh the page, I get saved check states.

When I restart the server, the values are back to defaults (because the demo plugin does not persist those values).

Do you mean a different view?

Edited by softworkz
Link to comment
Share on other sites

Well Im starting with a "basic" UI for now, I didnt think I need like a "page" and its like the values are saving, its just not reloading them?  Maybe I missed an override someplace to load it? @softworkz
image.thumb.gif.bc1f6e309e97b33ff7eacd87737709f1.gif

 

public class PluginOptions : EditableOptionsBase
    {
        public override string EditorTitle => "MDBLists Channel MDBListsPlugin Options";

        [DisplayName("MDBList Api Key")]
        [Description("Api key from MDBList website")] 
        [Required]
        public string ApiKey { get; set; }
        
        [DisplayName("Channel 1")]
        public MdbListChannel Channel1 { get; set; } = new MdbListChannel();
    }

public class MdbListChannel: EditableOptionsBase
    {
        public override string EditorTitle => "Channel Configuration";

        [DisplayName("Enable channel")]
        public bool Enabled { get; set; } = false;
        
        [DisplayName("Display name of the channel")]
        [Required]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public string ChannelName { get; set; }
        
        [DisplayName("The list id from MDBList website")]
        [Description("This is found by hovering over the \"Create your Movie Filter\" button and looking at the ?list= parameter in the URL, or by looking for listId in the page source.")]
        [Required]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public int ListId { get; set; }

        [DisplayName("Type of items in the list")]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public ChannelListMediaType ListMediaType { get; set; } = ChannelListMediaType.Movie;

        [DisplayName("Rating of channel")]
        [VisibleCondition(nameof(Enabled), SimpleCondition.IsTrue)]
        public ChannelParentalRating ChannelRating { get; set; } = ChannelParentalRating.Adult;
    }

 

Edited by bakes82
Link to comment
Share on other sites

@softworkzYes

 

public class MDBListsPlugin : BasePluginSimpleUI<PluginOptions>, IHasThumbImage
    {
        /// <summary>The MDBListsPlugin ID.</summary>
        private readonly Guid _id = new Guid("E7CCDD69-8EC3-41EE-93C5-48CD12441933");

        private readonly ILogger _logger;

        /// <summary>Initializes a new instance of the <see cref="MDBListsPlugin" /> class.</summary>
        /// <param name="applicationHost">The application host.</param>
        /// <param name="logManager">The log manager.</param>
        public MDBListsPlugin(IApplicationHost applicationHost, ILogManager logManager) : base(applicationHost)
        {
            _logger = logManager.GetLogger(Name);
            _logger.Info("My _mdbListsPlugin ({0}) is getting loaded", Name);
        }

        /// <summary>Gets the description.</summary>
        /// <value>The description.</value>
        public override string Description => "Generate channels from MDBLists";

        /// <summary>Gets the unique id.</summary>
        /// <value>The unique id.</value>
        public override Guid Id => _id;

        /// <summary>Gets the name of the _mdbListsPlugin</summary>
        /// <value>The name.</value>
        public override sealed string Name => "MDBLists Channels";

        /// <summary>Gets the thumb image format.</summary>
        /// <value>The thumb image format.</value>
        public ImageFormat ThumbImageFormat => ImageFormat.Png;
        
        /// <summary>Gets the plugin options.</summary>
        /// <returns>The plugin options.</returns>
        public PluginOptions GetPluginOptions()
        {
            return GetOptions();
        }

        /// <summary>Gets the thumb image.</summary>
        /// <returns>An image stream.</returns>
        public Stream GetThumbImage()
        {
            var type = GetType();
            return type.Assembly.GetManifestResourceStream(type.Namespace + ".ThumbImage.png");
        }
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...