Skip to content

Commit

Permalink
Fixes on synchronization page
Browse files Browse the repository at this point in the history
  • Loading branch information
albaintor committed Nov 2, 2024
1 parent 656044b commit ede1b69
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
17 changes: 15 additions & 2 deletions src/app/activity-sync/activity-sync.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ export class ActivitySyncComponent implements AfterViewInit {
this.progress = true;
this.cdr.detectChanges();

forkJoin(tasks).subscribe(results => {
forkJoin(tasks).subscribe({next: results =>
{
this.blockedMenu = false;
this.progress = false;
this.cdr.detectChanges();
Expand All @@ -594,7 +595,18 @@ export class ActivitySyncComponent implements AfterViewInit {
// this.activitiesDiff.sort((a1, a2) => a1.status.com)
console.debug("Differences between activities", this.activitiesDiff);
this.cdr.detectChanges();
})
},
error: err => {
this.blockedMenu = false;
this.progress = false;
this.messageService.add({
severity: "error",
summary: "Error during the extraction of activities"
});
console.error("Error during remote extraction", err);
this.cdr.detectChanges();
}
})
}

compareIntegrations()
Expand Down Expand Up @@ -696,6 +708,7 @@ export class ActivitySyncComponent implements AfterViewInit {
summary: `${this.remoteOperations.length} operations done`
});
this.selectedActivities = [];
this.blockedMenu = false;
this.cdr.detectChanges();
}

Expand Down
5 changes: 3 additions & 2 deletions src/app/remote-operations/remote-operations.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<p-toast key="operation"></p-toast>
<p-dialog #operationsDialog [header]="'Remotes operations to '+remote?.remote_name+' ('+remote?.address+')'" [(visible)]="visible" [style]="{width: '100vw'}" [draggable]="true"
[resizable]="true">

[resizable]="true" [closable]="!progress">
<div class="flex align-content-center flex-wrap gap-3" style="min-height: 100px">
<div class="flex align-items-center justify-content-center">
<ng-container *ngIf="operations.length > 0">
Expand All @@ -15,6 +14,8 @@
<p-button label="Reset errors only" (onClick)="resetErrors()" severity="secondary" icon="pi pi-minus" size="small" [rounded]="true"></p-button>
</div>
</div>
<p-progressBar *ngIf="progress" [value]="Math.round(100*operationsProcessed/operationsTotal)"/>
<ng-container *ngIf="progress && operationsErrors > 0">&nbsp;{{operationsErrors}} errors...</ng-container>
<ng-container *ngIf="!groupByActivities">
<p-table [value]="_operations" styleClass="p-datatable-sm p-datatable-striped" [resizableColumns]="true"
[scrollable]="true" [scrollHeight]="'calc(70vh - 50px)'" [(selection)]="selectedOperations" >
Expand Down
39 changes: 34 additions & 5 deletions src/app/remote-operations/remote-operations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {ChipModule} from "primeng/chip";
import {Helper} from "../helper";
import {Ripple} from "primeng/ripple";
import {OverlayPanel, OverlayPanelModule} from "primeng/overlaypanel";
import {ProgressBarModule} from "primeng/progressbar";

