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'
+};