forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmy-dspace-page.component.ts
More file actions
87 lines (74 loc) · 2.91 KB
/
Copy pathmy-dspace-page.component.ts
File metadata and controls
87 lines (74 loc) · 2.91 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
import { ChangeDetectionStrategy, Component, Inject, InjectionToken, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { SearchService } from '../core/shared/search/search.service';
import { MyDSpaceResponseParsingService } from '../core/data/mydspace-response-parsing.service';
import { SearchConfigurationOption } from '../shared/search/search-switch-configuration/search-configuration-option.model';
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
import { MyDSpaceConfigurationService } from './my-dspace-configuration.service';
import { ViewMode } from '../core/shared/view-mode.model';
import { MyDSpaceRequest } from '../core/data/request.models';
import { Context } from '../core/shared/context.model';
import { RoleType } from '../core/roles/role-types';
export const MYDSPACE_ROUTE = '/mydspace';
export const SEARCH_CONFIG_SERVICE: InjectionToken<SearchConfigurationService> = new InjectionToken<SearchConfigurationService>('searchConfigurationService');
/**
* This component represents the whole mydspace page
*/
@Component({
selector: 'ds-my-dspace-page',
styleUrls: ['./my-dspace-page.component.scss'],
templateUrl: './my-dspace-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
provide: SEARCH_CONFIG_SERVICE,
useClass: MyDSpaceConfigurationService
}
]
})
export class MyDSpacePageComponent implements OnInit {
/**
* The list of available configuration options
*/
configurationList$: Observable<SearchConfigurationOption[]>;
/**
* The start context to use in the search: workspace or workflow
*/
context: Context;
/**
* The start configuration to use in the search: workspace or workflow
*/
configuration: string;
/**
* Variable for enumeration RoleType
*/
roleTypeEnum = RoleType;
/**
* List of available view mode
*/
viewModeList = [ViewMode.ListElement];
constructor(private service: SearchService,
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: MyDSpaceConfigurationService) {
this.service.setServiceOptions(MyDSpaceResponseParsingService, MyDSpaceRequest);
}
/**
* Initialize available configuration list
*
* Listening to changes in the paginated search options
* If something changes, update the search results
*
* Listen to changes in the scope
* If something changes, update the list of scopes for the dropdown
*
* Listen to changes in the configuration
* If something changes, update the current context
*/
ngOnInit(): void {
this.configurationList$ = this.searchConfigService.getAvailableConfigurationOptions();
this.configurationList$.pipe(take(1)).subscribe((configurationList: SearchConfigurationOption[]) => {
this.configuration = configurationList[0].value;
this.context = configurationList[0].context;
});
}
}