Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Add-on] Diskspace Monitor Tab Add-on Version 1.00 final for Muximux #52

Open
alienx2 opened this issue Feb 16, 2016 · 16 comments
Open
Labels

Comments

@alienx2
Copy link

alienx2 commented Feb 16, 2016

I think it will be useful... refresh every 30 mins or 1 hour. like this free space "27GB / 40GB" possible if you prefer style you can use progress bar with CSS style =)

@alienx2 alienx2 changed the title [Feature Request] Monitor Disk space on top [Feature Request] Monitor Disk space on tab Feb 16, 2016
@alienx2
Copy link
Author

alienx2 commented Feb 16, 2016

credits by Darian Brown (http://www.thecave.info/) and modified by me.

sample

version 1.00 final released! =)

Looking for code? Please look below.

@mescon
Copy link
Owner

mescon commented Feb 16, 2016

People who want this are free to add it, so I wont close the issue for the time being - however, this is beyong the scope of Muximux itself so it will most likely not be included in the official repo.

@alienx2
Copy link
Author

alienx2 commented Feb 16, 2016

ok this is like add-on for muximux =)

@alienx2 alienx2 changed the title [Feature Request] Monitor Disk space on tab [Add-on] Monitor Disk space on tab Feb 16, 2016
@monsieurpouet
Copy link

I've a little issue:
capture

Why I've a scrollbar ? :(

@alienx2
Copy link
Author

alienx2 commented Feb 21, 2016

@monsieurpouet >
same problem here: #49

SOLUTION: find <nav> then replace with <nav style='overflow-y: hidden;'> in muximux.php

Great news! very soon to update code with click to refresh on it =)

@monsieurpouet
Copy link

It must put ' instead of ".
If not, this don't work.

Like that:

Thanks for your answer :)

@alienx2
Copy link
Author

alienx2 commented Feb 21, 2016

@monsieurpouet oops.. sorry =) i made code without testing.... I'm glad you like this feature.

@JudsonHat
Copy link

Great news! very soon to update code with click to refresh on it =)

@alienx2 Thanks for your contribution to this project. Did you find a way to refresh the disk space information with a click?

@alienx2
Copy link
Author

alienx2 commented Mar 2, 2016

@judhat2... yes im completed script for click to refresh but im about to release final version with 3 mode: timer, click and regular and i'm making easy to install this feature for everyone. stay tuned! =)

@JudsonHat
Copy link

Thanks, good to hear!

@alienx2
Copy link
Author

alienx2 commented Mar 2, 2016

Diskspace Monitor Add-on for Muximux Version 1.00 final

copy and paste code to notepad and save it as "diskspace.php" to where muximux installed folder.

How to Install?

(2 Steps only)
Edit index.php with any code editor or notepad and following:

  1. Add this line after "require 'muximux.php';":
    require('diskspace.php');

  2. Insert this line to <head> </head>:
    <?php echo insertscript('install'); ?>

Added Features:

  • Mode: Click, Timer, Normal
  • Text format
  • Easy to Install for everyone. Just 2 lines only
  • Easy to config
<?php
##########################################################
##########################################################
//                   Created by AlienX2                  //
##########################################################
##########################################################
####### HOW TO INSTALL ###################################
#   * Add to index.php after "require 'muximux.php';":   #
#       require('diskspace.php');                        #
#                                                        #
#   * Add to index.php in <head> </head>:                #
/*      <?php echo insertscript('install'); ?>          */
#                                                        #
##########################################################
##########################################################
###### SETTINGS ##########################################
#   
#   // 'click' = click to refresh; 
#   // 'time' = refresh per time;
#   // 'none' = nothing, just reload page.
    $mode = 'none'; 
#   
#   // 'percent' = percent of how big used of space;
#   // 'ut' = Used space / Total Space;
#   // 'ft' = Free space / Total Space;
#   // 'free' = Free space of size;
    $textbar_type = 'ft';
#   
#   // Required: $mode='time';
#   // xxxx seconds
#   // e.g. '60' seconds = 1 minute; '300' seconds = 5 mins; '900' seconds = 15mins;
    $time = '5';
#   
#   // drive path in '' . e.g. 'd:/' or '/mnt/DownloadHDD'
    $monitor_path = '/mnt/LinuxHOME'; 
#
##########################################################



if(isset($_GET['diskspace'])) {
    echo progressbar('update');
    //echo 'hello';
    return;
}

if(isset($_GET['percentofspace'])) {
    echo progressbar('dp').'%';
    return;
}

if(isset($_GET['html'])) {
    echo progressbar('html');
    return;
}

