-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bafedc4
commit e7a6e56
Showing
3 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
44 changes: 42 additions & 2 deletions
44
src/app/features/elastic-search-reindex/components/elastic-search-reindex.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
25 changes: 23 additions & 2 deletions
25
...red/components/reindex/reindex-confirmation-modal/reindex-confirmation-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
}); | ||
} | ||
} |