Add new update mech
This commit is contained in:
@@ -18,6 +18,8 @@ export class AppComponent implements OnInit {
|
||||
jobStatus: string | null = null;
|
||||
jobProgress: number = 0;
|
||||
jobs: Array<any> = [];
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user