function insertscript($type) {
    global $mode;
    global $time;

    if($type=='install') {

        $insertcode = "<script src='//code.jquery.com/jquery-1.12.0.min.js'></script><style type='text/css'>

    .diskspace {
        height:35px;
        float: right !important;
        margin-right: 5px;
        margin-top: 3px;
    }

    .progress {
/*          background: #747B8B;*/
        background:none;
            border: 2px solid #747B8B;
            height: 32px;
            width: 120px;
    }

    .progress .prgbar {
            position: relative;
            height: 32px;
            z-index: 999;
    }

    .prgbar {
        background:#f5f5f5 !important;
    }
    .progress .prgtext {
            color: gray;
            text-align: center;
            font-size: 13px;
            padding: 6px 0 0;
            width: 120px;
            position: absolute;
            z-index: 1000;
            text-shadow: 1px 1px #747B8B;
    }
    .progress .prginfo {
            margin: 3px 0;
    }

    </style>
    ";

    if ($mode == 'time') {
        $insertcode .= "
            <script>
                $(document).ready(function() {
                    $('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

                    $.get('diskspace.php?html', function(data){
                        $('li.diskspace').html(data);
                    });

                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });
                });
            </script>
        <script>
            var refresh = setInterval(
                function (){
                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });

                    $.get('diskspace.php?percentofspace', function(data){
                        $('.progress .prgbar').width(data);
                    });

                    $('div.prgtext').load('diskspace.php?diskspace');

                    }, ".convertmilliseconds($time).");
        </script>
        ";
    } else if ($mode == 'click') {
        $insertcode .= "<script>
        $(document).ready(function() {
            $('".'<li class="diskspace"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

            $.get('diskspace.php?html', function(data){
                $('li.diskspace').html(data);
            });

            $.get('diskspace.php?percentofspace', function(data){
                $('.progress .prgbar').width(data);
            });

            $('.diskspace').click(function() {
                $.get('diskspace.php?percentofspace', function(data){
                    $('.progress .prgbar').width(data);
                });

                $('.diskspace div.prgtext').load('diskspace.php?diskspace');
            });
        });
        </script>";
    } else { $insertcode .= "<script>
        $(document).ready(function() {
            $('".'<li class="diskspace" style="cursor:default !important;"></li>'."').insertBefore( 'ul.cd-tabs-navigation nav li:last-child' );

            $.get('diskspace.php?html', function(data){
                $('li.diskspace').html(data);
            });

            $.get('diskspace.php?percentofspace', function(data){
                $('.progress .prgbar').width(data);
            });
        });
        </script>

        "; }


    return $insertcode;


    }
}

function convertmilliseconds ($seconds) {
    return $seconds * 1000;
}

function progressbar($request = '') {

    global $monitor_path;
    global $textbar_type;

    $dfree = disk_free_space($monitor_path);
    $dt = disk_total_space($monitor_path);
    $du = $dt - $dfree;
    $dp = sprintf('%.2f',($du / $dt) * 100);
    $df = HumanSize($dfree);
    $dt = HumanSize($dt);
    $du = HumanSize($du);

    if($textbar_type == 'percent') {
        $data = $dp.' %';
    } else if($textbar_type == 'ut') {
        $data = $du." / ".$dt;
    } else if($textbar_type == 'ft') {
        $data = $df." / ".$dt;
    } else if($textbar_type == 'free') {
        $data = HumanSize($dfree, 2).' left';
    } else {
        $data = 'ERROR: $textbar_type is missing!';
    }

    if($request == 'dp') {
     return $dp;    
    } else if ($request == "update") {
        return $data;

        //return $df .'/'. $dt;
    } else if ($request == "html") {
     return 
        '<div class="progress">
           <div class="prgtext">'.$data.'</div><div class="prgbar"></div><div class="prginfo">
                   </div></div>';
    }

}

function HumanSize($bytes, $digit = 1)
{
    $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
            for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
                    return( round( $bytes, $digit ) . " " . $types[$i] );
}

?>

@alienx2
Copy link
Author

alienx2 commented Mar 2, 2016

@judhat2 @monsieurpouet i just release code. Grab it =) Don't forget to install fresh muximux.

@alienx2 alienx2 changed the title [Add-on] Monitor Disk space on tab [Add-on] Diskspace Monitor Tab Add-on for Muximux Version 1.00 final Mar 2, 2016
@alienx2 alienx2 changed the title [Add-on] Diskspace Monitor Tab Add-on for Muximux Version 1.00 final [Add-on] Diskspace Monitor Tab Add-on Version 1.00 final for Muximux Mar 2, 2016
@mescon
Copy link
Owner

mescon commented Mar 3, 2016

@alienx2 Nice job! FYI, you're inserting an instance of jQuery, when Muximux itself already loads jQuery. This creates a javascript conflict, so perhaps you could make it work with the bundled jquery version?

@alienx2
Copy link
Author

alienx2 commented Mar 3, 2016

@mescon Thanks =) and i tried tested it not working without add jQuery. that's why i added.

@alienx2
Copy link
Author

alienx2 commented Mar 5, 2016

@mescon i found you put jquery in index.php but very bottom instead of put in <head></head>... it didnt work with my code? even also jquery wont work?

@mescon
Copy link
Owner

mescon commented Mar 6, 2016

@alienx2 All javascript is at the bottom for performance reasons. Read more here: https://developer.yahoo.com/performance/rules.html#js_bottom=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants