aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/training/training.component.ts
diff options
context:
space:
mode:
authorDanijel Anđelković <adanijel99@gmail.com>2022-04-19 21:44:08 +0200
committerDanijel Anđelković <adanijel99@gmail.com>2022-04-19 21:45:03 +0200
commit32d776709f2b5df14dbcfd3f610306a899959851 (patch)
treec3f90bd8efe0ffe8895cae52e3787851f527dab2 /frontend/src/app/training/training.component.ts
parent2c68a5c7926bfb62902ef9ad4b705d675c2293f7 (diff)
Dodao event kada se korisnik uloguje tako da komponente koje treba da osveze vrednost mogu da osveze svoje vrednosti tako sto se prijave na taj event.
Diffstat (limited to 'frontend/src/app/training/training.component.ts')
-rw-r--r--frontend/src/app/training/training.component.ts35
1 files changed, 27 insertions, 8 deletions
diff --git a/frontend/src/app/training/training.component.ts b/frontend/src/app/training/training.component.ts
index c82a6b79..1b85b947 100644
--- a/frontend/src/app/training/training.component.ts
+++ b/frontend/src/app/training/training.component.ts
@@ -4,15 +4,17 @@ import Shared from '../Shared';
import Experiment from '../_data/Experiment';
import Model, { ProblemType } from '../_data/Model';
import { ModelLoadComponent } from '../_elements/model-load/model-load.component';
+import { AuthService } from '../_services/auth.service';
import { ExperimentsService } from '../_services/experiments.service';
import { ModelsService } from '../_services/models.service';
+import { SignalRService } from '../_services/signal-r.service';
@Component({
selector: 'app-training',
templateUrl: './training.component.html',
styleUrls: ['./training.component.css']
})
-export class TrainingComponent implements OnInit{
+export class TrainingComponent implements OnInit {
@ViewChild(ModelLoadComponent) modelLoadComponent?: ModelLoadComponent;
@@ -24,22 +26,39 @@ export class TrainingComponent implements OnInit{
term: string = "";
- constructor(private modelsService: ModelsService, private route: ActivatedRoute, private experimentsService: ExperimentsService) {
+ constructor(private modelsService: ModelsService, private route: ActivatedRoute, private experimentsService: ExperimentsService, private authService: AuthService, private signalRService: SignalRService) {
+ if (this.signalRService.hubConnection) {
+ this.signalRService.hubConnection.on("NotifyEpoch", (mName: string, mId: string, stat: string, totalEpochs: number, currentEpoch: number) => {
+ if (this.selectedModel?._id == mId) {
+ this.trainingResult = stat;
+ }
+ });
+ }
}
- ngOnInit(): void {
+ ngOnInit(): void {
this.route.queryParams.subscribe(params => {
- let experimentId =this.route.snapshot.paramMap.get("id");
+ let experimentId = this.route.snapshot.paramMap.get("id");
- this.experimentsService.getMyExperiments().subscribe((experiments) => {
- this.myExperiments = experiments;
+ this.fetchExperiments(experimentId);
- this.selectedExperiment = this.myExperiments.filter(x => x._id == experimentId)[0];
- console.log("selektovan exp u training comp: ", this.selectedExperiment);
+ this.authService.loggedInEvent.subscribe(_ => {
+ this.fetchExperiments(experimentId);
+
+ this.signalRService.startConnection()
});
});
}
+ fetchExperiments(andSelectWithId: string | null = '') {
+ this.experimentsService.getMyExperiments().subscribe((experiments) => {
+ this.myExperiments = experiments;
+
+ this.selectedExperiment = this.myExperiments.filter(x => x._id == andSelectWithId)[0];
+ console.log("selektovan exp u training comp: ", this.selectedExperiment);
+ });
+ }
+
selectThisExperiment(experiment: Experiment) {
this.selectedExperiment = experiment;
this.modelLoadComponent!.newModel.type = this.selectedExperiment.type;