From ee51ea46a7efcaef8b0c0c57fdb239a376899600 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 10:29:26 +0100 Subject: [PATCH 01/10] disabled sample edit --- .../dataset-detail.component.html | 8 +++- .../dataset-detail.component.ts | 47 ++++++++++--------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.html b/src/app/datasets/dataset-detail/dataset-detail.component.html index db97d4657..54c511c6f 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.html +++ b/src/app/datasets/dataset-detail/dataset-detail.component.html @@ -268,13 +268,17 @@ {{ sample.description }} - + diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail.component.ts index 3de466a4e..b7b2cd67d 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.ts @@ -277,28 +277,31 @@ export class DatasetDetailComponent this.router.navigateByUrl("/samples/" + id); } - openSampleEditDialog() { - if (this.dataset) { - this.dialog - .open(SampleEditComponent, { - width: "1000px", - data: { - ownerGroup: this.dataset.ownerGroup, - sampleId: this.sample?.sampleId, - }, - }) - .afterClosed() - .subscribe((res) => { - if (res && this.dataset) { - const { sample } = res; - this.sample = sample; - const pid = this.dataset.pid; - const property = { sampleId: sample.sampleId }; - this.store.dispatch(updatePropertyAction({ pid, property })); - } - }); - } - } + // NOTE: Sample editing is currently disabled. + // This feature not only contains bugs that need to be fixed, + // but we also want to have a centralized edit button in one location. + // openSampleEditDialog() { + // if (this.dataset) { + // this.dialog + // .open(SampleEditComponent, { + // width: "1000px", + // data: { + // ownerGroup: this.dataset.ownerGroup, + // sampleId: this.sample?.sampleId, + // }, + // }) + // .afterClosed() + // .subscribe((res) => { + // if (res && this.dataset) { + // const { sample } = res; + // this.sample = sample; + // const pid = this.dataset.pid; + // const property = { sampleId: sample.sampleId }; + // this.store.dispatch(updatePropertyAction({ pid, property })); + // } + // }); + // } + // } onSlidePublic(event: MatSlideToggleChange) { if (this.dataset) { From 1472fbefadcfb44c6d7c62f569d6eccd9a354cae Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 10:56:51 +0100 Subject: [PATCH 02/10] enhanced large file download instructions and update config --- src/app/app-config.service.ts | 1 + src/app/datasets/datafiles/datafiles.component.html | 11 +---------- src/app/datasets/datafiles/datafiles.component.ts | 11 ++++++++++- src/app/datasets/datasets.module.ts | 1 - 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index 904df35da..12af7e9d5 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -82,6 +82,7 @@ export interface AppConfig { searchPublicDataEnabled: boolean; searchSamples: boolean; sftpHost: string | null; + largeDataFileAccessInstruction?: string; shareEnabled: boolean; shoppingCartEnabled: boolean; shoppingCartOnHeader: boolean; diff --git a/src/app/datasets/datafiles/datafiles.component.html b/src/app/datasets/datafiles/datafiles.component.html index 8eb776fa3..c2867c6e2 100644 --- a/src/app/datasets/datafiles/datafiles.component.html +++ b/src/app/datasets/datafiles/datafiles.component.html @@ -2,16 +2,7 @@ warning - One or more files are too large to be downloaded directly. - {{ - sftpHost - ? "These files are available via sftp host " + - sftpHost + - " in directory " + - sourcefolder + - "." - : "" - }} + diff --git a/src/app/datasets/datafiles/datafiles.component.ts b/src/app/datasets/datafiles/datafiles.component.ts index 136e192bd..854af36a9 100644 --- a/src/app/datasets/datafiles/datafiles.component.ts +++ b/src/app/datasets/datafiles/datafiles.component.ts @@ -76,7 +76,9 @@ export class DatafilesComponent this.appConfig.fileserverButtonLabel || "Download"; multipleDownloadAction: string | null = this.appConfig.multipleDownloadAction; maxFileSize: number | null = this.appConfig.maxDirectDownloadSize; - sftpHost: string | null = this.appConfig.sftpHost; + sftpHost: string = this.appConfig.sftpHost || "no sftp host provided"; + customSourcefolder: string | null = + this.appConfig.largeDataFileAccessInstruction; jwt: any; auth_token: any; @@ -204,6 +206,13 @@ export class DatafilesComponent } } + replace_dynamic_values() { + const fileTooLargeMessage = `Some files are too big, but they can be downloaded at our sftp server: ${this.sftpHost} at the folder: + ${this.customSourcefolder || this.sourcefolder}`; + + return fileTooLargeMessage; + } + ngAfterViewInit() { this.subscriptions.push( this.dataset$.subscribe((dataset) => { diff --git a/src/app/datasets/datasets.module.ts b/src/app/datasets/datasets.module.ts index ad668eb0a..d20615983 100644 --- a/src/app/datasets/datasets.module.ts +++ b/src/app/datasets/datasets.module.ts @@ -89,7 +89,6 @@ import { DatasetsFilterSettingsComponent } from "./datasets-filter/settings/data import { CdkDrag, CdkDragHandle, CdkDropList } from "@angular/cdk/drag-drop"; import { FiltersModule } from "shared/modules/filters/filters.module"; import { userReducer } from "state-management/reducers/user.reducer"; -import { AttachmentService } from "shared/services/attachment.service"; @NgModule({ imports: [ From a51bbdbfba11102cdd1e595eee609cc0ade0cf23 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 10:58:45 +0100 Subject: [PATCH 03/10] commented out sample edit test --- .../dataset-detail.component.spec.ts | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts index e83e5f4fd..57f2ceed1 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts @@ -341,33 +341,37 @@ describe("DatasetDetailComponent", () => { }); }); - describe("#openSampleEditDialog()", () => { - it("should open the sample edit dialog and dispatch updatePropertyAction", () => { - const dispatchSpy = spyOn(store, "dispatch"); - component.dataset = new Dataset(); - component.dataset.ownerGroup = "test"; - component.sample = new Sample(); - const sampleId = "testId"; - component.sample.sampleId = sampleId; - const pid = "testPid"; - component.dataset.pid = pid; - const property = { sampleId }; - const dialogOpenSpy = spyOn(component.dialog, "open").and.returnValue({ - afterClosed: () => of({ sample: { sampleId: "testId" } }), - } as MatDialogRef); - component.openSampleEditDialog(); - - expect(dialogOpenSpy).toHaveBeenCalledTimes(1); - expect(dialogOpenSpy).toHaveBeenCalledWith(SampleEditComponent, { - width: "1000px", - data: { ownerGroup: "test", sampleId: "testId" }, - }); - expect(dispatchSpy).toHaveBeenCalledTimes(1); - expect(dispatchSpy).toHaveBeenCalledWith( - updatePropertyAction({ pid, property }), - ); - }); - }); + // NOTE: Sample editing is currently disabled. + // This feature not only contains bugs that need to be fixed, + // but we also want to have a centralized edit button in one location. + + // describe("#openSampleEditDialog()", () => { + // it("should open the sample edit dialog and dispatch updatePropertyAction", () => { + // const dispatchSpy = spyOn(store, "dispatch"); + // component.dataset = new Dataset(); + // component.dataset.ownerGroup = "test"; + // component.sample = new Sample(); + // const sampleId = "testId"; + // component.sample.sampleId = sampleId; + // const pid = "testPid"; + // component.dataset.pid = pid; + // const property = { sampleId }; + // const dialogOpenSpy = spyOn(component.dialog, "open").and.returnValue({ + // afterClosed: () => of({ sample: { sampleId: "testId" } }), + // } as MatDialogRef); + // component.openSampleEditDialog(); + + // expect(dialogOpenSpy).toHaveBeenCalledTimes(1); + // expect(dialogOpenSpy).toHaveBeenCalledWith(SampleEditComponent, { + // width: "1000px", + // data: { ownerGroup: "test", sampleId: "testId" }, + // }); + // expect(dispatchSpy).toHaveBeenCalledTimes(1); + // expect(dispatchSpy).toHaveBeenCalledWith( + // updatePropertyAction({ pid, property }), + // ); + // }); + // }); describe("#onSaveMetadata()", () => { it("should dispatch an updatePropertyAction", () => { From 29d76ff342bb4766c08a766aee8e8347fc0dfbb1 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 11:26:02 +0100 Subject: [PATCH 04/10] fix the issue of the red cross icon appearing for PDF images in the dataset table --- .../dataset-detail/dataset-detail.component.ts | 8 ++------ .../file-uploader/file-uploader.component.ts | 6 +----- src/app/shared/services/attachment.service.ts | 15 +++++++++++++++ src/app/shared/services/thumbnail.service.ts | 4 +++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail.component.ts index b7b2cd67d..4292ad467 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.ts @@ -4,7 +4,7 @@ import { ENTER, COMMA, SPACE } from "@angular/cdk/keycodes"; import { MatChipInputEvent } from "@angular/material/chips"; import { MatDialog } from "@angular/material/dialog"; -import { SampleEditComponent } from "datasets/sample-edit/sample-edit.component"; +// import { SampleEditComponent } from "datasets/sample-edit/sample-edit.component"; import { DialogComponent } from "shared/modules/dialog/dialog.component"; import { combineLatest, fromEvent, Observable, Subscription } from "rxjs"; import { Store } from "@ngrx/store"; @@ -354,11 +354,7 @@ export class DatasetDetailComponent } getImageUrl(encoded: string) { - const mimeType = this.base64MimeType(encoded); - if (mimeType === "application/pdf") { - return "assets/images/pdf-icon.svg"; - } - return encoded; + return this.attachmentService.getImageUrl(encoded); } openAttachment(encoded: string) { diff --git a/src/app/shared/modules/file-uploader/file-uploader.component.ts b/src/app/shared/modules/file-uploader/file-uploader.component.ts index 9970a2b0e..af18cfb49 100644 --- a/src/app/shared/modules/file-uploader/file-uploader.component.ts +++ b/src/app/shared/modules/file-uploader/file-uploader.component.ts @@ -109,11 +109,7 @@ export class FileUploaderComponent { } getImageUrl(encoded: string) { - const mimeType = this.base64MimeType(encoded); - if (mimeType === "application/pdf") { - return "assets/images/pdf-icon.svg"; - } - return encoded; + return this.attachmentService.getImageUrl(encoded); } openAttachment(encoded: string) { diff --git a/src/app/shared/services/attachment.service.ts b/src/app/shared/services/attachment.service.ts index 7d4e054a6..8dde4815e 100644 --- a/src/app/shared/services/attachment.service.ts +++ b/src/app/shared/services/attachment.service.ts @@ -3,6 +3,8 @@ import { Injectable } from "@angular/core"; @Injectable() export class AttachmentService { base64MimeType(encoded: string): string { + if (!encoded) return null; + let result = null; if (typeof encoded !== "string") { @@ -17,7 +19,20 @@ export class AttachmentService { return result; } + + getImageUrl(encoded: string) { + if (!encoded) return null; + + const mimeType = this.base64MimeType(encoded); + if (mimeType === "application/pdf") { + return "assets/images/pdf-icon.svg"; + } + return encoded; + } + openAttachment(encoded: string) { + if (!encoded) return null; + const mimeType = this.base64MimeType(encoded); const strippedData = encoded.replace( new RegExp(`^data:${mimeType};base64,`), diff --git a/src/app/shared/services/thumbnail.service.ts b/src/app/shared/services/thumbnail.service.ts index f4879b2bb..7990139de 100644 --- a/src/app/shared/services/thumbnail.service.ts +++ b/src/app/shared/services/thumbnail.service.ts @@ -4,6 +4,7 @@ import { distinctUntilChanged, firstValueFrom } from "rxjs"; import { DatasetApi } from "shared/sdk"; import { selectDatasetsPerPage } from "state-management/selectors/datasets.selectors"; import { AppConfigService } from "app-config.service"; +import { AttachmentService } from "./attachment.service"; interface ThumbnailCache { [pid: string]: { @@ -25,6 +26,7 @@ export class ThumbnailService { constructor( private datasetApi: DatasetApi, private store: Store, + private attachmentService: AttachmentService, private appConfigService: AppConfigService, ) { this.store @@ -60,7 +62,7 @@ export class ThumbnailService { try { const encodedPid = encodeURIComponent(pid); const res = await firstValueFrom(this.datasetApi.thumbnail(encodedPid)); - const thumbnail = res?.thumbnail || null; + const thumbnail = this.attachmentService.getImageUrl(res?.thumbnail); this.thumbnailCache[pid] = { value: thumbnail, From 1f2fb15623648c12d05ae690c94fea859288e619 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 11:32:28 +0100 Subject: [PATCH 05/10] fix for thumbnail image being cut off --- src/app/datasets/dataset-table/dataset-table.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/datasets/dataset-table/dataset-table.component.html b/src/app/datasets/dataset-table/dataset-table.component.html index 99657fe7d..9aa6f3dd9 100644 --- a/src/app/datasets/dataset-table/dataset-table.component.html +++ b/src/app/datasets/dataset-table/dataset-table.component.html @@ -208,7 +208,7 @@ From dceb6ae9f851ef881f1d19d4288f8f44dbf92478 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 11:35:30 +0100 Subject: [PATCH 06/10] fixes based on AI PR review --- src/app/datasets/datafiles/datafiles.component.ts | 7 +++---- src/app/shared/services/attachment.service.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/datasets/datafiles/datafiles.component.ts b/src/app/datasets/datafiles/datafiles.component.ts index 854af36a9..f6b76ec3b 100644 --- a/src/app/datasets/datafiles/datafiles.component.ts +++ b/src/app/datasets/datafiles/datafiles.component.ts @@ -207,10 +207,9 @@ export class DatafilesComponent } replace_dynamic_values() { - const fileTooLargeMessage = `Some files are too big, but they can be downloaded at our sftp server: ${this.sftpHost} at the folder: - ${this.customSourcefolder || this.sourcefolder}`; - - return fileTooLargeMessage; + return `Some files are too big, but they can be downloaded + at our sftp server: ${this.sftpHost} + at the folder: ${this.customSourcefolder || this.sourcefolder}`; } ngAfterViewInit() { diff --git a/src/app/shared/services/attachment.service.ts b/src/app/shared/services/attachment.service.ts index 8dde4815e..9ad1f9ab8 100644 --- a/src/app/shared/services/attachment.service.ts +++ b/src/app/shared/services/attachment.service.ts @@ -3,7 +3,9 @@ import { Injectable } from "@angular/core"; @Injectable() export class AttachmentService { base64MimeType(encoded: string): string { - if (!encoded) return null; + if (!encoded) { + return null; + } let result = null; @@ -21,7 +23,9 @@ export class AttachmentService { } getImageUrl(encoded: string) { - if (!encoded) return null; + if (!encoded) { + return null; + } const mimeType = this.base64MimeType(encoded); if (mimeType === "application/pdf") { @@ -31,7 +35,9 @@ export class AttachmentService { } openAttachment(encoded: string) { - if (!encoded) return null; + if (!encoded) { + return null; + } const mimeType = this.base64MimeType(encoded); const strippedData = encoded.replace( From 1f9b4338c367e5ecc0bf7a48ba92c3faacb2e14f Mon Sep 17 00:00:00 2001 From: junjiequan Date: Wed, 20 Nov 2024 11:43:27 +0100 Subject: [PATCH 07/10] added unit test for the change --- .../shared/services/attachment.service.spec.ts | 16 +++++++++++++++- .../shared/services/thumbnail.service.spec.ts | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app/shared/services/attachment.service.spec.ts b/src/app/shared/services/attachment.service.spec.ts index 4cb7f76fd..888753ec8 100644 --- a/src/app/shared/services/attachment.service.spec.ts +++ b/src/app/shared/services/attachment.service.spec.ts @@ -29,11 +29,25 @@ describe("AttachmentService", () => { }); it("should return null for non-string input", () => { - const mimeType = service.base64MimeType(null as any); + const mimeType = service.base64MimeType(null); expect(mimeType).toBeNull(); }); }); + describe("getImageUrl", () => { + it("should return the pdf icon if the file is pdf", () => { + const encoded = "data:application/pdf;base64,SGVsbG8sIFdvcmxkIQ=="; + const imageUrl = service.getImageUrl(encoded); + expect(imageUrl).toBe("assets/images/pdf-icon.svg"); + }); + + it("should return the encoded string if the file is not pdf", () => { + const encoded = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA"; + const imageUrl = service.getImageUrl(encoded); + expect(imageUrl).toBe(encoded); + }); + }); + describe("openAttachment", () => { it("should open a new window with the correct object URL", () => { const encoded = "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ=="; diff --git a/src/app/shared/services/thumbnail.service.spec.ts b/src/app/shared/services/thumbnail.service.spec.ts index 9a441dfbc..fb187528d 100644 --- a/src/app/shared/services/thumbnail.service.spec.ts +++ b/src/app/shared/services/thumbnail.service.spec.ts @@ -5,6 +5,7 @@ import { ThumbnailService } from "./thumbnail.service"; import { selectDatasetsPerPage } from "state-management/selectors/datasets.selectors"; import { MockStore, provideMockStore } from "@ngrx/store/testing"; import { of, throwError } from "rxjs"; +import { AttachmentService } from "./attachment.service"; describe("ThumbnailService", () => { let service: ThumbnailService; @@ -27,6 +28,9 @@ describe("ThumbnailService", () => { provide: AppConfigService, useValue: { getConfig }, }, + { + provide: AttachmentService, + }, provideMockStore({ selectors: [ { From 01e2e9c733f811a5651578e7787539c0cefc4056 Mon Sep 17 00:00:00 2001 From: Jay Quan Date: Wed, 20 Nov 2024 20:04:19 +0100 Subject: [PATCH 08/10] rename for large file message function --- src/app/datasets/datafiles/datafiles.component.html | 2 +- src/app/datasets/datafiles/datafiles.component.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/datasets/datafiles/datafiles.component.html b/src/app/datasets/datafiles/datafiles.component.html index c2867c6e2..7fcf7d951 100644 --- a/src/app/datasets/datafiles/datafiles.component.html +++ b/src/app/datasets/datafiles/datafiles.component.html @@ -2,7 +2,7 @@ warning - + diff --git a/src/app/datasets/datafiles/datafiles.component.ts b/src/app/datasets/datafiles/datafiles.component.ts index f6b76ec3b..a1b7f2f73 100644 --- a/src/app/datasets/datafiles/datafiles.component.ts +++ b/src/app/datasets/datafiles/datafiles.component.ts @@ -206,10 +206,12 @@ export class DatafilesComponent } } - replace_dynamic_values() { + hasTooLargeFilesMessage() { return `Some files are too big, but they can be downloaded at our sftp server: ${this.sftpHost} - at the folder: ${this.customSourcefolder || this.sourcefolder}`; + at the folder: ${ + this.customSourcefolder || this.sourcefolder + }`; } ngAfterViewInit() { From bc3fcfeee8024ac1b33d2d99917dd3578b8482a4 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Mon, 25 Nov 2024 16:10:36 +0100 Subject: [PATCH 09/10] fix based on comments --- src/app/app-config.service.ts | 3 +- .../datafiles/datafiles.component.html | 6 +-- .../datasets/datafiles/datafiles.component.ts | 48 ++++++++++++++----- .../dataset-detail.component.html | 11 ----- .../dataset-detail.component.spec.ts | 32 ------------- .../dataset-detail.component.ts | 26 ---------- 6 files changed, 41 insertions(+), 85 deletions(-) diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index 12af7e9d5..acd6e3ea9 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -82,7 +82,8 @@ export interface AppConfig { searchPublicDataEnabled: boolean; searchSamples: boolean; sftpHost: string | null; - largeDataFileAccessInstruction?: string; + sourceFolder?: string; + maxFileSizeWarning?: string; shareEnabled: boolean; shoppingCartEnabled: boolean; shoppingCartOnHeader: boolean; diff --git a/src/app/datasets/datafiles/datafiles.component.html b/src/app/datasets/datafiles/datafiles.component.html index 7fcf7d951..001ca7d38 100644 --- a/src/app/datasets/datafiles/datafiles.component.html +++ b/src/app/datasets/datafiles/datafiles.component.html @@ -2,7 +2,7 @@ warning - + @@ -45,7 +45,7 @@

