2020-03-11 10:06:43 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { Router } from '@angular/router';
|
2023-12-14 13:34:39 +01:00
|
|
|
import { MaintenanceService } from '@app/core/services/maintenance/maintenance.service';
|
2020-03-11 10:06:43 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-index-managment',
|
|
|
|
templateUrl: './index-managment.component.html',
|
|
|
|
styleUrls: ['./index-managment.component.scss']
|
|
|
|
})
|
|
|
|
export class IndexManagmentComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private uiNotificationService: UiNotificationService,
|
|
|
|
private translate: TranslateService,
|
|
|
|
private router: Router,
|
2023-12-14 13:34:39 +01:00
|
|
|
private maintenanceService: MaintenanceService
|
2020-03-11 10:06:43 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
generateIndex(ev: Event) {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = true;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.datasetService.generateIndex().pipe(takeUntil(this._destroyed)).subscribe(
|
|
|
|
// response => {
|
2023-12-14 13:34:39 +01:00
|
|
|
// (ev.target as HTMLButtonElement).disabled = false;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.onCallbackSuccess();
|
|
|
|
// },
|
|
|
|
// error => {
|
2023-12-14 13:34:39 +01:00
|
|
|
// (ev.target as HTMLButtonElement).disabled = false;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.onCallbackError(error);
|
|
|
|
// }
|
|
|
|
// );
|
2023-12-14 13:34:39 +01:00
|
|
|
this.maintenanceService.generateElasticIndex().pipe(takeUntil(this._destroyed)).subscribe(
|
2020-04-01 17:16:06 +02:00
|
|
|
response => {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = false;
|
2020-04-01 17:16:06 +02:00
|
|
|
this.onCallbackSuccess();
|
|
|
|
},
|
|
|
|
error => {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = false;
|
2020-04-01 17:16:06 +02:00
|
|
|
this.onCallbackError(error);
|
|
|
|
}
|
|
|
|
);
|
2020-03-11 10:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
clearIndex(ev: Event) {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = true;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.datasetService.clearIndex().pipe(takeUntil(this._destroyed)).subscribe(
|
|
|
|
// response => {
|
2023-12-14 13:34:39 +01:00
|
|
|
// (ev.target as HTMLButtonElement).disabled = false;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.onCallbackSuccess();
|
|
|
|
// },
|
|
|
|
// error => {
|
2023-12-14 13:34:39 +01:00
|
|
|
// (ev.target as HTMLButtonElement).disabled = false;
|
2020-04-17 12:01:26 +02:00
|
|
|
// this.onCallbackError(error);
|
|
|
|
// }
|
|
|
|
// );
|
2023-12-14 13:34:39 +01:00
|
|
|
this.maintenanceService.clearElasticIndex().pipe(takeUntil(this._destroyed)).subscribe(
|
2020-04-01 17:16:06 +02:00
|
|
|
response => {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = false;
|
2020-04-01 17:16:06 +02:00
|
|
|
this.onCallbackSuccess();
|
|
|
|
},
|
|
|
|
error => {
|
2023-12-14 13:34:39 +01:00
|
|
|
(ev.target as HTMLButtonElement).disabled = false;
|
2020-04-01 17:16:06 +02:00
|
|
|
this.onCallbackError(error);
|
|
|
|
}
|
|
|
|
);
|
2020-03-11 10:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onCallbackSuccess(): void {
|
|
|
|
this.uiNotificationService.snackBarNotification( this.translate.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
|
|
|
this.router.navigate(['/reload']).then(() => this.router.navigate(['/index-managment']));
|
|
|
|
}
|
|
|
|
|
|
|
|
onCallbackError(error: any) {
|
|
|
|
this.uiNotificationService.snackBarNotification( error, SnackBarNotificationLevel.Error);
|
|
|
|
//this.validateAllFormFields(this.formGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|