-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Macro-Deck-App/19-add-usb-connection-button
Add USB settings and button
- Loading branch information
Showing
58 changed files
with
720 additions
and
484 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<ion-app> | ||
<ion-router-outlet></ion-router-outlet> | ||
<ion-nav [root]="rootComponent"></ion-nav> | ||
</ion-app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,45 @@ | ||
import {NgModule, isDevMode} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {RouteReuseStrategy} from '@angular/router'; | ||
|
||
import {IonicModule, IonicRouteStrategy} from '@ionic/angular'; | ||
import {IonicModule} from '@ionic/angular'; | ||
|
||
import {AppRoutingModule} from './app-routing.module'; | ||
import {AppComponent} from './app.component'; | ||
import {FormsModule} from "@angular/forms"; | ||
import {IonicStorageModule} from "@ionic/storage-angular"; | ||
import {WidgetContentComponentsModule} from "./widget-content-components/widget-content-components.module"; | ||
import { ServiceWorkerModule } from '@angular/service-worker'; | ||
import {ServiceWorkerModule} from '@angular/service-worker'; | ||
import {SettingsModalComponent} from "./pages/shared/modals/settings-modal/settings-modal.component"; | ||
import {HttpClientModule} from "@angular/common/http"; | ||
import {WebHomePageModule} from "./pages/web-home/web-home.module"; | ||
import {HomePageModule} from "./pages/home/home.module"; | ||
import {DeckPageModule} from "./pages/deck/deck.module"; | ||
import {ConnectionLostPageModule} from "./pages/connection-lost/connection-lost.module"; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AppComponent, | ||
SettingsModalComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
HttpClientModule, | ||
IonicModule.forRoot({swipeBackEnabled: false}), | ||
IonicStorageModule.forRoot(), | ||
AppRoutingModule, | ||
FormsModule, | ||
WidgetContentComponentsModule, | ||
ServiceWorkerModule.register('ngsw-worker.js', { | ||
enabled: !isDevMode(), | ||
// Register the ServiceWorker as soon as the application is stable | ||
// or after 30 seconds (whichever comes first). | ||
registrationStrategy: 'registerWhenStable:30000' | ||
}) | ||
], | ||
providers: [ | ||
{provide: RouteReuseStrategy, useClass: IonicRouteStrategy} | ||
], | ||
bootstrap: [AppComponent], | ||
declarations: [ | ||
AppComponent, | ||
SettingsModalComponent | ||
], | ||
imports: [ | ||
BrowserModule, | ||
HttpClientModule, | ||
IonicModule.forRoot({swipeBackEnabled: false}), | ||
IonicStorageModule.forRoot(), | ||
FormsModule, | ||
WidgetContentComponentsModule, | ||
WebHomePageModule, | ||
HomePageModule, | ||
DeckPageModule, | ||
ConnectionLostPageModule, | ||
ServiceWorkerModule.register('ngsw-worker.js', { | ||
enabled: !isDevMode(), | ||
// Register the ServiceWorker as soon as the application is stable | ||
// or after 30 seconds (whichever comes first). | ||
registrationStrategy: 'registerWhenStable:30000' | ||
}) | ||
], | ||
providers: [], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum NavigationDestination { | ||
Home, | ||
Deck, | ||
ConnectionLost | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { ConnectionLostPage } from './connection-lost.page'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule | ||
], | ||
declarations: [ConnectionLostPage] | ||
}) | ||
export class ConnectionLostPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ion-content> | ||
<div class="d-flex justify-content-center align-items-center align-content-center h-100"> | ||
<div class="d-flex flex-column align-items-center"> | ||
<div class="icon mb-2"></div> | ||
<h4>I lost the connection to the server</h4> | ||
<p>I'll try to reconnect in {{retryCountdown}}...</p> | ||
|
||
<div class="d-flex flex-row gap-3 mt-1"> | ||
<ion-button (click)="connect()">Retry now</ion-button> | ||
<ion-button fill="outline" (click)="cancel()">Cancel</ion-button> | ||
</div> | ||
</div> | ||
</div> | ||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.icon { | ||
background-image: url(^assets/icon.png); | ||
width: 10rem; | ||
height: 10rem; | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
transform: scale(.9); | ||
animation: pulseAnimation 2s ease 1s infinite normal forwards; | ||
} | ||
|
||
@keyframes pulseAnimation { | ||
0% { | ||
transform: scale(.9); | ||
} | ||
|
||
50% { | ||
transform: scale(1); | ||
} | ||
|
||
100% { | ||
transform: scale(.9); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...home/connections/connections.page.spec.ts → ...nection-lost/connection-lost.page.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import {Component} from '@angular/core'; | ||
import {WebsocketService} from "../../services/websocket/websocket.service"; | ||
import {Connection} from "../../datatypes/connection"; | ||
import {Subscription} from "rxjs"; | ||
import {NavigationService} from "../../services/navigation/navigation.service"; | ||
import {NavigationDestination} from "../../enums/navigation-destination"; | ||
import {ViewDidEnter, ViewDidLeave} from "@ionic/angular"; | ||
|
||
@Component({ | ||
selector: 'app-connection-lost', | ||
templateUrl: './connection-lost.page.html', | ||
styleUrls: ['./connection-lost.page.scss'], | ||
}) | ||
export class ConnectionLostPage implements ViewDidEnter, ViewDidLeave { | ||
|
||
retryCountdown: number = 10; | ||
|
||
connection: Connection | undefined; | ||
|
||
private subscription: Subscription = new Subscription(); | ||
|
||
private interval: any; | ||
|
||
constructor(private websocketService: WebsocketService, | ||
private navigationService: NavigationService) { | ||
this.connection = websocketService.getConnection(); | ||
} | ||
|
||
ionViewDidLeave() { | ||
this.subscription.unsubscribe(); | ||
} | ||
|
||
async ionViewDidEnter() { | ||
this.subscription.add(this.websocketService.connectionFailed.subscribe(() => { | ||
this.startRetry(); | ||
})); | ||
await this.startRetry(); | ||
} | ||
|
||
async startRetry() { | ||
this.retryCountdown = 10; | ||
this.interval = setInterval(async () => { | ||
this.retryCountdown--; | ||
if (this.retryCountdown == 0) { | ||
await this.connect(); | ||
} | ||
}, 1000); | ||
} | ||
|
||
async connect() { | ||
clearInterval(this.interval); | ||
if (this.connection == undefined) { | ||
await this.navigationService.navigateTo(NavigationDestination.Home); | ||
return; | ||
} | ||
await this.websocketService.connectToConnection(this.connection); | ||
} | ||
|
||
async cancel() { | ||
clearInterval(this.interval); | ||
await this.navigationService.navigateTo(NavigationDestination.Home); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.