|
|
@@ -3,10 +3,12 @@ import { HttpClient } from '@angular/common/http';
|
|
|
import { NgModule } from '@angular/core';
|
|
|
import { BrowserModule, Title } from '@angular/platform-browser';
|
|
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
|
+import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
|
|
import { TranslateCompiler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
|
|
|
|
|
import { getAppConfig } from './app.config';
|
|
|
import { getDefaultUiLanguage } from './common/utilities/get-default-ui-language';
|
|
|
+import { AlertsComponent } from './components/alerts/alerts.component';
|
|
|
import { AppShellComponent } from './components/app-shell/app-shell.component';
|
|
|
import { BaseNavComponent } from './components/base-nav/base-nav.component';
|
|
|
import { BreadcrumbComponent } from './components/breadcrumb/breadcrumb.component';
|
|
|
@@ -19,10 +21,13 @@ import { ThemeSwitcherComponent } from './components/theme-switcher/theme-switch
|
|
|
import { UiLanguageSwitcherDialogComponent } from './components/ui-language-switcher-dialog/ui-language-switcher-dialog.component';
|
|
|
import { UserMenuComponent } from './components/user-menu/user-menu.component';
|
|
|
import { DataModule } from './data/data.module';
|
|
|
+import { DataService } from './data/providers/data.service';
|
|
|
+import { AlertsService } from './providers/alerts/alerts.service';
|
|
|
import { CustomHttpTranslationLoader } from './providers/i18n/custom-http-loader';
|
|
|
import { InjectableTranslateMessageFormatCompiler } from './providers/i18n/custom-message-format-compiler';
|
|
|
import { I18nService } from './providers/i18n/i18n.service';
|
|
|
import { LocalStorageService } from './providers/local-storage/local-storage.service';
|
|
|
+import { NotificationService } from './providers/notification/notification.service';
|
|
|
import { registerDefaultFormInputs } from './shared/dynamic-form-inputs/register-dynamic-input-components';
|
|
|
import { SharedModule } from './shared/shared.module';
|
|
|
|
|
|
@@ -56,6 +61,7 @@ import { SharedModule } from './shared/shared.module';
|
|
|
UiLanguageSwitcherDialogComponent,
|
|
|
ChannelSwitcherComponent,
|
|
|
ThemeSwitcherComponent,
|
|
|
+ AlertsComponent,
|
|
|
],
|
|
|
})
|
|
|
export class CoreModule {
|
|
|
@@ -63,9 +69,13 @@ export class CoreModule {
|
|
|
private i18nService: I18nService,
|
|
|
private localStorageService: LocalStorageService,
|
|
|
private titleService: Title,
|
|
|
+ private alertsService: AlertsService,
|
|
|
+ private dataService: DataService,
|
|
|
+ private notificationService: NotificationService,
|
|
|
) {
|
|
|
this.initUiLanguages();
|
|
|
this.initUiTitle();
|
|
|
+ this.initAlerts();
|
|
|
}
|
|
|
|
|
|
private initUiLanguages() {
|
|
|
@@ -93,6 +103,30 @@ export class CoreModule {
|
|
|
|
|
|
this.titleService.setTitle(title);
|
|
|
}
|
|
|
+
|
|
|
+ private initAlerts() {
|
|
|
+ this.alertsService.configureAlert({
|
|
|
+ id: 'pending-search-index-updates',
|
|
|
+ check: () =>
|
|
|
+ this.dataService.product
|
|
|
+ .getPendingSearchIndexUpdates()
|
|
|
+ .mapSingle(({ pendingSearchIndexUpdates }) => pendingSearchIndexUpdates),
|
|
|
+ recheckIntervalMs: 1000 * 30,
|
|
|
+ isAlert: data => 0 < data,
|
|
|
+ action: data => {
|
|
|
+ this.dataService.product.runPendingSearchIndexUpdates().subscribe(value => {
|
|
|
+ this.notificationService.info(_('catalog.running-search-index-updates'), {
|
|
|
+ count: data,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ label: data => ({
|
|
|
+ text: _('catalog.run-pending-search-index-updates'),
|
|
|
+ translationVars: { count: data },
|
|
|
+ }),
|
|
|
+ });
|
|
|
+ this.alertsService.refresh();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export function HttpLoaderFactory(http: HttpClient, location: PlatformLocation) {
|