fix the progressbar renderer for the file tree
add a new file priority "Mixed" add progress bars and priorities for directories using the new tree format
This commit is contained in:
parent
7727a98c45
commit
2afd0a4e97
|
@ -207,6 +207,12 @@ dl.singleline dd {
|
|||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* Files TreeGrid */
|
||||
.x-treegrid-col {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* Options Tab Styles */
|
||||
.x-deluge-options-label {
|
||||
margin-right: 10px;
|
||||
|
|
|
@ -34,10 +34,10 @@ Copyright:
|
|||
/* Renderers for the column tree */
|
||||
function fileProgressRenderer(value) {
|
||||
var progress = value * 100;
|
||||
return Deluge.progressBar(progress, this.width - 50, progress.toFixed(2) + '%', 0);
|
||||
return Deluge.progressBar(progress, this.col.width, progress.toFixed(2) + '%', 0);
|
||||
}
|
||||
function priorityRenderer(value) {
|
||||
if (!value) return '';
|
||||
if (isNaN(value)) return '';
|
||||
return String.format('<div class="{0}">{1}</div>', FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
|
||||
}
|
||||
|
||||
|
@ -55,19 +55,19 @@ Copyright:
|
|||
width: 330,
|
||||
dataIndex: 'filename'
|
||||
}, {
|
||||
xtype: 'tgcustomcolumn',
|
||||
xtype: 'tgrendercolumn',
|
||||
header: _('Size'),
|
||||
width: 150,
|
||||
dataIndex: 'size',
|
||||
renderer: fsize
|
||||
}, {
|
||||
xtype: 'tgcustomcolumn',
|
||||
xtype: 'tgrendercolumn',
|
||||
header: _('Progress'),
|
||||
width: 150,
|
||||
dataIndex: 'progress',
|
||||
renderer: fileProgressRenderer
|
||||
}, {
|
||||
xtype: 'tgcustomcolumn',
|
||||
xtype: 'tgrendercolumn',
|
||||
header: _('Priority'),
|
||||
width: 150,
|
||||
dataIndex: 'priority',
|
||||
|
@ -176,15 +176,18 @@ Copyright:
|
|||
|
||||
onRequestComplete: function(files, options) {
|
||||
function walk(files, parent) {
|
||||
for (var file in files) {
|
||||
var item = files[file];
|
||||
for (var file in files.contents) {
|
||||
var item = files.contents[file];
|
||||
var child = parent.findChild('id', file);
|
||||
if (Ext.type(item) == 'object') {
|
||||
if (item.type == 'dir') {
|
||||
if (!child) {
|
||||
child = new Ext.tree.TreeNode({
|
||||
id: file,
|
||||
text: file,
|
||||
filename: file
|
||||
filename: file,
|
||||
size: item['size'],
|
||||
progress: item['progress'],
|
||||
priority: item['priority']
|
||||
});
|
||||
parent.appendChild(child);
|
||||
}
|
||||
|
@ -195,10 +198,10 @@ Copyright:
|
|||
id: file,
|
||||
filename: file,
|
||||
text: file, // this needs to be here for sorting
|
||||
fileIndex: item[0],
|
||||
size: item[1],
|
||||
progress: item[2],
|
||||
priority: item[3],
|
||||
fileIndex: item['index'],
|
||||
size: item['size'],
|
||||
progress: item['progress'],
|
||||
priority: item['priority'],
|
||||
leaf: true,
|
||||
iconCls: 'x-deluge-file',
|
||||
uiProvider: Ext.ux.tree.TreeGridNodeUI
|
||||
|
|
|
@ -119,10 +119,12 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
|||
// _('High Priority')
|
||||
// _('Highest Priority')
|
||||
FILE_PRIORITY = {
|
||||
9: 'Mixed',
|
||||
0: 'Do Not Download',
|
||||
1: 'Normal Priority',
|
||||
2: 'High Priority',
|
||||
5: 'Highest Priority',
|
||||
'Mixed': 9,
|
||||
'Do Not Download': 0,
|
||||
'Normal Priority': 1,
|
||||
'High Priority': 2,
|
||||
|
@ -130,6 +132,7 @@ FILE_PRIORITY = {
|
|||
}
|
||||
|
||||
FILE_PRIORITY_CSS = {
|
||||
9: 'x-mixed-download',
|
||||
0: 'x-no-download',
|
||||
1: 'x-normal-download',
|
||||
2: 'x-high-download',
|
||||
|
|
|
@ -532,6 +532,7 @@ class WebApi(JSONComponent):
|
|||
|
||||
paths = []
|
||||
info = {}
|
||||
dir_info = {}
|
||||
for index, torrent_file in enumerate(files):
|
||||
path = torrent_file["path"]
|
||||
paths.append(path)
|
||||
|
@ -540,13 +541,28 @@ class WebApi(JSONComponent):
|
|||
torrent_file["index"] = index
|
||||
info[path] = torrent_file
|
||||
|
||||
def walk(path, item):
|
||||
if type(item) is dict:
|
||||
return item
|
||||
return [info[path]["index"], info[path]["size"],
|
||||
info[path]["progress"], info[path]["priority"]]
|
||||
# update the directory info
|
||||
dirinfo = info.setdefault(os.path.dirname(path), {})
|
||||
dirinfo["size"] = dirinfo.get("size", 0) + torrent_file["size"]
|
||||
if "priority" not in dirinfo:
|
||||
dirinfo["priority"] = torrent_file["priority"]
|
||||
else:
|
||||
if dirinfo["priority"] != torrent_file["priority"]:
|
||||
dirinfo["priority"] = 9
|
||||
|
||||
file_tree = uicommon.FileTree(paths)
|
||||
progresses = dirinfo.setdefault("progresses", [])
|
||||
progresses.append(torrent_file["progress"])
|
||||
dirinfo["progress"] = float(sum(progresses)) / len(progresses)
|
||||
|
||||
def walk(path, item):
|
||||
if item["type"] == "dir":
|
||||
item.update(info[path])
|
||||
return item
|
||||
else:
|
||||
item.update(info[path])
|
||||
return item
|
||||
|
||||
file_tree = uicommon.FileTree2(paths)
|
||||
file_tree.walk(walk)
|
||||
d.callback(file_tree.get_tree())
|
||||
|
||||
|
|
Loading…
Reference in New Issue