chef 3744 Posted December 30, 2019 Share Posted December 30, 2019 (edited) I made this plugin quickly today because I was having issues with certain client application swamping my device lists. As you can see from the image below: The plugin will list and group all your devices saved in the Emby Database: WOW! 1394 versions of Chrome saved in the Database! Let's remove the old and insignificant ones using this plugin. Okay, now there is only one version of Chrome, which is the Client Session that is being currently run (the plugin skips over any sessions that are currently in use - We don't want to kick anyone off the server inadvertently). This is better, and the Devices page loads instantaneously after doing a little bit of browser cache clearing. Note: See how quickly Chrome tricks Emby into thinking it is a new Device Connection! Holy COW three more just added themselves since the clean up! The console will list the removed device ids in red There is a user dialog which allows for custom threshold limits with regards to what is considered too many devices stored. Fixes: -Plugin is satisfied with the amount of clients logged in the database and didn't know what do. Now it does. -Added User input Threshold limit dialog -Device removal will show in red inside the browser console - these are not errors, it it's to confusing I'll change the color to hot pink. Possible Future Updates: 1. Create a Scheduled task that will be customizable to remove specific clients automatically that are a certain age. 2. User will be able to set the threshold for what is considered "TOO MANY INSTANCES!" (Currently set to 25 instances) 3. Update Plugin UI when Devices are removed from the Database. (There is currently no UI updating - Press the Get Devices List - Button) 4. Make it pretty or something (right now it is utility, and there is no time to make it pretty). DOWNLOAD: DeviceEditor.zip Edited February 12, 2022 by Happy2Play updated link 10 3 Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 30, 2019 Share Posted December 30, 2019 Plugin Displayed name may need updating "Copy and Decompression". Don't know is beta server makes a difference, but all I get is the spinning circle when trying to get device list. Only 18 devices appear via Dashboard-Devices. Don't really see anything in the server log. 1 Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) Plugin Displayed name may need updating "Copy and Decompression". Don't know is beta server makes a difference, but all I get is the spinning circle when trying to get device list. Only 18 devices appear via Dashboard-Devices. Don't really see anything in the server log. I found the issue, thanks for that @@Happy2Play What happens when the plugin is satisfied that there isn't an abundance of extra clients in the Database? A spinning circle. Will fix immediately. Edited December 30, 2019 by chef 1 Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 30, 2019 Share Posted December 30, 2019 (edited) Are there any errors in the browser console by chance? Could be a beta thing, ApiClient is only requesting "Devices" endpoint. Sometimes it can take a while to return a large list. But 18 shouldn't take long. Ah, right... Copy and Compression, my goto copy paste plugin code. Yes configurationpage?name=DeviceEditorConfigurationPageJS&v=4.4.0.4:81 Uncaught (in promise) ReferenceError: i is not defined at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.4.0.4:81 at Map.forEach (<anonymous>) at createDeviceGroups (configurationpage?name=DeviceEditorConfigurationPageJS&v=4.4.0.4:59) at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.4.0.4:124 note I see the same on stable 4.3.1.0 Edited December 30, 2019 by Happy2Play 1 Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) Fixed it, and re-posted to the OP download link. Didn't think about making the plugin satisfied with conditions, and the "i" was a counter which was for the console. Thank you again. Edited December 30, 2019 by chef Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 30, 2019 Share Posted December 30, 2019 I don't see any change in the updated plugin. And on my stable server I have over 100 devices listed and get the same results. Uncaught (in promise) ReferenceError: i is not defined at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:81 at Map.forEach (<anonymous>) at createDeviceGroups (configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:59) at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:124 Does this plugin work for anyone else or is it just me? 1 Link to comment Share on other sites More sharing options...
Sammy 735 Posted December 30, 2019 Share Posted December 30, 2019 I'll check this out when I get a chance! Sent from my SM-G960U1 using Tapatalk 1 Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 I don't see any change in the updated plugin. And on my stable server I have over 100 devices listed and get the same results. Uncaught (in promise) ReferenceError: i is not defined at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:81 at Map.forEach (<anonymous>) at createDeviceGroups (configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:59) at configurationpage?name=DeviceEditorConfigurationPageJS&v=4.3.1.0:124 Does this plugin work for anyone else or is it just me? @@Happy2Play I've double checked the instance of the "i" counter in the javascript and put a new build at the top.. Because the plugin version doesn't change for each build, it is possible that the browser would have cached the original code and will have to be cleared. This was the first time I wrote a plugin where 90% of the conditions are figured out on the front end in the javascript instead of in the code behind. I think that is why those console errors for 'i' are not disappearing. Looking forward to seeing how you make out with all of those devices in the list. Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 30, 2019 Share Posted December 30, 2019 (edited) @@Happy2Play I've double checked the instance of the "i" counter in the javascript and put a new build at the top.. Because the plugin version doesn't change for each build, it is possible that the browser would have cached the original code and will have to be cleared. This was the first time I wrote a plugin where 90% of the conditions are figured out on the front end in the javascript instead of in the code behind. I think that is why those console errors for 'i' are not disappearing. Looking forward to seeing how you make out with all of those devices in the list. Clearing the browser cache resolved the issue. I end up with Chrome 45 devices and a Fix it button but the button doesn't do anything for me. alone with all the other named devices listed. No logging or console errors. Edited December 30, 2019 by Happy2Play 1 Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) Clearing the browser cache resolved the issue. I end up with Chrome 45 devices and a Fix it button but the button doesn't do anything for me. alone with all the other named devices listed. No logging or console errors.If you refresh the browser page and then press the button again, does it show a smaller list? The UI doesn't update, in that version, so it has removed devices from the database but it can't let you know about it yet. I fixed it in the OP download. Now the plugin will remove all the HTML and have the user press the button again to retrieve updated info. With all the JavaScript promises this was the easiest way to update the configuration html. The only other thing is the Emby devices menu doesn't update its list of devices without a media scan and a browser cache clear. Not sure how to handle that. Might just have to let emby do its thing and users will have to be patient with their device page. Edited December 30, 2019 by chef Link to comment Share on other sites More sharing options...
CBers 6742 Posted December 30, 2019 Share Posted December 30, 2019 Nice work @@chef.You can't actually delete devices via the plugin yet, as not seeing the FIX IT button on my server? Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 Nice work @@chef. You can't actually delete devices via the plugin yet, as not seeing the FIX IT button on my server? Hey thanks @@CBers, the fix it button will only appear if there are over 25 instances of the same client. Do you have a device group with more then 25 items? I do have a version here that will allow for the user to change the threshold. Link to comment Share on other sites More sharing options...
CBers 6742 Posted December 30, 2019 Share Posted December 30, 2019 I didn't, no. Had 42 in total, but all in different device groups. Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 (edited) Added user defined threshold limit dialog Also lists the removed devices in the console. If the plugin has older versions of itself installed - after adding the new version in the OP download, rerstart server and clear the browser cache to make the browser honer the new javascript code. Edited December 30, 2019 by chef 1 Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 30, 2019 Share Posted December 30, 2019 (edited) Added user defined threshold limit dialog Also lists the removed devices in the console. If the plugin has older versions of itself installed - after adding the new version in the OP download, rerstart server and clear the browser cache to make the browser honer the new javascript code. Newest version worked. Ideally I would envision devices be automatically removed after X days of inactivity. Edited December 30, 2019 by Happy2Play Link to comment Share on other sites More sharing options...
chef 3744 Posted December 30, 2019 Author Share Posted December 30, 2019 Newest version worked. Ideally I would envision devices be automatically removed after X days of inactivity. Perfect, I finished a hidden scheduled task which will run automatically every night and will look at devices dates and remove them based on user defined time spans. If that works out, is it worth requesting a catalogue entry, or maybe it's more of a 'leave it in the threads' plugin? Link to comment Share on other sites More sharing options...
CBers 6742 Posted December 30, 2019 Share Posted December 30, 2019 Added user defined threshold limit dialog Where is this setting please? Can't see it in the plugin, even after clearing browser cache and restarting Emby. Link to comment Share on other sites More sharing options...
chef 3744 Posted December 31, 2019 Author Share Posted December 31, 2019 Where is this setting please? Can't see it in the plugin, even after clearing browser cache and restarting Emby. There should be a gear icon at the top, that will open a dialog with the option. Link to comment Share on other sites More sharing options...
CBers 6742 Posted December 31, 2019 Share Posted December 31, 2019 There should be a gear icon at the top, that will open a dialog with the option. Thanks, I did not see that Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 31, 2019 Share Posted December 31, 2019 Perfect, I finished a hidden scheduled task which will run automatically every night and will look at devices dates and remove them based on user defined time spans. If that works out, is it worth requesting a catalogue entry, or maybe it's more of a 'leave it in the threads' plugin? Personally I would like to see this added to the catalog for potential update purposes. Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 31, 2019 Share Posted December 31, 2019 Is the threshold limit working @@CBers? I can't seem to get it to maintain a value. Link to comment Share on other sites More sharing options...
chef 3744 Posted December 31, 2019 Author Share Posted December 31, 2019 I have a scheduled task all laid out, but unfortunately there is no easy way to remove devices in the IDeviceManager object in the code behind. In order to remove a device, an IHttpClient (in the plugin) has to be created and authorized, which would create another device under embys Devices tab for the plugin. this seems counter productive. There is an IAuth service which might lead to a quick way to create an api_key to make requests, but I'm not sure. We'll have to wait on the scheduled task. Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 31, 2019 Share Posted December 31, 2019 I have a scheduled task all laid out, but unfortunately there is no easy way to remove devices in the IDeviceManager object in the code behind. In order to remove a device, an IHttpClient (in the plugin) has to be created and authorized, which would create another device under embys Devices tab for the plugin. this seems counter productive. There is an IAuth service which might lead to a quick way to create an api_key to make requests, but I'm not sure. We'll have to wait on the scheduled task. No worries this is a good start. Are you seeing any issues with the Threshold limit setting as it doesn't appear to do anything to me? To me the server should automatically remove devices that are inactive after X days in my opinion though. 1 Link to comment Share on other sites More sharing options...
chef 3744 Posted December 31, 2019 Author Share Posted December 31, 2019 @@Happy2Play I think I figured out that issue. Now when the "OK" button is pressed in the settings Dialog the device groups are removed from the page and the "Get Device List" button is brought to the top of the page again. After pressing the button, the threshold should be honored. I've updated the Download. Link to comment Share on other sites More sharing options...
Happy2Play 8144 Posted December 31, 2019 Share Posted December 31, 2019 (edited) @@Happy2Play I think I figured out that issue. Now when the "OK" button is pressed in the settings Dialog the device groups are removed from the page and the "Get Device List" button is brought to the top of the page again. After pressing the button, the threshold should be honored. I've updated the Download. Progress, but I don't see a Okay button in Chrome but do in FireFox. So setting it in FireFox saved the setting and was honored in Chrome. Looks like it is related to system Display Scaling. If not at 100% it pushes button out of view. Well my stable is not scaled and was still out of view in dialog box. Had ot set browser zoom to 80% to see. Edited December 31, 2019 by Happy2Play Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now