Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link raw derived datasets #976

Merged
merged 37 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
59726ec
Create new component related-datasets
henrikjohansson712 Jun 3, 2022
d695471
Create actions for fetching related datasets
henrikjohansson712 Jun 3, 2022
e9561bf
Set up shared-table
henrikjohansson712 Jun 9, 2022
1ff8d31
Set up routing for new related-datasets component
henrikjohansson712 Jun 9, 2022
9de18d9
Add tab for related datasets
henrikjohansson712 Jun 9, 2022
43a7fe1
Merge master
henrikjohansson712 Jun 9, 2022
14a6a3d
Update default filters
henrikjohansson712 Jun 10, 2022
b59368c
Add fetchDatasetAction
henrikjohansson712 Jun 16, 2022
d9c1dc0
Set up init action for related tab
henrikjohansson712 Jun 16, 2022
294c97a
Set up flex layout
henrikjohansson712 Jun 16, 2022
84c2815
Add margin-top
henrikjohansson712 Jun 16, 2022
fd3077a
Set up table data
henrikjohansson712 Jun 16, 2022
5902c1a
Set up tests
henrikjohansson712 Jun 16, 2022
501bbdf
Update props for fetch related datasets actions
henrikjohansson712 Jun 16, 2022
7db9ff9
Create fetchRelatedDatasets$ effect
henrikjohansson712 Jun 16, 2022
9d083c4
Set up reducer for fetchRelatedDatasetsCompleteAction
henrikjohansson712 Jun 16, 2022
8b4ec85
Create selector for relatedDatasets
henrikjohansson712 Jun 16, 2022
6b886de
Add property relatedDatasets to dataset state
henrikjohansson712 Jun 16, 2022
145e59a
Rename `related` to `related-datasets`
henrikjohansson712 Jun 16, 2022
a391dd9
Remove flex layout
henrikjohansson712 Jun 16, 2022
e5076ca
Update table columns
henrikjohansson712 Jun 16, 2022
492a83d
Set up pagination for related datasets table
henrikjohansson712 Jun 16, 2022
eea178c
Add check for dataset history property
henrikjohansson712 Jun 16, 2022
bd35465
Remove unused imports
henrikjohansson712 Jun 16, 2022
e906aef
Add relatedDatasets prop to clearCurrentDatesetStateAction
henrikjohansson712 Jun 23, 2022
d1ca485
Add actions to clear dataset proposal and sample on destroy
henrikjohansson712 Jun 23, 2022
e328f17
Create new global service for lazy loaded child components
henrikjohansson712 Jun 30, 2022
5b2e070
Implement lazy child service
henrikjohansson712 Jun 30, 2022
887dddd
Revert changes
henrikjohansson712 Jun 30, 2022
cf1d8ef
Reload data on event from lazy child service
henrikjohansson712 Jun 30, 2022
d74afeb
Add lazy child service to providers
henrikjohansson712 Jun 30, 2022
b7e5185
Move clear state actions to parent component
henrikjohansson712 Jul 11, 2022
1f08e8a
Set all tabs to not loaded when navigating from child
henrikjohansson712 Jul 11, 2022
fc4d3c9
Fix the lazy load problem for related-datasets tab
nguyenlinhlinh Jul 18, 2022
bd1a964
removed references to LazyChild
nguyenlinhlinh Jul 19, 2022
2045156
add semi colon
nguyenlinhlinh Jul 19, 2022
0f2b8c1
fixed deep scan error
nguyenlinhlinh Jul 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DatasetDetailComponent } from "datasets/dataset-detail/dataset-detail.c
import { DatasetFileUploaderComponent } from "datasets/dataset-file-uploader/dataset-file-uploader.component";
import { DatasetLifecycleComponent } from "datasets/dataset-lifecycle/dataset-lifecycle.component";
import { ReduceComponent } from "datasets/reduce/reduce.component";
import { RelatedDatasetsComponent } from "datasets/related-datasets/related-datasets.component";
import { LogbooksDashboardComponent } from "logbooks/logbooks-dashboard/logbooks-dashboard.component";
const routes: Routes = [
{
Expand All @@ -22,6 +23,10 @@ const routes: Routes = [
component: DatafilesComponent,

},
{
path: "related-datasets",
component: RelatedDatasetsComponent,
},
// For reduce && logbook this is a work around because guard priority somehow doesn't work and this work around make guards excuted sequencial
// Expected behavior should be that ServiceGuard return false should have higher priority than AuthGuard therefore it shoulds navigate to /404 instead of /login
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { MatSnackBarModule } from "@angular/material/snack-bar";
import { LayoutModule } from "_layout/layout.module";
import { AppConfigService } from "app-config.service";
import { AppThemeService } from "app-theme.service";
import { LazyChildService } from "lazy-child.service";

const appConfigInitializerFn = (appConfig: AppConfigService) => {
return () => appConfig.loadAppConfig();
Expand Down Expand Up @@ -74,6 +75,7 @@ const appThemeInitializerFn = (appTheme: AppThemeService) => {
deps: [AppThemeService],
},
AppThemeService,
LazyChildService,
UserApi,
SampleApi,
Title,
Expand Down
4 changes: 2 additions & 2 deletions src/app/datasets/dataset-detail/dataset-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Inject, OnInit, OnDestroy } from "@angular/core";
import { Component, OnInit, OnDestroy } from "@angular/core";
import { Dataset, Proposal, Sample } from "shared/sdk/models";
import { ENTER, COMMA, SPACE } from "@angular/cdk/keycodes";
import { MatChipInputEvent } from "@angular/material/chips";
Expand Down Expand Up @@ -74,7 +74,7 @@ export class DatasetDetailComponent
public dialog: MatDialog,
private store: Store,
private router: Router
) { }
) {}