No files associated to this dataset

- + No files associated to this dataset - + = []; - sourcefolder = ""; datasetPid = ""; actionDataset: ActionDataset; @@ -76,9 +75,12 @@ export class DatafilesComponent this.appConfig.fileserverButtonLabel || "Download"; multipleDownloadAction: string | null = this.appConfig.multipleDownloadAction; maxFileSize: number | null = this.appConfig.maxDirectDownloadSize; + sourceFolder: string | null = + this.appConfig.sourceFolder || "no source folder provided"; sftpHost: string = this.appConfig.sftpHost || "no sftp host provided"; - customSourcefolder: string | null = - this.appConfig.largeDataFileAccessInstruction; + maxFileSizeWarning: string | null = + this.appConfig.maxFileSizeWarning || + `Some files are above the max size ${this.fileSizePipe.transform(this.maxFileSize)}`; jwt: any; auth_token: any; @@ -112,6 +114,7 @@ export class DatafilesComponent private store: Store, private cdRef: ChangeDetectorRef, private dialog: MatDialog, + private fileSizePipe: FileSizePipe, private userApi: UserApi, ) {} @@ -206,19 +209,40 @@ export class DatafilesComponent } } - hasTooLargeFilesMessage() { - return `Some files are too big, but they can be downloaded - at our sftp server: ${this.sftpHost} - at the folder: ${ - this.customSourcefolder || this.sourcefolder - }`; - } + hasFileAboveMaxSizeWarning() { + /** + * Template for a file size warning message. + * Placeholders: + * - : Maximum file size allowed (e.g., "10 MB"). + * - : SFTP host for downloading large files. + * - : Directory path on the SFTP host. + * + * Example usage: + * Some files are above . These file can be accessed via sftp host: in directory: + */ + + const valueMapping = { + sftpHost: this.sftpHost, + sourceFolder: this.sourceFolder, + maxDirectDownloadSize: this.fileSizePipe.transform(this.maxFileSize), + }; + let warning = this.maxFileSizeWarning; + + Object.keys(valueMapping).forEach((key) => { + warning = warning.replace( + "<" + key + ">", + `${valueMapping[key]}`, + ); + }); + + return warning; + } ngAfterViewInit() { this.subscriptions.push( this.dataset$.subscribe((dataset) => { if (dataset) { - this.sourcefolder = dataset.sourceFolder; + this.sourceFolder = dataset.sourceFolder; this.datasetPid = dataset.pid; this.actionDataset = dataset; } @@ -297,7 +321,7 @@ export class DatafilesComponent return ( this.fileserverBaseURL + "&origin_path=" + - encodeURIComponent(this.sourcefolder) + encodeURIComponent(this.sourceFolder) ); } } diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.html b/src/app/datasets/dataset-detail/dataset-detail.component.html index 54c511c6f..d049b4fe8 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.html +++ b/src/app/datasets/dataset-detail/dataset-detail.component.html @@ -268,17 +268,6 @@ {{ sample.description }} - - diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts index 57f2ceed1..96c778a5e 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.spec.ts @@ -341,38 +341,6 @@ describe("DatasetDetailComponent", () => { }); }); - // NOTE: Sample editing is currently disabled. - // This feature not only contains bugs that need to be fixed, - // but we also want to have a centralized edit button in one location. - - // describe("#openSampleEditDialog()", () => { - // it("should open the sample edit dialog and dispatch updatePropertyAction", () => { - // const dispatchSpy = spyOn(store, "dispatch"); - // component.dataset = new Dataset(); - // component.dataset.ownerGroup = "test"; - // component.sample = new Sample(); - // const sampleId = "testId"; - // component.sample.sampleId = sampleId; - // const pid = "testPid"; - // component.dataset.pid = pid; - // const property = { sampleId }; - // const dialogOpenSpy = spyOn(component.dialog, "open").and.returnValue({ - // afterClosed: () => of({ sample: { sampleId: "testId" } }), - // } as MatDialogRef); - // component.openSampleEditDialog(); - - // expect(dialogOpenSpy).toHaveBeenCalledTimes(1); - // expect(dialogOpenSpy).toHaveBeenCalledWith(SampleEditComponent, { - // width: "1000px", - // data: { ownerGroup: "test", sampleId: "testId" }, - // }); - // expect(dispatchSpy).toHaveBeenCalledTimes(1); - // expect(dispatchSpy).toHaveBeenCalledWith( - // updatePropertyAction({ pid, property }), - // ); - // }); - // }); - describe("#onSaveMetadata()", () => { it("should dispatch an updatePropertyAction", () => { const dispatchSpy = spyOn(store, "dispatch"); diff --git a/src/app/datasets/dataset-detail/dataset-detail.component.ts b/src/app/datasets/dataset-detail/dataset-detail.component.ts index 4292ad467..c48fb223c 100644 --- a/src/app/datasets/dataset-detail/dataset-detail.component.ts +++ b/src/app/datasets/dataset-detail/dataset-detail.component.ts @@ -277,32 +277,6 @@ export class DatasetDetailComponent this.router.navigateByUrl("/samples/" + id); } - // NOTE: Sample editing is currently disabled. - // This feature not only contains bugs that need to be fixed, - // but we also want to have a centralized edit button in one location. - // openSampleEditDialog() { - // if (this.dataset) { - // this.dialog - // .open(SampleEditComponent, { - // width: "1000px", - // data: { - // ownerGroup: this.dataset.ownerGroup, - // sampleId: this.sample?.sampleId, - // }, - // }) - // .afterClosed() - // .subscribe((res) => { - // if (res && this.dataset) { - // const { sample } = res; - // this.sample = sample; - // const pid = this.dataset.pid; - // const property = { sampleId: sample.sampleId }; - // this.store.dispatch(updatePropertyAction({ pid, property })); - // } - // }); - // } - // } - onSlidePublic(event: MatSlideToggleChange) { if (this.dataset) { const pid = this.dataset.pid; From 31e29a148dc91152d359faf096d12b2c81b1137d Mon Sep 17 00:00:00 2001 From: junjiequan Date: Tue, 26 Nov 2024 10:01:09 +0100 Subject: [PATCH 10/10] fix failing test --- src/app/app-config.service.spec.ts | 2 ++ src/app/datasets/dashboard/dashboard.component.ts | 1 - src/app/datasets/datafiles/datafiles.component.spec.ts | 4 +++- src/app/datasets/datafiles/datafiles.component.ts | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/app-config.service.spec.ts b/src/app/app-config.service.spec.ts index 517350b83..e276c8dec 100644 --- a/src/app/app-config.service.spec.ts +++ b/src/app/app-config.service.spec.ts @@ -54,6 +54,8 @@ const appConfig: AppConfig = { searchPublicDataEnabled: true, searchSamples: true, sftpHost: "login.esss.dk", + sourceFolder: "default", + maxFileSizeWarning: "Some files are above the max size", shareEnabled: true, shoppingCartEnabled: true, shoppingCartOnHeader: true, diff --git a/src/app/datasets/dashboard/dashboard.component.ts b/src/app/datasets/dashboard/dashboard.component.ts index 94b501441..a8f61ac02 100644 --- a/src/app/datasets/dashboard/dashboard.component.ts +++ b/src/app/datasets/dashboard/dashboard.component.ts @@ -73,7 +73,6 @@ export class DashboardComponent implements OnInit, OnDestroy { subscriptions: Subscription[] = []; appConfig = this.appConfigService.getConfig(); - currentUser: User = new User(); userGroups: string[] = []; clearColumnSearch = false; diff --git a/src/app/datasets/datafiles/datafiles.component.spec.ts b/src/app/datasets/datafiles/datafiles.component.spec.ts index 2e6e0125d..589fb0c3e 100644 --- a/src/app/datasets/datafiles/datafiles.component.spec.ts +++ b/src/app/datasets/datafiles/datafiles.component.spec.ts @@ -19,6 +19,7 @@ import { MatButtonModule } from "@angular/material/button"; import { AppConfigService } from "app-config.service"; import { MatDialogModule, MatDialogRef } from "@angular/material/dialog"; import { DatafilesActionsComponent } from "datasets/datafiles-actions/datafiles-actions.component"; +import { FileSizePipe } from "shared/pipes/filesize.pipe"; describe("DatafilesComponent", () => { let component: DatafilesComponent; @@ -100,6 +101,7 @@ describe("DatafilesComponent", () => { provide: DatafilesActionsComponent, useClass: MockDatafilesActionsComponent, }, + { provide: FileSizePipe }, ], }, }); @@ -140,7 +142,7 @@ describe("DatafilesComponent", () => { }, ]; component.tableData = component.files; - component.sourcefolder = "/test/"; + component.sourceFolder = "/test/"; fixture.detectChanges(); }); diff --git a/src/app/datasets/datafiles/datafiles.component.ts b/src/app/datasets/datafiles/datafiles.component.ts index ca016683a..c643ac84b 100644 --- a/src/app/datasets/datafiles/datafiles.component.ts +++ b/src/app/datasets/datafiles/datafiles.component.ts @@ -75,9 +75,9 @@ export class DatafilesComponent this.appConfig.fileserverButtonLabel || "Download"; multipleDownloadAction: string | null = this.appConfig.multipleDownloadAction; maxFileSize: number | null = this.appConfig.maxDirectDownloadSize; - sourceFolder: string | null = - this.appConfig.sourceFolder || "no source folder provided"; - sftpHost: string = this.appConfig.sftpHost || "no sftp host provided"; + sourceFolder: string = + this.appConfig.sourceFolder || "No source folder provided"; + sftpHost: string = this.appConfig.sftpHost || "No sftp host provided"; maxFileSizeWarning: string | null = this.appConfig.maxFileSizeWarning || `Some files are above the max size ${this.fileSizePipe.transform(this.maxFileSize)}`;