Skip to content

Commit ddec636

Browse files
committed
Merge branch 'dspace-cris-7' into alignment-with-7.3
# Conflicts: # src/app/collection-page/collection-page-routing.module.ts # src/app/core/auth/auth-request.service.ts # src/app/core/auth/auth.service.ts # src/app/core/metadata/metadata.service.ts # src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/attachment/attachment.component.spec.ts # src/app/profile-page/profile-page.component.ts # src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts # src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.spec.ts # src/app/shared/search/search-filters/search-filters.component.spec.ts # src/app/shared/search/search-filters/search-filters.component.ts # src/app/shared/search/search.component.spec.ts # src/app/submission/sections/accesses/section-accesses.component.spec.ts # src/app/submission/sections/accesses/section-accesses.component.ts # src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.ts # src/assets/i18n/en.json5
2 parents 06a0210 + 14ce8c7 commit ddec636

165 files changed

Lines changed: 4836 additions & 575 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

angular.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@
282282
"defaultProject": "dspace-angular",
283283
"cli": {
284284
"analytics": false,
285-
"defaultCollection": "@angular-eslint/schematics"
285+
"defaultCollection": "@angular-eslint/schematics",
286+
"cache": {
287+
"enabled": true,
288+
"environment": "local"
289+
}
286290
}
287291
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "dspace-angular",
3-
"version": "2021.01.02-SNAPSHOT",
3+
"version": "2022.01.03-SNAPSHOT",
44
"scripts": {
55
"ng": "ng",
66
"config:watch": "nodemon",
77
"test:rest": "ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
88
"start": "yarn run start:prod",
9-
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
9+
"start:dev": "ng config cli.cache.environment local && nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
1010
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
1111
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
1212
"preserve": "yarn base-href",
@@ -15,6 +15,7 @@
1515
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
1616
"build": "ng build --configuration development",
1717
"build:stats": "ng build --stats-json",
18+
"build:ci": "ng config cli.cache.environment ci && yarn run build:ssr",
1819
"build:prod": "yarn run build:ssr",
1920
"build:ssr": "npm run ng-high-memory -- build --configuration production && ng run dspace-angular:server:production",
2021
"ng-high-memory": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng",

src/app/collection-page/collection-page-routing.module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { CollectionPageAdministratorGuard } from './collection-page-administrato
2121
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
2222
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
2323
import { MenuItemType } from '../shared/menu/menu-item-type.model';
24+
import { EditCollectionResolver } from '../core/shared/resolvers/edit-collection.resolver';
2425

2526
@NgModule({
2627
imports: [
@@ -39,6 +40,9 @@ import { MenuItemType } from '../shared/menu/menu-item-type.model';
3940
runGuardsAndResolvers: 'always',
4041
children: [
4142
{
43+
resolve: {
44+
dso: EditCollectionResolver,
45+
},
4246
path: COLLECTION_EDIT_PATH,
4347
loadChildren: () => import('./edit-collection-page/edit-collection-page.module')
4448
.then((m) => m.EditCollectionPageModule),
@@ -90,7 +94,8 @@ import { MenuItemType } from '../shared/menu/menu-item-type.model';
9094
DSOBreadcrumbsService,
9195
LinkService,
9296
CreateCollectionPageGuard,
93-
CollectionPageAdministratorGuard
97+
CollectionPageAdministratorGuard,
98+
EditCollectionResolver
9499
]
95100
})
96101
export class CollectionPageRoutingModule {

src/app/collection-page/collection-page.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { CollectionFormModule } from './collection-form/collection-form.module';
1616
import { ContextMenuModule } from '../shared/context-menu/context-menu.module';
1717
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
1818
import { ComcolModule } from '../shared/comcol/comcol.module';
19+
import { EditCollectionResolver } from './../core/shared/resolvers/edit-collection.resolver';
1920

2021
@NgModule({
2122
imports: [
@@ -38,6 +39,7 @@ import { ComcolModule } from '../shared/comcol/comcol.module';
3839
],
3940
providers: [
4041
SearchService,
42+
EditCollectionResolver
4143
]
4244
})
4345
export class CollectionPageModule {

src/app/community-page/edit-community-page/edit-community-page.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CommunityAuthorizationsComponent } from './community-authorizations/com
1010
import { CommunityFormModule } from '../community-form/community-form.module';
1111
import { ResourcePoliciesModule } from '../../shared/resource-policies/resource-policies.module';
1212
import { ComcolModule } from '../../shared/comcol/comcol.module';
13+
import { DataService } from '../../core/data/data.service';
1314

1415
/**
1516
* Module that contains all components related to the Edit Community page administrator functionality

src/app/community-page/edit-community-page/edit-community-page.routing.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ResourcePolicyCreateComponent } from '../../shared/resource-policies/cr
1111
import { ResourcePolicyResolver } from '../../shared/resource-policies/resolvers/resource-policy.resolver';
1212
import { ResourcePolicyEditComponent } from '../../shared/resource-policies/edit/resource-policy-edit.component';
1313
import { CommunityAdministratorGuard } from '../../core/data/feature-authorization/feature-authorization-guard/community-administrator.guard';
14+
import { EditCommunityResolver } from './../../core/shared/resolvers/edit-community.resolver';
1415

1516
/**
1617
* Routing module that handles the routing for the Edit Community page administrator functionality
@@ -21,7 +22,8 @@ import { CommunityAdministratorGuard } from '../../core/data/feature-authorizati
2122
{
2223
path: '',
2324
resolve: {
24-
breadcrumb: I18nBreadcrumbResolver
25+
breadcrumb: I18nBreadcrumbResolver,
26+
dso: EditCommunityResolver
2527
},
2628
data: { breadcrumbKey: 'community.edit' },
2729
component: EditCommunityPageComponent,
@@ -89,7 +91,8 @@ import { CommunityAdministratorGuard } from '../../core/data/feature-authorizati
8991
],
9092
providers: [
9193
ResourcePolicyResolver,
92-
ResourcePolicyTargetResolver
94+
ResourcePolicyTargetResolver,
95+
EditCommunityResolver
9396
]
9497
})
9598
export class EditCommunityPageRoutingModule {

src/app/core/auth/auth-request.service.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Observable } from 'rxjs';
22
import { distinctUntilChanged, filter, map, mergeMap, switchMap, tap } from 'rxjs/operators';
33
import { HALEndpointService } from '../shared/hal-endpoint.service';
44
import { RequestService } from '../data/request.service';
5-
import { isNotEmpty } from '../../shared/empty.util';
6-
import { GetRequest, PostRequest, } from '../data/request.models';
5+
import { isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
6+
import { DeleteRequest, GetRequest, PostRequest } from '../data/request.models';
77
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
88
import { getFirstCompletedRemoteData } from '../shared/operators';
99
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
@@ -13,13 +13,17 @@ import { ShortLivedToken } from './models/short-lived-token.model';
1313
import { URLCombiner } from '../url-combiner/url-combiner';
1414
import { RestRequest } from '../data/rest-request.model';
1515
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
16+
import { MachineToken } from './models/machine-token.model';
17+
import { NoContent } from '../shared/NoContent.model';
18+
import { sendRequest } from '../shared/request.operators';
1619

1720
/**
1821
* Abstract service to send authentication requests
1922
*/
2023
export abstract class AuthRequestService {
2124
protected linkName = 'authn';
2225
protected shortlivedtokensEndpoint = 'shortlivedtokens';
26+
protected machinetokenEndpoint = 'machinetokens';
2327

2428
constructor(protected halService: HALEndpointService,
2529
protected requestService: RequestService,
@@ -97,4 +101,32 @@ export abstract class AuthRequestService {
97101
})
98102
);
99103
}
104+
105+
/**
106+
* Send a post request to create a machine token
107+
*/
108+
public postToMachineTokenEndpoint(): Observable<RemoteData<MachineToken>> {
109+
return this.halService.getEndpoint(this.linkName).pipe(
110+
isNotEmptyOperator(),
111+
distinctUntilChanged(),
112+
map((href: string) => new URLCombiner(href, this.machinetokenEndpoint).toString()),
113+
map((endpointURL: string) => new PostRequest(this.requestService.generateRequestId(), endpointURL)),
114+
tap((request: RestRequest) => this.requestService.send(request)),
115+
switchMap((request: RestRequest) => this.rdbService.buildFromRequestUUID<MachineToken>(request.uuid))
116+
);
117+
}
118+
119+
/**
120+
* Send a delete request to destroy a machine token
121+
*/
122+
public deleteToMachineTokenEndpoint(): Observable<RemoteData<NoContent>> {
123+
return this.halService.getEndpoint(this.linkName).pipe(
124+
isNotEmptyOperator(),
125+
distinctUntilChanged(),
126+
map((href: string) => new URLCombiner(href, this.machinetokenEndpoint).toString()),
127+
map((endpointURL: string) => new DeleteRequest(this.requestService.generateRequestId(), endpointURL)),
128+
sendRequest(this.requestService),
129+
switchMap((request: RestRequest) => this.rdbService.buildFromRequestUUID<MachineToken>(request.uuid)),
130+
);
131+
}
100132
}

src/app/core/auth/auth.service.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import { Group } from '../eperson/models/group.model';
4848
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
4949
import { PageInfo } from '../shared/page-info.model';
5050
import { followLink } from '../../shared/utils/follow-link-config.model';
51+
import { MachineToken } from './models/machine-token.model';
52+
import { NoContent } from '../shared/NoContent.model';
5153

5254
export const LOGIN_ROUTE = '/login';
5355
export const LOGOUT_ROUTE = '/logout';
@@ -604,4 +606,18 @@ export class AuthService {
604606
}
605607
}
606608

609+
/**
610+
* Create a new machine token for the current user
611+
*/
612+
public createMachineToken(): Observable<RemoteData<MachineToken>> {
613+
return this.authRequestService.postToMachineTokenEndpoint();
614+
}
615+
616+
/**
617+
* Delete the machine token for the current user
618+
*/
619+
public deleteMachineToken(): Observable<RemoteData<NoContent>> {
620+
return this.authRequestService.deleteToMachineTokenEndpoint();
621+
}
622+
607623
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
2+
3+
import { typedObject } from '../../cache/builders/build-decorators';
4+
import { CacheableObject } from '../../cache/object-cache.reducer';
5+
import { excludeFromEquals } from '../../utilities/equals.decorators';
6+
import { ResourceType } from '../../shared/resource-type';
7+
import { HALLink } from '../../shared/hal-link.model';
8+
import { MACHINE_TOKEN } from './machine-token.resource-type';
9+
10+
/**
11+
* A machine token that can be used to authenticate a rest request
12+
*/
13+
@typedObject
14+
export class MachineToken implements CacheableObject {
15+
static type = MACHINE_TOKEN;
16+
/**
17+
* The type for this MachineToken
18+
*/
19+
@excludeFromEquals
20+
@autoserialize
21+
type: ResourceType;
22+
23+
/**
24+
* The value for this MachineToken
25+
*/
26+
@autoserializeAs('token')
27+
value: string;
28+
29+
/**
30+
* The {@link HALLink}s for this MachineToken
31+
*/
32+
@deserialize
33+
_links: {
34+
self: HALLink;
35+
};
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ResourceType } from '../../shared/resource-type';
2+
3+
/**
4+
* The resource type for MachineToken
5+
*
6+
* Needs to be in a separate file to prevent circular
7+
* dependencies in webpack.
8+
*/
9+
export const MACHINE_TOKEN = new ResourceType('machinetoken');

0 commit comments

Comments
 (0)