Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
-.- committed Aug 6, 2018
1 parent e8f2313 commit 1ba3261
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 45 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 16,3 @@ ng build --prod --build-optimizer
install nginx
copy dist/web/* to your /var/www/html


2 changes: 1 addition & 1 deletion src/app/app.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 19,7 @@
}
.menu-item{padding-top: 20px;}
.menu-item .fa{font-size: 36px;}
.menu-item span{display: inline-block;padding-left: 20px;position: relative;top:-6px;font-size: 24px;}
.menu-item span{display: inline-block;padding-left: 5px;position: relative;top:-5px;font-size: 24px;}
.menu-item{color: #ADAEAE;}
.menu .menu-item.active,.menu .menu-item:hover{color: #0099FB;cursor: pointer}
.main{margin-top: 50px;}
20 changes: 12 additions & 8 deletions src/app/download/download.component.css
Original file line number Diff line number Diff line change
@@ -1,11 1,5 @@
.global-chart-wrapper{width: 100%;height: 50px;position: absolute;top:200px;opacity: 0.3;left:-100px}
.global-chart-wrapper{width: 100%;height: 50px;position: absolute;top:200px;opacity: 0.3;left:-30px}
.download-container{margin-top: 30px;margin-bottom: 30px;}


.download-table{margin-top: 32px;table-layout: fixed}



.download-header{font-weight: 600;height: 40px;margin-top: 30px;padding: 8px 0 6px 0;display: flex;border-top: 1px solid #ced4da}
.download-item{padding: 9px 0 8px 0;cursor: pointer;display: flex;border-top: 1px solid #ced4da}
.download-item:hover{background-color: #EEEEEE}
Expand All @@ -18,6 12,16 @@
.circle-progress{position: relative;left: -9px;}
.progress-mask{position: absolute;margin-top: 8px;font-size: 14px;width:40px;text-align: center;left:4px}

@media screen and (max-width:800px) {
.col-size,.col-status{display: none !important;}
.col-prog,.col-speed{max-width: none}
.download-item-nav{width: 75px !important;}
.tab-wrapper{width: calc(100% - 82px) !important;}
.detail-table th{width: 40% !important;}
.detail-table td{width: 60% !important;}

}

.nav-link{cursor: pointer;background-color: white;padding-left: 5px;border-left: 1px solid #ced4da;border-top: 1px solid #ced4da;border-bottom: 1px solid #ced4da;margin-bottom: 4px;border-radius: 3px;}
.nav-link.active,.nav-link:hover{color: #007bff !important;}
.download-item-nav{width: 8.333333%;padding-left: 15px;}
Expand All @@ -27,7 31,7 @@

.item-controls{margin: 15px 0;}
.item-controls button{display: inline-block;margin-right: 15px;}

.files-filename{word-break: break-all}
.files-table{font-size: 14px;}
.mix-content{padding-top: 24px;}
.speed-chart{margin-bottom: 20px;}
Expand Down
32 changes: 16 additions & 16 deletions src/app/download/download.component.html
Original file line number Diff line number Diff line change
@@ -1,8 1,8 @@
<div class="row">
<div class="row" #cc>
<h4 class="col-8">Downloading</h4>
<div class="global-chart-wrapper">
<ngx-charts-area-chart
[view]="[2100, 60]"
[view]="[cc.ownerDocument.body.offsetWidth 60, 60]"
[scheme]="{'domain': ['#007bff', '#28a745']}"
[results]="global_data.chart"
[yAxisTickFormatting]="formatSize"
Expand Down Expand Up @@ -33,15 33,15 @@ <h4 class="col-8">Downloading</h4>
<button class="btn btn-sm btn-primary" (click)="pauseAll()"><i class="fa fa-pause-circle-o" aria-hidden="true"></i> pauseAll</button>
</div>
<div class="download-header">
<div class="col-1">#</div>
<div class="col-6">Name</div>
<div class="col-1">Size</div>
<div class="col-2">Speed</div>
<div class="col-2">Status</div>
<div class="col-1 col-prog flex-fill">#</div>
<div class="col-6 col-name">Name</div>
<div class="col-1 col-size">Size</div>
<div class="col-2 col-speed flex-fill">Speed</div>
<div class="col-2 col-status">Status</div>
</div>
<div *ngFor="let active of active_data">
<div class="download-item" (click)="active.show_tab = !active.show_tab;">
<div class="col-1">
<div class="col-1 col-prog flex-fill">
<div class="progress-mask">{{ active.percent | number: '1.0-0'}}</div>
<round-progress class="circle-progress"
[current]="active.percent"
Expand All @@ -52,19 52,19 @@ <h4 class="col-8">Downloading</h4>
[color]="'#fd7e14'"
></round-progress>
</div>
<div class="col-6">
<div class="col-6 col-name">
<div class="main-content">{{ active.name }}</div>
<div class="secondary-content">{{ active.dir }}</div>
</div>
<div class="col-1">
<div class="col-1 col-size">
<div class="main-content">{{ active.completed }}</div>
<div class="secondary-content">{{ active.length }}</div>
</div>
<div class="col-2">
<div class="col-2 col-speed flex-fill">
<div class="main-content">{{ active.down_speed_human }}</div>
<div class="secondary-content">{{ active.remain }}</div>
</div>
<div class="col-2">
<div class="col-2 col-status">
<div class="main-content">{{ active.status |uppercase }}</div>
<div class="secondary-content">{{ active.connections }}个连接, {{ active.file_completed }} / {{ active.files.length }}个文件完成 </div>
</div>
Expand Down Expand Up @@ -120,9 120,9 @@ <h4 class="col-8">Downloading</h4>
</table>
</div>
<div *ngIf="active.tab == 'speed'">
<div class="speed-wrapper">
<div class="speed-wrapper" #cd>
<ngx-charts-line-chart
[view]="[1000, 200]"
[view]="[cc.offsetWidth - 110, 200]"
[scheme]="{'domain': ['#007bff', '#28a745']}"
[results]="active.chart"
[yAxisTickFormatting]="formatSize"
Expand All @@ -144,10 144,10 @@ <h4 class="col-8">Downloading</h4>
</div>
<table class="table files-table">
<tr *ngFor="let file of active.files">
<td>
<td class="files-filename">
{{ file.name }}
</td>
<td>{{ file.completed }} / {{ file.length }}</td>
<td class="files-percent">{{ file.completed }} / {{ file.length }}</td>
</tr>
</table>
</div>
Expand Down
28 changes: 14 additions & 14 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
@@ -1,44 1,44 @@
<div *ngIf="config">
<form (ngSubmit)="submit()">
<div class="form-group row">
<label for="rpc" class="col-2 col-form-label">RPC URI</label>
<div class="col-10">
<label for="rpc" class="col-4 col-form-label">RPC URI</label>
<div class="col-8">
<input type="text" class="form-control" id="rpc" name="rpc" #rpc="ngModel" [pattern]="'^http://.*$'" required placeholder="Example http://192.168.1.1:6800/jsonrpc" [(ngModel)]="config['rpc']">
</div>
</div>
<div class="form-group row">
<label for="token" class="col-2 col-form-label">Token</label>
<div class="col-10">
<label for="token" class="col-4 col-form-label">Token</label>
<div class="col-8">
<input type="text" class="form-control" id="token" name="token" #token="ngModel" minlength="1" required placeholder="Example 123456" [(ngModel)]="config['token']">
</div>
</div>
<div class="form-group row">
<label for="down" class="col-2 col-form-label">Download Limit</label>
<div class="col-10">
<label for="down" class="col-4 col-form-label">Download Limit</label>
<div class="col-8">
<input type="number" class="form-control" id="down" min="10" name="down" #down="ngModel" placeholder="Example 123456 Byte / S" [(ngModel)]="config['max-overall-download-limit']">
</div>
</div>
<div class="form-group row">
<label for="up" class="col-2 col-form-label">Upload Limit</label>
<div class="col-10">
<label for="up" class="col-4 col-form-label">Upload Limit</label>
<div class="col-8">
<input type="number" class="form-control" id="up" min="10" name="up" #up="ngModel" placeholder="Example 123456 Byte / S" [(ngModel)]="config['max-overall-upload-limit']">
</div>
</div>
<div class="form-group row">
<label for="concurrent" class="col-2 col-form-label">Concurrent Download</label>
<div class="col-10">
<label for="concurrent" class="col-4 col-form-label">Concurrent Download</label>
<div class="col-8">
<input type="number" class="form-control" id="concurrent" min="1" max="50" name="concurrent" #concurrent="ngModel" placeholder="Example 10" [(ngModel)]="config['max-concurrent-downloads']">
</div>
</div>
<div class="form-group row">
<label for="entry" class="col-2 col-form-label">DHT Entry</label>
<div class="col-10">
<label for="entry" class="col-4 col-form-label">DHT Entry</label>
<div class="col-8">
<input type="text" class="form-control" id="entry" name="entry" #entry="ngModel" [pattern]="'^(\\d \\.){3}\\d \:\\d $'" placeholder="Example 212.129.33.59:6881" [(ngModel)]="config['dht-entry-point']">
</div>
</div>
<div class="form-group row">
<label for="trackers" class="col-2 col-form-label">Trackers</label>
<div class="col-10">
<label for="trackers" class="col-4 col-form-label">Trackers</label>
<div class="col-8">
<textarea class="form-control" rows="8" id="trackers" name="trackers" #trackers="ngModel" placeholder="Example udp://62.138.0.158:6969/announce" [(ngModel)]="config['bt-tracker']"></textarea>
</div>
</div>
Expand Down
27 changes: 22 additions & 5 deletions src/app/wrapper.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
import { Injectable } from '@angular/core';
import { DownloadService } from "./download.service";
import { Observable, interval } from "rxjs";
import {sp} from "@angular/core/src/render3";

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -45,6 46,7 @@ export class WrapperService {
let res = [];
const humanSize = WrapperService.human_size;
const fileName = WrapperService.file_name;
const remainTime = WrapperService.remain_time;
active.forEach(function(value, index){
let item = {};
item['gid'] = value.gid;
Expand All @@ -65,11 67,7 @@ export class WrapperService {
}else{
item['name'] = null;
}
if(value.totalLength - value.completedLength > 0 && value.downloadSpeed > 0){
item['remain'] = ((value.totalLength - value.completedLength) / value.downloadSpeed / 60).toFixed(1) " 分钟剩余";
}else{
item['remain'] = "无法估算"
}
item['remain'] = remainTime(value.totalLength - value.completedLength, value.downloadSpeed);
item['files'] = [];
if(typeof value.bitfield !== "undefined" && value.bitfield !== null){
item['bitfield'] = value.bitfield.split('');
Expand Down Expand Up @@ -120,6 118,25 @@ export class WrapperService {
return "";
}

public static remain_time(size, speed){
if(size && size > 0 && speed && speed > 0){
let res = "";
let mins = size / speed / 60;
if(mins > 60 * 24){
res = (mins / 60 / 24).toFixed(2) " 天剩余";
}else if(mins > 60){
res = (mins / 60).toFixed(2) " 小时剩余";
}else if(mins > 1){
res = mins.toFixed(2) " 分剩余"
}else{
res = "马上完成";
}
return res;

}
return "无法估算"
}

public static file_name(full_path): string {
if(typeof full_path !== "undefined" && full_path !== null){
let nodes = null;
Expand Down

0 comments on commit 1ba3261

Please sign in to comment.