-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from irohalab/download-directly
download directly support
- Loading branch information
Showing
14 changed files
with
321 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "mira-ui", | ||
"version": "2.5.4", | ||
"version": "2.6.0", | ||
"scripts": { | ||
"ng": "ng", | ||
"start": "ng serve", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/app/admin/bangumi-detail/universal-builder/download-editor/download-editor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; | ||
import { MediaFile } from '../../../../entity/MediaFile'; | ||
import { UIDialogRef, UIToast, UIToastComponent, UIToastRef } from '@irohalab/deneb-ui'; | ||
import { Subscription } from 'rxjs'; | ||
import { AdminService } from '../../../admin.service'; | ||
import { Item } from '../../../../entity/item'; | ||
import { copyElementValueToClipboard } from '../../../../../helpers/clipboard'; | ||
|
||
@Component({ | ||
selector: 'download-editor', | ||
templateUrl: './download-editor.html', | ||
styleUrls: ['./download-editor.less'] | ||
}) | ||
export class DownloadEditorComponent implements OnDestroy { | ||
private _subscription = new Subscription(); | ||
private _toastRef: UIToastRef<UIToastComponent>; | ||
|
||
torrentTitle: string; | ||
downloadUrl: string; | ||
|
||
files: MediaFile[]; | ||
|
||
eps_mapping: {eps_no: number, format: string, selected: boolean}[]; | ||
|
||
bangumi_id: string; | ||
|
||
@ViewChild('downloadUrlTextBox', {static: true}) _downloadUrlTextBoxRef: ElementRef; | ||
|
||
constructor(private _adminService: AdminService, | ||
private _dialogRef: UIDialogRef<DownloadEditorComponent>, | ||
toast: UIToast) { | ||
this._toastRef = toast.makeText(); | ||
} | ||
copyDownloadUrlToClipboard(): void { | ||
const downloadUrlInput = this._downloadUrlTextBoxRef.nativeElement; | ||
copyElementValueToClipboard(downloadUrlInput) | ||
this._toastRef.show('已经复制到剪贴板'); | ||
} | ||
download(): void { | ||
this._subscription.add( | ||
this._adminService.downloadDirectly( | ||
this.bangumi_id, | ||
this.eps_mapping.filter(mapping => mapping.selected).map((mapping, idx) => { | ||
return { | ||
download_url: this.downloadUrl, | ||
eps_no: mapping.eps_no, | ||
file_path: this.files[idx].path, | ||
file_name: this.files[idx].name | ||
}; | ||
})) | ||
.subscribe({ | ||
next: () => { | ||
this._dialogRef.close(true); | ||
}, | ||
error: (error) => { | ||
this._toastRef.show(error?.message); | ||
} | ||
}) | ||
); | ||
} | ||
|
||
cancel(): void { | ||
this._dialogRef.close(false); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this._subscription.unsubscribe(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/app/admin/bangumi-detail/universal-builder/download-editor/download-editor.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div class="download-editor-container"> | ||
<div class="torrent-info-wrapper"> | ||
<h3 class="torrent-name">{{torrentTitle}}</h3> | ||
<div class="download-url-wrapper ui mini fluid icon input"> | ||
<input class="download-url" type="text" [value]="downloadUrl" #downloadUrlTextBox /> | ||
<i class="copy outline link icon" (click)="copyDownloadUrlToClipboard()"></i> | ||
</div> | ||
</div> | ||
<div class="file-list-wrapper"> | ||
<table class="file-list-table ui striped table"> | ||
<thead> | ||
<tr> | ||
<th>File Path</th> | ||
<th>Size</th> | ||
<th>Episode</th> | ||
<th>Select</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let file of files; index as i"> | ||
<td>{{file.path}}</td> | ||
<td>{{file.size | readableUnit:'byte':2}}</td> | ||
<td class="episode-number"><input type="number" [(ngModel)]="eps_mapping[i].eps_no" /></td> | ||
<td> | ||
<div class="ui checkbox"> | ||
<input type="checkbox" [(ngModel)]="eps_mapping[i].selected"> | ||
<label></label> | ||
</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="footer"> | ||
<button class="ui button" (click)="cancel()">取消</button> | ||
<button class="ui primary button" (click)="download()">下载</button> | ||
</div> | ||
</div> |
88 changes: 88 additions & 0 deletions
88
src/app/admin/bangumi-detail/universal-builder/download-editor/download-editor.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
.download-editor-container { | ||
text-align: left; | ||
@media(max-width: 767px) { | ||
width: 100%; | ||
} | ||
@media(min-width: 768px) and (max-width: 991px) { | ||
width: 723px; | ||
} | ||
@media(min-width: 992px) and (max-width: 1200px) { | ||
width: 933px; | ||
} | ||
@media(min-width: 1201px) and (max-width: 1599px){ | ||
width: 1127px; | ||
} | ||
@media(min-width: 1601px) { | ||
width: 1600px; | ||
} | ||
@media(min-height: 700px) { | ||
height: 80%; | ||
} | ||
@media(max-height: 639px) { | ||
height: 100%; | ||
} | ||
margin: auto; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
position: absolute; | ||
border-radius: 4px; | ||
background-color: #fff; | ||
overflow: hidden; | ||
padding-top: 5rem; | ||
.ui.dropdown .menu { | ||
z-index: 310; | ||
} | ||
} | ||
|
||
.torrent-info-wrapper { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 5rem; | ||
border-bottom: 1px solid #cccccc; | ||
border-top-left-radius: 4px; | ||
border-top-right-radius: 4px; | ||
background-color: #ffffff; | ||
.torrent-name { | ||
margin: 0.5rem 0.6rem; | ||
} | ||
.download-url-wrapper { | ||
margin-left: 0.6rem; | ||
margin-right: 0.6rem; | ||
} | ||
} | ||
|
||
.file-list-wrapper { | ||
position: relative; | ||
height: 100%; | ||
width: 100%; | ||
padding-bottom: 5rem; | ||
overflow-y: scroll; | ||
overflow-x: auto; | ||
|
||
td.episode-number > input[type=number] { | ||
width: 4.5em; | ||
} | ||
} | ||
|
||
.footer { | ||
position: absolute; | ||
width: 100%; | ||
height: 5rem; | ||
left: 0; | ||
bottom: 0; | ||
padding-right: 1rem; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-items: center; | ||
border-top: 1px solid #e2e2e2; | ||
background-color: #fff; | ||
z-index: 220; | ||
> .ui.button { | ||
margin-right: 2rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.