Skip to content

Commit 05a8456

Browse files
committed
Added Profile selection and a Standby Clock
1 parent 80f9d10 commit 05a8456

25 files changed

+876
-30
lines changed

src/app/app.module.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ import { ToggleSwitchComponent } from './shared/toggle-switch/toggle-switch.comp
6464
import { StandbyComponent } from './standby/standby.component';
6565
import { UpdateComponent } from './update/update.component';
6666
import { URLSafePipe } from './url.pipe';
67+
import { ProfilesComponent } from './profiles/profiles.component';
68+
import { ProfileService } from './services/profiles/profiles.service';
69+
import { ProfileOctoprintService } from './services/profiles/profiles.octoprint.service';
70+
import { ConfirmComponent } from './confirm/confirm.component';
6771

6872
export function playerFactory(): LottiePlayer {
6973
return player;
@@ -103,6 +107,8 @@ export function playerFactory(): LottiePlayer {
103107
PurgeFilamentComponent,
104108
CustomActionsComponent,
105109
ToggleSwitchComponent,
110+
ProfilesComponent,
111+
ConfirmComponent,
106112
],
107113
imports: [
108114
AppRoutingModule,
@@ -123,6 +129,17 @@ export function playerFactory(): LottiePlayer {
123129
EventService,
124130
NotificationService,
125131
[
132+
{
133+
provide: ProfileService,
134+
deps: [ConfigService, NotificationService, HttpClient],
135+
useFactory: (
136+
configService: ConfigService,
137+
notificationService: NotificationService,
138+
httpClient: HttpClient,
139+
) => {
140+
return new ProfileOctoprintService(configService, notificationService, httpClient);
141+
},
142+
},
126143
{
127144
provide: SystemService,
128145
deps: [ConfigService, NotificationService, HttpClient],

src/app/app.routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { FilamentComponent } from './filament/filament.component';
99
import { FilesComponent } from './files/files.component';
1010
import { MainScreenComponent } from './main-screen/main-screen.component';
1111
import { MainScreenNoTouchComponent } from './main-screen/no-touch/main-screen-no-touch.component';
12+
import { ProfilesComponent } from './profiles/profiles.component';
1213
import { SettingsComponent } from './settings/settings.component';
1314
import { StandbyComponent } from './standby/standby.component';
1415

@@ -49,6 +50,10 @@ const routes: Routes = [
4950
path: 'standby',
5051
component: StandbyComponent,
5152
},
53+
{
54+
path: 'profiles',
55+
component: ProfilesComponent,
56+
},
5257
];
5358

5459
@NgModule({

src/app/bottom-bar/bottom-bar.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<table class="bottom-bar">
22
<tr>
3-
<td class="bottom-bar__printer-name">{{ getPrinterName() }}</td>
3+
<td class="bottom-bar__printer-name" (click)="showProfiles()">{{ PrinterName }}</td>
44
<td class="bottom-bar__enclosure-temperature" *ngIf="enclosureTemperature">
55
<img src="assets/thermometer.svg" class="bottom-bar__enclosure-temperature-icon" />
66
{{ enclosureTemperature.temperature }}{{ enclosureTemperature.unit }}
@@ -10,3 +10,4 @@
1010
</td>
1111
</tr>
1212
</table>
13+
<app-profiles *ngIf="profiles" (closeFunction)="hideProfiles()"></app-profiles>

src/app/bottom-bar/bottom-bar.component.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ConfigService } from '../config/config.service';
55
import { PrinterState, PrinterStatus, TemperatureReading } from '../model';
66
import { NotificationService } from '../notification/notification.service';
77
import { EnclosureService } from '../services/enclosure/enclosure.service';
8+
import { ProfileService } from '../services/profiles/profiles.service';
89
import { SocketService } from '../services/socket/socket.service';
910

1011
@Component({
@@ -18,12 +19,14 @@ export class BottomBarComponent implements OnDestroy {
1819

1920
public printerStatus: PrinterState;
2021
public enclosureTemperature: TemperatureReading;
21-
22+
public profiles:boolean = false;
23+
public PrinterName:String;
2224
public constructor(
2325
private socketService: SocketService,
2426
private configService: ConfigService,
2527
private enclosureService: EnclosureService,
2628
private notificationService: NotificationService,
29+
private profileService: ProfileService
2730
) {
2831
if (this.configService.getAmbientTemperatureSensorName() !== null) {
2932
this.subscriptions.add(
@@ -52,17 +55,33 @@ export class BottomBarComponent implements OnDestroy {
5255
}
5356
}),
5457
);
58+
this.getPrinterName();
5559
}
5660

5761
public getStringStatus(printerState: PrinterState): string {
5862
return PrinterState[printerState];
5963
}
6064

61-
public getPrinterName(): string {
62-
return this.configService.getPrinterName();
65+
public getPrinterName(): void {
66+
this.profileService.getActiveProfile().subscribe((profile)=>{
67+
this.PrinterName = profile.name;
68+
});
6369
}
6470

6571
public ngOnDestroy(): void {
6672
this.subscriptions.unsubscribe();
6773
}
74+
75+
public showProfiles(){
76+
if (this.printerStatus == PrinterState.operational){
77+
this.profiles = true;
78+
}
79+
}
80+
81+
public hideProfiles(): void {
82+
setTimeout((): void => {
83+
this.profiles = false;
84+
this.getPrinterName();
85+
}, 350);
86+
}
6887
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div style="z-index: 9999" class="confirm__wrapper" *ngIf="show">
2+
<div class="confirm">
3+
<h1 i18n="@@are-you-sure">are you sure?</h1>
4+
<p class="confirm__sub-heading" i18n="@@confirm-exec">{{Question}}</p>
5+
<p class="confirm__gcode" *ngIf="Command">{{ Command }}</p>
6+
<img
7+
class="confirm__icon"
8+
src="assets/confirm-small.svg"
9+
(click)="okClicked()"
10+
/>
11+
<img class="confirm__icon" src="assets/cancel-small.svg" (click)="cancelClicked()" />
12+
</div>
13+
</div>

src/app/confirm/confirm.component.scss

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ConfirmComponent } from './confirm.component';
4+
5+
describe('ConfirmComponent', () => {
6+
let component: ConfirmComponent;
7+
let fixture: ComponentFixture<ConfirmComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ ConfirmComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ConfirmComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { _getShadowRoot } from '@angular/cdk/platform';
2+
import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core';
3+
4+
@Component({
5+
selector: 'app-confirm',
6+
templateUrl: './confirm.component.html',
7+
styleUrls: ['./confirm.component.scss']
8+
})
9+
export class ConfirmComponent implements OnInit {
10+
public show: boolean;
11+
@Input() Question: string;
12+
@Input() Command?: string;
13+
@Input()
14+
get Show(): boolean{
15+
return this.show;
16+
};
17+
set Show(value){
18+
this.show = value;
19+
};
20+
@Output() Ok = new EventEmitter();
21+
@Output() Cancel = new EventEmitter();
22+
23+
constructor() { }
24+
25+
ngOnInit(): void {
26+
}
27+
okClicked(): void {
28+
this.Ok.emit();
29+
this.show = false;
30+
}
31+
cancelClicked(): void{
32+
this.show = false;
33+
this.Cancel.emit();
34+
}
35+
}

src/app/control/control.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Component } from '@angular/core';
33
import { OctoprintPrinterProfile } from '../model/octoprint';
44
import { NotificationService } from '../notification/notification.service';
55
import { PrinterService } from '../services/printer/printer.service';
6+
import { ProfileService } from '../services/profiles/profiles.service';
67

78
@Component({
89
selector: 'app-control',
@@ -15,8 +16,8 @@ export class ControlComponent {
1516
public jogDistance = 10;
1617
public showHelp = false;
1718

18-
public constructor(private printerService: PrinterService, private notificationService: NotificationService) {
19-
this.printerService.getActiveProfile().subscribe(
19+
public constructor(private printerService: PrinterService, private profileService: ProfileService, private notificationService: NotificationService) {
20+
this.profileService.getActiveProfile().subscribe(
2021
(printerProfile: OctoprintPrinterProfile) => (this.printerProfile = printerProfile),
2122
err => {
2223
this.notificationService.setError(

src/app/model/octoprint/printer-commands.model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ export interface TemperatureHeatbedCommand {
3737
export interface DisconnectCommand {
3838
command: string;
3939
}
40+
41+
export interface ProfileCommand {
42+
current: boolean;
43+
}

0 commit comments

Comments
 (0)