From 280b3a5c83df2ee5cb0485403d89959f19a27bfc Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Mon, 29 Apr 2024 17:05:43 +0200 Subject: [PATCH] Add option to disable menu button --- src/app/pages/deck/deck.page.html | 59 +++++++++++++------ src/app/pages/deck/deck.page.ts | 20 ++++++- src/app/pages/home/home.page.ts | 9 +-- .../settings-modal.component.html | 7 +++ .../settings-modal.component.ts | 17 ++++++ .../services/diagnostic/diagnostic.service.ts | 9 ++- src/app/services/settings/settings.service.ts | 9 +++ 7 files changed, 100 insertions(+), 30 deletions(-) diff --git a/src/app/pages/deck/deck.page.html b/src/app/pages/deck/deck.page.html index 065f8f9..f61575a 100644 --- a/src/app/pages/deck/deck.page.html +++ b/src/app/pages/deck/deck.page.html @@ -1,20 +1,41 @@ - - + + + + Macro Deck + + + + + + + + Open full screen + + + + Settings + + + + Close connection + + + + + + {{version}} | Client Id: {{clientId}} + + - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + +
diff --git a/src/app/pages/deck/deck.page.ts b/src/app/pages/deck/deck.page.ts index de449fa..d6c98f2 100644 --- a/src/app/pages/deck/deck.page.ts +++ b/src/app/pages/deck/deck.page.ts @@ -5,6 +5,8 @@ import {CurrentPlatformService} from "../../services/current-platform/current-pl import {SettingsModalComponent} from "../shared/modals/settings-modal/settings-modal.component"; import {ModalController} from "@ionic/angular"; import {environment} from "../../../environments/environment"; +import {SettingsService} from "../../services/settings/settings.service"; +import {DiagnosticService} from "../../services/diagnostic/diagnostic.service"; @Component({ selector: 'app-deck', @@ -13,17 +15,25 @@ import {environment} from "../../../environments/environment"; }) export class DeckPage implements AfterViewInit { + showMenuButton: boolean = true; + clientId: string = ""; + version: string = ""; constructor(private websocketService: WebsocketService, private router: Router, - private currentPlatformService: CurrentPlatformService, - private modalController: ModalController) { + private modalController: ModalController, + private settingsService: SettingsService, + private diagnosticsService: DiagnosticService) { } async ngAfterViewInit() { if (!this.websocketService.isConnected) { await this.router.navigate([''], {replaceUrl: true}); } + + this.clientId = await this.settingsService.getClientId(); + this.version = await this.diagnosticsService.getVersion(); + await this.loadSettings(); } async close() { @@ -35,6 +45,8 @@ export class DeckPage implements AfterViewInit { component: SettingsModalComponent }); await modal.present(); + await modal.onWillDismiss(); + await this.loadSettings(); } openFullscreen() { @@ -44,5 +56,9 @@ export class DeckPage implements AfterViewInit { } } + private async loadSettings() { + this.showMenuButton = await this.settingsService.getShowMenuButton(); + } + protected readonly environment = environment; } diff --git a/src/app/pages/home/home.page.ts b/src/app/pages/home/home.page.ts index b9bbdaa..e29e427 100644 --- a/src/app/pages/home/home.page.ts +++ b/src/app/pages/home/home.page.ts @@ -3,7 +3,6 @@ import {ModalController} from "@ionic/angular"; import {SettingsService} from "../../services/settings/settings.service"; import {environment} from "../../../environments/environment"; import {DiagnosticService} from "../../services/diagnostic/diagnostic.service"; -import {Capacitor} from "@capacitor/core"; import {SettingsModalComponent} from "../shared/modals/settings-modal/settings-modal.component"; @Component({ @@ -23,13 +22,7 @@ export class HomePage implements OnInit { async ngOnInit() { this.clientId = await this.settingsService.getClientId(); - if (Capacitor.isNativePlatform()) { - this.diagnosticService.getVersion().then(version => { - this.version = `v${version}`; - }); - } else { - this.version = "Web Version"; - } + this.version = await this.diagnosticsService.getVersion(); } protected readonly environment = environment; diff --git a/src/app/pages/shared/modals/settings-modal/settings-modal.component.html b/src/app/pages/shared/modals/settings-modal/settings-modal.component.html index fedc468..5219733 100644 --- a/src/app/pages/shared/modals/settings-modal/settings-modal.component.html +++ b/src/app/pages/shared/modals/settings-modal/settings-modal.component.html @@ -19,6 +19,13 @@ [(ngModel)]="preventScreenTimeout">Prevent screen timeout + + + Show menu button + + info.version); + if (Capacitor.isNativePlatform()) { + await App.getInfo().then(info => { + return `v${info.version}`; + }); + } + + return "Web Version"; } public isAndroid() { diff --git a/src/app/services/settings/settings.service.ts b/src/app/services/settings/settings.service.ts index ab01448..16e2d09 100644 --- a/src/app/services/settings/settings.service.ts +++ b/src/app/services/settings/settings.service.ts @@ -9,6 +9,7 @@ const screenOrientationKey: string = "screen_orientation"; const connectionCountKey: string = "connection_count"; const lastConnectionKey: string = "last_connection"; const skipSslValidationKey: string = "skip_ssl_validation"; +const showMenuButtonKey: string = "show_menu_button"; @Injectable({ providedIn: 'root' @@ -19,6 +20,14 @@ export class SettingsService { constructor(private storage: Storage) { } + public async setShowMenuButton(showMenuButton: boolean) { + await this.storage.set(showMenuButtonKey, showMenuButton); + } + + public async getShowMenuButton() { + return await this.storage.get(showMenuButtonKey) ?? true; + } + public async setSkipSslValidation(lastConnection: boolean) { await this.storage.set(skipSslValidationKey, lastConnection); }