Small Cleaning and autorun bug fix

This commit is contained in:
Myx
2022-01-02 05:45:05 +01:00
parent bcdab6b162
commit 01bf3770fc
49 changed files with 208 additions and 16420 deletions

View File

@@ -11,10 +11,6 @@
<param name="onload" value="true"/>
</feature>
<feature name="Ping">
<param name="android-package" value="com.spartan0nix.plugins.Ping"/>
</feature>
<feature name="SQLitePlugin">
<param name="android-package" value="io.sqlc.SQLitePlugin"/>
</feature>

15722
Client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +1,9 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { RouterModule } from '@angular/router';
import { StoreRouterConnectingModule } from '@ngrx/router-store';
import { StoreModule } from '@ngrx/store';
import { gotobedReducer } from './store/gotobed.reducer';
const routes: Routes = [
{
path: '',
loadChildren: () => import('./components/menu/menu.module').then(page => page.MenuPageModule)
}
];
@NgModule({
imports: [
StoreModule.forFeature('Gotobed', gotobedReducer), StoreRouterConnectingModule.forRoot(),

View File

@@ -19,5 +19,4 @@ describe('AppComponent', () => {
expect(app).toBeTruthy();
});
// TODO: add more tests!
});

View File

@@ -1,9 +1,4 @@
import { Component } from '@angular/core';
import { StorageService } from './services/storage.service';
import { ProtocolStorageKey, PortStorageKey, AddressStorageKey } from './gotobed.models';
import { GotobedState, initialGotoBedState } from './store/gotobed.state';
import { Store } from '@ngrx/store';
import { ProtocolSettingsChanged } from './store/gotobed.actions';
@Component({
selector: 'app-root',
@@ -12,10 +7,5 @@ import { ProtocolSettingsChanged } from './store/gotobed.actions';
})
export class AppComponent {
constructor(private storage: StorageService, private _store: Store<GotobedState>) {
//this.storage.initializeStorage();
// this._store.dispatch(new ProtocolSettingsChanged(await this.storage.fetchFromStorage(ProtocolStorageKey).then(protocol => protocol)));
// this.storage.fetchFromStorage(PortStorageKey).then(port => (initialGotoBedState.port = port));
// this.storage.fetchFromStorage(AddressStorageKey).then(address => (initialGotoBedState.address = address));
}
constructor() { }
}

View File

@@ -5,7 +5,6 @@ import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { Drivers } from '@ionic/storage';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MenuPage } from './components/menu/menu.page';
@@ -16,17 +15,17 @@ import { HttpClientModule } from '@angular/common/http';
import { AppStoreModule } from './app-store.module';
import { EffectsModule } from '@ngrx/effects';
import { GotobedStoreModule } from './store/gotobed.store.module';
import { GotobedEffects } from './store/gotoved.effects';
import { GotobedEffects } from './store/gotobed.effects';
import { IonicStorageModule } from '@ionic/storage-angular';
import * as CordovaSQLLiteDriver from 'localforage-cordovasqlitedriver'
import * as CordovaSQLLiteDriver from 'localforage-cordovasqlitedriver';
import { SettingsPage } from './components/settings/settings.page';
import { HTTP } from '@awesome-cordova-plugins/http/ngx';
const components = [
AppComponent,
MenuPage,
ServerSettingsComponent,
SettingsPage,
MenuPage,
ServerSettingsComponent,
SettingsPage,
ExploreContainerComponent
];

View File

@@ -1,6 +1,5 @@
#container {
text-align: center;
position: absolute;
left: 0;
right: 0;

View File

