Hi !
The question is - "Is it possible to add text information about disk usage ( used\free ) at the status box?"
Now there i see number of torrents and up/down speed.
Thanks for answer.
free disk space usage
-
- Posts: 3
- Joined: Wed Sep 16, 2009 9:08 pm
Re: free disk space usage
Hello,
i've made some modification on webui to get space disk :
1] Create a file get.js in /usr/share/transmission/web/javascript (linux path here)
As you can see, the file data.txt should be in the same directory /usr/share/transmission/web/javascript/
2] We need to make some modification on the index.html file :
nano /usr/share/transmission/web/index.html
Find this line :
3] Another modification in index.html :
Find this line :
You should have this :
Next i've just make a cron that is check every hours the disk space and put the result in the data.txt file.
for every 10 mins :
That's all.
The cron launch the script every hours, then put the disk space on data.txt and the javascript in webui just read the data.txt file.
Sorry for my bad english
For any question, just ask me !
ps : the disk space appear in the bottom right corner of webui
i've made some modification on webui to get space disk :
1] Create a file get.js in /usr/share/transmission/web/javascript (linux path here)
touch /usr/share/transmission/web/javascript/get.js
nano /usr/share/transmission/web/javascript/get.js
Code: Select all
var data = new Array();
var i = 0;
var datafile = window.location.href.substring(0,
window.location.href.lastIndexOf("/") + 1) +
"./javascript/data.txt";
var url = new java.net.URL(datafile);
var connect = url.openConnection();
var input = new java.io.BufferedReader(
new java.io.InputStreamReader(
connect.getInputStream()));
var aLine = ""
while((aLine = input.readLine()) != null) {
data[i++] = aLine;
}
2] We need to make some modification on the index.html file :
nano /usr/share/transmission/web/index.html
Find this line :
Then add before or after this one :<script type="text/javascript" src="./javascript/jquery/jquery.transmenu.min.js"></script>
Code: Select all
<script type="text/javascript" src="./javascript/get.js"></script>
Find this line :
Put this between <div></div>:<div id="disk_space_container"></div>
Code: Select all
Disk Space :
<SCRIPT language = "Javascript">
var temp = ""
temp = data[0];
document.write(temp);
</SCRIPT>
For this part, there is no need to but on Linux, but the path should be different.<div id="disk_space_container">Disk Space :
<SCRIPT language = "Javascript">
var temp = ""
temp = data[0];
document.write(temp);
</SCRIPT>
</div>
Next i've just make a cron that is check every hours the disk space and put the result in the data.txt file.
touch ~/disk_trans.sh
nano ~/disk_trans.sh
Code: Select all
df /mnt -h | grep -i /mnt | awk {'print "Used:",$3,"- Free:",$4'} >/usr/share/transmission/web/javascript/data.txt
chmod +x ~/disk_trans.sh
crontab -e
Code: Select all
@hourly /root/disk_trans.sh
Code: Select all
0,10,20,30,40,50 * * * * /root/disk_trans.sh
The cron launch the script every hours, then put the disk space on data.txt and the javascript in webui just read the data.txt file.
Sorry for my bad english
For any question, just ask me !
ps : the disk space appear in the bottom right corner of webui
Re: free disk space usage
Yes at version 1.74 it worked. After update to 1.75 it has broken (nothing display, even "Disk Space..." but at index.html your modifications exists). Also it method works if installed java development kit at my workstation, but I'am a user, not developer and i don't need such software. This method never will include in distributive. Don't want edit by hands webgui-scripts after each update
Аnyway, thanks for help and your time.
Now work at 1.75 becouse install-prefix changed from /usr to /usr/local. (now web-gui scripts at /usr/local/share/transmission/web)
ps. using transmission-daemon-1.75, transmission-web-1.75 on FreeBSD 7.2-STABLE
Аnyway, thanks for help and your time.
Now work at 1.75 becouse install-prefix changed from /usr to /usr/local. (now web-gui scripts at /usr/local/share/transmission/web)
ps. using transmission-daemon-1.75, transmission-web-1.75 on FreeBSD 7.2-STABLE
Re: free disk space usage
for some reason firefox on os x pukes for the above java solution with not finding getInputStream() method. so i implemented a nice auto refreshing solution with ajax.
get.js:
index.html -> no further modification needed!:
edit: some edits to deal with caching etc. safari also needs something like min-width:400px for the div, because when it first sees the div its empty and the text will not be visible when its put there. firefox displays correctly ootb.
get.js:
Code: Select all
function disk_space() {
var oRequest = new XMLHttpRequest();
var sURL = "http://yourtransmissionmachine:8091/transmission/web/javascript/data.txt";
var currentTime = new Date();
var hr = currentTime.getHours();
var min = currentTime.getMinutes();
// var sec = currentTime.getSeconds();
oRequest.open("GET",sURL + '?nocache=' + currentTime.getTime(),false); // make a unique URL to disable browser side caching
oRequest.setRequestHeader("User-Agent",navigator.userAgent);
oRequest.send(null);
document.getElementById('disk_space_container').innerHTML = oRequest.responseText + ' | ' + hr + ':' + min;
}
window.onload = disk_space; // execute disk_space after whole page with our disk_space_container has been loaded
setInterval(disk_space, 300000); // refresh free disk space every 5 minutes
Code: Select all
<div id="disk_space_container">
</div>
-
- Posts: 3
- Joined: Wed Sep 16, 2009 9:08 pm
Re: free disk space usage
Very nice ! it's better with ajax
i take your solution !
thanks a lot !
i take your solution !
thanks a lot !