Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"@ngx-translate/core": "^17.0.0",
"@ngxmc/datetime-picker": "^19.3.1",
"@scicatproject/scicat-sdk-ts-angular": "^4.27.0",
"ajv": "^8.18.0",
"ajv-formats": "^3.0.1",
"ajv-keywords": "^5.1.0",
"autolinker": "^4.0.0",
"deep-equal": "^2.0.5",
"exceljs": "^4.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
OutputDatasetObsoleteDto,
ProposalClass,
ReturnedUserDto,
SampleClass,
OutputSampleDto,
} from "@scicatproject/scicat-sdk-ts-angular";
import { AttachmentService } from "shared/services/attachment.service";

Expand Down Expand Up @@ -80,7 +80,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
loading$ = this.store.select(selectIsLoading);
instrument: Instrument | undefined;
proposal: ProposalClass | undefined;
sample: SampleClass | undefined;
sample: OutputSampleDto | undefined;
user: ReturnedUserDto | undefined;
editingAllowed = false;
editEnabled = false;
Expand Down
5 changes: 2 additions & 3 deletions src/app/datasets/publish/publish.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
[schema]="schema"
[uischema]="uiSchema"
[renderers]="renderers"
[ajv]="ajv"
(errors)="onErrors($event)"
(dataChange)="onMetadataChange($event)"
></jsonforms>
Expand All @@ -69,9 +70,7 @@
class="save-and-continue"
mat-raised-button
color="primary"
[disabled]="
!formIsValid() || (panelOpenState() && !metadataIsValid())
"
[disabled]="!formIsValid()"
>
Save and Continue
</button>
Expand Down
7 changes: 5 additions & 2 deletions src/app/datasets/publish/publish.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import { MatInputModule } from "@angular/material/input";
import { MatSelectModule } from "@angular/material/select";
import { MatButtonModule } from "@angular/material/button";
import { AppConfigService } from "app-config.service";
import { PublishedDataService } from "@scicatproject/scicat-sdk-ts-angular";
import { PublishedDataV4Service } from "@scicatproject/scicat-sdk-ts-angular";
import { AjvService } from "shared/services/ajv.service";
import { SharedScicatFrontendModule } from "shared/shared.module";