@@ -1,6 +1,5 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponent } from './explore-container.component';
describe('ExploreContainerComponent', () => {

View File

@@ -11,5 +11,4 @@ export class ExploreContainerComponent implements OnInit {
constructor() { }
ngOnInit() {}
}

View File

@@ -1,9 +1,7 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponent } from './explore-container.component';
@NgModule({

View File

@@ -4,7 +4,6 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { HomePageRoutingModule } from './home-routing.module';
import { RouterModule } from '@angular/router';

View File

@@ -1,8 +1,6 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Home
</ion-title>
<ion-title>Home</ion-title>
</ion-toolbar>
</ion-header>
@@ -17,7 +15,7 @@
<ion-grid>
<ion-row>
<ion-col>
<ion-card class="noselect" (click)="presentAlert('shutdown')">
<ion-card class="noselect" (click)="commandAlert('shutdown')">
<ion-card-header>
<ion-card-title>Shutdown</ion-card-title>
</ion-card-header>
@@ -30,7 +28,7 @@
<ion-row>
<ion-col>
<ion-card class="noselect" (click)="presentAlert('sleep')">
<ion-card class="noselect" (click)="commandAlert('sleep')">
<ion-card-header>
<ion-card-title>Sleep</ion-card-title>
</ion-card-header>
@@ -40,7 +38,7 @@
</ion-card>
</ion-col>
<ion-col>
<ion-card class="noselect" (click)="presentAlert('reboot')">
<ion-card class="noselect" (click)="commandAlert('reboot')">
<ion-card-header>
<ion-card-title>Reboot</ion-card-title>
</ion-card-header>
@@ -52,7 +50,7 @@
</ion-row>
<ion-row>
<ion-col>
<ion-card class="noselect" (click)="presentAlert('logout')">
<ion-card class="noselect" (click)="commandAlert('logout')">
<ion-card-header>
<ion-card-title>Logout</ion-card-title>
</ion-card-header>

View File

@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { HomePage } from './home.page';
describe('HomePage', () => {

View File

@@ -12,17 +12,16 @@ import { getAddress, getCommandType, getPort, getProtocol } from '../../store/go
})
export class HomePage implements OnInit{
commandtype$ = this.store.select(getCommandType);
port = null;
address = '';
protocol = '';
constructor(
public alertController: AlertController,
private httpCommand: NetworkRequestsService,
private store: Store) {}
commandtype$ = this.store.select(getCommandType);
port = null;
address = "";
protocol = "";
private store: Store
) {}
ngOnInit() {
this.store
@@ -38,27 +37,21 @@ export class HomePage implements OnInit{
.subscribe(protocol => (this.protocol = protocol));
}
async presentAlert(commandType) {
async commandAlert(commandValue) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
cssClass: 'alert',
header: 'Are you sure?',
message: `You are about to send a ${commandType} command to the device.`,
message: `You are about to send a ${commandValue} command to the device.`,
buttons: [
{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: (blah) => {
console.log('Confirm Cancel: blah');
this.commandtype$.subscribe(commandType => {
console.log(commandType);
});
}
cssClass: 'secondary'
}, {
text: 'Send',
handler: () => {
this.store.dispatch(new SendCommandChanged(commandType));
this.httpCommand.sendCommand(commandType, this.address, this.port, this.protocol);
this.store.dispatch(new SendCommandChanged(commandValue));
this.httpCommand.sendCommand(commandValue, this.address, this.port, this.protocol);
}
}
]

View File

@@ -1,5 +1,4 @@
<ion-tabs>
<ion-tab-bar slot="bottom">
<ion-tab-button tab="home">
<ion-icon name="home-sharp"></ion-icon>
@@ -16,5 +15,4 @@
<ion-label>Settings</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-tabs>

View File

@@ -7,7 +7,5 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MenuPage {
constructor() {}
}

View File

@@ -1,11 +1,9 @@
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { SearchHostPage } from './searchHost.page';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { SearchHostPageRoutingModule } from './searchHost-routing.module';
@NgModule({

View File

@@ -1,17 +1,15 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Search Host
</ion-title>
<ion-title>Search Host</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Tab 2</ion-title>
<ion-title size="large">WOL</ion-title>
</ion-toolbar>
</ion-header>
<app-explore-container name="Tab 2 page"></app-explore-container>
<app-explore-container name="WOL"></app-explore-container>
</ion-content>

View File

@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { SearchHostPage } from './searchHost.page';
describe('SearchHostPage', () => {

View File

@@ -1,29 +1,8 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-searchHost',
selector: 'app-searchhost',
templateUrl: 'searchHost.page.html',
styleUrls: ['searchHost.page.scss']
})
export class SearchHostPage {
constructor() {}
testText = '';
test() {
// console.log("!test")
// // Zeroconf.watchAddressFamily = 'ipv4';
// // Zeroconf.watch('_http._tcp.', 'local.').subscribe(result => {
// // this.testText = JSON.stringify(result.service.ipv4Addresses);
// // console.log(JSON.stringify(result.service.ipv4Addresses))
// // });
// ServiceDiscovery.getNetworkServices('ssdp:all')
// .then(devices => {
// console.log(JSON.stringify(devices))
// this.testText = JSON.stringify(devices)
// })
// .catch(error => console.error(error));
}
}
export class SearchHostPage { }

View File

@@ -1,6 +1,6 @@
<ion-list>
<ion-list-header>
<ion-label (click)="test()"> Remote Server Settings </ion-label>
<ion-label> Remote Server Settings </ion-label>
</ion-list-header>
<ion-item>
<ion-label position="fixed">Protocol</ion-label>

View File

@@ -1,8 +1,4 @@
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { ServerSettingsComponent } from './serverSettings.component';
describe('ServerSettingsComponent', () => {

View File

@@ -1,6 +1,5 @@
import { getAddress, getPort, getProtocol } from './../../../store/gotobed.selectors';
import { Store } from '@ngrx/store';
import { Component, OnInit } from '@angular/core';
import { PortSettingsChanged, ProtocolSettingsChanged, SaveAddressSettings } from 'src/app/store/gotobed.actions';
import { GotobedState } from 'src/app/store/gotobed.state';
@@ -12,38 +11,37 @@ import { InputCustomEvent } from 'src/app/gotobed.models';
styleUrls: ['./serverSettings.component.scss']
})
export class ServerSettingsComponent implements OnInit{
constructor(private _store: Store<GotobedState>) { }
port = null;
address = "";
protocol = "";
address = '';
protocol = '';
constructor(private store: Store<GotobedState>) { }
ngOnInit() {
console.log("#Render server settings");
this._store
console.log('#Render server settings');
this.store
.select(getPort)
.subscribe(port => (this.port = port));
this._store
this.store
.select(getAddress)
.subscribe(address => (this.address = address));
this._store
this.store
.select(getProtocol)
.subscribe(protocol => (this.protocol = protocol));
}
onProtocolChange(protocol: InputCustomEvent){
console.log(protocol.detail.value)
this._store.dispatch(new ProtocolSettingsChanged(protocol.detail.value));
console.log(protocol.detail.value);
this.store.dispatch(new ProtocolSettingsChanged(protocol.detail.value));
}
onAddressChange(address: InputCustomEvent){
console.log(address.detail.value)
this._store.dispatch(new SaveAddressSettings(address.detail.value));
console.log(address.detail.value);
this.store.dispatch(new SaveAddressSettings(address.detail.value));
}
onPortChange(port: InputCustomEvent){
console.log(port.detail.value)
this._store.dispatch(new PortSettingsChanged(port.detail.value));
console.log(port.detail.value);
this.store.dispatch(new PortSettingsChanged(port.detail.value));
}
}

View File

@@ -6,7 +6,6 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { SettingsPage } from './settings.page';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { SettingsPageRoutingModule } from './settings-routing.module';
@NgModule({

View File

@@ -1,12 +1,10 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Settings
</ion-title>
<ion-title>Settings</ion-title>
</ion-toolbar>
</ion-header>
<<ion-content [fullscreen]="true">
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Settings</ion-title>

View File

@@ -1,7 +1,6 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
import { SettingsPage } from './settings.page';
describe('SettingsPage', () => {

View File

@@ -5,8 +5,4 @@ import { Component } from '@angular/core';
templateUrl: 'settings.page.html',
styleUrls: ['settings.page.scss']
})
export class SettingsPage {
constructor() {}
}
export class SettingsPage { }

View File

@@ -1,13 +1,13 @@
export const AddressStorageKey = "AddressKey";
export const PortStorageKey = "PortKey";
export const ProtocolStorageKey = "ProtocolKey";
export const CommandStorageKey = "CommandKey";
export const addressStorageKey = 'AddressKey';
export const portStorageKey = 'PortKey';
export const protocolStorageKey = 'ProtocolKey';
export const commandStorageKey = 'CommandKey';
export interface InputChangeEventDetail {
value: string | undefined | null;
}
export interface InputCustomEvent extends CustomEvent {
detail: InputChangeEventDetail;
target: HTMLIonInputElement;
@@ -15,4 +15,4 @@ export interface InputCustomEvent extends CustomEvent {
export interface NetRequest{
command: string;
}
}

View File

@@ -8,18 +8,18 @@ import { HttpErrorResponse } from '@angular/common/http';
providedIn: 'root'
})
export class NetworkRequestsService {
constructor(private readonly _httpClient: HTTP, public toastController: ToastController) { }
constructor(private readonly httpClient: HTTP, public toastController: ToastController) { }
public sendCommand(command: string, address: string, port: number, connectionProtocol?: string,) {
const request: NetRequest = {
command: command,
}
command,
};
this._httpClient.setDataSerializer('json');
this._httpClient.setServerTrustMode('nocheck');
this.httpClient.setDataSerializer('json');
this.httpClient.setServerTrustMode('nocheck');
this._httpClient.post(encodeURI(`${connectionProtocol ?? 'http'}://${address + ":" + port}/commandbridge`), request, {
ContentType: 'text/html;'
this.httpClient.post(encodeURI(`${connectionProtocol ?? 'http'}://${address + ':' + port}/commandbridge`), request, {
contentType: 'text/html;'
}).catch(response => {
this.showErrorMessage(response);
});
@@ -34,4 +34,4 @@ export class NetworkRequestsService {
});
toast.present();
}
}
}

View File

@@ -1,19 +1,19 @@
import { Injectable } from "@angular/core";
import { Storage } from "@ionic/storage-angular";
import * as cordovaSQLiteDriver from "localforage-cordovasqlitedriver";
import { BehaviorSubject, from, of } from "rxjs";
import { filter, switchMap, tap } from "rxjs/operators";
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage-angular';
import * as cordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
import { BehaviorSubject, from, of } from 'rxjs';
import { filter, switchMap, tap } from 'rxjs/operators';
@Injectable({
providedIn: "root"
providedIn: 'root'
})
export class StorageService {
constructor(private storage: Storage) {
//this.initializeStorage();
}
private isStorageLoaded = new BehaviorSubject(false);
constructor(private storage: Storage) {
//this.initializeStorage(); TO BE USED ONCE MIGRATING TO NATIVE STORAGE
}
async initializeStorage() {
await this.storage.defineDriver(cordovaSQLiteDriver);
await this.storage.create();
@@ -39,4 +39,4 @@ export class StorageService {
const newData = currentData.pipe(tap(existingData => existingData.splice(data, 1)));
this.storage.set(key, newData);
}
}
}

View File

@@ -2,41 +2,41 @@ import { Action } from '@ngrx/store';
import { LoadSettingsState } from './gotobed.state';
export enum EGotobedActions {
SendCommandChanged = '[GOTOBED] Command changed',
AddressSettingsChanged = '[GOTOBED] Address settings changed',
ProtocolSettingsChanged = '[GOTOBED] Protocol settings changed',
PortSettingsChanged = '[GOTOBED] Port settings changed',
AppInitialized = '[GOTOBED] App initialized',
sendCommandChanged = '[GOTOBED] Command changed',
addressSettingsChanged = '[GOTOBED] Address settings changed',
protocolSettingsChanged = '[GOTOBED] Protocol settings changed',
portSettingsChanged = '[GOTOBED] Port settings changed',
appInitialized = '[GOTOBED] App initialized',
}
export class SendCommandChanged implements Action {
public readonly type = EGotobedActions.SendCommandChanged;
public readonly type = EGotobedActions.sendCommandChanged;
constructor(public payload: string) { }
}
export class SaveAddressSettings implements Action {
public readonly type = EGotobedActions.AddressSettingsChanged;
public readonly type = EGotobedActions.addressSettingsChanged;
constructor(public payload: string) { }
}
export class ProtocolSettingsChanged implements Action {
public readonly type = EGotobedActions.ProtocolSettingsChanged;
public readonly type = EGotobedActions.protocolSettingsChanged;
constructor(public payload: string) { }
}
export class PortSettingsChanged implements Action {
public readonly type = EGotobedActions.PortSettingsChanged;
public readonly type = EGotobedActions.portSettingsChanged;
constructor(public payload: string) { }
}
export class AppInitialized implements Action {
public readonly type = EGotobedActions.AppInitialized;
public readonly type = EGotobedActions.appInitialized;
constructor(public payload: LoadSettingsState) { }
}
export type GotobedActions =
export type GotobedActions =
SendCommandChanged |
ProtocolSettingsChanged |
ProtocolSettingsChanged |
PortSettingsChanged |
SaveAddressSettings |
SaveAddressSettings |
AppInitialized;

View File

@@ -0,0 +1,57 @@
import { portStorageKey } from '../gotobed.models';
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType, concatLatestFrom, ROOT_EFFECTS_INIT } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { map, tap, withLatestFrom } from 'rxjs/operators';
import { addressStorageKey, protocolStorageKey } from '../gotobed.models';
import { StorageService } from '../services/storage.service';
import { AppInitialized, EGotobedActions, ProtocolSettingsChanged, SaveAddressSettings } from './gotobed.actions';
@Injectable()
export class GotobedEffects {
init$ = createEffect(() =>
this.actions$.pipe(
ofType<AppInitialized>(ROOT_EFFECTS_INIT),
concatLatestFrom(() => this.store),
map(async ([action]) => {
this.storage.initializeStorage();
return action.payload = {
address: localStorage.getItem(addressStorageKey),
port: localStorage.getItem(portStorageKey),
protocol: localStorage.getItem(protocolStorageKey),
};
})
), { dispatch: false }
);
saveAddressSettings$ = createEffect(() => this.actions$.pipe(
ofType<SaveAddressSettings>(EGotobedActions.addressSettingsChanged),
withLatestFrom(this.store),
tap(([action]) => {
localStorage.setItem(addressStorageKey, action.payload);
})
), { dispatch: false });
saveProtocolSettings$ = createEffect(() => this.actions$.pipe(
ofType<ProtocolSettingsChanged>(EGotobedActions.protocolSettingsChanged),
withLatestFrom(this.store),
tap(([action]) => {
localStorage.setItem(protocolStorageKey, action.payload);
})
), { dispatch: false });
savePortSettings$ = createEffect(() => this.actions$.pipe(
ofType<ProtocolSettingsChanged>(EGotobedActions.portSettingsChanged),
withLatestFrom(this.store),
tap(([action]) => {
localStorage.setItem(portStorageKey, action.payload);
})
), { dispatch: false });
constructor(
private readonly actions$: Actions,
private readonly store: Store,
private storage: StorageService
) { }
}

View File

@@ -3,22 +3,22 @@ import { GotobedState, initialGotoBedState } from './gotobed.state';
export function gotobedReducer(state = initialGotoBedState, action: GotobedActions): GotobedState {
switch (action.type) {
case EGotobedActions.SendCommandChanged:
case EGotobedActions.sendCommandChanged:
return {
...state,
command: action.payload,
};
case EGotobedActions.ProtocolSettingsChanged:
case EGotobedActions.protocolSettingsChanged:
return {
...state,
protocol: action.payload,
};
case EGotobedActions.AddressSettingsChanged:
case EGotobedActions.addressSettingsChanged:
return {
...state,
address: action.payload,
};
case EGotobedActions.PortSettingsChanged:
case EGotobedActions.portSettingsChanged:
return {
...state,
port: action.payload,
@@ -26,4 +26,4 @@ export function gotobedReducer(state = initialGotoBedState, action: GotobedActio
default:
return state;
}
}
};

View File

@@ -1,8 +1,7 @@
import { AddressStorageKey, PortStorageKey, ProtocolStorageKey } from "../gotobed.models";
import { addressStorageKey, portStorageKey, protocolStorageKey } from '../gotobed.models';
export const storeName = 'Gotobed';
export interface GotobedState {
command: string;
isLoading: boolean;
@@ -15,9 +14,9 @@ export interface GotobedState {
export const initialGotoBedState: GotobedState = {
command: '',
isLoading: false,
protocol: localStorage.getItem(ProtocolStorageKey) ?? "http",
port: localStorage.getItem(PortStorageKey) ?? '3000',
address: localStorage.getItem(AddressStorageKey) ?? 'localhost:8080',
protocol: localStorage.getItem(protocolStorageKey) ?? 'http',
port: localStorage.getItem(portStorageKey) ?? '3000',
address: localStorage.getItem(addressStorageKey) ?? 'localhost:8080',
isConnected: false,
};
@@ -25,4 +24,4 @@ export interface LoadSettingsState {
protocol: string;
port: string;
address: string;
}
}

View File

@@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { gotobedReducer } from './gotobed.reducer';
import { GotobedEffects } from './gotoved.effects';
import { GotobedEffects } from './gotobed.effects';
@NgModule({
imports: [

View File

@@ -1,69 +0,0 @@
import { PortStorageKey } from './../gotobed.models';
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType, concatLatestFrom, ROOT_EFFECTS_INIT } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { map, tap, withLatestFrom } from 'rxjs/operators';
import { AddressStorageKey, ProtocolStorageKey } from '../gotobed.models';
import { StorageService } from '../services/storage.service';
import { AppInitialized, EGotobedActions, ProtocolSettingsChanged, SaveAddressSettings, SendCommandChanged } from './gotobed.actions';
@Injectable()
export class GotobedEffects {
init$ = createEffect(() =>
this._actions$.pipe(
ofType<AppInitialized>(ROOT_EFFECTS_INIT),
concatLatestFrom(() => this._store),
map(async ([action]) => {
this.storage.initializeStorage();
console.log("Loading# Srorage")
return action.payload = {
address: localStorage.getItem(AddressStorageKey),
port: localStorage.getItem(PortStorageKey),
protocol: localStorage.getItem(ProtocolStorageKey),
}
})
), { dispatch: false }
);
saveAddressSettings$ = createEffect(() => this._actions$.pipe(
ofType<SaveAddressSettings>(EGotobedActions.AddressSettingsChanged),
withLatestFrom(this._store),
tap(([action, state]) => {
//this.storage.addToStorage(ProtocolStorageKey, action.payload);
localStorage.setItem(AddressStorageKey, action.payload);
})
), { dispatch: false });
logCommand$ = createEffect(() => this._actions$.pipe(
ofType<SendCommandChanged>(EGotobedActions.SendCommandChanged),
withLatestFrom(this._store),
tap(([action, state]) => {
//this.storage.addToStorage(AddressStorageKey, action.payload);
})
), { dispatch: false });
saveProtocolSettings$ = createEffect(() => this._actions$.pipe(
ofType<ProtocolSettingsChanged>(EGotobedActions.ProtocolSettingsChanged),
withLatestFrom(this._store),
tap(([action, state]) => {
//this.storage.addToStorage(ProtocolStorageKey, action.payload);
localStorage.setItem(ProtocolStorageKey, action.payload);
})
), { dispatch: false });
savePortSettings$ = createEffect(() => this._actions$.pipe(
ofType<ProtocolSettingsChanged>(EGotobedActions.PortSettingsChanged),
withLatestFrom(this._store),
tap(([action, state]) => {
//this.storage.addToStorage(PortStorageKey, action.payload);
localStorage.setItem(PortStorageKey, action.payload);
})
), { dispatch: false });
constructor(
private readonly _actions$: Actions,
private readonly _store: Store,
private storage: StorageService
) { }
}

View File

@@ -1,28 +1,10 @@
/*
* App Global CSS
* ----------------------------------------------------------------------------
* Put style rules here that you want to apply globally. These styles are for
* the entire app and not just one component. Additionally, this file can be
* used as an entry point to import other CSS/Sass files to be included in the
* output CSS.
* For more information on global stylesheets, visit the documentation:
* https://ionicframework.com/docs/layout/global-stylesheets
*/
/* Core CSS required for Ionic components to work properly */
@import "~@ionic/angular/css/core.css";
/* Basic CSS for apps built with Ionic */
@import "~@ionic/angular/css/normalize.css";
@import "~@ionic/angular/css/structure.css";
@import "~@ionic/angular/css/typography.css";
@import '~@ionic/angular/css/display.css';
/* Optional CSS utils that can be commented out */
@import "~@ionic/angular/css/padding.css";
@import "~@ionic/angular/css/float-elements.css";
@import "~@ionic/angular/css/text-alignment.css";
@import "~@ionic/angular/css/text-transformation.css";
@import "~@ionic/angular/css/flex-utils.css";
// $nb-enable-css-custom-properties: false; // <-- enable css custom properties
@import "~@ionic/angular/css/flex-utils.css";

View File

@@ -1,26 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>GOTOBED</title>
<base href="/" />
<meta name="color-scheme" content="dark" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<link rel="icon" type="image/png" href="assets/icon/favicon.png" />
<!-- add to menuscreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body>
<app-root></app-root>
</body>
<head>
<meta charset="utf-8" />
<title>GOTOBED</title>
<base href="/" />
<meta name="color-scheme" content="dark" />
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<link rel="icon" type="image/png" href="assets/icon/favicon.png" />
<!-- add to menuscreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@@ -1,6 +1,5 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

View File

@@ -1,10 +1,4 @@
// Ionic Variables and Theming. For more info, please see:
// http://ionicframework.com/docs/theming/
/** Ionic CSS Variables **/
:root {
/** primary **/
--ion-color-primary: #3880ff;
--ion-color-primary-rgb: 56, 128, 255;
--ion-color-primary-contrast: #ffffff;
@@ -379,396 +373,5 @@
--ion-color-shade: var(--ion-color-academind-shade);
--ion-color-tint: var(--ion-color-academind-tint);
}
// }
// // Ionic Variables and Theming. For more info, please see:
// // http://ionicframework.com/docs/theming/
// /** Ionic CSS Variables **/
// :root {
// /** primary **/
// --ion-color-primary: #3880FF;
// --ion-color-primary-rgb: 56, 128, 255;
// --ion-color-primary-contrast: #ffffff;
// --ion-color-primary-contrast-rgb: 255, 255, 255;
// --ion-color-primary-shade: #3171e0;
// --ion-color-primary-tint: #4c8dff;
// /** secondary **/
// --ion-color-secondary: #3dc2ff;
// --ion-color-secondary-rgb: 61, 194, 255;
// --ion-color-secondary-contrast: #ffffff;
// --ion-color-secondary-contrast-rgb: 255, 255, 255;
// --ion-color-secondary-shade: #36abe0;
// --ion-color-secondary-tint: #50c8ff;
// /** tertiary **/
// --ion-color-tertiary: #5260ff;
// --ion-color-tertiary-rgb: 82, 96, 255;
// --ion-color-tertiary-contrast: #ffffff;
// --ion-color-tertiary-contrast-rgb: 255, 255, 255;
// --ion-color-tertiary-shade: #4854e0;
// --ion-color-tertiary-tint: #6370ff;
// /** success **/
// --ion-color-success: #2dd36f;
// --ion-color-success-rgb: 45, 211, 111;
// --ion-color-success-contrast: #ffffff;
// --ion-color-success-contrast-rgb: 255, 255, 255;
// --ion-color-success-shade: #28ba62;
// --ion-color-success-tint: #42d77d;
// /** warning **/
// --ion-color-warning: #ffc409;
// --ion-color-warning-rgb: 255, 196, 9;
// --ion-color-warning-contrast: #000000;
// --ion-color-warning-contrast-rgb: 0, 0, 0;
// --ion-color-warning-shade: #e0ac08;
// --ion-color-warning-tint: #ffca22;
// /** danger **/
// --ion-color-danger: #eb445a;
// --ion-color-danger-rgb: 235, 68, 90;
// --ion-color-danger-contrast: #ffffff;
// --ion-color-danger-contrast-rgb: 255, 255, 255;
// --ion-color-danger-shade: #cf3c4f;
// --ion-color-danger-tint: #ed576b;
// /** dark **/
// --ion-color-dark: #222428;
// --ion-color-dark-rgb: 34, 36, 40;
// --ion-color-dark-contrast: #ffffff;
// --ion-color-dark-contrast-rgb: 255, 255, 255;
// --ion-color-dark-shade: #1e2023;
// --ion-color-dark-tint: #383a3e;
// /** medium **/
// --ion-color-medium: #92949c;
// --ion-color-medium-rgb: 146, 148, 156;
// --ion-color-medium-contrast: #ffffff;
// --ion-color-medium-contrast-rgb: 255, 255, 255;
// --ion-color-medium-shade: #808289;
// --ion-color-medium-tint: #9d9fa6;
// /** light **/
// --ion-color-light: #f4f5f8;
// --ion-color-light-rgb: 244, 245, 248;
// --ion-color-light-contrast: #000000;
// --ion-color-light-contrast-rgb: 0, 0, 0;
// --ion-color-light-shade: #d7d8da;
// --ion-color-light-tint: #f5f6f9;
// }
// @media (prefers-color-scheme: dark) {
// /*
// * Dark Colors
// * -------------------------------------------
// */
// body {
// --ion-color-primary: #afccff;
// --ion-color-primary-rgb: 175, 204, 255;
// --ion-color-primary-contrast: #000000;
// --ion-color-primary-contrast-rgb: 0, 0, 0;
// --ion-color-primary-shade: #9ab4e0;
// --ion-color-primary-tint: #b7d1ff;
// --ion-color-secondary: #50c8ff;
// --ion-color-secondary-rgb: 80,200,255;
// --ion-color-secondary-contrast: #ffffff;
// --ion-color-secondary-contrast-rgb: 255,255,255;
// --ion-color-secondary-shade: #46b0e0;
// --ion-color-secondary-tint: #62ceff;
// --ion-color-tertiary: #6a64ff;
// --ion-color-tertiary-rgb: 106,100,255;
// --ion-color-tertiary-contrast: #ffffff;
// --ion-color-tertiary-contrast-rgb: 255,255,255;
// --ion-color-tertiary-shade: #5d58e0;
// --ion-color-tertiary-tint: #7974ff;
// --ion-color-success: #2fdf75;
// --ion-color-success-rgb: 47,223,117;
// --ion-color-success-contrast: #000000;
// --ion-color-success-contrast-rgb: 0,0,0;
// --ion-color-success-shade: #29c467;
// --ion-color-success-tint: #44e283;
// --ion-color-warning: #ffd534;
// --ion-color-warning-rgb: 255,213,52;
// --ion-color-warning-contrast: #000000;
// --ion-color-warning-contrast-rgb: 0,0,0;
// --ion-color-warning-shade: #e0bb2e;
// --ion-color-warning-tint: #ffd948;
// --ion-color-danger: #ff4961;
// --ion-color-danger-rgb: 255,73,97;
// --ion-color-danger-contrast: #ffffff;
// --ion-color-danger-contrast-rgb: 255,255,255;
// --ion-color-danger-shade: #e04055;
// --ion-color-danger-tint: #ff5b71;
// --ion-color-dark: #f4f5f8;
// --ion-color-dark-rgb: 244,245,248;
// --ion-color-dark-contrast: #000000;
// --ion-color-dark-contrast-rgb: 0,0,0;
// --ion-color-dark-shade: #d7d8da;
// --ion-color-dark-tint: #f5f6f9;
// --ion-color-medium: #989aa2;
// --ion-color-medium-rgb: 152,154,162;
// --ion-color-medium-contrast: #000000;
// --ion-color-medium-contrast-rgb: 0,0,0;
// --ion-color-medium-shade: #86888f;
// --ion-color-medium-tint: #a2a4ab;
// --ion-color-light: #222428;
// --ion-color-light-rgb: 34,36,40;
// --ion-color-light-contrast: #ffffff;
// --ion-color-light-contrast-rgb: 255,255,255;
// --ion-color-light-shade: #1e2023;
// --ion-color-light-tint: #383a3e;
// }
// /*
// * iOS Dark Theme
// * -------------------------------------------
// */
// .ios body {
// --ion-background-color: #1b1b38;
// --ion-background-color-rgb: 0,0,0;
// --ion-text-color: #ffffff;
// --ion-text-color-rgb: 255,255,255;
// --ion-color-step-50: #0d0d0d;
// --ion-color-step-100: #1a1a1a;
// --ion-color-step-150: #262626;
// --ion-color-step-200: #333333;
// --ion-color-step-250: #404040;
// --ion-color-step-300: #4d4d4d;
// --ion-color-step-350: #595959;
// --ion-color-step-400: #666666;
// --ion-color-step-450: #737373;
// --ion-color-step-500: #808080;
// --ion-color-step-550: #8c8c8c;
// --ion-color-step-600: #999999;
// --ion-color-step-650: #a6a6a6;
// --ion-color-step-700: #b3b3b3;
// --ion-color-step-750: #bfbfbf;
// --ion-color-step-800: #cccccc;
// --ion-color-step-850: #d9d9d9;
// --ion-color-step-900: #e6e6e6;
// --ion-color-step-950: #f2f2f2;
// --ion-item-background: #000000;
// --ion-card-background: #1c1c1d;
// }
// .ios ion-modal {
// --ion-background-color: var(--ion-color-step-100);
// --ion-toolbar-background: var(--ion-color-step-150);
// --ion-toolbar-border-color: var(--ion-color-step-250);
// }
// /*
// * Material Design Dark Theme
// * -------------------------------------------
// */
// .md body {
// --ion-background-color: #121212;
// --ion-background-color-rgb: 18,18,18;
// --ion-text-color: #ffffff;
// --ion-text-color-rgb: 255,255,255;
// --ion-border-color: #222222;
// --ion-color-step-50: #1e1e1e;
// --ion-color-step-100: #2a2a2a;
// --ion-color-step-150: #363636;
// --ion-color-step-200: #414141;
// --ion-color-step-250: #4d4d4d;
// --ion-color-step-300: #595959;
// --ion-color-step-350: #656565;
// --ion-color-step-400: #717171;
// --ion-color-step-450: #7d7d7d;
// --ion-color-step-500: #898989;
// --ion-color-step-550: #949494;
// --ion-color-step-600: #a0a0a0;
// --ion-color-step-650: #acacac;
// --ion-color-step-700: #b8b8b8;
// --ion-color-step-750: #c4c4c4;
// --ion-color-step-800: #d0d0d0;
// --ion-color-step-850: #dbdbdb;
// --ion-color-step-900: #e7e7e7;
// --ion-color-step-950: #f3f3f3;
// --ion-item-background: #1e1e1e;
// --ion-toolbar-background: #1f1f1f;
// --ion-tab-bar-background: #1f1f1f;
// --ion-card-background: #1e1e1e;
// }
// }
// body.dark {
// --ion-color-primary: #428cff;
// --ion-color-primary-rgb: 66, 140, 255;
// --ion-color-primary-contrast: #ffffff;
// --ion-color-primary-contrast-rgb: 255, 255, 255;
// --ion-color-primary-shade: #3a7be0;
// --ion-color-primary-tint: #5598ff;
// --ion-color-secondary: #50c8ff;
// --ion-color-secondary-rgb: 80, 200, 255;
// --ion-color-secondary-contrast: #ffffff;
// --ion-color-secondary-contrast-rgb: 255, 255, 255;
// --ion-color-secondary-shade: #46b0e0;
// --ion-color-secondary-tint: #62ceff;
// --ion-color-tertiary: #6a64ff;
// --ion-color-tertiary-rgb: 106, 100, 255;
// --ion-color-tertiary-contrast: #ffffff;
// --ion-color-tertiary-contrast-rgb: 255, 255, 255;
// --ion-color-tertiary-shade: #5d58e0;
// --ion-color-tertiary-tint: #7974ff;
// --ion-color-success: #2fdf75;
// --ion-color-success-rgb: 47, 223, 117;
// --ion-color-success-contrast: #000000;
// --ion-color-success-contrast-rgb: 0, 0, 0;
// --ion-color-success-shade: #29c467;
// --ion-color-success-tint: #44e283;
// --ion-color-warning: #ffd534;
// --ion-color-warning-rgb: 255, 213, 52;
// --ion-color-warning-contrast: #000000;
// --ion-color-warning-contrast-rgb: 0, 0, 0;
// --ion-color-warning-shade: #e0bb2e;
// --ion-color-warning-tint: #ffd948;
// --ion-color-danger: #ff4961;
// --ion-color-danger-rgb: 255, 73, 97;
// --ion-color-danger-contrast: #ffffff;
// --ion-color-danger-contrast-rgb: 255, 255, 255;
// --ion-color-danger-shade: #e04055;
// --ion-color-danger-tint: #ff5b71;
// --ion-color-dark: #f4f5f8;
// --ion-color-dark-rgb: 244, 245, 248;
// --ion-color-dark-contrast: #000000;
// --ion-color-dark-contrast-rgb: 0, 0, 0;
// --ion-color-dark-shade: #d7d8da;
// --ion-color-dark-tint: #f5f6f9;
// --ion-color-medium: #989aa2;
// --ion-color-medium-rgb: 152, 154, 162;
// --ion-color-medium-contrast: #000000;
// --ion-color-medium-contrast-rgb: 0, 0, 0;
// --ion-color-medium-shade: #86888f;
// --ion-color-medium-tint: #a2a4ab;
// --ion-color-light: #222428;
// --ion-color-light-rgb: 34, 36, 40;
// --ion-color-light-contrast: #ffffff;
// --ion-color-light-contrast-rgb: 255, 255, 255;
// --ion-color-light-shade: #1e2023;
// --ion-color-light-tint: #383a3e;
// }
// /*
// * iOS Dark Theme
// * -------------------------------------------
// */
// .ios body.dark {
// --ion-background-color: #000000;
// --ion-background-color-rgb: 0, 0, 0;
// --ion-text-color: #ffffff;
// --ion-text-color-rgb: 255, 255, 255;
// --ion-color-step-50: #0d0d0d;
// --ion-color-step-100: #1a1a1a;
// --ion-color-step-150: #262626;
// --ion-color-step-200: #333333;
// --ion-color-step-250: #404040;
// --ion-color-step-300: #4d4d4d;
// --ion-color-step-350: #595959;
// --ion-color-step-400: #666666;
// --ion-color-step-450: #737373;
// --ion-color-step-500: #808080;
// --ion-color-step-550: #8c8c8c;
// --ion-color-step-600: #999999;
// --ion-color-step-650: #a6a6a6;
// --ion-color-step-700: #b3b3b3;
// --ion-color-step-750: #bfbfbf;
// --ion-color-step-800: #cccccc;
// --ion-color-step-850: #d9d9d9;
// --ion-color-step-900: #e6e6e6;
// --ion-color-step-950: #f2f2f2;
// --ion-item-background: #000000;
// --ion-card-background: #1c1c1d;
// }
// .ios body.dark ion-modal {
// --ion-background-color: var(--ion-color-step-100);
// --ion-toolbar-background: var(--ion-color-step-150);
// --ion-toolbar-border-color: var(--ion-color-step-250);
// --ion-item-background: var(--ion-color-step-150);
// }
// /*
// * Material Design Dark Theme
// * -------------------------------------------
// */
// .md body.dark {
// --ion-background-color: #121212;
// --ion-background-color-rgb: 18, 18, 18;
// --ion-text-color: #ffffff;
// --ion-text-color-rgb: 255, 255, 255;
// --ion-border-color: #222222;
// --ion-color-step-50: #1e1e1e;
// --ion-color-step-100: #2a2a2a;
// --ion-color-step-150: #363636;
// --ion-color-step-200: #414141;
// --ion-color-step-250: #4d4d4d;
// --ion-color-step-300: #595959;
// --ion-color-step-350: #656565;
// --ion-color-step-400: #717171;
// --ion-color-step-450: #7d7d7d;
// --ion-color-step-500: #898989;
// --ion-color-step-550: #949494;
// --ion-color-step-600: #a0a0a0;
// --ion-color-step-650: #acacac;
// --ion-color-step-700: #b8b8b8;
// --ion-color-step-750: #c4c4c4;
// --ion-color-step-800: #d0d0d0;
// --ion-color-step-850: #dbdbdb;
// --ion-color-step-900: #e7e7e7;
// --ion-color-step-950: #f3f3f3;
// --ion-item-background: #1e1e1e;
// --ion-toolbar-background: #1f1f1f;
// --ion-tab-bar-background: #1f1f1f;
// --ion-card-background: #1e1e1e;
// }
@import 'themes';