Skip to content

Commit 719ae23

Browse files
committed
frontend: show train-status in top-bar
1 parent 054325f commit 719ae23

File tree

11 files changed

+115
-26
lines changed

11 files changed

+115
-26
lines changed

frontend-angular/src/app/app-main/app-main.component.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
<!-- Navigation ------------------------------------ -->
22
<nav class="nav-extended">
33
<div class="nav-wrapper">
4-
5-
<ul class="right hide-on-med-and-down">
4+
<!-- connection indicator -->
5+
<ul class="right">
66
<li><a [ngClass]="connected ? 'green-text' : 'red-text'" class="btn white btn-flat no-select">{{connected ? 'connected' : 'not connected'}}
77
<i [ngClass]="connected ? 'green-text' : 'red-text'" class="material-icons red-text right">{{connected ? 'wifi' : 'wifi_off'}}</i></a></li>
88
</ul>
9+
10+
<ul class="right" *ngIf="appState.training">
11+
<li>
12+
<a class="green-text btn white btn-flat no-select">
13+
Training
14+
<app-progress-indicator class="right" style="margin-top: 5px; margin-left: 10px;"></app-progress-indicator>
15+
</a>
16+
</li>
17+
</ul>
18+
919
<div class="col s12" id="nav-at" style="margin-left: 20px">
1020
<a class="breadcrumb no-select" id="home"><i routerLink="/" class="material-icons">home</i></a>
1121
</div>

frontend-angular/src/app/app-main/app-main.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {toastErr, toastInfo} from "../util/Log";
77
import {DOCUMENT} from "@angular/common";
88
import {BehaviorSubject} from "rxjs/BehaviorSubject";
99
import {TestPlaygroundComponent} from "@frontend/test-playground/test-playground.component";
10+
import {AppState} from "@frontend/settings/app-state.service";
1011

