Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b6cc7fe
replaced some old tables with dynamic-mat-table and removed column icons
abdimo101 Apr 22, 2026
0e53d5d
Merge branch 'master' into replace-old-tables-with-dynamic-mat-table
abdimo101 Apr 27, 2026
961274c
sourcery changes
abdimo101 Apr 27, 2026
669c7e5
test fix: added provider for HttpClient
abdimo101 Apr 27, 2026
fa9e3a2
eslint fix
abdimo101 Apr 27, 2026
b16bc40
test: removed unneeded config options
abdimo101 Apr 27, 2026
e002fbd
added actionMenu for datafiles table
abdimo101 May 11, 2026
832a970
synced related datasets table with user column settings
abdimo101 May 11, 2026
0b41cfd
fixed tests
abdimo101 May 11, 2026
17936d2
added pipe for test
abdimo101 May 11, 2026
a53e166
sample dashboard table now covers the white space horizontally
abdimo101 May 11, 2026
063d240
replaced some old tables with dynamic-mat-table and removed column icons
abdimo101 Apr 22, 2026
638bd7c
sourcery changes
abdimo101 Apr 27, 2026
e0636d4
test fix: added provider for HttpClient
abdimo101 Apr 27, 2026
36afc8b
eslint fix
abdimo101 Apr 27, 2026
a23182b
test: removed unneeded config options
abdimo101 Apr 27, 2026
7245b79
added actionMenu for datafiles table
abdimo101 May 11, 2026
9fa42fb
synced related datasets table with user column settings
abdimo101 May 11, 2026
db46373
fixed tests
abdimo101 May 11, 2026
dc7951d
added pipe for test
abdimo101 May 11, 2026
7bd8e58
sample dashboard table now covers the white space horizontally
abdimo101 May 11, 2026
524d5e9
remove display:flow-root and fix root cause
Junjiequan May 22, 2026
72428ea
Merge branch 'replace-old-tables-with-dynamic-mat-table' of github.co…
abdimo101 Jun 3, 2026
e78ad71
addressed requested changes and changed the pagination for datafiles …
abdimo101 Jun 10, 2026
6830ba4
fixed unit tests
abdimo101 Jun 10, 2026
a07fdcc
fixed cypress test
abdimo101 Jun 10, 2026
d2cd3b9
Merge branch 'master' into replace-old-tables-with-dynamic-mat-table
abdimo101 Jun 10, 2026
9f36a1e
fixed cypress test x2
abdimo101 Jun 10, 2026
557c0bf
Merge branch 'replace-old-tables-with-dynamic-mat-table' of github.co…
abdimo101 Jun 10, 2026
986d10f
Merge branch 'master' into replace-old-tables-with-dynamic-mat-table
abdimo101 Jun 17, 2026
90f3512
eslint fix
abdimo101 Jun 17, 2026
14f0469
removed fixed height of sample table
abdimo101 Jun 24, 2026
6fc1513
Merge branch 'master' into replace-old-tables-with-dynamic-mat-table
abdimo101 Jun 29, 2026
97f5533
added effect, actions and reducer for origdatablockcount, also added …
abdimo101 Jun 29, 2026
867fbd8
eslint & unit test fix
abdimo101 Jun 29, 2026
2f1f475
added loading spinner for datafiles & related datasets tables
abdimo101 Jun 29, 2026
66ca1b9
unit test fix
abdimo101 Jun 29, 2026
2cfb37e
Merge branch 'master' into replace-old-tables-with-dynamic-mat-table
Junjiequan Jul 9, 2026
b8a2d39
fix: related datasets show same item on different pages
Junjiequan Jul 9, 2026
997095d
fix pagination infinite count loading icon for related datasets and s…
Junjiequan Jul 9, 2026
3a1360d
lint fix
Junjiequan Jul 9, 2026
93beb10
check user.id instead of user to prevent empty object matc
Junjiequan Jul 9, 2026
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
24 changes: 12 additions & 12 deletions src/app/datasets/datafiles/datafiles.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
</ng-template>

