Skip to content

Commit

Permalink
fix(settings/media-repurposing): remove errored entries from review b…
Browse files Browse the repository at this point in the history
…ucketKMCNG-2589 (#1069)
  • Loading branch information
amirch1 committed Jun 20, 2024
1 parent d99f92d commit a865d98
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 7 deletions.
16 changes: 16 additions & 0 deletions src/applications/settings-mr-app/mr-store/mr-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ export class MrStoreService implements OnDestroy {
}
}

public dismissReview(review: ObjectState): Observable<ObjectState> {
try {
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/objectState/update`, {id: review.id, inReview: false}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<ObjectState>;
} catch (ex) {
return throwError(new Error('An error occurred while trying to update object state inReview'));
}
}

public performReview(review: ObjectState): Observable<ObjectState> {
try {
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/objectState/update`, {id: review.id, plannedExecutionTime: new Date()}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<ObjectState>;
Expand All @@ -234,6 +242,14 @@ export class MrStoreService implements OnDestroy {
}
}

public bulkDismiss(ids: string[]): Observable<any> {
try {
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/objectState/bulkUpdate`, {ids, inReview: false}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<any>;
} catch (ex) {
return throwError(new Error('An error occurred while trying to bulk update object states status'));
}
}

public bulkPerformNow(ids: string[]): Observable<any> {
try {
return this._http.post(`${serverConfig.externalServices.mrEndpoint.uri}/objectState/bulkUpdate`, {ids, plannedExecutionTime: new Date()}, this.getHttpOptions()).pipe(cancelOnDestroy(this)) as Observable<any>;
Expand Down
11 changes: 6 additions & 5 deletions src/applications/settings-mr-app/review/review.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
<p-sortIcon [field]="'plannedExecutionTime'"></p-sortIcon>
</th>

<th data-cid="status" [ngStyle]="{'width': '90px'}">
<th data-cid="status" [ngStyle]="{'width': '100px'}">
{{'applications.settings.authentication.table.status' | translate}}
</th>
<th [ngStyle]="{'overflow': 'hidden', 'width': '80px'}"></th>
<th [ngStyle]="{'overflow': 'hidden', 'width': '70px'}"></th>
</tr>
</ng-template>

Expand Down Expand Up @@ -113,12 +113,13 @@
{{review.plannedExecutionTime | kmcDate}}
</span>
</td>
<td [ngStyle]="{'width': '90px'}">
<td [ngStyle]="{'width': '100px'}">
<span class="kTableColumn" [kTooltip]="review.status | status" [showOnEllipsis]="true">
{{review.status | status}}
</span>
</span>
<i class="kIconwarning" *ngIf="review.status === ERROR_STATUS" [kTooltip]="'applications.settings.mr.removeEntry_tt' | translate"></i>
</td>
<td [ngStyle]="{'overflow': 'hidden', 'width': '80px'}">
<td [ngStyle]="{'overflow': 'hidden', 'width': '70px'}">
<div class="kProfilesTableActions">
<button type="button" pButton icon="kIconmore" class="kMoreActionsButton"
(click)="_openActionsMenu($event, review)"></button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@
font-weight: bold;
color: $kGrayscale1;
}

.kIconwarning {
margin-left: 8px;
cursor: pointer;
}
.kProfilesTableActions {
width: 100%;
text-align: center;
Expand Down
59 changes: 59 additions & 0 deletions src/applications/settings-mr-app/review/review.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class ReviewComponent implements OnInit {
public _items: MenuItem[];
public _bulkActionsMenu: MenuItem[] = [];
public _query: any = {};
public ERROR_STATUS = 'error';

public _freeTextSearch = '';

Expand Down Expand Up @@ -74,6 +75,10 @@ export class ReviewComponent implements OnInit {
this._notifySingleOwner = false;
this.notifyPopup.open();
}
},
{
label: this._appLocalization.get('applications.settings.mr.bulkRemove'),
command: () => this.bulkDismiss()
}
];
}
Expand Down Expand Up @@ -150,6 +155,26 @@ export class ReviewComponent implements OnInit {
)
}

private dismissReview(review: ObjectState): void {
this._browserService.confirm({
header: this._appLocalization.get('applications.settings.mr.removeEntryTitle'),
message: this._appLocalization.get('applications.settings.mr.removeEntryMsg'),
accept: () => {
this._blockerMessage = null;
this._isBusy = true;
this._mrStore.dismissReview(review).subscribe(
(updatedReview: ObjectState) => {
this._browserService.showToastMessage({severity: 'success', detail: this._appLocalization.get('applications.settings.mr.dismissSuccess')});
this._refresh()
},
error => {
this.displayError(this._appLocalization.get('applications.settings.mr.statusError'), () => this.dismissReview(review));
}
);
}
});
}

private updateEntryStatus(review: ObjectState, status: string): void {
this._blockerMessage = null;
this._isBusy = true;
Expand Down Expand Up @@ -180,6 +205,33 @@ export class ReviewComponent implements OnInit {
);
}

private bulkDismiss(): void {
this._browserService.confirm({
header: this._appLocalization.get('applications.settings.mr.bulkRemove'),
message: this._appLocalization.get('applications.settings.mr.bulkRemoveMsg'),
accept: () => {
const entryIds = this._selectedReviews.filter(review => review.status === this.ERROR_STATUS).map(review => review.id);
if (entryIds.length) {
this._blockerMessage = null;
this._isBusy = true;
this._mrStore.bulkDismiss(entryIds).subscribe(
(success) => {
this._selectedReviews = [];
this._refresh();
this._browserService.showToastMessage({
severity: 'success',
detail: this._appLocalization.get('applications.settings.mr.bulkDismissSuccess')
});
},
error => {
this.displayError(this._appLocalization.get('applications.settings.mr.statusError'), () => this.bulkDismiss());
}
);
}
}
});
}

private performNow(review: ObjectState): void {
this._blockerMessage = null;
this._isBusy = true;
Expand Down Expand Up @@ -252,6 +304,13 @@ export class ReviewComponent implements OnInit {
}
}
];
if (review.status === this.ERROR_STATUS) {
this._items.push({
id: 'dismiss',
label: this._appLocalization.get('applications.settings.mr.remove'),
command: () => this.dismissReview(review)
});
}
}

public _refresh(): void {
Expand Down
9 changes: 8 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,7 @@
"statusError": "Error updating status",
"notifyError": "Error notifying owners",
"statusSuccess": "Status updated",
"dismissSuccess": "Entry removed successfully",
"notifySuccess": "Notification send successfully",
"preformError": "Error updating execution date",
"preformSuccess": "Execution should start momentarily",
Expand Down Expand Up @@ -3610,7 +3611,13 @@
"deny": "Deny",
"perform": "Perform now",
"notify": "Notify owner",
"delete": "Remove",
"remove": "Remove",
"bulkRemove": "Remove errored entries",
"bulkRemoveMsg": "Are you sure you want to remove the selected entries?\nPlease note: entries that do not have the status error cannot not be removed",
"bulkDismissSuccess": "Entries removed successfully",
"removeEntryTitle": "Remove entry",
"removeEntryMsg": "Are you sure you want to remove the entry?",
"removeEntry_tt": "An error occurred in performing the action on this entry. Please remove the entry for it to be scanned the next time the rule runs",
"owner": "Rule owner",
"newOwner": "Set a new owner for this rule",
"filter": {
Expand Down

0 comments on commit a865d98

Please sign in to comment.