Skip to content

Commit

Permalink
Merge pull request #492 from NUM-Forschungsdatenplattform/release/v1.…
Browse files Browse the repository at this point in the history
…16.0

Release/v1.16.0
  • Loading branch information
richardbartha authored Oct 27, 2023
2 parents 2090fde + ab5e547 commit e78daf4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "num-portal-webapp",
"version": "1.15.0",
"version": "1.16.0",
"scripts": {
"postinstall": "ngcc",
"ng": "ng",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ <h3>{{ 'DATA_EXPLORER.HEADLINE_RETRIEVE_SECTION' | translate }}</h3>
class="num-margin-b-40"
>
<num-button
[isDisabled]="!isCompositionsFetched || !compiledQuery || isDataSetLoading || isExportLoading"
[isDisabled]="
!isCompositionsFetched ||
!compiledQuery ||
isDataSetLoading ||
isExportLoading ||
!isUserResearcher
"
type="primary"
icon="play"
(singleClick)="getDataSet()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { IAqlBuilderDialogOutput } from 'src/app/shared/models/archetype-query-b
import { ProjectService } from 'src/app/core/services/project/project.service'
import { IToastMessageConfig } from 'src/app/shared/models/toast-message-config.interface'
import { CohortGroupUiModel } from 'src/app/shared/models/project/cohort-group-ui.model'
import { ProfileService } from 'src/app/core/services/profile/profile.service'

describe('DataExplorerComponent', () => {
let component: DataExplorerComponent
Expand All @@ -66,6 +67,10 @@ describe('DataExplorerComponent', () => {
parameters: {},
}

const profileService = {
get: jest.fn(),
} as unknown as ProfileService

const cohortService = {
create: jest.fn(),
update: jest.fn(),
Expand Down Expand Up @@ -180,6 +185,10 @@ describe('DataExplorerComponent', () => {
provide: ToastMessageService,
useValue: toastMessageService,
},
{
provide: ProfileService,
useValue: profileService,
},
],
}).compileComponents()
})
Expand All @@ -192,6 +201,18 @@ describe('DataExplorerComponent', () => {
jest.spyOn(cohortService, 'get').mockImplementation(() => of(mockCohort1))
jest.spyOn(cohortService, 'update').mockImplementation(() => of(mockCohort1))
jest.spyOn(adminService, 'getUsersByIds').mockImplementation(() => of(mockUsers))
jest.spyOn(profileService, 'get').mockImplementation(() =>
of({
id: '123-abc',
username: 'string',
firstName: 'string',
lastName: 'string',
email: 'string',
createdTimestamp: 1,
approved: true,
organization: null,
})
)
})

describe('When the components gets initialized and the cohortId is not specified', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
import { forkJoin, Subscription } from 'rxjs'
import { combineLatest, forkJoin, Subscription } from 'rxjs'
import { map, mergeMap } from 'rxjs/operators'
import { AdminService } from 'src/app/core/services/admin/admin.service'
import { AqlEditorService } from 'src/app/core/services/aql-editor/aql-editor.service'
Expand Down Expand Up @@ -47,6 +47,7 @@ import { ProjectService } from 'src/app/core/services/project/project.service'
import { IToastMessageConfig } from 'src/app/shared/models/toast-message-config.interface'
import { cloneDeep } from 'lodash-es'
import { downloadFile } from 'src/app/core/utils/download-file.utils'
import { ProfileService } from 'src/app/core/services/profile/profile.service'

@Component({
selector: 'num-data-explorer',
Expand Down Expand Up @@ -77,6 +78,8 @@ export class DataExplorerComponent implements OnInit, OnDestroy {
isCohortBuilderDisabled = true
isFilteringDisabled = true

isUserResearcher = false

generalInfoData: IDefinitionList[]

get project(): ProjectUiModel {
Expand All @@ -100,7 +103,8 @@ export class DataExplorerComponent implements OnInit, OnDestroy {
private projectService: ProjectService,
private dialogService: DialogService,
private aqlEditorService: AqlEditorService,
private toastMessageService: ToastMessageService
private toastMessageService: ToastMessageService,
private profileService: ProfileService
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -181,9 +185,17 @@ export class DataExplorerComponent implements OnInit, OnDestroy {
this.isResearchersFetched = true
} else {
this.subscriptions.add(
this.adminService.getUsersByIds(userIds).subscribe((researchers) => {
combineLatest([
this.adminService.getUsersByIds(userIds),
this.profileService.get(),
]).subscribe(([researchers, userProfile]) => {
this.project.researchers = researchers
this.isResearchersFetched = true
this.project.researchers.forEach((researcher) => {
if (researcher.id === userProfile.id) {
this.isUserResearcher = true
}
})
})
)
}
Expand Down
7 changes: 6 additions & 1 deletion src/mocks/data-mocks/project.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export const mockProject1: IProjectApi = {
templates: [],
cohortId: 1,
coordinator: mockUserSuperAdmin,
researchers: [],
researchers: [
{
approved: true,
userId: '123-abc',
},
],
firstHypotheses: 'Test Hypothesis',
status: ProjectStatus.Draft,
createDate: DateHelperService.getDateString(moment()),
Expand Down

0 comments on commit e78daf4

Please sign in to comment.