Skip to content

Commit

Permalink
feat(admin-ui): Reindex search index from product list
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed May 13, 2019
1 parent 4d5f0d9 commit de7f22d
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
(searchTermChange)="setSearchTerm($event)"
(facetValueChange)="setFacetValueIds($event)"
></vdr-product-search-input>
<clr-dropdown class="search-settings-menu">
<button type="button" clrDropdownTrigger>
<clr-icon shape="cog"></clr-icon>
</button>
<clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
<button type="button" clrDropdownItem (click)="rebuildSearchIndex()">
{{ 'catalog.rebuild-search-index' | translate }}
</button>
</clr-dropdown-menu>
</clr-dropdown>
</div>
<clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox [(ngModel)]="groupByProduct" />
Expand All @@ -17,7 +27,6 @@
<a class="btn btn-primary" [routerLink]="['./create']">
<clr-icon shape="plus"></clr-icon>
<span class="full-label">{{ 'catalog.create-new-product' | translate }}</span>
<span class="compact-label">{{ 'common.create' | translate }}</span>
</a>
</vdr-ab-right>
</vdr-action-bar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
min-width: 100px;
}
}
.search-settings-menu {
margin: 0 12px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ export class ProductListComponent
this.refresh();
}

rebuildSearchIndex() {
this.dataService.product.reindex().subscribe(({ reindex }) => {
if (reindex.success) {
const time = new Intl.NumberFormat().format(reindex.timeTaken);
this.notificationService.success(_('catalog.reindex-successful'), {
count: reindex.indexedItemCount,
time,
});
this.refresh();
} else {
this.notificationService.error(_('catalog.reindex-error'));
}
});
}

deleteProduct(productId: string) {
this.modalService
.dialog({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
margin-top: 6px;
display: block;
width: 100%;
margin-right: 24px;

::ng-deep {

Expand Down
Loading

0 comments on commit de7f22d

Please sign in to comment.