diff --git a/backend/packages/Upgrade/src/api/controllers/ExperimentController.ts b/backend/packages/Upgrade/src/api/controllers/ExperimentController.ts
index abff21948f..e2f42b15da 100644
--- a/backend/packages/Upgrade/src/api/controllers/ExperimentController.ts
+++ b/backend/packages/Upgrade/src/api/controllers/ExperimentController.ts
@@ -1146,21 +1146,44 @@ export class ExperimentController {
/**
* @swagger
* /experiments/{validation}:
- * put:
+ * post:
* description: Validating Experiment
* consumes:
* - application/json
* parameters:
- * - in: path
+ * - in: body
+ * name: experiments
+ * required: true
+ * schema:
+ * type: array
+ * items:
+ * type: object
+ * properties:
+ * fileName:
+ * type: string
+ * fileContent:
+ * type: string
+ * description: Experiment Files
* tags:
* - Experiments
* produces:
* - application/json
* responses:
* '200':
- * description: Validations are done
+ * description: Validations are completed
+ * schema:
+ * type: array
+ * items:
+ * type: object
+ * properties:
+ * fileName:
+ * type: string
+ * error:
+ * type: string
* '401':
* description: AuthorizationRequiredError
+ * '500':
+ * description: Internal Server Error
*/
@Post('/validation')
public validateExperiment(
@@ -1173,12 +1196,24 @@ export class ExperimentController {
/**
* @swagger
* /experiments/{import}:
- * put:
+ * post:
* description: Import New Experiment
* consumes:
* - application/json
* parameters:
- * - in: path
+ * - in: body
+ * name: experiments
+ * required: true
+ * schema:
+ * type: array
+ * items:
+ * type: object
+ * properties:
+ * fileName:
+ * type: string
+ * fileContent:
+ * type: string
+ * description: Experiment Files
* tags:
* - Experiments
* produces:
@@ -1186,8 +1221,19 @@ export class ExperimentController {
* responses:
* '200':
* description: Experiment is imported
+ * schema:
+ * type: array
+ * items:
+ * type: object
+ * properties:
+ * fileName:
+ * type: string
+ * error:
+ * type: string
* '401':
* description: AuthorizationRequiredError
+ * '500':
+ * description: Internal Server Error
*/
@Post('/import')
public importExperiment(
diff --git a/frontend/projects/upgrade/src/app/features/dashboard/home/components/modal/import-experiment/import-experiment.component.ts b/frontend/projects/upgrade/src/app/features/dashboard/home/components/modal/import-experiment/import-experiment.component.ts
index 5eea1bc57d..93d684fbe0 100644
--- a/frontend/projects/upgrade/src/app/features/dashboard/home/components/modal/import-experiment/import-experiment.component.ts
+++ b/frontend/projects/upgrade/src/app/features/dashboard/home/components/modal/import-experiment/import-experiment.component.ts
@@ -48,13 +48,12 @@ export class ImportExperimentComponent implements OnInit {
}
async importExperiment() {
+ this.onCancelClick();
const importResult = (await this.dataService
.importExperiment(this.allExperiments)
.toPromise()) as ValidateExperimentError[];
//this.experimentService.importExperiment(this.allExperiments);
this.showNotification(importResult);
- this.onCancelClick();
-
this.experimentService.loadExperiments(true);
}
@@ -86,8 +85,6 @@ export class ImportExperimentComponent implements OnInit {
}
async uploadFile(event) {
- const index = 0;
- const reader = new FileReader();
this.uploadedFileCount = event.target.files.length;
this.importFileErrors = [];
this.allExperiments = [];
@@ -97,25 +94,22 @@ export class ImportExperimentComponent implements OnInit {
// Set loading to true before processing the files
this.isLoadingExperiments$ = true;
- const readFile = (fileIndex) => {
- if (fileIndex >= event.target.files.length) {
- // Check if this is the last file
- if (fileIndex >= this.uploadedFileCount) {
- this.checkValidation();
- this.isLoadingExperiments$ = false;
- }
- return;
- }
- const file = event.target.files[fileIndex];
- const fileName = file.name;
- reader.onload = (e) => {
- const fileContent = e.target.result;
- this.allExperiments.push({ fileName: fileName, fileContent: fileContent });
- readFile(fileIndex + 1);
- };
- reader.readAsText(file);
- };
-
- readFile(index);
+ const filesArray = Array.from(event.target.files) as any[];
+ await Promise.all(
+ filesArray.map((file) => {
+ return new Promise