1112
/*
1213
*-- MainComponent ------------------------------------------------------- */
@@ -28,6 +29,7 @@ export class AppMainComponent {
2829
connected: boolean = false;
2930

3031
constructor(
32+
public appState: AppState,
3133
route: ActivatedRoute,
3234
@Inject(DOCUMENT) private document: Document)
3335
{

frontend-angular/src/app/app.module.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {ApiChart} from "@catflow/extensions/Chart-range";
2020
import {KeysPipe} from "@catflow/Utils";
2121
import { SettingsComponent } from './settings/settings.component';
2222
import { SelectionViewComponent } from './settings/selection-view/selection-view.component';
23-
import {SettingsService} from "@frontend/settings/settings.service";
23+
import {AppState} from "@frontend/settings/app-state.service";
2424
import {ApiSeriesChart} from "@catflow/extensions/Chart-series";
2525
import {AngularResizedEventModule} from "angular-resize-event";
2626
import { ModelEditorComponent } from './test-playground/model-editor/model-editor.component';
@@ -29,6 +29,7 @@ import { TestPlaygroundComponent } from './test-playground/test-playground.compo
2929
import { ChartPlotlyComponent } from './test-playground/chart-plotly/chart-plotly.component';
3030
import { ModelEditorNodeComponent } from './test-playground/model-editor/model-editor-node/model-editor-node.component';
3131
import { ModelEditorConnectionComponent } from './test-playground/model-editor/model-editor-connection/model-editor-connection.component';
32+
import { ProgressIndicatorComponent } from './util/progress-indicator/progress-indicator.component';
3233

3334

3435

@@ -50,7 +51,8 @@ import { ModelEditorConnectionComponent } from './test-playground/model-editor/m
5051
TestPlaygroundComponent,
5152
ChartPlotlyComponent,
5253
ModelEditorNodeComponent,
53-
ModelEditorConnectionComponent
54+
ModelEditorConnectionComponent,
55+
ProgressIndicatorComponent
5456
],
5557
imports: [
5658
BrowserModule,
@@ -65,7 +67,7 @@ import { ModelEditorConnectionComponent } from './test-playground/model-editor/m
6567
],
6668
providers: [
6769
Api,
68-
SettingsService
70+
AppState
6971
/*{provide: RouteReuseStrategy, useClass: CustomReuseStrategy}*/
7072
],
7173
entryComponents: [

frontend-angular/src/app/backend-console/backend-console.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import {ApiConnection, CONNECTION_STATUS} from "@catflow/ApiConnection";
3-
import {SettingsService} from "@frontend/settings/settings.service";
3+
import {AppState} from "@frontend/settings/app-state.service";
44

55
@Component({
66
selector: 'app-backend-console',
@@ -15,7 +15,7 @@ export class BackendConsoleComponent implements OnInit {
1515
CONNECTION_STATUS = CONNECTION_STATUS;
1616

1717

18-
constructor(private settings:SettingsService) {
18+
constructor(private settings:AppState) {
1919
ApiConnection.onReceive.subscribe(data => {
2020
this.log.push({direction: 'got', message: data});
2121
if (this.log.length > 50)

frontend-angular/src/app/network-train/network-train.component.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {toastInfo, toastOk} from "../util/Log";
55
import {FormBuilder, FormGroup} from "@angular/forms";
66
import {ApiObject} from "@catflow/ApiObject";
77
import { Chart, ChartData, Point } from 'chart.js';
8+
import {AppState} from "@frontend/settings/app-state.service";
89

910

1011
@Component({
@@ -26,9 +27,11 @@ export class NetworkTrainComponent implements OnInit {
2627
lastProgressValue: number = -1;
2728
private dataChartInited: boolean = false;
2829

29-
constructor(private router: ActivatedRoute,
30-
private fb: FormBuilder,
31-
public api: Api)
30+
constructor(
31+
private appState: AppState,
32+
private router: ActivatedRoute,
33+
private fb: FormBuilder,
34+
public api: Api)
3235
{
3336

3437

@@ -66,6 +69,7 @@ export class NetworkTrainComponent implements OnInit {
6669
this.networkChart.apiObject = this.api.object('/dataStructures/' + this.structureID + '/networks/' + this.networkID + '/charts/netOutput/');
6770
this.networkProgressChart.apiObject = this.api.object('/dataStructures/' + this.structureID + '/networks/' + this.networkID + '/charts/progress/');
6871
this.networkProgressChart.lastValues.subscribe(value => this.lastProgressValue = Math.round(value[0] *100000) /100000);
72+
//this.modelEditor.networkObject = this.network;
6973
this.dataChartInited = true;
7074
}
7175

@@ -138,13 +142,17 @@ export class NetworkTrainComponent implements OnInit {
138142
//toastInfo("start train: ", this.trainParams.value);
139143
this.network.update(this.trainParams.value);
140144
this.network.action('startTrain')
141-
.then(() => toastOk('start train'));
142-
143-
144-
145+
.then(() => {
146+
this.appState.training = true;
147+
toastOk('start train');
148+
});
145149
}
146150
else {
147-
this.network.action('stopTrain').then(() => toastOk('stopped train'));
151+
this.network.action('stopTrain')
152+
.then(() => {
153+
this.appState.training = false;
154+
toastOk('stopped train');
155+
});
148156
}
149157
}
150158

frontend-angular/src/app/settings/settings.service.ts renamed to frontend-angular/src/app/settings/app-state.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Injectable } from '@angular/core';
22

33
@Injectable()
4-
export class SettingsService {
4+
export class AppState {
55

66
public settings:any = undefined;
7+
public training: boolean = false;
78

89
constructor() {}
910

frontend-angular/src/app/settings/settings.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Component, OnInit} from '@angular/core';
22
import {Api} from "@catflow/Api";
33
import {ApiObject} from "@catflow/ApiObject";
44
import {toastOk} from "@frontend/util/Log";
5-
import {SettingsService} from "@frontend/settings/settings.service";
5+
import {AppState} from "@frontend/settings/app-state.service";
66

77
@Component({
88
selector: 'app-settings',
@@ -14,7 +14,7 @@ export class SettingsComponent implements OnInit {
1414
settings: any = undefined;
1515
settingsKeys: any[] = [];
1616

17-
constructor(private api: Api, settingsServ:SettingsService) {
17+
constructor(private api: Api, settingsServ:AppState) {
1818
api.object("/settings/").subscribe();
1919
api.object("/settings/").object().subscribe(value => {
2020
if (value == null)

frontend-angular/src/app/test-playground/model-editor/model-editor-connection/model-editor-connection.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class ModelEditorConnectionComponent implements OnInit, AfterViewInit, On
2222
static tension = 0.5;
2323
dragOutput: Drag;
2424
static dragging: boolean = false;
25-
2625
@Input() editor: ModelEditorComponent;
2726
@Input() inPoint: Point = {x:1, y:2};
2827
@Input() outPoint: Point = {x:100, y:20};

frontend-angular/src/app/test-playground/model-editor/model-editor.component.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<div style="">
2-
<p>
3-
model-editor works!
4-
</p>
5-
6-
72
<div class="row s12">
83
<!-- editor panel ------------------------------------------------ -->
94
<div class="col s9 backgroundCol" >
@@ -23,8 +18,6 @@ <h5>Add Layer</h5>
2318
<div style="margin-top: 40px">
2419
<div class="btn waves-effect green" (click)="saveModel()">Save Model <i class="material-icons right">save</i></div>
2520
</div>
26-
<div class="btn waves-effect green" (click)="removeAllNodesAndConnections(); modelToJson();">Clear<i class="material-icons right">delete</i></div>
27-
<div class="btn waves-effect green" (click)="modelToJson();">To Jon<i class="material-icons right">refresh</i></div>
2821
<pre>{{modelJson | json}}</pre>
2922
</div>
3023

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.spinner {
2+
width: 40px;
3+
height: 25px;
4+
text-align: center;
5+
font-size: 10px;
6+
}
7+
8+
.spinner > div {
9+
background-color: #4CAF50;
10+
height: 100%;
11+
width: 4px;
12+
display: inline-block;
13+
14+
-webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
15+
animation: sk-stretchdelay 1.2s infinite ease-in-out;
16+
}
17+
18+
.spinner .rect2 {
19+
-webkit-animation-delay: -1.1s;
20+
animation-delay: -1.1s;
21+
}
22+
23+
.spinner .rect3 {
24+
-webkit-animation-delay: -1.0s;
25+
animation-delay: -1.0s;
26+
}
27+
28+
.spinner .rect4 {
29+
-webkit-animation-delay: -0.9s;
30+
animation-delay: -0.9s;
31+
}
32+
33+
.spinner .rect5 {
34+
-webkit-animation-delay: -0.8s;
35+
animation-delay: -0.8s;
36+
}
37+
38+
@-webkit-keyframes sk-stretchdelay {
39+
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
40+
20% { -webkit-transform: scaleY(1.0) }
41+
}
42+
43+
@keyframes sk-stretchdelay {
44+
0%, 40%, 100% {
45+
transform: scaleY(0.4);
46+
-webkit-transform: scaleY(0.4);
47+
} 20% {
48+
transform: scaleY(1.0);
49+
-webkit-transform: scaleY(1.0);
50+
}
51+
}

0 commit comments

Comments
 (0)