-
Notifications
You must be signed in to change notification settings - Fork 539
Expand file tree
/
Copy pathapp-routing-paths.ts
More file actions
189 lines (146 loc) · 5.15 KB
/
app-routing-paths.ts
File metadata and controls
189 lines (146 loc) · 5.15 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import { environment } from 'src/environments/environment';
import { getCollectionPageRoute } from './collection-page/collection-page-routing-paths';
import { getCommunityPageRoute } from './community-page/community-page-routing-paths';
import { Collection } from './core/shared/collection.model';
import { Community } from './core/shared/community.model';
import { DSpaceObject } from './core/shared/dspace-object.model';
import { Item } from './core/shared/item.model';
import { URLCombiner } from './core/url-combiner/url-combiner';
import {
getItemModuleRoute,
getItemPageRoute,
} from './item-page/item-page-routing-paths';
import { hasValue } from './shared/empty.util';
export const BITSTREAM_MODULE_PATH = 'bitstreams';
/**
* The bitstream module path to resolve XMLUI and JSPUI bitstream download URLs
*/
export const LEGACY_BITSTREAM_MODULE_PATH = 'bitstream';
export function getBitstreamModuleRoute() {
return `/${BITSTREAM_MODULE_PATH}`;
}
/**
* Normalizes the application's contextPath:
* - Returns "" if it is "/" or empty.
* - Ensures it starts with "/" if missing.
* - Removes trailing "/" if present.
*/
export function normalizeContextPath(contextPath?: string): string {
if (!contextPath || contextPath === '/') {
return '';
}
let path = contextPath.trim();
if (!path.startsWith('/')) {
path = '/' + path;
}
if (path.endsWith('/')) {
path = path.slice(0, -1);
}
return path;
}
export function getBitstreamDownloadRoute(bitstream): string {
const contextPath = normalizeContextPath(environment.ui.nameSpace);
return new URLCombiner(contextPath + getBitstreamModuleRoute(), bitstream.uuid, 'download').toString();
}
export function getBitstreamRequestACopyRoute(item, bitstream): { routerLink: string, queryParams: any } {
const url = new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString();
return {
routerLink: url,
queryParams: {
bitstream: bitstream.uuid,
},
};
}
/**
* Get a bitstream download route with an access token (to provide direct access to a user) added as a query parameter
* @param bitstream the bitstream to download
* @param accessToken the access token, which should match an access_token in the requestitem table
*/
export function getBitstreamDownloadWithAccessTokenRoute(bitstream, accessToken): { routerLink: string, queryParams: any } {
const url = new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString();
const options = {
routerLink: url,
queryParams: {},
};
// Only add the access token if it is not empty, otherwise keep valid empty query parameters
if (hasValue(accessToken)) {
options.queryParams = { accessToken: accessToken };
}
return options;
}
export const COAR_NOTIFY_SUPPORT = 'coar-notify-support';
export const HOME_PAGE_PATH = 'home';
export function getHomePageRoute() {
return `/${HOME_PAGE_PATH}`;
}
export const ADMIN_MODULE_PATH = 'admin';
export function getAdminModuleRoute() {
return `/${ADMIN_MODULE_PATH}`;
}
export const PROFILE_MODULE_PATH = 'profile';
export function getProfileModuleRoute() {
return `/${PROFILE_MODULE_PATH}`;
}
export const REGISTER_PATH = 'register';
export function getRegisterRoute() {
return `/${REGISTER_PATH}`;
}
export const FORGOT_PASSWORD_PATH = 'forgot';
export function getForgotPasswordRoute() {
return `/${FORGOT_PASSWORD_PATH}`;
}
export const WORKFLOW_ITEM_MODULE_PATH = 'workflowitems';
export function getWorkflowItemModuleRoute() {
return `/${WORKFLOW_ITEM_MODULE_PATH}`;
}
export const WORKSPACE_ITEM_MODULE_PATH = 'workspaceitems';
export function getWorkspaceItemModuleRoute() {
return `/${WORKSPACE_ITEM_MODULE_PATH}`;
}
export function getDSORoute(dso: DSpaceObject): string {
if (hasValue(dso)) {
switch ((dso as any).type) {
case Community.type.value:
return getCommunityPageRoute(dso.uuid);
case Collection.type.value:
return getCollectionPageRoute(dso.uuid);
case Item.type.value:
return getItemPageRoute(dso as Item);
}
}
}
export const FORBIDDEN_PATH = '403';
export function getForbiddenRoute() {
return `/${FORBIDDEN_PATH}`;
}
export const PAGE_NOT_FOUND_PATH = '404';
export function getPageNotFoundRoute() {
return `/${PAGE_NOT_FOUND_PATH}`;
}
export const INTERNAL_SERVER_ERROR = '500';
export function getPageInternalServerErrorRoute() {
return `/${INTERNAL_SERVER_ERROR}`;
}
export const ERROR_PAGE = 'error';
export const INFO_MODULE_PATH = 'info';
export function getInfoModulePath() {
return `/${INFO_MODULE_PATH}`;
}
export const ACCESS_CONTROL_MODULE_PATH = 'access-control';
export function getAccessControlModuleRoute() {
return `/${ACCESS_CONTROL_MODULE_PATH}`;
}
export const REQUEST_COPY_MODULE_PATH = 'request-a-copy';
export function getRequestCopyModulePath() {
return `/${REQUEST_COPY_MODULE_PATH}`;
}
export const HEALTH_PAGE_PATH = 'health';
export const SUBSCRIPTIONS_MODULE_PATH = 'subscriptions';
export function getSubscriptionsModuleRoute() {
return `/${SUBSCRIPTIONS_MODULE_PATH}`;
}
export const EDIT_ITEM_PATH = 'edit-items';
export function getEditItemPageRoute() {
return `/${EDIT_ITEM_PATH}`;
}
export const CORRECTION_TYPE_PATH = 'corrections';