From abcb3f915980ed210025ca01b58727a4190da39d Mon Sep 17 00:00:00 2001 From: Joris Bertomeu Date: Tue, 1 Oct 2024 17:44:55 +0200 Subject: [PATCH] Add new update mech --- angular.json | 8 ++- src/app/app.component.html | 61 ++++++++++++++++++++- src/app/app.component.ts | 53 +++++++++++------- src/app/video-processing.service.ts | 11 +++- src/environments/environment.development.ts | 3 + src/environments/environment.ts | 3 + 6 files changed, 117 insertions(+), 22 deletions(-) create mode 100644 src/environments/environment.development.ts create mode 100644 src/environments/environment.ts diff --git a/angular.json b/angular.json index 355d08e..ede55f6 100644 --- a/angular.json +++ b/angular.json @@ -50,7 +50,13 @@ "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/src/app/app.component.html b/src/app/app.component.html index 4a51a56..3025918 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -6,6 +6,63 @@ Paramount+ / Max HBO / Netflix / Disney+ / Amazon Prime / Canal+ +
+
+
+
+ Downloader +
+
+ Installed binary: + + Yes + + + No + +
+
+ Update available: + + Yes - + + + No + +
+
+
+
+ Content Decrypter +
+
+ Installed binary: + + Yes + + + No + +
+
+ Update available: + + Yes - + + + No + +
+
+
+
+
+
+ +
+
+
+
@@ -52,11 +109,13 @@
Jobs Queue ({{jobs.length}}) +
- + + Nothing to display
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a2ba128..4ba1112 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -18,6 +18,8 @@ export class AppComponent implements OnInit { jobStatus: string | null = null; jobProgress: number = 0; jobs: Array = []; + lastJobSuccess: boolean = false; + welcomeHeader: any = null; initForm() { this.processingForm = this.fb.group({ @@ -40,6 +42,7 @@ export class AppComponent implements OnInit { ngOnInit(): void { this.startPollingJobsStatus(); + this.sayHello(); } downloadFileFromAPI(filePath: string, filename: string, job: any) { @@ -62,6 +65,34 @@ export class AppComponent implements OnInit { }); } + processUpdate(item: any, binType: string) { + item.isUpdating = true; + + this.videoProcessingService.processUpdate(Object.assign(item, {binType})).subscribe({ + next: (response) => { + item.isUpdating = false; + this.welcomeHeader = null; + this.sayHello(); + }, + error: (error) => { + console.error('Hello failed', error); + item.isUpdating = false; + } + }); + } + + sayHello() { + this.videoProcessingService.hello().subscribe({ + next: (response) => { + console.log('Hello success', response); + this.welcomeHeader = response; + }, + error: (error) => { + console.error('Hello failed', error); + } + }); + } + onSubmit() { if (this.processingForm.valid) { const formData = this.processingForm.value; @@ -90,28 +121,11 @@ export class AppComponent implements OnInit { }); } - // startPollingJobsStatus() { - // const interval = setInterval(() => { - // this.videoProcessingService.getJobsStatus(this.jobId!).subscribe({ - // next: (response) => { - // this.jobStatus = response.state; - // this.jobProgress = response.progress; - // if (['completed', 'failed'].includes(response.state)) { - // clearInterval(interval); - // } - // }, - // error: (error) => { - // console.error('Error fetching job status:', error); - // clearInterval(interval); - // } - // }); - // }, 1000); - // } - startPollingJobsStatus() { const interval = setInterval(() => { this.videoProcessingService.getJobsStatus().subscribe({ next: (response) => { + this.lastJobSuccess = true; this.jobs = response; // if (['completed', 'failed'].includes(response.state)) { // clearInterval(interval); @@ -119,9 +133,10 @@ export class AppComponent implements OnInit { }, error: (error) => { console.error('Error fetching job status:', error); + this.lastJobSuccess = false; //clearInterval(interval); } }); - }, 1000); + }, 1500); } } \ No newline at end of file diff --git a/src/app/video-processing.service.ts b/src/app/video-processing.service.ts index 2d1d7f4..302b001 100644 --- a/src/app/video-processing.service.ts +++ b/src/app/video-processing.service.ts @@ -1,12 +1,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; +import { environment } from '../environments/environment'; @Injectable({ providedIn: 'root' }) export class VideoProcessingService { - private apiUrl = '/api'; + private apiUrl = environment.serviceEndpoint; constructor(private http: HttpClient) { } @@ -18,6 +19,14 @@ export class VideoProcessingService { return this.http.get>(`${this.apiUrl}/jobs-status`); } + hello(): Observable> { + return this.http.get(`${this.apiUrl}/hello`); + } + + processUpdate(data: any): Observable { + return this.http.post(`${this.apiUrl}/processUpdate`, data); + } + downloadFile(filePath: string): Observable { return this.http.get(`${this.apiUrl}/download/${filePath}`, { responseType: 'blob' }); } diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts new file mode 100644 index 0000000..b9cc331 --- /dev/null +++ b/src/environments/environment.development.ts @@ -0,0 +1,3 @@ +export const environment = { + serviceEndpoint: 'http://localhost:3000' +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..a5546e9 --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,3 @@ +export const environment = { + serviceEndpoint: '/api' +};