From 3ee069c876754122c6d7a41c840bd2a688c7a0d6 Mon Sep 17 00:00:00 2001 From: Joris Bertomeu Date: Mon, 25 Aug 2025 14:34:33 +0200 Subject: [PATCH] lil fix + add flush queue feat --- src/app/app.component.html | 7 +++++-- src/app/app.component.spec.ts | 29 ----------------------------- src/app/app.component.ts | 11 ++++++++++- src/app/video-processing.service.ts | 4 ++++ 4 files changed, 19 insertions(+), 32 deletions(-) delete mode 100644 src/app/app.component.spec.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 051cac1..59125dd 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -129,6 +129,9 @@
Jobs Queue ({{jobs.length}}) +
@@ -149,8 +152,8 @@
{{job.data.wantedResolution?.name || 'Unknown'}} @{{humanFileSize(job.data.wantedResolution.bandwidth)}} ({{job.data.wantedResolution.codec}})
- {{displayJobAudio(job.data.wantedAudioTracks) || 'Unknown'}}
- {{displayJobAudio(job.data.wantedSubtitles) || 'Unknown'}}
+ {{displayJobAudio(job?.data?.wantedAudioTracks) || 'Unknown'}}
+ {{displayJobAudio(job?.data?.wantedSubtitles) || 'Unknown'}}
diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index da988d4..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have the 'crawlflix' title`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('crawlflix'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, crawlflix'); - }); -}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4a3a266..9c494e2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -100,6 +100,15 @@ export class AppComponent implements OnInit { }); } + flushQueue() { + this.videoProcessingService.flushQueue().subscribe({ + next: (response) => { + }, + error: (error) => { + } + }); + } + humanFileSize(size: number) { var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024)); return +((size / Math.pow(1024, i)).toFixed(2)) * 1 + ' ' + ['bps', 'kbps', 'mbps', 'gbps', 'tbps'][i]; @@ -132,7 +141,7 @@ export class AppComponent implements OnInit { displayJobAudio(tracks: any) { if (tracks.length === 0) return 'None'; - return tracks.map((elem: any) => `${elem.name} (${elem.attributes.CODECS})`).join(' + '); + return tracks.map((elem: any) => `${elem.name}${elem.attributes?.CODECS ? ` (${elem.attributes.CODECS || 'N/A'})` : ''}`).join(' + '); } onSubmitLoad() { diff --git a/src/app/video-processing.service.ts b/src/app/video-processing.service.ts index 026b48c..4364595 100644 --- a/src/app/video-processing.service.ts +++ b/src/app/video-processing.service.ts @@ -34,4 +34,8 @@ export class VideoProcessingService { downloadFile(filePath: string): Observable { return this.http.get(`${this.apiUrl}/download/${filePath}`, { responseType: 'blob' }); } + + flushQueue(): Observable { + return this.http.delete(`${this.apiUrl}/jobs/completed`, {}); + } } \ No newline at end of file