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

WebUI: Allow to move state icon to name column in torrents table #22118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

skomerko
Copy link
Contributor

@skomerko skomerko commented Jan 6, 2025

See #22118 (comment) for updated information.

@stalkerok
Copy link
Contributor

stalkerok commented Jan 7, 2025

This is not a good solution. Some users on the contrary request separate columns for the GUI #18193

I would suggest making a full column for WebUI called “Status Icon” or just “Icon” instead of merging.

@skomerko
Copy link
Contributor Author

skomerko commented Jan 7, 2025

This is not a good solution. Some users on the contrary request separate columns for the GUI #18193

I would suggest making a full column for WebUI called “Status Icon” or just “Icon” instead of merging.

I see, thanks for letting me know. It doesn't hurt to keep the old state icon column so I'll modify the PR and bring it back.

@xavier2k6 xavier2k6 added the WebUI WebUI-related issues/changes label Jan 10, 2025
@skomerko skomerko force-pushed the webui-state-icon-column branch from ad6fafb to 08272b6 Compare January 18, 2025 21:11
@skomerko skomerko changed the title WebUI: Merge 'state icon' and 'name' columns in torrents table WebUI: Allow to move state icon to name column in torrents table Jan 18, 2025
@skomerko
Copy link
Contributor Author

skomerko commented Jan 18, 2025

PR has been updated. Notable changes:

  • By default, standalone state icon column is disabled and state icon is displayed next to torrents name (this part matches the behavior of the GUI):

image

  • When standalone state icon column is enabled, icons in name column are hidden:

image

  • Added name to state icon column
  • State icon column is now sortable

edit: PR title probably should be changed(?), not sure to what though.

@stalkerok
Copy link
Contributor

stalkerok commented Jan 21, 2025

How about the name “Icon”? #22131 (comment)

the column content will always be smaller than the column header

@@ -612,31 +628,21 @@ window.qBittorrent.DynamicTable ??= (() => {
return -1;
},

updateColumn: function(columnName) {
updateColumn: function(columnName, updateCellData = false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chocobo1, changes made around this method are not strictly necessery - name column could be updated from within onVisibilityChange callback but I thought it's better to improve updateColumn a bit instead (though things are definitely not perfect but I didn't want to change too much).

this.columns["state_icon"].updateTd = function(td, row) {
let state = this.getRowValue(row);
let img_path;
const getStateIconClasses = (state) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be singular?

Suggested change
const getStateIconClasses = (state) => {
const getStateIconClass = (state) => {

@@ -789,6 +795,14 @@ window.qBittorrent.DynamicTable ??= (() => {
}
},

getTrs: function() {
return [...this.tableBody.rows];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
return [...this.tableBody.rows];
return this.tableBody.rows;

It should be enough if you only need iteration.

Copy link
Contributor Author

@skomerko skomerko Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both rows & cells properties return a live HTMLCollection which is automatically updated when the underlying document is changed, so I convert them to a static one to avoid it. IIRC getElements called with a simple tag does the same thing - it uses getElementsByTagName internally and then creates Elements collection (live -> static).

Maybe it would be better to return this.tableBody.querySelectorAll("tr") instead? I can't tell if there is a difference in performance between these two approaches.

},

getRowCells: (tr) => {
return [...tr.cells];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too:

Suggested change
return [...tr.cells];
return tr.cells;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebUI WebUI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants