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

More torrent columns + other stuff #145

Merged
merged 6 commits into from
Nov 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 27 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<div [ngClass]="{'dark-theme': isDarkTheme | async}" class="upload_outer_container">
<div class="mat-dialog-inner-container mat-app-background upload_container">
<h2 mat-dialog-title>Upload Torrents</h2>

<div class="row space-between align-baseline">
<h2 mat-dialog-title>Upload Torrents</h2>

<mat-dialog-actions *ngIf="isMobileUser" align="end">
<button disabled={{isLoading}} mat-button [mat-dialog-close]="true">Cancel</button>
<button disabled={{isUploadDisabled()}} mat-raised-button (click)="handleUpload()" color="primary" cdkFocusInitial>Upload</button>
</mat-dialog-actions>
</div>

<mat-dialog-content class="mat-typography dialog_content">
<mat-tab-group mat-align-tabs="start" (selectedTabChange)="handleTabChange($event)" [selectedIndex]="currentTab?.index || 0">
<mat-tab label="File Upload">
@@ -63,7 +72,7 @@ <h3>Save Location</h3>
</div>
</mat-dialog-content>

<mat-dialog-actions align="end">
<mat-dialog-actions *ngIf="!isMobileUser" align="end">
<button disabled={{isLoading}} mat-button [mat-dialog-close]="true">Cancel</button>
<button disabled={{isUploadDisabled()}} mat-raised-button (click)="handleUpload()" color="primary" cdkFocusInitial>Upload</button>
</mat-dialog-actions>
Original file line number Diff line number Diff line change
@@ -11,6 +11,11 @@ <h2 mat-dialog-title>Choose Save Location</h2>
<mat-icon>search</mat-icon>
<input id="directorySearchInput" type="text" (keyup)="onSearchValueChange($event)" placeholder="Search...">
</mat-card>

<div class="row align-center" *ngIf="isMobileUser">
<button mat-button [mat-dialog-close]="false"> Cancel </button>
<button mat-raised-button (click)="closeDialog()" color="primary"> Confirm </button>
</div>
</div>

<mat-divider></mat-divider>
@@ -85,7 +90,7 @@ <h4 id="saveLocation">Location: {{getFilePath() === "" ? "N/A" : getFilePath()}}
<br/>

</mat-dialog-content>
<mat-dialog-actions align="end">
<mat-dialog-actions *ngIf="!isMobileUser" align="end">
<button mat-button [mat-dialog-close]="false"> Cancel </button>
<button mat-raised-button (click)="closeDialog()" color="primary"> Confirm </button>
</mat-dialog-actions>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div [ngClass]="{'dark-theme': isDarkTheme | async}" class="mat-dialog-inner-container mat-app-background">

<h2 mat-dialog-title>
<div class="row space-between align-baseline">
<h2 mat-dialog-title>
{{torrent.name}}
<p style="font-size: 10pt; margin: 0;"><i>{{torrent.hash}}</i></p>
<p></p>
@@ -18,7 +19,12 @@ <h2 mat-dialog-title>
>
</p-tag>
</div>
</h2>
</h2>

<button *ngIf="isMobileUser" mat-icon-button [mat-dialog-close]="true">
<mat-icon>close</mat-icon>
</button>
</div>

<mat-dialog-content class="mat-typography torrent-info-container">
<mat-tab-group mat-align-tabs="start">
@@ -81,7 +87,7 @@ <h2 mat-dialog-title>
</mat-dialog-content>

<mat-dialog-actions align="end">
<button mat-button [mat-dialog-close]="true">Close</button>
<button *ngIf="!isMobileUser" mat-button [mat-dialog-close]="true">Close</button>
</mat-dialog-actions>

</div>
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { TorrentDataStoreService } from '../../services/torrent-management/torre
import { NetworkConnectionInformationService } from '../../services/network/network-connection-information.service';
import { FileSystemService, SerializedNode } from '../../services/file-system/file-system.service';
import DirectoryNode from 'src/app/services/file-system/FileSystemNodes/DirectoryNode';
import { getClassForStatus } from 'src/utils/Helpers';
import { getClassForStatus, IsMobileUser } from 'src/utils/Helpers';
import { SnackbarService } from 'src/app/services/notifications/snackbar.service';

