Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishant0928 committed Jun 13, 2024
1 parent bafedc4 commit e7a6e56
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
import { Component } from "@angular/core";
import { Component, OnInit } from "@angular/core";
import { HyDialogService } from '@hyland/ui/dialog';
import { ReindexConfirmationModalComponent } from '../../../shared/components/reindex/reindex-confirmation-modal/reindex-confirmation-modal.component';

@Component({
selector: "elastic-search-reindex",
templateUrl: "./elastic-search-reindex.component.html",
})
export class ElasticSearchReindexComponent {}
export class ElasticSearchReindexComponent implements OnInit {
numberOfDocuments: number = 5000;
timeInHumanReadableFormat: string = "30 minutes";
impactMessage: string = "The query could impact performance if it involves high volumes. Documents will not be available for search while reindexing is in progress.";

constructor(private dialogService: HyDialogService) {}

ngOnInit() {
this.openDialog();
}

openDialog() {

const hasError = false;
const isCompleted = true;
const actionId = '12345';

const dialogRef = this.dialogService.open(ReindexConfirmationModalComponent, {
height: '400px',
width: '780px',
data: {
header: "Example Dialog",
confirmLabel: "Agree",
dismissLabel: "Disagree",
impactMessage: this.impactMessage,
numberOfDocuments: this.numberOfDocuments,
timeInHumanReadableFormat: this.timeInHumanReadableFormat,
confirmationFlag: !hasError && !isCompleted,
errorFlag: hasError,
completedFlag: isCompleted,
actionId: actionId
},
});

dialogRef.afterClosed().subscribe(result => {
// Handle dialog closure
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<hy-dialog-box>
<hy-dialog-box-header>
<hy-dialog-box-title>
{{ data.errorFlag ? 'An error happened' : data.completedFlag ? 'Action launched' : data.header }}
</hy-dialog-box-title>
</hy-dialog-box-header>

<hy-dialog-box-content>
<div *ngIf="data.confirmationFlag && !data.errorFlag && !data.completedFlag">
<p>
<strong>{{ data.impactMessage }}</strong>
</p>
<p>
This action will impact {{ data.numberOfDocuments }} documents. <br>
This action could take approximately {{ data.timeInHumanReadableFormat }}.
</p>
<p>Continue?</p>
</div>
<div *ngIf="data.errorFlag && !data.confirmationFlag && !data.completedFlag">
<p>
Your action was not executed due to an error. Details:
[ERROR MESSAGE RETURNED BY THE SERVER]
</p>
</div>
<div *ngIf="data.completedFlag && !data.confirmationFlag && !data.errorFlag">
<p>
Congratulations! Your action is launched with ID {{ data.actionId }}.
Remember to take note of the ID if you want to monitor it later on.
</p>
<button mat-button (click)="copyActionId()">Copy action ID</button>
</div>
</hy-dialog-box-content>

<hy-dialog-box-footer>
<button mat-stroked-button color="primary" (click)="cancel()">Cancel</button>
<button mat-flat-button color="primary" (click)="confirm()">
{{ data.errorFlag || data.completedFlag ? 'Close' : data.confirmLabel }}
</button>
</hy-dialog-box-footer>
</hy-dialog-box>
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import { Component } from "@angular/core";
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
selector: "reindex-confirmation-modal",
templateUrl: "./reindex-confirmation-modal.component.html",
styleUrls: ["./reindex-confirmation-modal.component.scss"],
})
export class ReindexConfirmationModalComponent {}
export class ReindexConfirmationModalComponent {

constructor(
private dialogRef: MatDialogRef<ReindexConfirmationModalComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) {}

confirm() {
this.dialogRef.close(true);
}

cancel() {
this.dialogRef.close(false);
}

copyActionId() {
navigator.clipboard.writeText(this.data.actionId).then(() => {
alert('Action ID copied to clipboard!');
});
}
}

0 comments on commit e7a6e56

Please sign in to comment.