mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-25 22:20:56 +03:00
Archive improvements
Began UI for viewing/modifying archives
This commit is contained in:
@@ -94,6 +94,7 @@ import { TaskSettingsComponent } from './components/task-settings/task-settings.
|
||||
import { GenerateRssUrlComponent } from './dialogs/generate-rss-url/generate-rss-url.component';
|
||||
import { SortPropertyComponent } from './components/sort-property/sort-property.component';
|
||||
import { OnlyNumberDirective } from './directives/only-number.directive';
|
||||
import { ArchiveViewerComponent } from './components/archive-viewer/archive-viewer.component';
|
||||
|
||||
registerLocaleData(es, 'es');
|
||||
|
||||
@@ -145,7 +146,8 @@ registerLocaleData(es, 'es');
|
||||
TaskSettingsComponent,
|
||||
GenerateRssUrlComponent,
|
||||
SortPropertyComponent,
|
||||
OnlyNumberDirective
|
||||
OnlyNumberDirective,
|
||||
ArchiveViewerComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<!-- (selectionChange)="sidePanelModeChanged($event.value)" -->
|
||||
|
||||
<div [hidden]="!(archives && archives.length > 0)">
|
||||
<div style="overflow: hidden;" class="mat-elevation-z8">
|
||||
<mat-table style="overflow: hidden" matSort [dataSource]="dataSource">
|
||||
|
||||
<!-- Date Column -->
|
||||
<ng-container matColumnDef="timestamp">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> <ng-container i18n="Date">Date</ng-container> </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element"> {{element.timestamp | date: 'short'}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Title Column -->
|
||||
<ng-container matColumnDef="title">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> <ng-container i18n="Title">Title</ng-container> </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element">
|
||||
<span class="one-line" [matTooltip]="element.title ? element.title : null">
|
||||
{{element.title}}
|
||||
</span>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- ID Column -->
|
||||
<ng-container matColumnDef="id">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> <ng-container i18n="ID">ID</ng-container> </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element">
|
||||
<span class="one-line" [matTooltip]="element.title ? element.title : null">
|
||||
{{element.id}}
|
||||
</span>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Extractor Column -->
|
||||
<ng-container matColumnDef="extractor">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> <ng-container i18n="Extractor">Extractor</ng-container> </mat-header-cell>
|
||||
<mat-cell *matCellDef="let element">
|
||||
<span class="one-line" [matTooltip]="element.extractor? element.extractor : null">
|
||||
{{element.extractor}}
|
||||
</span>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="(!archives || archives.length === 0)">
|
||||
<h4 style="text-align: center; margin-top: 10px;" i18n="Archives empty">Archives empty</h4>
|
||||
</div>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ArchiveViewerComponent } from './archive-viewer.component';
|
||||
|
||||
describe('ArchiveViewerComponent', () => {
|
||||
let component: ArchiveViewerComponent;
|
||||
let fixture: ComponentFixture<ArchiveViewerComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ArchiveViewerComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ArchiveViewerComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { Archive } from 'api-types/models/Archive';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
|
||||
@Component({
|
||||
selector: 'app-archive-viewer',
|
||||
templateUrl: './archive-viewer.component.html',
|
||||
styleUrls: ['./archive-viewer.component.scss']
|
||||
})
|
||||
export class ArchiveViewerComponent {
|
||||
archives = null;
|
||||
displayedColumns: string[] = ['timestamp', 'title', 'id', 'extractor'];
|
||||
dataSource = null;
|
||||
archives_retrieved = false;
|
||||
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(private postsService: PostsService) {
|
||||
|
||||
}
|
||||
|
||||
filterSelectionChanged(value: string): void {
|
||||
this.getArchives(value);
|
||||
}
|
||||
|
||||
getArchives(sub_id: string = null): void {
|
||||
this.postsService.getArchives(sub_id).subscribe(res => {
|
||||
if (res['archives'] !== null
|
||||
&& res['archives'] !== undefined
|
||||
&& JSON.stringify(this.archives) !== JSON.stringify(res['archives'])) {
|
||||
this.archives = res['archives']
|
||||
this.dataSource = new MatTableDataSource<Archive>(this.archives);
|
||||
this.dataSource.sort = this.sort;
|
||||
} else {
|
||||
// failed to get downloads
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,8 @@ export class CookiesUploaderDialogComponent implements OnInit {
|
||||
// Is it a file?
|
||||
if (droppedFile.fileEntry.isFile) {
|
||||
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
|
||||
fileEntry.file((file: File) => {
|
||||
// You could upload it like this:
|
||||
const formData = new FormData()
|
||||
formData.append('cookies', file, droppedFile.relativePath);
|
||||
this.postsService.uploadCookiesFile(formData).subscribe(res => {
|
||||
fileEntry.file((file: File) => {
|
||||
this.postsService.uploadCookiesFile(file, droppedFile.relativePath).subscribe(res => {
|
||||
this.uploading = false;
|
||||
if (res['success']) {
|
||||
this.uploaded = true;
|
||||
|
||||
@@ -106,7 +106,10 @@ import {
|
||||
SetNotificationsToReadRequest,
|
||||
GetNotificationsResponse,
|
||||
UpdateTaskOptionsRequest,
|
||||
User
|
||||
User,
|
||||
DeleteArchiveItemRequest,
|
||||
GetArchivesRequest,
|
||||
GetArchivesResponse
|
||||
} from '../api-types';
|
||||
import { isoLangs } from './settings/locales_list';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
@@ -431,8 +434,11 @@ export class PostsService implements CanActivate {
|
||||
return this.http.post<UpdateConcurrentStreamResponse>(this.path + 'updateConcurrentStream', body, this.httpOptions);
|
||||
}
|
||||
|
||||
uploadCookiesFile(fileFormData) {
|
||||
return this.http.post<SuccessObject>(this.path + 'uploadCookies', fileFormData, this.httpOptions);
|
||||
uploadCookiesFile(cookiesFile: File, cookiesFilePath: string) {
|
||||
const formData = new FormData()
|
||||
formData.append('cookies', cookiesFile, cookiesFilePath);
|
||||
// const body: UploadCookiesRequest = formData;
|
||||
return this.http.post<SuccessObject>(this.path + 'uploadCookies', formData, this.httpOptions);
|
||||
}
|
||||
|
||||
downloadArchive(type: FileType, sub_id: string) {
|
||||
@@ -440,6 +446,24 @@ export class PostsService implements CanActivate {
|
||||
return this.http.post(this.path + 'downloadArchive', body, {responseType: 'blob', params: this.httpOptions.params});
|
||||
}
|
||||
|
||||
getArchives(sub_id: string) {
|
||||
const body: GetArchivesRequest = {sub_id: sub_id};
|
||||
return this.http.post<GetArchivesResponse>(this.path + 'getArchives', body, this.httpOptions);
|
||||
}
|
||||
|
||||
importArchive(archiveFile: File, type: FileType, sub_id: string = null) {
|
||||
const formData = new FormData()
|
||||
formData.append('archive', archiveFile, 'archive.txt');
|
||||
formData.append('type', type);
|
||||
formData.append('sub_id', sub_id);
|
||||
return this.http.post<SuccessObject>(this.path + 'importArchive', formData, this.httpOptions);
|
||||
}
|
||||
|
||||
deleteArchiveItem(extractor: string, id: string, type: FileType, sub_id: string = null) {
|
||||
const body: DeleteArchiveItemRequest = {extractor: extractor, id: id, type: type, sub_id: sub_id};
|
||||
return this.http.post<SuccessObject>(this.path + 'deleteArchiveItem', body, this.httpOptions);
|
||||
}
|
||||
|
||||
getFileFormats(url) {
|
||||
const body: GetFileFormatsRequest = {url: url};
|
||||
return this.http.post<GetFileFormatsResponse>(this.path + 'getFileFormats', body, this.httpOptions);
|
||||
|
||||
Reference in New Issue
Block a user