ngOnInit() {
this.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MatIconModule } from "@angular/material/icon";
import { MatButtonModule } from "@angular/material/button";
import { MockStore } from "@ngrx/store/testing";
import { AppConfigService } from "app-config.service";
import { LazyChildService } from "lazy-child.service";

describe("DetailsDashboardComponent", () => {
let component: DatasetDetailsDashboardComponent;
Expand All @@ -32,38 +33,37 @@ describe("DetailsDashboardComponent", () => {
editMetadataEnabled: true,
});

beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
declarations: [DatasetDetailsDashboardComponent],
imports: [
MatButtonModule,
MatIconModule,
MatSlideToggleModule,
MatTabsModule,
SharedScicatFrontendModule,
StoreModule.forRoot({}),
],
});
TestBed.overrideComponent(DatasetDetailsDashboardComponent, {
set: {
providers: [
{ provide: Router, useValue: router },
{
provide: AppConfigService,
useValue: {
getConfig,
},
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
schemas: [NO_ERRORS_SCHEMA],
declarations: [DatasetDetailsDashboardComponent],
imports: [
MatButtonModule,
MatIconModule,
MatSlideToggleModule,
MatTabsModule,
SharedScicatFrontendModule,
StoreModule.forRoot({}),
],
providers: [LazyChildService],
});
TestBed.overrideComponent(DatasetDetailsDashboardComponent, {
set: {
providers: [
{ provide: Router, useValue: router },
{
provide: AppConfigService,
useValue: {
getConfig,
},
{ provide: ActivatedRoute, useClass: MockActivatedRoute },
{ provide: UserApi, useClass: MockUserApi },
],
},
});
TestBed.compileComponents();
})
);
},
{ provide: ActivatedRoute, useClass: MockActivatedRoute },
{ provide: UserApi, useClass: MockUserApi },
],
},
});
TestBed.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DatasetDetailsDashboardComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
fetchDatablocksAction,
fetchDatasetAction,
fetchOrigDatablocksAction,
fetchRelatedDatasetsAction,
} from "state-management/actions/datasets.actions";
import {
clearLogbookAction,
Expand All @@ -39,6 +40,7 @@ import {
import { MatDialog } from "@angular/material/dialog";
import { AppConfigService } from "app-config.service";
import { fetchInstrumentAction } from "state-management/actions/instruments.actions";
import { LazyChildService } from "lazy-child.service";

export interface JWT {
jwt: string;
Expand All @@ -51,6 +53,7 @@ export interface FileObject {
enum TAB {
details = "Details",
datafiles = "Datafiles",
relatedDatasets = "Related Datasets",
reduce = "Reduce",
logbook = "Logbook",
attachments = "Attachments",
Expand Down Expand Up @@ -81,6 +84,10 @@ export class DatasetDetailsDashboardComponent
}[] = [];
fetchDataActions: { [tab: string]: { action: any; loaded: boolean } } = {
[TAB.details]: { action: fetchDatasetAction, loaded: false },
[TAB.relatedDatasets]: {
action: fetchRelatedDatasetsAction,
loaded: false,
},
[TAB.datafiles]: { action: fetchOrigDatablocksAction, loaded: false },
[TAB.logbook]: { action: fetchLogbookAction, loaded: false },
[TAB.attachments]: { action: fetchAttachmentsAction, loaded: false },
Expand All @@ -95,23 +102,24 @@ export class DatasetDetailsDashboardComponent
constructor(
public appConfigService: AppConfigService,
private cdRef: ChangeDetectorRef,
private lazyChildService: LazyChildService,
private route: ActivatedRoute,
private store: Store,
private userApi: UserApi,
public dialog: MatDialog
) {}

ngOnInit() {
this.route.params
.pipe(pluck("id"))
.subscribe((id: string) => {
this.subscriptions.push(
this.route.params.pipe(pluck("id")).subscribe((id: string) => {
if (id) {
// Fetch dataset details
this.store.dispatch(fetchDatasetAction({ pid: id }));
this.fetchDataActions[TAB.details].loaded = true;
}
})
.unsubscribe();
);

const datasetSub = this.dataset$
.pipe(takeWhile((dataset) => !dataset, true))
.subscribe((dataset) => {
Expand All @@ -134,6 +142,12 @@ export class DatasetDetailsDashboardComponent
icon: "cloud_download",
enabled: true,
},
{
location: "./related-datasets",
label: TAB.relatedDatasets,
icon: "folder",
enabled: true,
},
{
location: "./reduce",
label: TAB.reduce,
Expand Down Expand Up @@ -181,28 +195,19 @@ export class DatasetDetailsDashboardComponent
})
.unsubscribe();

if ("proposalId" in dataset) {
this.store.dispatch(
fetchProposalAction({ proposalId: dataset["proposalId"] })
);
} else {
this.store.dispatch(clearLogbookAction());
}
if ("sampleId" in dataset) {
this.store.dispatch(
fetchSampleAction({ sampleId: dataset["sampleId"] })
);
}
if ("instrumentId" in dataset) {
this.store.dispatch(
fetchInstrumentAction({ pid: dataset["instrumentId"] })
);
}
this.fetchDatasetRelatedDocuments();
}
});
this.subscriptions.push(datasetSub);
this.jwt$ = this.userApi.jwt();
};

this.lazyChildService.childChanges().subscribe((tabName) => {
nguyenlinhlinh marked this conversation as resolved.
Show resolved Hide resolved
console.log({ tabName });

this.fetchDataActions[tabName].loaded = false;
this.fetchDatasetRelatedDocuments();
});
}
onTabSelected(tab: string) {
this.fetchDataForTab(tab);
}
Expand Down Expand Up @@ -239,6 +244,29 @@ export class DatasetDetailsDashboardComponent
}
}
}

