Skip to content
Merged
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
21 changes: 4 additions & 17 deletions src/app/datasets/admin-tab/admin-tab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,11 @@ export class AdminTabComponent implements OnInit, OnDestroy {
.subscribe((user) => {
if (user && this.dataset) {
const job = new Job();
job.emailJobInitiator = user.email;
job.jobParams = {};
job.jobParams["username"] = user.username;
job.creationTime = new Date();
job.createdBy = user.username;
job.createdAt = new Date();
job.type = "reset";
const fileObj: FileObject = {
pid: "",
files: [],
};
const fileList: string[] = [];
fileObj.pid = this.dataset["pid"];
if (this.dataset["datablocks"]) {
this.dataset["datablocks"].map((d) => {
fileList.push(d["archiveId"]);
});
}
fileObj.files = fileList;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this change with some site that used the files property.

job.datasetList = [fileObj];
job.jobParams = {};
job.jobParams["datasetIds"] = [this.dataset["pid"]];
console.log(job);
this.store.dispatch(submitJobAction({ job }));
}
Expand Down
22 changes: 7 additions & 15 deletions src/app/datasets/archiving.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ describe("ArchivingService", () => {
it("should create a new object of type Job", () => {
const user = new User({ username: "testName", email: "[email protected]" });
const datasets = [new Dataset()];
const datasetList = datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
}));
const datasetList = datasets.map((dataset) => dataset.pid);
const archive = true;
const destinationPath = { destinationPath: "/test/path/" };

Expand All @@ -63,9 +60,8 @@ describe("ArchivingService", () => {
);

expect(job).toBeInstanceOf(Job);
expect(job["emailJobInitiator"]).toEqual("[email protected]");
expect(job["jobParams"]["username"]).toEqual("testName");
expect(job["datasetList"]).toEqual(datasetList);
expect(job["createdBy"]).toEqual("testName");
expect(job["jobParams"]["datasetIds"]).toEqual(datasetList);
expect(job["type"]).toEqual("archive");
});
});
Expand All @@ -85,16 +81,12 @@ describe("ArchivingService", () => {

const user = new User({ username: "testName", email: "[email protected]" });
const datasets = [new Dataset()];
const datasetList = datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
}));
const datasetList = datasets.map((dataset) => dataset.pid);
const archive = true;
const job = new Job({
jobParams: { username: user.username },
emailJobInitiator: user.email,
creationTime: new Date(),
datasetList,
jobParams: { datasetIds: datasetList },
createdBy: user.username,
createdAt: new Date(),
type: "archive",
});
const createJobSpy = spyOn<any, string>(
Expand Down
8 changes: 2 additions & 6 deletions src/app/datasets/archiving.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ArchivingService {
): Job {
const extra = archive ? {} : destinationPath;
const jobParams = {
username: user.username,
datasetIds: datasets.map((dataset) => dataset.pid),
...extra,
};

Expand All @@ -37,12 +37,8 @@ export class ArchivingService {

const data = {
jobParams,
emailJobInitiator: user.email,
createdBy: user.username,
// Revise this, files == []...? See earlier version of this method in dataset-table component for context
datasetList: datasets.map((dataset) => ({
pid: dataset.pid,
files: [],
})),
type: archive ? "archive" : "retrieve",
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe("1000: DatafilesActionComponent", () => {
beforeEach(() => {
fixture = TestBed.createComponent(DatafilesActionComponent);
component = fixture.componentInstance;
component.files = structuredClone(actionFiles);
component.files = JSON.parse(JSON.stringify(actionFiles));
component.actionConfig = actionsConfig[0];
component.actionDataset = actionDataset;
component.maxFileSize = lowerMaxFileSizeLimit;
Expand Down Expand Up @@ -476,7 +476,7 @@ describe("1000: DatafilesActionComponent", () => {
component.maxFileSize = lowerMaxFileSizeLimit;
break;
}
component.files = structuredClone(actionFiles);
component.files = JSON.parse(JSON.stringify(actionFiles));
switch (selectedFiles) {
case selectedFilesType.file1:
component.files[0].selected = true;
Expand Down
13 changes: 5 additions & 8 deletions src/app/datasets/datafiles/datafiles.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,12 @@ export class DatafilesComponent
if (email) {
this.getSelectedFiles();
const data = {
emailJobInitiator: email,
creationTime: new Date(),
createdBy: email,
createdAt: new Date(),
type: "public",
datasetList: [
{
pid: this.datasetPid,
files: this.getSelectedFiles(),
},
],
jobParams: {
datasetIds: [this.datasetPid],
},
};
const job = new Job(data);
this.store.dispatch(submitJobAction({ job }));
Expand Down
25 changes: 8 additions & 17 deletions src/app/jobs/jobs-dashboard-new/jobs-dashboard-new.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Component,
OnDestroy,
} from "@angular/core";
import { Router } from "@angular/router";
import { SciCatDataSource } from "../../shared/services/scicat.datasource";
import { ScicatDataService } from "../../shared/services/scicat-data-service";
import { ExportExcelService } from "../../shared/services/export-excel.service";
Expand All @@ -30,11 +31,11 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked {
hideOrder: 0,
},
{
id: "emailJobInitiator",
label: "Initiator",
id: "createdBy",
label: "Creator",
icon: "person",
canSort: true,
matchMode: "contains",
matchMode: "is",
hideOrder: 1,
},
{
Expand All @@ -46,7 +47,7 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked {
hideOrder: 2,
},
{
id: "creationTime",
id: "createdAt",
icon: "schedule",
label: "Created at local time",
format: "date medium ",
Expand All @@ -64,22 +65,13 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked {
hideOrder: 4,
},
{
id: "jobStatusMessage",
id: "statusCode",
icon: "traffic",
label: "Status",
format: "json",
canSort: true,
matchMode: "contains",
hideOrder: 5,
},
{
id: "datasetList",
icon: "list",
label: "Datasets",
format: "json",
canSort: true,
hideOrder: 6,
},
{
id: "jobResultObject",
icon: "work_outline",
Expand All @@ -102,6 +94,7 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked {
private cdRef: ChangeDetectorRef,
private dataService: ScicatDataService,
private exportService: ExportExcelService,
private router: Router,
) {
this.dataSource = new SciCatDataSource(
this.appConfigService,
Expand All @@ -120,9 +113,7 @@ export class JobsDashboardNewComponent implements OnDestroy, AfterViewChecked {
}

onRowClick(job: Job) {
// currently deactivated, no extra data available
/* console.log("Row clicked:", job);
const id = encodeURIComponent(job.id);
this.router.navigateByUrl("/user/jobs/" + id); */
this.router.navigateByUrl("/user/jobs/" + id);
}
}
4 changes: 2 additions & 2 deletions src/app/jobs/jobs-dashboard/jobs-dashboard.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe("JobsDashboardComponent", () => {
dispatchSpy = spyOn(store, "dispatch");

const mode = JobViewMode.myJobs;
component.email = "[email protected]";
const viewMode = { emailJobInitiator: component.email };
component.username = "testName";
const viewMode = { createdBy: component.username };
component.onModeChange(mode);

expect(dispatchSpy).toHaveBeenCalledTimes(1);
Expand Down
21 changes: 9 additions & 12 deletions src/app/jobs/jobs-dashboard/jobs-dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class JobsDashboardComponent implements OnInit, OnDestroy {

jobs: JobsTableData[] = [];
profile: any;
email = "";
username = "";

subscriptions: Subscription[] = [];

Expand Down Expand Up @@ -96,13 +96,10 @@ export class JobsDashboardComponent implements OnInit, OnDestroy {
if (jobs) {
tableData = jobs.map((job) => ({
id: job.id,
initiator: job.emailJobInitiator,
initiator: job.createdBy,
type: job.type,
createdAt: this.datePipe.transform(
job.creationTime,
"yyyy-MM-dd HH:mm",
),
statusMessage: job.jobStatusMessage,
createdAt: this.datePipe.transform(job.createdAt, "yyyy-MM-dd HH:mm"),
statusMessage: job.statusMessage,
}));
}
return tableData;
Expand All @@ -129,7 +126,7 @@ export class JobsDashboardComponent implements OnInit, OnDestroy {
break;
}
case JobViewMode.myJobs: {
viewMode = { emailJobInitiator: this.email };
viewMode = { createdBy: this.username };
break;
}
default: {
Expand All @@ -154,11 +151,11 @@ export class JobsDashboardComponent implements OnInit, OnDestroy {
// map column names back to original names
switch (event.active) {
case "statusMessage": {
event.active = "jobStatusMessage";
event.active = "statusMessage";
break;
}
case "initiator": {
event.active = "emailJobInitiator";
event.active = "createdBy";
break;
}
default: {
Expand All @@ -181,13 +178,13 @@ export class JobsDashboardComponent implements OnInit, OnDestroy {
this.subscriptions.push(
this.store.select(selectCurrentUser).subscribe((current) => {
if (current) {
this.email = current.email;
this.username = current.username;

if (!current.realm) {
this.store.select(selectProfile).subscribe((profile) => {
if (profile) {
this.profile = profile;
this.email = profile.email;
this.username = profile.username;
}
this.onModeChange(JobViewMode.myJobs);
});
Expand Down
Loading