<ng-template [ngIf]="tableData && maxFileSize">
<ng-template [ngIf]="files.length > 0 && maxFileSize">
<div class="selected" fxLayout="row" fxLayoutAlign="space-evenly end">
<div fxFlex="auto" style="margin-bottom: 0.5em">
Selected: {{ selectedFileSize | filesize
Expand All @@ -38,17 +38,17 @@ <h3>No files associated to this dataset</h3>
></configurable-actions>
</div>

<app-table
[data]="tableData"
<dynamic-mat-table
[columns]="tableColumns"
[paginate]="true"
[currentPage]="currentPage"
[dataCount]="count"
[dataPerPage]="pageSize"
(pageChange)="onPageChange($event)"
[select]="fileDownloadEnabled"
(selectAll)="onSelectAll($event)"
(selectOne)="onSelectOne($event)"
[dataSource]="dataSource"
[setting]="setting"
[pagination]="pagination"
[pagingMode]="paginationMode"
[showGlobalTextSearch]="false"
[rowSelectionMode]="rowSelectionMode"
[emptyMessage]="'No datafiles available'"
(onRowEvent)="onRowEvent($event)"
(paginationChange)="onPaginationChange($event)"
>
</app-table>
</dynamic-mat-table>
</ng-template>
2 changes: 1 addition & 1 deletion src/app/datasets/datafiles/datafiles.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mat-icon {

.datafiles-header {
margin-top: 1em;
height: 40px;
min-height: 40px;

.nbr-of-files {
font-size: larger;
Expand Down
199 changes: 52 additions & 147 deletions src/app/datasets/datafiles/datafiles.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { MatTableModule } from "@angular/material/table";
import { PipesModule } from "shared/pipes/pipes.module";
import { RouterModule } from "@angular/router";
import { StoreModule } from "@ngrx/store";
import { CheckboxEvent } from "shared/modules/table/table.component";
import {
MockAuthService,
MockDatafilesActionsComponent,
MockMatDialogRef,
MockUserApi,
} from "shared/MockStubs";
import { MatCheckboxChange } from "@angular/material/checkbox";
import { MatIconModule } from "@angular/material/icon";
import { MatButtonModule } from "@angular/material/button";
import { AppConfigService } from "app-config.service";
Expand All @@ -22,6 +20,7 @@ import { ConfigurableActionsComponent } from "shared/modules/configurable-action
import { UsersService } from "@scicatproject/scicat-sdk-ts-angular";
import { AuthService } from "shared/services/auth/auth.service";
import { FileSizePipe } from "shared/pipes/filesize.pipe";
import { RowEventType } from "shared/modules/dynamic-material-table/models/table-row.model";

describe("DatafilesComponent", () => {
let component: DatafilesComponent;
Expand Down Expand Up @@ -92,6 +91,7 @@ describe("DatafilesComponent", () => {
],
declarations: [DatafilesComponent],
});

TestBed.overrideComponent(DatafilesComponent, {
set: {
providers: [
Expand All @@ -107,20 +107,14 @@ describe("DatafilesComponent", () => {
],
},
});

TestBed.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DatafilesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

afterEach(() => {
fixture.destroy();
});

beforeEach(() => {
component.files = [
{
path: "test1",
Expand All @@ -145,182 +139,93 @@ describe("DatafilesComponent", () => {
hash: "",
},
];
component.tableData = component.files;

component.sourceFolder = "/test/";
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});

describe("#getAreAllSelected()", () => {
it("should return 'false' if no file is selected", () => {
const areAllSelected = component.getAreAllSelected();

expect(areAllSelected).toEqual(false);
});

it("should return 'false' if only some files are selected", () => {
component.tableData[0].selected = true;
const areAllSelected = component.getAreAllSelected();

expect(areAllSelected).toEqual(false);
});

it("should return 'true' if all files are selected", () => {
component.tableData.forEach((file) => {
file.selected = true;
});
const areAllSelected = component.getAreAllSelected();

expect(areAllSelected).toEqual(true);
});
afterEach(() => {
fixture.destroy();
});

describe("#getIsNoneSelected()", () => {
it("should return 'true' if no file is selected", () => {
const isNoneSelected = component.getIsNoneSelected();

expect(isNoneSelected).toEqual(true);
});

it("should return 'false' if some files are selected", () => {
component.tableData[0].selected = true;
const isNoneSelected = component.getIsNoneSelected();

expect(isNoneSelected).toEqual(false);
});

it("should return 'false' if all files are selected", () => {
component.tableData.forEach((file) => {
file.selected = true;
});
const isNoneSelected = component.getIsNoneSelected();

expect(isNoneSelected).toEqual(false);
});
it("should create", () => {
expect(component).toBeTruthy();
});

describe("#getAllFiles()", () => {
it("should return an array of file paths of files in table", () => {
it("should return an array of file paths from files", () => {
const files = component.getAllFiles();

expect(Array.isArray(files)).toEqual(true);
expect(files.includes("test1")).toEqual(true);
expect(files.includes("test2")).toEqual(true);
expect(files).toEqual(["test1", "test2"]);
});
});

describe("#getSelectedFiles()", () => {
it("should return an array of file paths from selected files in table", () => {
component.tableData[0].selected = true;
it("should return selected file paths", () => {
component.files[0].selected = true;

const files = component.getSelectedFiles();

expect(Array.isArray(files)).toEqual(true);
expect(files.includes("test1")).toEqual(true);
expect(files).toEqual(["test1"]);
});
});

describe("#updateSelectionStatus()", () => {
it("should set 'areAllSelected' to false and 'isNoneSelected' to true if no file is selected", () => {
component.updateSelectionStatus();

expect(component.areAllSelected).toEqual(false);
expect(component.isNoneSelected).toEqual(true);
});

it("should set both 'areAllSelected' and 'isNoneSelected' to false if some files are selected", () => {
component.tableData[0].selected = true;
component.updateSelectionStatus();

expect(component.areAllSelected).toEqual(false);
expect(component.isNoneSelected).toEqual(false);
});
describe("#onRowEvent()", () => {
it("should select one row and update selectedFileSize", () => {
const row = component.files[0];

it("should set 'areAllSelected' to true and 'isNoneSelected' to false if all files are selected", () => {
component.tableData.forEach((file) => {
file.selected = true;
});
component.updateSelectionStatus();
component.onRowEvent({
event: RowEventType.RowSelectionChange,
sender: { row, checked: true },
} as any);

expect(component.areAllSelected).toEqual(true);
expect(component.isNoneSelected).toEqual(false);
expect(component.files[0].selected).toEqual(true);
expect(component.selectedFileSize).toEqual(5000);
});
});

describe("#onSelectOne()", () => {
it("should set 'selected' to true and add the size of the file to 'selectedFileSize'", () => {
const file = component.tableData[0];
const event = new MatCheckboxChange();
event.checked = true;
const checkboxEvent: CheckboxEvent = { event, row: file };
component.onSelectOne(checkboxEvent);
it("should unselect one row and update selectedFileSize", () => {
const row = component.files[0];
row.selected = true;
component.selectedFileSize = 5000;

expect(component.tableData[0].selected).toEqual(true);
expect(component.selectedFileSize).toEqual(file.size);
});
component.onRowEvent({
event: RowEventType.RowSelectionChange,
sender: { row, checked: false },
} as any);

it("should set 'selected' of the provided file to false and subtract the size of the file from 'selectedFileSize'", () => {
const firstFile = component.tableData[0];
const event = new MatCheckboxChange();
event.checked = true;
const firstCheckboxEvent: CheckboxEvent = { event, row: firstFile };
component.onSelectOne(firstCheckboxEvent);

expect(component.tableData[0].selected).toEqual(true);
expect(component.selectedFileSize).toEqual(firstFile.size);

const event2 = new MatCheckboxChange();
event2.checked = false;
const secondCheckboxEvent: CheckboxEvent = {
event: event2,
row: firstFile,
};
component.onSelectOne(secondCheckboxEvent);

expect(component.tableData[0].selected).toEqual(false);
expect(component.files[0].selected).toEqual(false);
expect(component.selectedFileSize).toEqual(0);
});
});

describe("#onSelectAll()", () => {
it("should set 'selected' of all files to true if previously set to false and add the size of the files to 'selectedFileSize'", () => {
const event = {
checked: true,
} as MatCheckboxChange;
component.onSelectAll(event);
it("should apply master selection from selectionModel", () => {
const selectionModel = {
isSelected: (file) => file.path === "test1",
};

component.tableData.forEach((file) => {
expect(file.selected).toEqual(true);
});
component.onRowEvent({
event: RowEventType.MasterSelectionChange,
sender: { selectionModel },
} as any);

expect(component.selectedFileSize).toEqual(15000);
expect(component.files[0].selected).toEqual(true);
expect(component.files[1].selected).toEqual(false);
expect(component.selectedFileSize).toEqual(5000);
});

it("should set 'selected' of all files to false and subtract the size of the files from 'selectedFileSize'", () => {
const firstEvent = {
checked: true,
} as MatCheckboxChange;
component.onSelectAll(firstEvent);
it("should select all rows in master selection", () => {
const selectionModel = {
isSelected: () => true,
};

component.tableData.forEach((file) => {
expect(file.selected).toEqual(true);
});
component.onRowEvent({
event: RowEventType.MasterSelectionChange,
sender: { selectionModel },
} as any);

expect(component.files[0].selected).toEqual(true);
expect(component.files[1].selected).toEqual(true);
expect(component.selectedFileSize).toEqual(15000);

const secondEvent = {
checked: false,
} as MatCheckboxChange;
component.onSelectAll(secondEvent);

component.tableData.forEach((file) => {
expect(file.selected).toEqual(false);
});

expect(component.selectedFileSize).toEqual(0);
});
});

Expand Down
Loading
Loading