From 3b552e38b263cff042578ee866063dc19c1c3ea7 Mon Sep 17 00:00:00 2001 From: Sonja Galovic Date: Wed, 25 May 2022 00:33:30 +0200 Subject: Opcije Update i Save As za experiment. Napravljena dijalog komponenta. --- .../update-experiment-dialog.component.css | 21 +++++++ .../update-experiment-dialog.component.html | 24 ++++++++ .../update-experiment-dialog.component.spec.ts | 25 ++++++++ .../update-experiment-dialog.component.ts | 68 ++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.css create mode 100644 frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.html create mode 100644 frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.spec.ts create mode 100644 frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.ts (limited to 'frontend/src/app/_modals') diff --git a/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.css b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.css new file mode 100644 index 00000000..551a4e21 --- /dev/null +++ b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.css @@ -0,0 +1,21 @@ +#btnYes { + background-color: var(--offwhite); + color: var(--ns-bg-dark-100); +} + +#btnNo { + color: gray; +} + +.wrongInput { + color: var(--ns-warn); + font-size: 11px; +} + +::ng-deep.mat-dialog-content { + overflow: visible; +} + +.hidden-class { + opacity: 0; +} \ No newline at end of file diff --git a/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.html b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.html new file mode 100644 index 00000000..db44dfe1 --- /dev/null +++ b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.html @@ -0,0 +1,24 @@ +

Sačuvaj izmene

+
+
+ + + Izmeni postojeći eksperiment + + Sačuvaj kao novi eksperiment + +
+ + + +
+
+

Eskperiment sa unetim nazivom već postoji u kolekciji.
Izaberite drugi naziv.

+

Unesite naziv eksperimenta.