const getConfig = () => ({
facility: "test",
Expand All @@ -49,6 +51,7 @@ describe("PublishComponent", () => {
MatInputModule,
MatSelectModule,
ReactiveFormsModule,
SharedScicatFrontendModule,
],
providers: [
provideMockStore({
Expand All @@ -65,7 +68,7 @@ describe("PublishComponent", () => {
{ provide: ActivatedRoute, useClass: MockActivatedRoute },
{ provide: ActionsSubject, useValue: of({}) },
{ provide: AppConfigService, useValue: { getConfig } },
{ provide: PublishedDataService, useClass: MockPublishedDataApi },
{ provide: PublishedDataV4Service, useClass: MockPublishedDataApi },
{ provide: Router, useClass: MockRouter },
{ provide: Store, useClass: MockStore },
],
Expand Down
23 changes: 13 additions & 10 deletions src/app/datasets/publish/publish.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { angularMaterialRenderers } from "@jsonforms/angular-material";
import {
CreatePublishedDataV4Dto,
PublishedData,
PublishedDataService,
PublishedDataV4Service,
} from "@scicatproject/scicat-sdk-ts-angular";
import { AppConfigService } from "app-config.service";
import { EditableComponent } from "app-routing/pending-changes.guard";
Expand All @@ -31,6 +31,8 @@ import {
accordionArrayLayoutRendererTester,
} from "shared/modules/jsonforms-custom-renderers/expand-panel-renderer/accordion-array-layout-renderer.component";
import { selectPublishedDataConfig } from "state-management/selectors/published-data.selectors";
import Ajv2019 from "ajv/dist/2019";
import { AjvService } from "shared/services/ajv.service";

@Component({
selector: "publish",
Expand All @@ -47,6 +49,7 @@ export class PublishComponent implements OnInit, OnDestroy, EditableComponent {
private beforeUnloadSubscription: Subscription;
readonly panelOpenState = signal(false);

ajv: Ajv2019;
appConfig = this.appConfigService.getConfig();
renderers = [
...angularMaterialRenderers,
Expand Down Expand Up @@ -76,10 +79,13 @@ export class PublishComponent implements OnInit, OnDestroy, EditableComponent {
constructor(
private appConfigService: AppConfigService,
private store: Store,
private publishedDataApi: PublishedDataService,
private publishedDataApi: PublishedDataV4Service,
private actionsSubj: ActionsSubject,
private router: Router,
) {}
private ajvService: AjvService,
) {
this.ajv = this.ajvService.newInstance();
}

public formIsValid() {
if (!Object.values(this.form).includes(undefined)) {
Expand Down Expand Up @@ -127,14 +133,10 @@ export class PublishComponent implements OnInit, OnDestroy, EditableComponent {
this.publishedDataConfigSubscription = this.publishedDataConfig$.subscribe(
(publishedDataConfig) => {
if (!isEmpty(publishedDataConfig)) {
this.schema = publishedDataConfig.metadataSchema;
// NOTE: We set the publicationYear by the system, so we remove it from the required fields in the frontend
this.schema?.required.splice(
this.schema.required.indexOf("publicationYear"),
1,
this.schema = this.ajvService.cleanupSchema(
publishedDataConfig.metadataSchema,
);
this.uiSchema = publishedDataConfig.uiSchema;
this.metadata = cloneDeep(publishedDataConfig.defaultValues) ?? {};
}
},
);
Expand All @@ -146,10 +148,11 @@ export class PublishComponent implements OnInit, OnDestroy, EditableComponent {
});

this.publishedDataApi
.publishedDataControllerFormPopulateV3(this.form.datasetPids[0])
.publishedDataV4ControllerFormPopulateV4(this.form.datasetPids)
.subscribe((result) => {
this.form.abstract = result.abstract;
this.form.title = result.title;
this.metadata = result.metadata;
});

this.actionSubjectSubscription = this.actionsSubj.subscribe((data) => {
Expand Down
8 changes: 4 additions & 4 deletions src/app/datasets/sample-edit/sample-edit.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "state-management/actions/samples.actions";

import { SampleEditComponent } from "./sample-edit.component";
import { SampleClass } from "@scicatproject/scicat-sdk-ts-angular";
import { OutputSampleDto } from "@scicatproject/scicat-sdk-ts-angular";

describe("SampleEditComponent", () => {
let component: SampleEditComponent;
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("SampleEditComponent", () => {
it("should return false if sample in form has same id as current sample", () => {
const sampleId = "abc123";

const sample = createMock<SampleClass>({
const sample = createMock<OutputSampleDto>({
sampleId,
owner: "test",
description: "test",
Expand All @@ -187,7 +187,7 @@ describe("SampleEditComponent", () => {
it("should return true if form is valid", () => {
const sampleId = "abc123";

const sample = createMock<SampleClass>({
const sample = createMock<OutputSampleDto>({
sampleId: "123abc",
owner: "test",
description: "test",
Expand Down Expand Up @@ -224,7 +224,7 @@ describe("SampleEditComponent", () => {
it("should close the dialog and emit data", () => {
const dialogCloseSpy = spyOn(component.dialogRef, "close");

const sample = createMock<SampleClass>({
const sample = createMock<OutputSampleDto>({
sampleId: "123abc",
owner: "test",
description: "test",
Expand Down
8 changes: 4 additions & 4 deletions src/app/datasets/sample-edit/sample-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
PageChangeEvent,
SortChangeEvent,
} from "shared/modules/table/table.component";
import { SampleClass } from "@scicatproject/scicat-sdk-ts-angular";
import { OutputSampleDto } from "@scicatproject/scicat-sdk-ts-angular";
import {
changePageAction,
fetchSamplesAction,
Expand Down Expand Up @@ -58,7 +58,7 @@ export class SampleEditComponent implements OnInit, OnDestroy {
);

samplesSubscription: Subscription = new Subscription();
samples: SampleClass[] = [];
samples: OutputSampleDto[] = [];

selectedSampleId = "";
displayedColumns = [
Expand All @@ -70,7 +70,7 @@ export class SampleEditComponent implements OnInit, OnDestroy {
];

form = new FormGroup({
sample: new FormControl<SampleClass>(null, [
sample: new FormControl<OutputSampleDto>(null, [
Validators.required,
this.sampleValidator(),
]),
Expand Down Expand Up @@ -129,7 +129,7 @@ export class SampleEditComponent implements OnInit, OnDestroy {
sortByColumnAction({ column: event.active, direction: event.direction }),
);

onRowClick = (sample: SampleClass): void => {
onRowClick = (sample: OutputSampleDto): void => {
this.selectedSampleId = sample.sampleId;
this.sample?.setValue(sample);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
[schema]="schema"
[uischema]="uiSchema"
[renderers]="renderers"
[ajv]="ajv"
(errors)="onErrors($event)"
(dataChange)="onMetadataChange($event)"
></jsonforms>
Expand All @@ -73,9 +74,7 @@
color="primary"
class="save-and-continue"
(click)="onPublishedDataUpdate(true)"
[disabled]="
!form.valid || (panelOpenState() && !metadataDataIsValid())
"
[disabled]="!form.valid"
>
Save and continue
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { MatButtonModule } from "@angular/material/button";
import { FlexLayoutModule } from "@ngbracket/ngx-layout";
import { PublishedDataService } from "@scicatproject/scicat-sdk-ts-angular";
import { AppConfigService } from "app-config.service";
import { SharedScicatFrontendModule } from "shared/shared.module";

describe("PublisheddataEditComponent", () => {
let component: PublisheddataEditComponent;
Expand All @@ -51,6 +52,7 @@ describe("PublisheddataEditComponent", () => {
MatOptionModule,
MatSelectModule,
ReactiveFormsModule,
SharedScicatFrontendModule,
],
providers: [
provideMockStore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { fromEvent, Observable, Subscription } from "rxjs";
import { angularMaterialRenderers } from "@jsonforms/angular-material";
import { EditableComponent } from "app-routing/pending-changes.guard";
import { isEmpty } from "lodash-es";
import { cloneDeep, isEmpty } from "lodash-es";
import { AppConfigService } from "app-config.service";
import {
AccordionArrayLayoutRendererComponent,
accordionArrayLayoutRendererTester,
} from "shared/modules/jsonforms-custom-renderers/expand-panel-renderer/accordion-array-layout-renderer.component";
import Ajv2019 from "ajv/dist/2019";
import { PublishComponent } from "datasets/publish/publish.component";
import { AjvService } from "shared/services/ajv.service";

@Component({
selector: "publisheddata-edit",
Expand All @@ -38,6 +41,7 @@ export class PublisheddataEditComponent
{
private _hasUnsavedChanges = false;
private publishedDataConfig$ = this.store.select(selectPublishedDataConfig);
ajv: Ajv2019;
renderers = [
...angularMaterialRenderers,
{
Expand Down Expand Up @@ -74,7 +78,10 @@ export class PublisheddataEditComponent
private router: Router,
private store: Store,
private appConfigService: AppConfigService,
) {}
private ajvService: AjvService,
) {
this.ajv = this.ajvService.newInstance();
}

public onPublishedDataUpdate(shouldRedirect = false) {
if (this.form.valid) {
Expand Down Expand Up @@ -143,11 +150,8 @@ export class PublisheddataEditComponent
this.publishedDataConfigSubscription = this.publishedDataConfig$.subscribe(
(publishedDataConfig) => {
if (!isEmpty(publishedDataConfig)) {
this.schema = publishedDataConfig.metadataSchema;
// NOTE: We set the publicationYear by the system, so we remove it from the required fields in the frontend
this.schema?.required.splice(
this.schema.required.indexOf("publicationYear"),
1,
this.schema = this.ajvService.cleanupSchema(
publishedDataConfig.metadataSchema,
);
this.uiSchema = publishedDataConfig.uiSchema;
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/samples/sample-dashboard/sample-dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, OnDestroy, ViewChild } from "@angular/core";
import { Store } from "@ngrx/store";
import { SampleClass } from "@scicatproject/scicat-sdk-ts-angular";
import { OutputSampleDto } from "@scicatproject/scicat-sdk-ts-angular";
import {
changePageAction,
fetchSamplesAction,
Expand Down Expand Up @@ -125,8 +125,8 @@ export class SampleDashboardComponent implements OnInit, OnDestroy {

paginationMode: TablePaginationMode = "server-side";

dataSource: BehaviorSubject<SampleClass[]> = new BehaviorSubject<
SampleClass[]
dataSource: BehaviorSubject<OutputSampleDto[]> = new BehaviorSubject<
OutputSampleDto[]
>([]);

pagination: TablePagination = {};
Expand Down Expand Up @@ -228,7 +228,7 @@ export class SampleDashboardComponent implements OnInit, OnDestroy {
);
};

formatTableData(samples: SampleClass[]): any {
formatTableData(samples: OutputSampleDto[]): any {
if (samples) {
return samples.map((sample) => ({
sampleId: sample.sampleId,
Expand Down Expand Up @@ -363,7 +363,7 @@ export class SampleDashboardComponent implements OnInit, OnDestroy {
}
}

onRowClick(event: IRowEvent<SampleClass>) {
onRowClick(event: IRowEvent<OutputSampleDto>) {
if (event.event === RowEventType.RowClick) {
const id = encodeURIComponent(event.sender.row.sampleId);
this.router.navigateByUrl("/samples/" + id);
Expand Down
4 changes: 2 additions & 2 deletions src/app/samples/sample-detail/sample-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
OutputAttachmentV3Dto,
OutputDatasetObsoleteDto,
ReturnedUserDto,
SampleClass,
OutputSampleDto,
} from "@scicatproject/scicat-sdk-ts-angular";

export interface TableData {
Expand All @@ -58,7 +58,7 @@ export class SampleDetailComponent

appConfig = this.appConfigService.getConfig();

sample: SampleClass;
sample: OutputSampleDto;
user: ReturnedUserDto;
attachment: CreateAttachmentV3Dto;
attachments: OutputAttachmentV3Dto[] = [];
Expand Down
Loading
Loading