Skip to content

Commit

Permalink
fix: load in AfterInit
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuioli committed Jul 4, 2019
1 parent 35cb73f commit 00c7f8f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
5 changes: 5 additions & 0 deletions cordova/package-lock.json

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

7 changes: 4 additions & 3 deletions cordova/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"description": "Odoo App for Community version.",
"main": "index.js",
"scripts": {
"build:android": "cordova-icon && cordova-splash && cordova build android",
"build:android_debug": "cordova build android --debug",
"build:android": "cordova-icon && cordova-splash && cordova build android",
"build:android_debug": "cordova build android --debug",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Moldeo Interactive",
"license": "Apache-2.0",
"dependencies": {
"cordova-android": "^7.1.4",
"cordova-plugin-background-mode": "^0.7.2",
"cordova-plugin-network-information": "2.0.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-whitelist": "^1.3.3"
Expand All @@ -27,4 +28,4 @@
"android"
]
}
}
}
2 changes: 1 addition & 1 deletion cordova/plugins/android.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
}
},
"dependent_plugins": {}
}
}
12 changes: 10 additions & 2 deletions cordova/plugins/fetch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cordova-plugin-whitelist": {
"source": {
"type": "registry",
"id": "cordova-plugin-whitelist@^1.3.3"
"id": "cordova-plugin-whitelist@1"
},
"is_top_level": true,
"variables": {}
Expand All @@ -18,7 +18,15 @@
"cordova-plugin-network-information": {
"source": {
"type": "registry",
"id": "cordova-plugin-network-information"
"id": "cordova-plugin-network-information@2.0.1"
},
"is_top_level": true,
"variables": {}
},
"cordova-plugin-background-mode": {
"source": {
"type": "registry",
"id": "cordova-plugin-background-mode"
},
"is_top_level": true,
"variables": {}
Expand Down
1 change: 0 additions & 1 deletion cordova/www/README.md

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<section class="container" *ngIf="odoo_login">
<div class="row">
<div class="col-12 text-center">
<form (submit)="validate()">
<form>
<mat-form-field class="box-responsive">
<input matInput placeholder="Odoo Server URL" [value]="odoo_url_value" required #odoo_url>
<mat-icon class="icon" color="primary" inline="true">insert_link</mat-icon>
Expand All @@ -30,7 +30,7 @@
<input matInput type="password" placeholder="Password" [value]="odoo_pass_value" required #odoo_pass>
<mat-icon class="icon" color="primary" inline="true">lock</mat-icon>
</mat-form-field>
<button mat-raised-button color="primary">Log Odoo Server</button>
<button (click)="validate()" mat-raised-button color="primary">Log Odoo Server</button>
</form>
</div>
</div>
Expand Down
23 changes: 17 additions & 6 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, ElementRef, Renderer2 } from '@angular/core';
import { Component, OnInit, ViewChild, ElementRef, Renderer2, AfterViewInit } from '@angular/core';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { JsonService } from './services/json.service';
import { timer } from 'rxjs';
Expand All @@ -12,11 +12,11 @@ declare var cordova: any;
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
@ViewChild('odoo_url', {static: true}) odoo_url: ElementRef;
@ViewChild('odoo_db', {static: true}) odoo_db: ElementRef;
@ViewChild('odoo_user', {static: true}) odoo_user: ElementRef;
@ViewChild('odoo_pass', {static: true}) odoo_pass: ElementRef;
export class AppComponent implements OnInit, AfterViewInit {
@ViewChild('odoo_url', {static: false}) odoo_url: ElementRef;
@ViewChild('odoo_db', {static: false}) odoo_db: ElementRef;
@ViewChild('odoo_user', {static: false}) odoo_user: ElementRef;
@ViewChild('odoo_pass', {static: false}) odoo_pass: ElementRef;
public odoo_url_value = '';
public odoo_db_value = '';
public odoo_user_value = '';
Expand Down Expand Up @@ -54,7 +54,9 @@ export class AppComponent implements OnInit {
console.log(navigator.connection.type);
this_.network = true;
});
}

public ngAfterViewInit(): void {
this.logData();
}

Expand All @@ -63,6 +65,15 @@ export class AppComponent implements OnInit {
this.odoo_db_value = window.localStorage.getItem('db');
this.odoo_user_value = window.localStorage.getItem('user');
this.odoo_pass_value = window.localStorage.getItem('pass');

const secondsCounter = timer(500); // Pre-Loading

secondsCounter.subscribe( () => {
if (window.localStorage.getItem('url') && window.localStorage.getItem('db') &&
window.localStorage.getItem('user') && window.localStorage.getItem('pass')) {
this.validate();
}
});
}

public logIn(): void {
Expand Down

0 comments on commit 00c7f8f

Please sign in to comment.