@Component({
@@ -30,6 +30,8 @@ export class TorrentInfoDialogComponent implements OnInit {

private allowDataRefresh = true;

public isMobileUser = IsMobileUser();

constructor(@Inject(MAT_DIALOG_DATA) data: any, private units_helper: UnitsHelperService,
private pp: PrettyPrintTorrentDataService, private theme: ThemeService, private data_store: TorrentDataStoreService,
private network_info: NetworkConnectionInformationService, private fs: FileSystemService, private snackbar: SnackbarService) {
@@ -76,6 +78,11 @@ export class TorrentInfoDialogComponent implements OnInit {

// Serialize & update
this.torrentContentsAsNodes = await this.fs.SerializeFileSystem(fs_root);

// Need a weighted average for total progress.
// Luckily qBittorrent already calculates this for us!
this.torrentContentsAsNodes[0].progress = this.torrent.progress;

this.isLoading = false;
}

47 changes: 25 additions & 22 deletions src/app/services/app/application-config.service.ts
Original file line number Diff line number Diff line change
@@ -12,34 +12,26 @@ import { ApplicationDefaults } from './defaults';
import { NetworkConnectionInformationService } from '../network/network-connection-information.service';
import { MergeDeep } from 'src/utils/Helpers';
import { BehaviorSubject } from 'rxjs';
import { Constants } from 'src/constants';

@Injectable({
providedIn: 'root'
})
export class ApplicationConfigService {

static THEME_OPTIONS = ['Light', 'Dark'];
static TORRENT_TABLE_COLUMNS: TORRENT_TABLE_COLUMNS[] = [
'Name', 'Size', 'Progress', 'Status',
'Down Speed', 'Up Speed', 'ETA',
'Ratio', 'Uploaded',
'Completed On', 'Added On', 'Last Activity'
];

static TORRENT_TABLE_COLUMNS_MAPPING = {
'Name': 'name',
'Size': 'size',
'Progress': 'progress',
'Status': 'state',
'Down Speed': 'dlspeed',
'Up Speed': 'upspeed',
'ETA': 'eta',
'Ratio': 'ratio',
'Uploaded': 'uploaded',
'Completed On': 'completion_on',
'Added On': 'added_on',
'Last Activity': 'last_activity'
}

static TORRENT_TABLE_COLUMNS: TORRENT_TABLE_COLUMNS[] = Constants.TORRENT_TABLE_COLUMNS;
static TORRENT_TABLE_COLUMNS_MAPPING = Constants.TORRENT_TABLE_COLUMNS_MAPPING;

/**
* Map column name to its user-desired width. If no width is set, defaults to zero (0).
*/
static TORRENT_TABLE_COLUMN_WIDTHS: { [x: string] : number } = ApplicationConfigService.TORRENT_TABLE_COLUMNS.reduce((prev, col) => {
prev[col] = 0;
return prev;
}, {})


/** All available columns for the torrent table */
static ALL_COLUMNS = ['select', 'Actions', ...ApplicationConfigService.TORRENT_TABLE_COLUMNS];
@@ -63,7 +55,6 @@ export class ApplicationConfigService {
private loaded_preferences = false;

constructor(private data_store: TorrentDataStoreService, private networkInfo: NetworkConnectionInformationService, private http: HttpClient) {

this.application_version = _appConfig.version;
this.data_store.GetApplicationBuildInfo()
.then(res => { this.qBitBuildInfo = res })
@@ -86,6 +77,18 @@ export class ApplicationConfigService {
this._persistWebUIOptions(updateNow);
}

/**
* Update column width with change in width provided.
*
* E.g. if previous width was 10, and delta = -5, then new width is 5.
* */
setColumnWidth(col: TORRENT_TABLE_COLUMNS, delta: number) {
let colWidths = this.user_preferences.web_ui_options.torrent_table.column_widths
colWidths[col] = colWidths[col] + delta;

this._persistWebUIOptions();
}

async getQbittorrentBuildInfo(): Promise<QbittorrentBuildInfo> {
if(!this.qBitBuildInfo) { this.qBitBuildInfo = await this.data_store.GetApplicationBuildInfo(); }

7 changes: 6 additions & 1 deletion src/app/services/app/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Constants } from 'src/constants';
import { WebUISettings } from 'src/utils/Interfaces';

const all_columns = Constants.TORRENT_TABLE_COLUMNS
const col_widths = Constants.TORRENT_TABLE_COLUMNS_WIDTHS

/** A class to represent various default configurations for the application. */
export class ApplicationDefaults {

@@ -14,7 +18,8 @@ export class ApplicationDefaults {
column_name: 'Completed On',
order: 'desc'
},
columns_to_show: ['select', 'Actions', 'Name', 'Size', 'Progress', 'Status', 'Down Speed', 'Up Speed', 'ETA', 'Completed On']
columns_to_show: ['select', 'Actions', 'Name', 'Size', 'Progress', 'Status', 'Down Speed', 'Up Speed', 'ETA', 'Completed On'],
column_widths: all_columns.reduce((prev, col) => { prev[col] = col_widths[col]; return prev; }, {})
},
upload_torrents: {
show_parsed_torrents_from_file: true,
Loading