+
+
+
+
+ + +
\ No newline at end of file diff --git a/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.spec.ts b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.spec.ts new file mode 100644 index 00000000..e0f26b2c --- /dev/null +++ b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { UpdateExperimentDialogComponent } from './update-experiment-dialog.component'; + +describe('UpdateExperimentDialogComponent', () => { + let component: UpdateExperimentDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ UpdateExperimentDialogComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(UpdateExperimentDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.ts b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.ts new file mode 100644 index 00000000..068aa2ef --- /dev/null +++ b/frontend/src/app/_modals/update-experiment-dialog/update-experiment-dialog.component.ts @@ -0,0 +1,68 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import Experiment from 'src/app/_data/Experiment'; +import { ExperimentsService } from 'src/app/_services/experiments.service'; + +interface DialogData { + experiment: Experiment; + selectedOption: number; +} + +@Component({ + selector: 'app-update-experiment-dialog', + templateUrl: './update-experiment-dialog.component.html', + styleUrls: ['./update-experiment-dialog.component.css'] +}) +export class UpdateExperimentDialogComponent implements OnInit { + + selectedOption: number = 1; + selectedName: string = ''; + wrongAlreadyExists: boolean = false; + wrongEmptyName: boolean = false; + + constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: DialogData, private experimentService: ExperimentsService) { + this.wrongAlreadyExists = false; + this.wrongEmptyName = false; + } + + ngOnInit(): void { + } + + onNoClick() { + this.dialogRef.close(); + } + + saveWithEnterKey(keyboardEvent: KeyboardEvent) { + if (keyboardEvent.code == "Enter" || keyboardEvent.code == "NumpadEnter") + this.onYesClick(); + } + + onYesClick() { + if (this.selectedOption == 1) { //update + this.experimentService.updateExperiment(this.data.experiment).subscribe((response) => { + this.data.experiment = response; + this.dialogRef.close(this.data.experiment); + }); + } + else { //save new + if (this.selectedName == "") { + this.wrongEmptyName = true; + return; + } + this.wrongEmptyName = false; + + const newExperiment = new Experiment(); + Object.assign(newExperiment, this.data.experiment); + newExperiment.name = this.selectedName; + newExperiment._id = ''; + this.experimentService.addExperiment(newExperiment!).subscribe((response) => { + this.wrongAlreadyExists = false; + this.dialogRef.close(response); + }, (error) => { + if (error.error == "Experiment with this name exists") { + this.wrongAlreadyExists = true; + } + }); + } + } +} -- cgit v1.2.3 From 09a33e72501affb6d07507e396151f02d16daf9a Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Mon, 6 Jun 2022 02:45:47 +0200 Subject: Dodao deljenje datasetova i modela, dialog za podesavanje opcija za deljenje (isPublic accessibleByLink), sa mogucnoscu kopiranja linka za deljenje. Dodao stranice za prikaz javnih datasetova / modela. --- backend/api/api/Controllers/DatasetController.cs | 32 ++++++++++ backend/api/api/Controllers/ModelController.cs | 32 ++++++++++ backend/api/api/Interfaces/IDatasetService.cs | 3 + backend/api/api/Interfaces/IModelService.cs | 3 + backend/api/api/Services/DatasetService.cs | 20 +++++- backend/api/api/Services/ModelService.cs | 16 +++++ docs/SpecifikacijaDizajnaSoftvera.docx | Bin 0 -> 5793452 bytes .../_charts/line-chart/line-chart.component.css | 3 +- .../_charts/line-chart/line-chart.component.html | 10 ++- .../src/app/_elements/folder/folder.component.html | 10 ++- .../src/app/_elements/folder/folder.component.ts | 36 ++++++++++- .../form-dataset/form-dataset.component.html | 8 +-- .../form-dataset/form-dataset.component.ts | 1 + .../_elements/form-model/form-model.component.ts | 2 + .../share-dialog/share-dialog.component.css | 0 .../share-dialog/share-dialog.component.html | 14 +++++ .../share-dialog/share-dialog.component.spec.ts | 25 ++++++++ .../_modals/share-dialog/share-dialog.component.ts | 70 +++++++++++++++++++++ .../_pages/page-dataset/page-dataset.component.css | 0 .../page-dataset/page-dataset.component.html | 4 ++ .../page-dataset/page-dataset.component.spec.ts | 25 ++++++++ .../_pages/page-dataset/page-dataset.component.ts | 45 +++++++++++++ .../app/_pages/page-model/page-model.component.css | 0 .../_pages/page-model/page-model.component.html | 4 ++ .../_pages/page-model/page-model.component.spec.ts | 25 ++++++++ .../app/_pages/page-model/page-model.component.ts | 41 ++++++++++++ frontend/src/app/_services/datasets.service.ts | 8 +++ frontend/src/app/_services/models.service.ts | 8 +++ frontend/src/app/app-routing.module.ts | 4 ++ frontend/src/app/app.module.ts | 8 ++- frontend/src/styles/layout.css | 12 +++- 31 files changed, 449 insertions(+), 20 deletions(-) create mode 100644 docs/SpecifikacijaDizajnaSoftvera.docx create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.css create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.html create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.spec.ts create mode 100644 frontend/src/app/_modals/share-dialog/share-dialog.component.ts create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.css create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.html create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.spec.ts create mode 100644 frontend/src/app/_pages/page-dataset/page-dataset.component.ts create mode 100644 frontend/src/app/_pages/page-model/page-model.component.css create mode 100644 frontend/src/app/_pages/page-model/page-model.component.html create mode 100644 frontend/src/app/_pages/page-model/page-model.component.spec.ts create mode 100644 frontend/src/app/_pages/page-model/page-model.component.ts (limited to 'frontend/src/app/_modals') diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs index c93ac9db..9a3c3d86 100644 --- a/backend/api/api/Controllers/DatasetController.cs +++ b/backend/api/api/Controllers/DatasetController.cs @@ -282,5 +282,37 @@ namespace api.Controllers return Ok($"Dataset with ID = {id} deleted"); } + + [HttpPut("UpdateAccessibleByLink/{datasetId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateAccessibleByLink(string datasetId, [FromBody] bool accessibleByLink) + { + string uploaderId = getUserId(); + + Dataset dataset = _datasetService.GetOneDataset(datasetId); + + if (uploaderId != dataset.uploaderId) + return Unauthorized(); + + _datasetService.UpdateAccessibleByLink(datasetId, accessibleByLink); + + return Ok(dataset.accessibleByLink); + } + + [HttpPut("UpdateIsPublic/{datasetId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateIsPublic(string datasetId, [FromBody] bool isPublic) + { + string uploaderId = getUserId(); + + Dataset dataset = _datasetService.GetOneDataset(datasetId); + + if (uploaderId != dataset.uploaderId) + return Unauthorized(); + + _datasetService.UpdateIsPublic(datasetId, isPublic); + + return Ok(dataset.isPublic); + } } } \ No newline at end of file diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index c574de28..c7dfe89c 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -312,6 +312,38 @@ namespace api.Controllers } + [HttpPut("UpdateAccessibleByLink/{modelId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateAccessibleByLink(string modelId, [FromBody] bool accessibleByLink) + { + string uploaderId = getUserId(); + + Model model = _modelService.GetOneModel(modelId); + + if (uploaderId != model.uploaderId) + return Unauthorized(); + + _modelService.UpdateAccessibleByLink(modelId, accessibleByLink); + + return Ok(model.accessibleByLink); + } + + [HttpPut("UpdateIsPublic/{modelId}")] + [Authorize(Roles = "User")] + public ActionResult UpdateIsPublic(string modelId, [FromBody] bool isPublic) + { + string uploaderId = getUserId(); + + Model model = _modelService.GetOneModel(modelId); + + if (uploaderId != model.uploaderId) + return Unauthorized(); + + _modelService.UpdateIsPublic(modelId, isPublic); + + return Ok(model.isPublic); + } + } public class TrainModelObject diff --git a/backend/api/api/Interfaces/IDatasetService.cs b/backend/api/api/Interfaces/IDatasetService.cs index 2f7d0010..5a91c82b 100644 --- a/backend/api/api/Interfaces/IDatasetService.cs +++ b/backend/api/api/Interfaces/IDatasetService.cs @@ -19,5 +19,8 @@ namespace api.Services public void Update(Dataset dataset); string GetDatasetId(string fileId); //bool CheckDb(); + + public void UpdateAccessibleByLink(string datasetId, bool accessibleByLink); + public void UpdateIsPublic(string datasetId, bool isPublic); } } diff --git a/backend/api/api/Interfaces/IModelService.cs b/backend/api/api/Interfaces/IModelService.cs index 41cd279c..949c7278 100644 --- a/backend/api/api/Interfaces/IModelService.cs +++ b/backend/api/api/Interfaces/IModelService.cs @@ -19,6 +19,9 @@ namespace api.Services void Delete(string userId, string name); bool CheckHyperparameters(int inputNeurons, int hiddenLayerNeurons, int hiddenLayers, int outputNeurons); bool CheckDb(); + + public void UpdateAccessibleByLink(string modelId, bool accessibleByLink); + public void UpdateIsPublic(string modelId, bool isPublic); } } diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs index 0b84721e..cd27f275 100644 --- a/backend/api/api/Services/DatasetService.cs +++ b/backend/api/api/Services/DatasetService.cs @@ -75,7 +75,7 @@ namespace api.Services public Dataset GetOneDataset(string userId, string id) { - return _dataset.Find(dataset => dataset.uploaderId == userId && dataset._id == id && dataset.isPreProcess).FirstOrDefault(); + return _dataset.Find(dataset => (dataset.uploaderId == userId || dataset.isPublic || dataset.accessibleByLink) && dataset._id == id && dataset.isPreProcess).FirstOrDefault(); } public Dataset GetOneDatasetN(string userId, string name) { @@ -104,6 +104,22 @@ namespace api.Services return dataset._id; } - + + public void UpdateAccessibleByLink(string datasetId, bool accessibleByLink) + { + Dataset dataset = _dataset.Find(dataset => dataset._id == datasetId).FirstOrDefault(); + dataset.accessibleByLink = accessibleByLink; + + _dataset.ReplaceOne(dataset => dataset._id == datasetId, dataset); + } + + public void UpdateIsPublic(string datasetId, bool isPublic) + { + Dataset dataset = _dataset.Find(dataset => dataset._id == datasetId).FirstOrDefault(); + dataset.isPublic = isPublic; + + _dataset.ReplaceOne(dataset => dataset._id == datasetId, dataset); + } + } } diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs index 71db6340..1c690ca7 100644 --- a/backend/api/api/Services/ModelService.cs +++ b/backend/api/api/Services/ModelService.cs @@ -106,5 +106,21 @@ namespace api.Services return true; } + + public void UpdateAccessibleByLink(string modelId, bool accessibleByLink) + { + Model model = _model.Find(model => model._id == modelId).FirstOrDefault(); + model.accessibleByLink = accessibleByLink; + + _model.ReplaceOne(model => model._id == modelId, model); + } + + public void UpdateIsPublic(string modelId, bool isPublic) + { + Model model = _model.Find(model => model._id == modelId).FirstOrDefault(); + model.isPublic = isPublic; + + _model.ReplaceOne(model => model._id == modelId, model); + } } } diff --git a/docs/SpecifikacijaDizajnaSoftvera.docx b/docs/SpecifikacijaDizajnaSoftvera.docx new file mode 100644 index 00000000..dfc5345b Binary files /dev/null and b/docs/SpecifikacijaDizajnaSoftvera.docx differ diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css index 862a86e1..60b341d0 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.css @@ -22,7 +22,8 @@ canvas { } .hide { - display: none; + display: none !important; + background-color: red; } .dl-button { diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html index cc1c0121..505dd50b 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.html @@ -1,5 +1,5 @@
-
+
@@ -9,18 +9,16 @@
-
-
+
+
-
+
- -

Model treniran za konfiguraciju: {{modelName}}Model se trenira za konfiguraciju: {{modelName}}

+ @@ -122,12 +125,15 @@
- - +