@Component({
selector: 'app-remote-operations',
Expand All @@ -36,7 +37,8 @@ import {OverlayPanel, OverlayPanelModule} from "primeng/overlaypanel";
NgxJsonViewerModule,
ChipModule,
Ripple,
OverlayPanelModule
OverlayPanelModule,
ProgressBarModule
],
templateUrl: './remote-operations.component.html',
styleUrl: './remote-operations.component.css',
Expand Down Expand Up @@ -85,9 +87,15 @@ export class RemoteOperationsComponent {
selectedOperations: RemoteOperation[] = [];
@Output() visibleChange: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() operationsDone: EventEmitter<RemoteOperation[]> = new EventEmitter<RemoteOperation[]>();
@Output() operationsStart: EventEmitter<RemoteOperation[]> = new EventEmitter<RemoteOperation[]>();
@ViewChild("resultsPannel", {static: false}) resultsPannel: OverlayPanel | undefined;
selectedOperation: RemoteOperation | undefined = undefined;
protected readonly Helper = Helper;
progress = false;
operationsTotal = 0;
operationsProcessed = 0;
operationsErrors = 0;
protected readonly OperationStatus = OperationStatus;

constructor(private server:ServerService, private cdr:ChangeDetectorRef, private messageService: MessageService)
{
Expand Down Expand Up @@ -167,8 +175,15 @@ export class RemoteOperationsComponent {

updateRemote() {
if (!this.remote) return;
const operations = from(this.selectedOperations
.filter(operation => operation.status == OperationStatus.Todo)).pipe(
this.operationsStart.emit(this.selectedOperations);
this.progress = true;
const operationsList = this.selectedOperations
.filter(operation => operation.status == OperationStatus.Todo)
this.operationsTotal = operationsList.length;
this.operationsProcessed = 0;
this.operationsErrors = 0;
this.cdr.detectChanges();
const operations = from(operationsList).pipe(
mergeMap(operation => {
this.updateOperation(operation);
if (operation.method === "POST")
Expand All @@ -177,12 +192,15 @@ export class RemoteOperationsComponent {
console.log("Results from remote for operation", operation, results);
operation.status = OperationStatus.Done;
operation.results = results;
this.operationsProcessed++;
this.cdr.detectChanges();
return of(operation);
}),
catchError(error => {
operation.status = OperationStatus.Error;
operation.message = this.getErrorMessage(error);
this.operationsProcessed++;
this.operationsErrors++;
this.cdr.detectChanges();
console.error("Error during update", operation, error);
return of(operation);
Expand All @@ -193,12 +211,15 @@ export class RemoteOperationsComponent {
console.log("Results from remote for operation", operation, results);
operation.status = OperationStatus.Done;
operation.results = results;
this.operationsProcessed++;
this.cdr.detectChanges();
return of(operation);
}),
catchError(error => {
operation.status = OperationStatus.Error;
operation.message = this.getErrorMessage(error);
this.operationsProcessed++;
this.operationsErrors++;
this.cdr.detectChanges();
console.error("Error during update", operation, error);
return of(operation);
Expand All @@ -209,12 +230,15 @@ export class RemoteOperationsComponent {
console.log("Results from remote for operation", operation, results);
operation.status = OperationStatus.Done;
operation.results = results;
this.operationsProcessed++;
this.cdr.detectChanges();
return of(operation);
}),
catchError(error => {
operation.status = OperationStatus.Error;
operation.message = this.getErrorMessage(error);
this.operationsProcessed++;
this.operationsErrors++;
this.cdr.detectChanges();
console.error("Error during update", operation, error);
return of(operation);
Expand All @@ -225,12 +249,15 @@ export class RemoteOperationsComponent {
console.log("Results from remote for operation", operation, results);
operation.status = OperationStatus.Done;
operation.results = results;
this.operationsProcessed++;
this.cdr.detectChanges();
return of(operation);
}),
catchError(error => {
operation.status = OperationStatus.Error;
operation.message = this.getErrorMessage(error);
this.operationsProcessed++;
this.operationsErrors++;
this.cdr.detectChanges();
console.error("Error during update", operation, error);
return of(operation);
Expand All @@ -249,6 +276,7 @@ export class RemoteOperationsComponent {
detail: `${success} success, ${errors} errors`,
key: "operation", sticky: true});
this.operationsDone.emit(this.operations);
this.progress = false;
this.cdr.detectChanges();
},
error: err => {
Expand All @@ -259,14 +287,13 @@ export class RemoteOperationsComponent {
detail: `${success} success, ${errors} errors`,
key: "operation", sticky: true});
this.operationsDone.emit(this.operations);
this.progress = false;
this.cdr.detectChanges();
}
}
)
}

protected readonly OperationStatus = OperationStatus;

setStatus(operation: RemoteOperation, status: OperationStatus) {
operation.status = status;
this.cdr.detectChanges();
Expand Down Expand Up @@ -300,4 +327,6 @@ export class RemoteOperationsComponent {
this.resultsPannel?.show(event, event.target);
this.cdr.detectChanges();
}

protected readonly Math = Math;
}

0 comments on commit ede1b69

Please sign in to comment.