diff --git a/ui-ngx/src/app/core/auth/auth.actions.ts b/ui-ngx/src/app/core/auth/auth.actions.ts index dedd67bcb9..3e2b22ff63 100644 --- a/ui-ngx/src/app/core/auth/auth.actions.ts +++ b/ui-ngx/src/app/core/auth/auth.actions.ts @@ -18,6 +18,7 @@ import { Action } from '@ngrx/store'; import { AuthUser, User } from '@shared/models/user.model'; import { AuthPayload } from '@core/auth/auth.models'; import { UserSettings } from '@shared/models/user-settings.models'; +import { TrendzSettings } from "@shared/models/trendz-settings.models"; export enum AuthActionTypes { AUTHENTICATED = '[Auth] Authenticated', @@ -31,6 +32,7 @@ export enum AuthActionTypes { UPDATE_OPENED_MENU_SECTION = '[Preferences] Update Opened Menu Section', PUT_USER_SETTINGS = '[Preferences] Put user settings', DELETE_USER_SETTINGS = '[Preferences] Delete user settings', + UPDATE_TRENDZ_SETTINGS = '[Auth] Update Trendz Settings', } export class ActionAuthAuthenticated implements Action { @@ -97,7 +99,13 @@ export class ActionPreferencesDeleteUserSettings implements Action { constructor(readonly payload: Array>) {} } +export class ActionAuthUpdateTrendzSettings implements Action { + readonly type = AuthActionTypes.UPDATE_TRENDZ_SETTINGS; + + constructor(readonly payload: TrendzSettings) {} +} + export type AuthActions = ActionAuthAuthenticated | ActionAuthUnauthenticated | ActionAuthLoadUser | ActionAuthUpdateUserDetails | ActionAuthUpdateLastPublicDashboardId | ActionAuthUpdateHasRepository | ActionPreferencesUpdateOpenedMenuSection | ActionPreferencesPutUserSettings | ActionPreferencesDeleteUserSettings | - ActionAuthUpdateAuthUser | ActionUpdateMobileQrCodeEnabled; + ActionAuthUpdateAuthUser | ActionUpdateMobileQrCodeEnabled | ActionAuthUpdateTrendzSettings; diff --git a/ui-ngx/src/app/core/auth/auth.reducer.ts b/ui-ngx/src/app/core/auth/auth.reducer.ts index fde778284d..785f40ce3c 100644 --- a/ui-ngx/src/app/core/auth/auth.reducer.ts +++ b/ui-ngx/src/app/core/auth/auth.reducer.ts @@ -99,6 +99,9 @@ export const authReducer = ( action.payload.forEach(path => unset(userSettings, path)); return { ...state, ...{ userSettings }}; + case AuthActionTypes.UPDATE_TRENDZ_SETTINGS: + return { ...state, trendzSettings: action.payload }; + default: return state; } diff --git a/ui-ngx/src/app/modules/home/pages/admin/trendz-settings.component.ts b/ui-ngx/src/app/modules/home/pages/admin/trendz-settings.component.ts index 16ae6bf1da..f477b6fdaf 100644 --- a/ui-ngx/src/app/modules/home/pages/admin/trendz-settings.component.ts +++ b/ui-ngx/src/app/modules/home/pages/admin/trendz-settings.component.ts @@ -21,6 +21,9 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { TrendzSettingsService } from '@core/http/trendz-settings.service'; import { TrendzSettings } from '@shared/models/trendz-settings.models'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { Store } from "@ngrx/store"; +import { AppState } from "@core/core.state"; +import { ActionAuthUpdateTrendzSettings } from "@core/auth/auth.actions"; @Component({ selector: 'tb-trendz-settings', @@ -31,7 +34,8 @@ export class TrendzSettingsComponent extends PageComponent implements OnInit, Ha trendzSettingsForm: FormGroup; - constructor(private fb: FormBuilder, + constructor(protected store: Store, + private fb: FormBuilder, private trendzSettingsService: TrendzSettingsService, private destroyRef: DestroyRef) { super(); @@ -93,6 +97,7 @@ export class TrendzSettingsComponent extends PageComponent implements OnInit, Ha this.trendzSettingsService.saveTrendzSettings(trendzSettings) .subscribe(() => { this.setTrendzSettings(trendzSettings); + this.store.dispatch(new ActionAuthUpdateTrendzSettings(trendzSettings)) }) } }