fetchDatasetRelatedDocuments(): void {
if (this.dataset) {
if ("proposalId" in this.dataset) {
this.store.dispatch(
fetchProposalAction({ proposalId: this.dataset["proposalId"] })
);
} else {
this.store.dispatch(clearLogbookAction());
}
if ("sampleId" in this.dataset) {
this.store.dispatch(
fetchSampleAction({ sampleId: this.dataset["sampleId"] })
);
}
if ("instrumentId" in this.dataset) {
this.store.dispatch(
fetchInstrumentAction({ pid: this.dataset["instrumentId"] })
);
}
}
}

ngAfterViewChecked() {
this.cdRef.detectChanges();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class DatasetLifecycleComponent implements OnInit, OnChanges {
) {}

private parseHistoryItems(): HistoryItem[] {
if (this.dataset) {
if (this.dataset && this.dataset.history) {
const history = this.dataset.history.map(
({ updatedAt, updatedBy, id, ...properties }) =>
Object.keys(properties).map(
Expand Down
2 changes: 2 additions & 0 deletions src/app/datasets/datasets.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import { DatasetFileUploaderComponent } from "./dataset-file-uploader/dataset-fi
import { AdminTabComponent } from "./admin-tab/admin-tab.component";
import { instrumentsReducer } from "state-management/reducers/instruments.reducer";
import { InstrumentEffects } from "state-management/effects/instruments.effects";
import { RelatedDatasetsComponent } from "./related-datasets/related-datasets.component";

@NgModule({
imports: [
Expand Down Expand Up @@ -155,6 +156,7 @@ import { InstrumentEffects } from "state-management/effects/instruments.effects"
ShareDialogComponent,
DatasetFileUploaderComponent,
AdminTabComponent,
RelatedDatasetsComponent,
],
providers: [
ArchivingService,
Expand Down
12 changes: 12 additions & 0 deletions src/app/datasets/related-datasets/related-datasets.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="dataset-table" *ngIf="vm$ | async as vm">
<app-table
[data]="vm.relatedDatasets"
[columns]="tableColumns"
[paginate]="tablePaginate"
[currentPage]="vm.relatedDatasetsFilters.skip"
[dataCount]="vm.relatedDatasetsCount"
[dataPerPage]="vm.relatedDatasetsFilters.limit"
(pageChange)="onPageChange($event)"
(rowClick)="onRowClick($event)"
></app-table>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.dataset-table {
margin-top: 5em;
}
Loading