Jump to content

New Plugin - Disk Space


chef

Recommended Posts

5e4758f4132af_cool.png

 

Look what I got working' LOL!


var ApiClient = () => {
    getJSON((endpoint) => {
        return new Promise((resolve, reject) => {
            var url = window.location.href.split("/web")[0] + "/emby";
            var xhr = new XMLHttpRequest();
            xhr.open('GET', url + endpoint, true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = () => {
                xhr.status === 200 ? resolve(JSON.parse(xhr.responseText)) : reject(xhr.status);
            }
            xhr.send();
        });
    })
}

ready(".localUrl", (element) => {
        var totalStorageNode = document.createElement('p');
        totalStorageNode.id = 'totalStorage';
        element.parentNode.insertBefore(totalStorageNode, element);

        ApiClient.getJSON('/GetTotalStorage').then((json) => {
            totalStorageNode.innerHTML = 'Total Drive Storage: ' + json['Used'] + '\\' + json['Total'];
        });
});

(function(win) {
    'use strict';
    
     var listeners = [],
        doc = win.document,
        MutationObserver = win.MutationObserver || win.WebKitMutationObserver,
        observer;



    function ready(selector, fn) {
        // Store the selector and callback to be monitored
        listeners.push({
            selector: selector,
            fn: fn
        });
        if (!observer) {
            // Watch for changes in the document
            observer = new MutationObserver(function(mutations) {

                check()
            });
            observer.observe(doc.documentElement, {
                childList: true,
                subtree: true,
                attributes: true,
                attributeOldValue: true,
            });
        }
        // Check if the element is currently in the DOM
        check();
    }



    function check() {
        // Check the DOM for elements matching a stored selector
        for (var i = 0, len = listeners.length, listener, elements; i < len; i++) {
            listener = listeners[i];
            // Query for elements matching the specified selector
            elements = doc.querySelectorAll(listener.selector);
            for (var j = 0, jLen = elements.length, element; j < jLen; j++) {
                element = elements[j];

                // Make sure the callback isn't invoked with the 
                // same element more than once
                if (!element.ready) {
                    element.ready = true;
                    // Invoke the callback with the element
                    listener.fn.call(element, element);
                }
            }
        }
    }    
    win.ready = ready;
})(this);

LOL! 

Link to comment
Share on other sites

maegibbons

Since the last update i am getting false alerts all the time. I have not been in to the config for ages. Do i need to re setup the plugin because of the changes?

 

Krs

 

Mark

 

Sent from my SM-N976B using Tapatalk

  • Like 1
Link to comment
Share on other sites

Dibbes

Since the last update i am getting false alerts all the time. I have not been in to the config for ages. Do i need to re setup the plugin because of the changes?

 

Looks like it's the wrong way around

 

5e47ab6171761_Untitled.png

Link to comment
Share on other sites

I would reconfigure the drives.

 

@@Dibbes you have made the threshold 15 GB, which means that anything over 15GB is going to alert you.

 

@@maegibbons make sure you also have the amount of gigs (which would be almost the whole drive) properly configured.

 

@@Spaceboy what are your thresholds limits set to?

 

If you guys want I can make an option which looks at the limit from the full drive instead of the empty one.

 

I see whats happening there are two ways to look at a threshold limit:

 

1. Is the actually limit in GB where if the available space exceeds the set limit (example: Cbers uses 756GB, anything over that is exceeded)

 

2. The amount of space left on the drive. (example: 10GB left as freespace on the drive, anything under the 10GB limit would be exceeded)

 

This is how to fix it:

 

input Max value equals drive total space

 

 

A label needs to be added to the threshold input which explains that it is the exact number in GBs to monitor for.

 

That should fix this problem.

Edited by chef
Link to comment
Share on other sites

Dibbes

@@chef That doesn't make sense to me, mate... If I put 150GB as a threshold I would expect that I'd get an alert when the free space goes below that 150GB

  • Like 2
Link to comment
Share on other sites

@@chef That doesn't make sense to me, mate... If I put 150GB as a threshold I would expect that I'd get an alert when the free space goes below that 150GB

Okay, I can change it back.

  • Like 1
Link to comment
Share on other sites

I have changed it back to the amount of space left of the drive before notifications sent. I believe it is properly coded.

 

Please let me know if you get rogue notifications so I can fix it quickly.

 

thanks so much to everyone :)

  • Like 3
Link to comment
Share on other sites

CBers

Just to throw a spanner in the works, but there's no way to configure the threshold in the mobile Chrome browser when in LINE chart mode.

 

It's OK in the PIE chart.

 

Thanks :)

Link to comment
Share on other sites

Just to throw a spanner in the works, but there's no way to configure the threshold in the mobile Chrome browser when in LINE chart mode.

 

It's OK in the PIE chart.

 

Thanks :)

Do you mean the table view? Is that because the table view hasn't been set up for mobile and you can't access the button?

 

Just want to make sure I understand.

  • Like 1
Link to comment
Share on other sites

this version work, but like tdiguy i have a shit load of path. Maybe if we can filter them that will be nice.

I'm just wondering how to do this.

 

I can split the path into an array and allow you to choose the part which is the most appropriate for the label, but I'm not sure how to show it in the UI.

 

Unless we create a rename feature, which allows you to rename the path for the label. Would that work? We are pretty much set up for that.

Link to comment
Share on other sites

CBers

Do you mean the table view? Is that because the table view hasn't been set up for mobile and you can't access the button?

 

Just want to make sure I understand.

 

Is that what it's called, TABLE view.

 

Yes, that one.

 

No, there's no button.

  • Like 1
Link to comment
Share on other sites

Spaceboy

Is that what it's called, TABLE view.

 

Yes, that one.

 

No, there's no button.

oh really? Works fine in iOS [emoji41]
  • Like 1
Link to comment
Share on other sites

Is that what it's called, TABLE view.

 

Yes, that one.

 

No, there's no button.

Should I add a media query, then make the entire row clickable, on mobile?

Link to comment
Share on other sites

Will that solve the issue ?

I'm not sure. The table layouts for the Emby aren't really mobile friendly. Auto organization pages suffer the same issues.

 

We can alter the table data for mobile, maybe streamline it and remove some of the column data.

 

Maybe only display, total space, used space, available space and make the row clickable as the config button.

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...