Skip to content

Commit

Permalink
Merge pull request #410 from ELNOGAL/production_app
Browse files Browse the repository at this point in the history
Añadido plugin insomnia para evitar suspender dispositivo en modo producción
  • Loading branch information
ELNOGAL authored Dec 30, 2024
2 parents 54deb83 + f718048 commit efc4f1f
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions production_app/static/productionApp/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@
<plugin name="phonegap-plugin-barcodescanner" spec="^8.1.0">
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-insomnia" spec="^4.3.0" />
<engine name="android" spec="7.0.0" />
</widget>
10 changes: 10 additions & 0 deletions production_app/static/productionApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion production_app/static/productionApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@ionic-native/barcode-scanner": "^4.20.0",
"@ionic-native/core": "4.20.0",
"@ionic-native/file": "^4.5.3",
"@ionic-native/insomnia": "^4.20.0",
"@ionic-native/network": "^4.5.3",
"@ionic-native/splash-screen": "4.20.0",
"@ionic-native/status-bar": "4.20.0",
Expand All @@ -30,6 +31,7 @@
"cordova-android": "7.0.0",
"cordova-plugin-device": "^2.1.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-insomnia": "^4.3.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^2.5.3",
"cordova-plugin-splashscreen": "^5.0.4",
Expand Down Expand Up @@ -60,7 +62,8 @@
"cordova-plugin-ionic-keyboard": {},
"phonegap-plugin-barcodescanner": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}
},
"cordova-plugin-insomnia": {}
},
"platforms": [
"android"
Expand Down
21 changes: 20 additions & 1 deletion production_app/static/productionApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
//import { Insomnia } from '@ionic-native/insomnia';

import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
Expand All @@ -16,7 +17,10 @@ export class MyApp {

pages: Array<{ title: string, component: any }>;

constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
constructor(public platform: Platform,
//private insomnia: Insomnia,
public statusBar: StatusBar,
public splashScreen: SplashScreen) {
this.initializeApp();

this.pages = [
Expand All @@ -29,6 +33,14 @@ export class MyApp {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.

// Mantener el dispositivo despierto globalmente
//this.insomnia.keepAwake().then(
// () => console.log('keepAwake success'),
// () => console.log('keepAwake error')
//);

// Configuración inicial de la aplicación
this.statusBar.styleDefault();
this.splashScreen.hide();
});
Expand All @@ -39,4 +51,11 @@ export class MyApp {
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
// Permitimos el modo suspensión cuando la aplicación se cierra
//ngOnDestroy() {
// this.insomnia.allowSleepAgain().then(
// () => console.log('allowSleep success'),
// () => console.log('allowSleep error')
// );
//}
}
2 changes: 1 addition & 1 deletion production_app/static/productionApp/src/app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<ion-footer>
<ion-item text-center color="light">
<span class="version-footer">ProductionApp - Versión: 2024.05.08</span>
<span class="version-footer">ProductionApp - Versión: 2024.30.12</span>
</ion-item>
</ion-footer>
</ion-menu>
Expand Down
3 changes: 2 additions & 1 deletion production_app/static/productionApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { Insomnia } from '@ionic-native/insomnia';
import { HttpModule } from '@angular/http';
import { IonicStorageModule } from '@ionic/storage';
import { Network } from '@ionic-native/network';
Expand Down Expand Up @@ -98,6 +98,7 @@ import { TimerComponent } from '../components/timer/timer';
providers: [
StatusBar,
SplashScreen,
Insomnia,
{ provide: ErrorHandler, useClass: IonicErrorHandler },
File,
Network,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, ViewChildren, QueryList } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController, ModalController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Insomnia } from '@ionic-native/insomnia';
import { HomePage } from '../../pages/home/home';
import { ChecksModalPage } from '../../pages/checks-modal/checks-modal';
import { CalculatorModalPage } from '../../pages/calculator/calculator';
Expand Down Expand Up @@ -30,16 +31,29 @@ export class ProductionPage {
constructor(public navCtrl: NavController, private storage: Storage,
public navParams: NavParams, public alertCtrl: AlertController,
public modalCtrl: ModalController,
private prodData: ProductionProvider) {
private prodData: ProductionProvider,
private insomnia: Insomnia) {
this.storage.get('CONEXION').then((con_data) => {
this.navbarColor = con_data.company == 'qv' ? 'qv' : 'vq';
})
}

ionViewDidLoad() {
this.insomnia.keepAwake().then(
() => console.log('keepAwake success'),
() => console.log('keepAwake error')
);
this.initProduction();
}

ionViewWillUnload() {
// Permitimos el modo suspensión de nuevo
this.insomnia.allowSleepAgain().then(
() => console.log('allowSleep success'),
() => console.log('allowSleep error')
);
}

initProduction() {
this.clearIntervales();
this.timer.toArray()[0].initTimer();
Expand Down

0 comments on commit efc4f1f

Please sign in to comment.