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