diff --git a/cspell.json b/cspell.json index 9e9b86be0..9789a3c84 100644 --- a/cspell.json +++ b/cspell.json @@ -4,6 +4,7 @@ "words": [ "succes", + "ngrx", "ngstack", "sidenav", "injectable", diff --git a/package-lock.json b/package-lock.json index 4d46e20e3..944545eca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -445,6 +445,26 @@ "resolved": "https://registry.npmjs.org/@mat-datetimepicker/moment/-/moment-1.0.1.tgz", "integrity": "sha1-YYUwbd/QeTBlq9XbBjKpQZgjdPQ=" }, + "@ngrx/effects": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@ngrx/effects/-/effects-5.2.0.tgz", + "integrity": "sha1-qnYractv1GRNckoc7NJlyqQrrwk=" + }, + "@ngrx/router-store": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@ngrx/router-store/-/router-store-5.2.0.tgz", + "integrity": "sha1-v0sXTOGaNuuoIR/B3erx41rnQ2g=" + }, + "@ngrx/store": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@ngrx/store/-/store-5.2.0.tgz", + "integrity": "sha1-Yn7XTJzZVGKTBIXZEqVXEXsjkD4=" + }, + "@ngrx/store-devtools": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@ngrx/store-devtools/-/store-devtools-5.2.0.tgz", + "integrity": "sha1-L/+RapqjSTdYJncrNZ27ZLnl1iI=" + }, "@ngstack/electron": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@ngstack/electron/-/electron-0.1.0.tgz", diff --git a/package.json b/package.json index bba3d1050..2799ebc8f 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,10 @@ "@angular/router": "5.1.1", "@mat-datetimepicker/core": "1.0.1", "@mat-datetimepicker/moment": "1.0.1", + "@ngrx/effects": "^5.2.0", + "@ngrx/router-store": "^5.2.0", + "@ngrx/store": "^5.2.0", + "@ngrx/store-devtools": "^5.2.0", "@ngstack/electron": "0.1.0", "@ngx-translate/core": "9.1.1", "alfresco-js-api": "2.4.0-beta9", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e1f84dca9..f2846ea89 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -30,6 +30,11 @@ import { FileModel, UploadService } from '@alfresco/adf-core'; import { ElectronService } from '@ngstack/electron'; +import { Store } from '@ngrx/store'; +import { AcaState } from './store/states/app.state'; +import { SetHeaderColorAction } from './store/actions/header-color.action'; +import { SetAppNameAction } from './store/actions/app-name.action'; +import { SetLogoPathAction } from './store/actions/logo-path.action'; @Component({ selector: 'app-root', @@ -42,7 +47,8 @@ export class AppComponent implements OnInit { private router: Router, private pageTitle: PageTitleService, preferences: UserPreferencesService, - config: AppConfigService, + private store: Store, + private config: AppConfigService, private electronService: ElectronService, private uploadService: UploadService) { // TODO: remove once ADF 2.3.0 is out (needs bug fixes) @@ -51,6 +57,9 @@ export class AppComponent implements OnInit { } ngOnInit() { + + this.loadAppSettings(); + const { router, pageTitle, route } = this; router @@ -89,4 +98,19 @@ export class AppComponent implements OnInit { } }); } + + private loadAppSettings() { + const headerColor = this.config.get('headerColor'); + if (headerColor) { + this.store.dispatch(new SetHeaderColorAction(headerColor)); + } + const appName = this.config.get('application.name'); + if (appName) { + this.store.dispatch(new SetAppNameAction(appName)); + } + const logoPath = this.config.get('application.logo'); + if (logoPath) { + this.store.dispatch(new SetLogoPathAction(logoPath)); + } + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index cef4d50fc..8776393e8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -32,6 +32,10 @@ import { TRANSLATION_PROVIDER, CoreModule, AppConfigService } from '@alfresco/ad import { ContentModule } from '@alfresco/adf-content-services'; import { ElectronModule } from '@ngstack/electron'; +import { StoreModule } from '@ngrx/store'; +import { EffectsModule } from '@ngrx/effects'; +import { StoreRouterConnectingModule } from '@ngrx/router-store'; + import { AppComponent } from './app.component'; import { APP_ROUTES } from './app.routes'; @@ -71,6 +75,10 @@ import { SettingsComponent } from './components/settings/settings.component'; import { HybridAppConfigService } from './common/services/hybrid-app-config.service'; import { SortingPreferenceKeyDirective } from './directives/sorting-preference-key.directive'; +import { INITIAL_STATE } from './store/states/app.state'; +import { appReducer } from './store/reducers/app.reducer'; + + @NgModule({ imports: [ BrowserModule, @@ -88,7 +96,11 @@ import { SortingPreferenceKeyDirective } from './directives/sorting-preference-k MatInputModule, CoreModule, ContentModule, - ElectronModule + ElectronModule, + + StoreModule.forRoot({ app: appReducer }, { initialState: INITIAL_STATE }), + StoreRouterConnectingModule.forRoot({ stateKey: 'router' }), + EffectsModule.forRoot([]) ], declarations: [ AppComponent, diff --git a/src/app/components/header/header.component.html b/src/app/components/header/header.component.html index d17090b6c..c389a6072 100644 --- a/src/app/components/header/header.component.html +++ b/src/app/components/header/header.component.html @@ -1,4 +1,4 @@ - +