From a84007440c92a014c57864015af1e4b100c2163d Mon Sep 17 00:00:00 2001 From: William Welling Date: Tue, 7 Apr 2020 14:41:28 -0500 Subject: [PATCH 1/6] minor admin cleanup --- src/app/+admin/admin.component.html | 2 +- src/app/+admin/admin.component.ts | 10 +++++----- .../directory-views/directory-views.component.html | 5 ++--- .../discovery-views/discovery-views.component.html | 1 - .../+admin/display-views/display-views.component.html | 1 - src/app/+admin/themes/themes.component.html | 1 - src/app/+admin/users/users.component.html | 3 +-- src/app/core/store/auth/auth.effects.ts | 2 +- .../recent-carousel/recent-carousel.component.scss | 2 +- src/assets/i18n/en.json | 11 ++--------- 10 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/app/+admin/admin.component.html b/src/app/+admin/admin.component.html index 2fcfb03ae..aac86a034 100644 --- a/src/app/+admin/admin.component.html +++ b/src/app/+admin/admin.component.html @@ -9,7 +9,7 @@
- {{ 'SHARED.SIDEBAR.ADMINISTRATION.TITLE' | translate }} + {{ 'ADMIN.TITLE' | translate }}
+ +
diff --git a/src/app/shared/sidebar/sidebar.component.scss b/src/app/shared/sidebar/sidebar.component.scss index 17abf8091..1ba9256b1 100644 --- a/src/app/shared/sidebar/sidebar.component.scss +++ b/src/app/shared/sidebar/sidebar.component.scss @@ -42,3 +42,49 @@ } } + +::ng-deep { + .custom-slider .ng5-slider .ng5-slider-bar { + background: var(--navigation-background-color); + height: 2px; + } + .custom-slider .ng5-slider .ng5-slider-selection { + background: var(--navigation-color); + } + + .custom-slider .ng5-slider .ng5-slider-pointer { + width: 10px; + height: 20px; + top: auto; /* to remove the default positioning */ + bottom: 0; + background-color: var(--primary); + border-top-left-radius: 3px; + border-top-right-radius: 3px; + } + + .custom-slider .ng5-slider .ng5-slider-pointer:after { + display: none; + } + + .custom-slider .ng5-slider .ng5-slider-bubble { + bottom: 14px; + } + + .custom-slider .ng5-slider .ng5-slider-limit { + font-weight: bold; + color: var(--navigation-color); + } + + .custom-slider .ng5-slider .ng5-slider-tick { + width: 1px; + height: 10px; + margin-left: 4px; + border-radius: 0; + background: var(--navigation-background-color); + top: -1px; + } + + .custom-slider .ng5-slider .ng5-slider-tick.ng5-slider-selected { + background: var(--navigation-color); + } +} \ No newline at end of file diff --git a/src/app/shared/sidebar/sidebar.component.ts b/src/app/shared/sidebar/sidebar.component.ts index ee72d806e..fbbd33633 100644 --- a/src/app/shared/sidebar/sidebar.component.ts +++ b/src/app/shared/sidebar/sidebar.component.ts @@ -4,7 +4,7 @@ import { Store, select, Action } from '@ngrx/store'; import { Observable } from 'rxjs'; import { AppState } from '../../core/store'; -import { SidebarMenu } from '../../core/model/sidebar'; +import { SidebarMenu, SidebarItem } from '../../core/model/sidebar'; import { selectIsSidebarCollapsed } from '../../core/store/layout'; import { selectMenu } from '../../core/store/sidebar'; @@ -12,6 +12,7 @@ import { selectResourceIsLoading } from '../../core/store/sdr'; import { fadeIn, expandCollapse } from '../utilities/animation.utility'; +import * as fromRouter from '../../core/store/router/router.actions'; import * as fromSidebar from '../../core/store/sidebar/sidebar.actions'; @Component({ @@ -27,7 +28,7 @@ export class SidebarComponent implements OnInit { public loading: Observable; - constructor(private store: Store) {} + constructor(private store: Store) { } ngOnInit() { this.isSidebarCollapsed = this.store.pipe(select(selectIsSidebarCollapsed)); @@ -42,4 +43,17 @@ export class SidebarComponent implements OnInit { public dispatchAction(action: Action): void { this.store.dispatch(action); } + + public onUserChangeEnd(sidebarItem: SidebarItem) { + const filters = sidebarItem.queryParams.filters; + sidebarItem.queryParams[`${sidebarItem.facet.field}.filter`] = `[${sidebarItem.rangeValues.from} TO ${sidebarItem.rangeValues.to}]`; + if (sidebarItem.queryParams.filters.indexOf(sidebarItem.facet.field) < 0) { + sidebarItem.queryParams.filters = filters.length ? `${filters},${sidebarItem.facet.field}` : sidebarItem.facet.field; + } + this.store.dispatch(new fromRouter.Go({ + path: sidebarItem.route, + query: sidebarItem.queryParams + })); + } + } diff --git a/src/app/shared/utilities/view.utility.ts b/src/app/shared/utilities/view.utility.ts index 6f6e5e39a..30c08d5b3 100644 --- a/src/app/shared/utilities/view.utility.ts +++ b/src/app/shared/utilities/view.utility.ts @@ -103,7 +103,9 @@ const getFilterField = (collectionView: CollectionView, actualFilter: Filter): s const getFilterValue = (collectionView: CollectionView, actualFilter: Filter): string => { for (const facet of collectionView.facets) { if (facet.type === FacetType.DATE_YEAR && facet.field === actualFilter.field) { - return actualFilter.value.substring(1, actualFilter.value.length - 1).split(' TO ')[0]; + const from = actualFilter.value.substring(1, actualFilter.value.length - 1).split(' TO ')[0]; + const year = new Date(from).getFullYear() + 1; + return year.toString(); } } return actualFilter.value; From a3506434885cb816fc829023bb7b6c75152901aa Mon Sep 17 00:00:00 2001 From: William Welling Date: Wed, 8 Apr 2020 08:30:21 -0500 Subject: [PATCH 5/6] minor cleanup --- src/app/+directory/directory.component.ts | 7 ++- src/app/+discovery/discovery.component.ts | 7 ++- src/app/core/guard/auth.guard.ts | 50 +++++++++---------- src/app/shared/sidebar/sidebar.component.html | 2 +- src/app/shared/sidebar/sidebar.component.ts | 3 -- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/app/+directory/directory.component.ts b/src/app/+directory/directory.component.ts index 7b8ec6433..d6e148787 100644 --- a/src/app/+directory/directory.component.ts +++ b/src/app/+directory/directory.component.ts @@ -45,7 +45,12 @@ export class DirectoryComponent implements OnDestroy, OnInit { private subscriptions: Subscription[]; - constructor(@Inject('APP_CONFIG') private appConfig: AppConfig, private store: Store, private router: Router, private route: ActivatedRoute) { + constructor( + @Inject('APP_CONFIG') private appConfig: AppConfig, + private store: Store, + private router: Router, + private route: ActivatedRoute + ) { this.subscriptions = []; } diff --git a/src/app/+discovery/discovery.component.ts b/src/app/+discovery/discovery.component.ts index b5b5ab2ce..7ccdb734b 100644 --- a/src/app/+discovery/discovery.component.ts +++ b/src/app/+discovery/discovery.component.ts @@ -54,7 +54,12 @@ export class DiscoveryComponent implements OnDestroy, OnInit { private subscriptions: Subscription[]; - constructor(@Inject('APP_CONFIG') private appConfig: AppConfig, private store: Store, private router: Router, private route: ActivatedRoute) { + constructor( + @Inject('APP_CONFIG') private appConfig: AppConfig, + private store: Store, + private router: Router, + private route: ActivatedRoute + ) { this.subscriptions = []; } diff --git a/src/app/core/guard/auth.guard.ts b/src/app/core/guard/auth.guard.ts index 7ee187b5a..33ba4149c 100644 --- a/src/app/core/guard/auth.guard.ts +++ b/src/app/core/guard/auth.guard.ts @@ -20,7 +20,13 @@ import * as fromRouter from '../store/router/router.actions'; @Injectable() export class AuthGuard implements CanActivate { - constructor(@Inject(PLATFORM_ID) private platformId: string, private alert: AlertService, private dialog: DialogService, private store: Store) {} + + constructor( + @Inject(PLATFORM_ID) private platformId: string, + private alert: AlertService, + private dialog: DialogService, + private store: Store + ) { } public canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { const roles = route.data.roles; @@ -36,26 +42,20 @@ export class AuthGuard implements CanActivate { } private isAuthorized(url: string, roles: Role[]): Observable { - return this.isAuthenticated(url).pipe( - switchMap((authenticated: boolean) => - authenticated - ? this.store.pipe( - select(selectUser), - filter((user: User) => user !== undefined), - map((user: User) => { - const authorized = user ? roles.indexOf(Role[user.role]) >= 0 : false; - if (!authorized) { - this.store.dispatch(new fromRouter.Go({ path: ['/'] })); - if (isPlatformBrowser(this.platformId)) { - this.store.dispatch(this.alert.unsubscribeFailureAlert()); - } - } - return authorized; - }) - ) - : scheduled([false], asap) - ) - ); + return this.isAuthenticated(url).pipe(switchMap((authenticated: boolean) => authenticated ? + this.store.pipe( + select(selectUser), + filter((user: User) => user !== undefined), + map((user: User) => { + const authorized = user ? roles.indexOf(Role[user.role]) >= 0 : false; + if (!authorized) { + this.store.dispatch(new fromRouter.Go({ path: ['/'] })); + if (isPlatformBrowser(this.platformId)) { + this.store.dispatch(this.alert.unsubscribeFailureAlert()); + } + } + return authorized; + })) : scheduled([false], asap))); } private isAuthenticated(url: string): Observable { @@ -65,11 +65,9 @@ export class AuthGuard implements CanActivate { if (!authenticated) { this.store.dispatch(new fromRouter.Go({ path: ['/'] })); if (isPlatformBrowser(this.platformId)) { - this.store.dispatch( - new fromAuth.SetLoginRedirectAction({ - navigation: { path: [url] }, - }) - ); + this.store.dispatch(new fromAuth.SetLoginRedirectAction({ + navigation: { path: [url] }, + })); this.store.dispatch(this.dialog.loginDialog()); this.store.dispatch(this.alert.forbiddenAlert()); } diff --git a/src/app/shared/sidebar/sidebar.component.html b/src/app/shared/sidebar/sidebar.component.html index bba63de28..46ecafde2 100644 --- a/src/app/shared/sidebar/sidebar.component.html +++ b/src/app/shared/sidebar/sidebar.component.html @@ -1,6 +1,6 @@