-
Notifications
You must be signed in to change notification settings - Fork 567
Expand file tree
/
Copy pathcollection-page.component.ts
More file actions
145 lines (133 loc) · 4.81 KB
/
Copy pathcollection-page.component.ts
File metadata and controls
145 lines (133 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import {
AsyncPipe,
NgIf,
} from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
OnInit,
} from '@angular/core';
import {
ActivatedRoute,
Router,
RouterOutlet,
} from '@angular/router';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import { Observable } from 'rxjs';
import {
filter,
map,
mergeMap,
take,
} from 'rxjs/operators';
import { environment } from '../../environments/environment';
import { AuthService } from '../core/auth/auth.service';
import { DSONameService } from '../core/breadcrumbs/dso-name.service';
import { SortOptions } from '../core/cache/models/sort-options.model';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../core/data/feature-authorization/feature-id';
import { RemoteData } from '../core/data/remote-data';
import { redirectOn4xx } from '../core/shared/authorized.operators';
import { Bitstream } from '../core/shared/bitstream.model';
import { Collection } from '../core/shared/collection.model';
import { getAllSucceededRemoteDataPayload } from '../core/shared/operators';
import {
fadeIn,
fadeInOut,
} from '../shared/animations/fade';
import { ThemedComcolPageBrowseByComponent } from '../shared/comcol/comcol-page-browse-by/themed-comcol-page-browse-by.component';
import { ThemedComcolPageContentComponent } from '../shared/comcol/comcol-page-content/themed-comcol-page-content.component';
import { ThemedComcolPageHandleComponent } from '../shared/comcol/comcol-page-handle/themed-comcol-page-handle.component';
import { ComcolPageHeaderComponent } from '../shared/comcol/comcol-page-header/comcol-page-header.component';
import { ComcolPageLogoComponent } from '../shared/comcol/comcol-page-logo/comcol-page-logo.component';
import { DsoEditMenuComponent } from '../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
import {
hasValue,
isNotEmpty,
} from '../shared/empty.util';
import { ErrorComponent } from '../shared/error/error.component';
import { ThemedLoadingComponent } from '../shared/loading/themed-loading.component';
import { ObjectCollectionComponent } from '../shared/object-collection/object-collection.component';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { VarDirective } from '../shared/utils/var.directive';
import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component';
import { getCollectionPageRoute } from './collection-page-routing-paths';
@Component({
selector: 'ds-base-collection-page',
styleUrls: ['./collection-page.component.scss'],
templateUrl: './collection-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [
fadeIn,
fadeInOut,
],
imports: [
ThemedComcolPageContentComponent,
ErrorComponent,
NgIf,
ThemedLoadingComponent,
TranslateModule,
ViewTrackerComponent,
VarDirective,
AsyncPipe,
ComcolPageHeaderComponent,
ComcolPageLogoComponent,
ThemedComcolPageHandleComponent,
DsoEditMenuComponent,
ThemedComcolPageBrowseByComponent,
ObjectCollectionComponent,
RouterOutlet,
],
standalone: true,
})
export class CollectionPageComponent implements OnInit {
collectionRD$: Observable<RemoteData<Collection>>;
logoRD$: Observable<RemoteData<Bitstream>>;
paginationConfig: PaginationComponentOptions;
sortConfig: SortOptions;
/**
* Whether the current user is a Community admin
*/
isCollectionAdmin$: Observable<boolean>;
/**
* Route to the community page
*/
collectionPageRoute$: Observable<string>;
/**
* The current language of the page
*/
currentLanguage: string = environment.defaultLanguage;
constructor(
protected route: ActivatedRoute,
protected router: Router,
protected authService: AuthService,
protected authorizationDataService: AuthorizationDataService,
public dsoNameService: DSONameService,
public translateService: TranslateService,
) {
}
ngOnInit(): void {
this.currentLanguage = this.translateService.currentLang;
this.collectionRD$ = this.route.data.pipe(
map((data) => data.dso as RemoteData<Collection>),
redirectOn4xx(this.router, this.authService),
take(1),
);
this.logoRD$ = this.collectionRD$.pipe(
map((rd: RemoteData<Collection>) => rd.payload),
filter((collection: Collection) => hasValue(collection)),
mergeMap((collection: Collection) => collection.logo),
);
this.isCollectionAdmin$ = this.authorizationDataService.isAuthorized(FeatureID.IsCollectionAdmin);
this.collectionPageRoute$ = this.collectionRD$.pipe(
getAllSucceededRemoteDataPayload(),
map((collection) => getCollectionPageRoute(collection.id)),
);
}
isNotEmpty(object: any) {
return isNotEmpty(object);
}
}