Browse Source

Add Status column to webui (addresses #6815) (#7032)

* Add Status column to webui (addresses #6815)
adaptive-webui-19844
Tom Piccirello 7 years ago committed by Mike Tzou
parent
commit
11b44407af
  1. 2
      src/webui/www/public/css/dynamicTable.css
  2. 2
      src/webui/www/public/scripts/client.js
  3. 66
      src/webui/www/public/scripts/dynamicTable.js

2
src/webui/www/public/css/dynamicTable.css

@ -33,7 +33,7 @@
cursor: pointer; cursor: pointer;
} }
#transferList img.statusIcon { #transferList img.stateIcon {
height: 1.3em; height: 1.3em;
vertical-align: middle; vertical-align: middle;
margin-bottom: -1px; margin-bottom: -1px;

2
src/webui/www/public/scripts/client.js

@ -312,6 +312,8 @@ window.addEvent('load', function () {
for (var key in response['torrents']) { for (var key in response['torrents']) {
response['torrents'][key]['hash'] = key; response['torrents'][key]['hash'] = key;
response['torrents'][key]['rowId'] = key; response['torrents'][key]['rowId'] = key;
if (response['torrents'][key]['state'])
response['torrents'][key]['status'] = response['torrents'][key]['state'];
torrentsTable.updateRowData(response['torrents'][key]); torrentsTable.updateRowData(response['torrents'][key]);
if (addTorrentToCategoryList(response['torrents'][key])) if (addTorrentToCategoryList(response['torrents'][key]))
update_categories = true; update_categories = true;

66
src/webui/www/public/scripts/dynamicTable.js

@ -734,6 +734,7 @@ var TorrentsTable = new Class({
this.newColumn('name', '', 'QBT_TR(Name)QBT_TR[CONTEXT=TorrentModel]', 200, true); this.newColumn('name', '', 'QBT_TR(Name)QBT_TR[CONTEXT=TorrentModel]', 200, true);
this.newColumn('size', '', 'QBT_TR(Size)QBT_TR[CONTEXT=TorrentModel]', 100, true); this.newColumn('size', '', 'QBT_TR(Size)QBT_TR[CONTEXT=TorrentModel]', 100, true);
this.newColumn('progress', '', 'QBT_TR(Done)QBT_TR[CONTEXT=TorrentModel]', 85, true); this.newColumn('progress', '', 'QBT_TR(Done)QBT_TR[CONTEXT=TorrentModel]', 85, true);
this.newColumn('status', '', 'QBT_TR(Status)QBT_TR[CONTEXT=TorrentModel]', 100, true);
this.newColumn('num_seeds', '', 'QBT_TR(Seeds)QBT_TR[CONTEXT=TorrentModel]', 100, true); this.newColumn('num_seeds', '', 'QBT_TR(Seeds)QBT_TR[CONTEXT=TorrentModel]', 100, true);
this.newColumn('num_leechs', '', 'QBT_TR(Peers)QBT_TR[CONTEXT=TorrentModel]', 100, true); this.newColumn('num_leechs', '', 'QBT_TR(Peers)QBT_TR[CONTEXT=TorrentModel]', 100, true);
this.newColumn('dlspeed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true); this.newColumn('dlspeed', '', 'QBT_TR(Down Speed)QBT_TR[CONTEXT=TorrentModel]', 100, true);
@ -771,26 +772,25 @@ var TorrentsTable = new Class({
initColumnsFunctions : function () { initColumnsFunctions : function () {
// state_icon // state_icon
this.columns['state_icon'].updateTd = function (td, row) { this.columns['state_icon'].updateTd = function (td, row) {
var state = this.getRowValue(row); var state = this.getRowValue(row);
if (state == "forcedDL" || state == "metaDL") if ((state === "forcedDL") || (state === "metaDL"))
state = "downloading"; state = "downloading";
else if (state == "allocating") else if (state === "allocating")
state = "stalledDL"; state = "stalledDL";
else if (state == "forcedUP") else if (state === "forcedUP")
state = "uploading"; state = "uploading";
else if (state == "pausedDL") else if (state === "pausedDL")
state = "paused"; state = "paused";
else if (state == "pausedUP") else if (state === "pausedUP")
state = "completed"; state = "completed";
else if (state == "queuedDL" || state == "queuedUP") else if ((state === "queuedDL") || (state === "queuedUP"))
state = "queued"; state = "queued";
else if (state == "checkingDL" || state == "checkingUP" || else if ((state === "checkingDL") || (state === "checkingUP") ||
state == "queuedForChecking" || state == "checkingResumeData") (state === "queuedForChecking") || (state === "checkingResumeData"))
state = "checking"; state = "checking";
else if (state == "unknown" || state == "error" || state == "missingFiles") else if ((state === "unknown") || (state === "error") || (state === "missingFiles"))
state = "error"; state = "error";
var img_path = 'images/skin/' + state + '.png'; var img_path = 'images/skin/' + state + '.png';
@ -803,12 +803,37 @@ var TorrentsTable = new Class({
else else
td.adopt(new Element('img', { td.adopt(new Element('img', {
'src' : img_path, 'src' : img_path,
'class' : 'statusIcon' 'class' : 'stateIcon'
})); }));
}; };
// priority // status
this.columns['status'].updateTd = function (td, row) {
var status = this.getRowValue(row);
if (!status) return;
if ((status === "downloading") || (status === "forcedDL") || (status === "metaDL"))
status = "Downloading";
else if ((status === "stalledDL") || (status === "stalledUP") || (status === "allocating"))
status = "Stalled";
else if ((status === "uploading") || (status === "forcedUP"))
status = "Uploading";
else if (status === "pausedDL")
status = "Paused";
else if (status === "pausedUP")
status = "Completed";
else if ((status === "queuedDL") || (status === "queuedUP"))
status = "Queued";
else if ((status === "checkingDL") || (status === "checkingUP") ||
(status === "queuedForChecking") || (status === "checkingResumeData"))
status = "Checking";
else if ((status === "unknown") || (status === "error") || (status === "missingFiles"))
status = "Error";
td.set('html', status);
};
// priority
this.columns['priority'].updateTd = function (td, row) { this.columns['priority'].updateTd = function (td, row) {
var priority = this.getRowValue(row); var priority = this.getRowValue(row);
td.set('html', priority < 1 ? '*' : priority); td.set('html', priority < 1 ? '*' : priority);
@ -829,21 +854,18 @@ var TorrentsTable = new Class({
}; };
// name, category // name, category
this.columns['name'].updateTd = function (td, row) { this.columns['name'].updateTd = function (td, row) {
td.set('html', escapeHtml(this.getRowValue(row))); td.set('html', escapeHtml(this.getRowValue(row)));
}; };
this.columns['category'].updateTd = this.columns['name'].updateTd; this.columns['category'].updateTd = this.columns['name'].updateTd;
// size // size
this.columns['size'].updateTd = function (td, row) { this.columns['size'].updateTd = function (td, row) {
var size = this.getRowValue(row); var size = this.getRowValue(row);
td.set('html', friendlyUnit(size, false)); td.set('html', friendlyUnit(size, false));
}; };
// progress // progress
this.columns['progress'].updateTd = function (td, row) { this.columns['progress'].updateTd = function (td, row) {
var progress = this.getRowValue(row); var progress = this.getRowValue(row);
var progressFormated = (progress * 100).round(1); var progressFormated = (progress * 100).round(1);
@ -883,7 +905,6 @@ var TorrentsTable = new Class({
}.bind(this); }.bind(this);
// num_seeds // num_seeds
this.columns['num_seeds'].updateTd = function (td, row) { this.columns['num_seeds'].updateTd = function (td, row) {
var num_seeds = this.getRowValue(row, 0); var num_seeds = this.getRowValue(row, 0);
var num_complete = this.getRowValue(row, 1); var num_complete = this.getRowValue(row, 1);
@ -911,30 +932,25 @@ var TorrentsTable = new Class({
}; };
// num_leechs // num_leechs
this.columns['num_leechs'].updateTd = this.columns['num_seeds'].updateTd; this.columns['num_leechs'].updateTd = this.columns['num_seeds'].updateTd;
this.columns['num_leechs'].compareRows = this.columns['num_seeds'].compareRows; this.columns['num_leechs'].compareRows = this.columns['num_seeds'].compareRows;
// dlspeed // dlspeed
this.columns['dlspeed'].updateTd = function (td, row) { this.columns['dlspeed'].updateTd = function (td, row) {
var speed = this.getRowValue(row); var speed = this.getRowValue(row);
td.set('html', friendlyUnit(speed, true)); td.set('html', friendlyUnit(speed, true));
}; };
// upspeed // upspeed
this.columns['upspeed'].updateTd = this.columns['dlspeed'].updateTd; this.columns['upspeed'].updateTd = this.columns['dlspeed'].updateTd;
// eta // eta
this.columns['eta'].updateTd = function (td, row) { this.columns['eta'].updateTd = function (td, row) {
var eta = this.getRowValue(row); var eta = this.getRowValue(row);
td.set('html', friendlyDuration(eta, true)); td.set('html', friendlyDuration(eta, true));
}; };
// ratio // ratio
this.columns['ratio'].updateTd = function (td, row) { this.columns['ratio'].updateTd = function (td, row) {
var ratio = this.getRowValue(row); var ratio = this.getRowValue(row);
var html = null; var html = null;
@ -946,14 +962,12 @@ var TorrentsTable = new Class({
}; };
// added on // added on
this.columns['added_on'].updateTd = function (td, row) { this.columns['added_on'].updateTd = function (td, row) {
var date = new Date(this.getRowValue(row) * 1000).toLocaleString(); var date = new Date(this.getRowValue(row) * 1000).toLocaleString();
td.set('html', date); td.set('html', date);
}; };
// completion_on // completion_on
this.columns['completion_on'].updateTd = function (td, row) { this.columns['completion_on'].updateTd = function (td, row) {
var val = this.getRowValue(row); var val = this.getRowValue(row);
if (val === 0xffffffff || val < 0) if (val === 0xffffffff || val < 0)
@ -965,11 +979,9 @@ var TorrentsTable = new Class({
}; };
// seen_complete // seen_complete
this.columns['seen_complete'].updateTd = this.columns['completion_on'].updateTd; this.columns['seen_complete'].updateTd = this.columns['completion_on'].updateTd;
// dl_limit, up_limit // dl_limit, up_limit
this.columns['dl_limit'].updateTd = function (td, row) { this.columns['dl_limit'].updateTd = function (td, row) {
var speed = this.getRowValue(row); var speed = this.getRowValue(row);
if (speed === 0) if (speed === 0)
@ -981,7 +993,6 @@ var TorrentsTable = new Class({
this.columns['up_limit'].updateTd = this.columns['dl_limit'].updateTd; this.columns['up_limit'].updateTd = this.columns['dl_limit'].updateTd;
// downloaded, uploaded, downloaded_session, uploaded_session, amount_left, completed, total_size // downloaded, uploaded, downloaded_session, uploaded_session, amount_left, completed, total_size
this.columns['downloaded'].updateTd = this.columns['size'].updateTd; this.columns['downloaded'].updateTd = this.columns['size'].updateTd;
this.columns['uploaded'].updateTd = this.columns['size'].updateTd; this.columns['uploaded'].updateTd = this.columns['size'].updateTd;
this.columns['downloaded_session'].updateTd = this.columns['size'].updateTd; this.columns['downloaded_session'].updateTd = this.columns['size'].updateTd;
@ -992,16 +1003,13 @@ var TorrentsTable = new Class({
this.columns['total_size'].updateTd = this.columns['size'].updateTd; this.columns['total_size'].updateTd = this.columns['size'].updateTd;
// save_path, tracker // save_path, tracker
this.columns['save_path'].updateTd = this.columns['name'].updateTd; this.columns['save_path'].updateTd = this.columns['name'].updateTd;
this.columns['tracker'].updateTd = this.columns['name'].updateTd; this.columns['tracker'].updateTd = this.columns['name'].updateTd;
// ratio_limit // ratio_limit
this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd; this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd;
// last_activity // last_activity
this.columns['last_activity'].updateTd = function (td, row) { this.columns['last_activity'].updateTd = function (td, row) {
var val = this.getRowValue(row); var val = this.getRowValue(row);
if (val < 1) if (val < 1)

Loading…
Cancel
Save