Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Timon G. <[email protected]>
  • Loading branch information
xunleii and UnchartedBull committed Dec 21, 2020
1 parent 335cd63 commit 8625748
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/app/config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const defaultConfig: Config = {
tplinkSmartPlug: {
enabled: false,
smartPlugIP: '127.0.0.1',
turnOnPowerWhenExitingSleep: false,
},
},
octodash: {
Expand Down
1 change: 0 additions & 1 deletion src/app/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ interface PSUControlPlugin extends Plugin {

interface TPLinkSmartPlugPlugin extends Plugin {
smartPlugIP: string;
turnOnPowerWhenExitingSleep: boolean;
}

interface OctoDash {
Expand Down
6 changes: 1 addition & 5 deletions src/app/config/config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const configSchema = {
tpLinkSmartPlug: {
$id: '#/properties/plugins/properties/tplinkSmartPlug',
type: 'object',
required: ['enabled', 'smartPlugIP', 'turnOnPowerWhenExitingSleep'],
required: ['enabled', 'smartPlugIP'],
properties: {
enabled: {
$id: '#/properties/plugins/properties/printTimeGenius/properties/enabled',
Expand All @@ -211,10 +211,6 @@ export const configSchema = {
$id: '#/properties/plugins/properties/smartPlugIP',
type: 'string',
},
turnOnPowerWhenExitingSleep: {
$id: '#/properties/plugins/properties/turnOnPowerWhenExitingSleep',
type: 'boolean',
},
},
},
},
Expand Down
9 changes: 4 additions & 5 deletions src/app/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,13 @@ export class ConfigService {
return this.config.plugins.psuControl.turnOnPSUWhenExitingSleep;
}

public getSmartPlugIP(): string {
return this.config.plugins.tplinkSmartPlug.smartPlugIP;
public useTpLinkSmartPlug(): string {
return this.config.plugins.tplinkSmartPlug.enabled;
}

public turnOnPowerWhenExitingSleep(): boolean {
return this.config.plugins.tplinkSmartPlug.turnOnPowerWhenExitingSleep;
public getSmartPlugIP(): string {
return this.config.plugins.tplinkSmartPlug.smartPlugIP;
}

public getFilamentThickness(): number {
return this.config.filament.thickness;
}
Expand Down
18 changes: 1 addition & 17 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,23 +577,7 @@
</span>
<span class="settings__checkbox-descriptor">enabled</span>
</div>
<div
class="settings__checkbox-container"
[ngClass]="{ 'settings__checkbox-container-disabled': !config.plugins.tplinkSmartPlug.enabled }"
(click)="
config.plugins.tplinkSmartPlug.turnOnPowerWhenExitingSleep = !config.plugins.tplinkSmartPlug.turnOnPowerWhenExitingSleep
"
>
<span class="settings__checkbox">
<span
class="settings__checkbox-checked"
[ngClass]="{ 'settings__checkbox-checked-disabled': !config.plugins.tplinkSmartPlug.enabled }"
*ngIf="config.plugins.tplinkSmartPlug.turnOnPowerWhenExitingSleep"
></span>
</span>
<span class="settings__checkbox-descriptor">Turn on TPLink when exiting sleep</span>
</div>
<label for="smart-plug-ip" class="settings__input-label">Smart plug IP</label>
<label for="smart-plug-ip" class="settings__input-label">SmartPlug IP</label>
<input
type="text"
id="smart-plug-ip"
Expand Down
9 changes: 5 additions & 4 deletions src/app/standby/standby.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ export class StandbyComponent implements OnInit {
public reconnect(): void {
this.connecting = true;
if (this.configService.turnOnPSUWhenExitingSleep()) {
this.psuControlService.changePSUState(true);
setTimeout(this.checkConnection.bind(this), 5000);
} else if (this.configService.turnOnPowerWhenExitingSleep()) {
this.tpLinkSmartPlugService.changePowerState(true);
if (this.configService.useTpLinkSmartPlug()) {
this.tpLinkSmartPlugService.changePowerState(true);
} else {
this.psuControlService.changePSUState(true);
}
setTimeout(this.checkConnection.bind(this), 5000);
} else {
this.checkConnection();
Expand Down

0 comments on commit 8625748

Please sign in to comment.