2 Ревизии 4e66dc0b61 ... 03c647a39e

Автор SHA1 Съобщение Дата
  Jorge Baquero 03c647a39e changes in the start of the app. In this moment doesn't show anymore the home screen when start the app in remember mode преди 7 години
  Jorge Baquero f4ba96fd27 Changes in the initialization of the app преди 7 години

+ 1 - 2
config.xml Целия файл

@@ -90,6 +90,5 @@
90 90
     <allow-navigation href="http://192.168.0.7:8100" />
91 91
     <plugin name="cordova-sqlite-storage" spec="^2.2.1" />
92 92
     <allow-navigation href="http://192.168.43.167:8100" />
93
-    <plugin name="cordova-plugin-x-socialsharing" spec="^5.3.2" />
94
-    <plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" spec="^4.2.0" />
93
+    <plugin name="cordova-plugin-local-notification" spec="^0.9.0-beta.2" />
95 94
 </widget>

+ 20 - 15
package-lock.json Целия файл

@@ -106,6 +106,16 @@
106 106
       "resolved": "https://registry.npmjs.org/@ionic-native/launch-navigator/-/launch-navigator-4.6.0.tgz",
107 107
       "integrity": "sha512-4BO2r/E1rnar+H/KIPbzBDwfsgUOVduFDfcU9Jx/bkB31FRbZKeW268jBFzZlPxOrg+hazmjs0w11ibgItDP9w=="
108 108
     },
109
+    "@ionic-native/local-notifications": {
110
+      "version": "4.7.0",
111
+      "resolved": "https://registry.npmjs.org/@ionic-native/local-notifications/-/local-notifications-4.7.0.tgz",
112
+      "integrity": "sha512-OVXpxF+JcHMvz11oKCEbJRLr/dlWQy/0HQYJMTk18cdevXVjju4IPazuhqTpTTxIXjBvTLHfUKu7rBO1ZJ8JRw=="
113
+    },
114
+    "@ionic-native/push": {
115
+      "version": "4.7.0",
116
+      "resolved": "https://registry.npmjs.org/@ionic-native/push/-/push-4.7.0.tgz",
117
+      "integrity": "sha512-ynucoNm2Kg30rYAdgOv0h9oGGjVLz+AugL7O1/ng5piMFhC46O/eIUDJPTwkPqyM1USR/d99zbosttRo9aNgLg=="
118
+    },
109 119
     "@ionic-native/social-sharing": {
110 120
       "version": "4.6.0",
111 121
       "resolved": "https://registry.npmjs.org/@ionic-native/social-sharing/-/social-sharing-4.6.0.tgz",
@@ -1329,6 +1339,11 @@
1329 1339
       "resolved": "https://registry.npmjs.org/cordova-plugin-actionsheet/-/cordova-plugin-actionsheet-2.3.3.tgz",
1330 1340
       "integrity": "sha1-6SYbLQBKjaQHOI1g31NMFWxS/xE="
1331 1341
     },
1342
+    "cordova-plugin-badge": {
1343
+      "version": "0.8.7",
1344
+      "resolved": "https://registry.npmjs.org/cordova-plugin-badge/-/cordova-plugin-badge-0.8.7.tgz",
1345
+      "integrity": "sha512-s+s4yusKdeJ4sMPhQs4zR3lR2UuROzSy14GFAp00pTHPiBfCtxeINSUYAZYnpuO3RGx6PPlVCwSJpVG0IdM58g=="
1346
+    },
1332 1347
     "cordova-plugin-device": {
1333 1348
       "version": "2.0.1",
1334 1349
       "resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.1.tgz",
@@ -1354,6 +1369,11 @@
1354 1369
       "resolved": "https://registry.npmjs.org/cordova-plugin-ionic-webview/-/cordova-plugin-ionic-webview-1.1.16.tgz",
1355 1370
       "integrity": "sha512-57EW4qNkKyCfcVt0pH11s88Dvwdtgf2UkbAyPNk2+T1cmLVQ503S/+3Wa3l173J0NGt/QGGyUM8Z66LkqTnoWg=="
1356 1371
     },
1372
+    "cordova-plugin-local-notification": {
1373
+      "version": "0.9.0-beta.2",
1374
+      "resolved": "https://registry.npmjs.org/cordova-plugin-local-notification/-/cordova-plugin-local-notification-0.9.0-beta.2.tgz",
1375
+      "integrity": "sha512-63n77K1pt8dnbWnNR8QWETi9Glezi1bvNHvHWmGNIOv0xCb0phZnm+Ku49BQ+omwe8Z5voMvrA4I03SYPpv38w=="
1376
+    },
1357 1377
     "cordova-plugin-splashscreen": {
1358 1378
       "version": "5.0.2",
1359 1379
       "resolved": "https://registry.npmjs.org/cordova-plugin-splashscreen/-/cordova-plugin-splashscreen-5.0.2.tgz",
@@ -1364,11 +1384,6 @@
1364 1384
       "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.3.tgz",
1365 1385
       "integrity": "sha1-tehezbv+Wu3tQKG/TuI3LmfZb7Q="
1366 1386
     },
1367
-    "cordova-plugin-x-socialsharing": {
1368
-      "version": "5.3.2",
1369
-      "resolved": "https://registry.npmjs.org/cordova-plugin-x-socialsharing/-/cordova-plugin-x-socialsharing-5.3.2.tgz",
1370
-      "integrity": "sha1-8SBYny+lB+kqMG8lypV7lvmWhrE="
1371
-    },
1372 1387
     "cordova-sqlite-storage": {
1373 1388
       "version": "2.2.1",
1374 1389
       "resolved": "https://registry.npmjs.org/cordova-sqlite-storage/-/cordova-sqlite-storage-2.2.1.tgz",
@@ -1757,11 +1772,6 @@
1757 1772
         "event-emitter": "0.3.5"
1758 1773
       }
1759 1774
     },
1760
-    "es6-promise-plugin": {
1761
-      "version": "4.2.2",
1762
-      "resolved": "https://registry.npmjs.org/es6-promise-plugin/-/es6-promise-plugin-4.2.2.tgz",
1763
-      "integrity": "sha512-uoA4aVplXI9oqUYJFBAVRwAqIN9/n9JgrTAUGX3qPbnSZVE5yY1+6/MsoN5f4xsaPO62WjPHOdtts6okMN6tNA=="
1764
-    },
1765 1775
     "es6-set": {
1766 1776
       "version": "0.1.5",
1767 1777
       "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
@@ -6264,11 +6274,6 @@
6264 6274
         }
6265 6275
       }
6266 6276
     },
6267
-    "uk.co.workingedge.phonegap.plugin.launchnavigator": {
6268
-      "version": "4.2.0",
6269
-      "resolved": "https://registry.npmjs.org/uk.co.workingedge.phonegap.plugin.launchnavigator/-/uk.co.workingedge.phonegap.plugin.launchnavigator-4.2.0.tgz",
6270
-      "integrity": "sha1-B7NHCzOpwUAVivRigpauIkw0YaU="
6271
-    },
6272 6277
     "ultron": {
6273 6278
       "version": "1.1.1",
6274 6279
       "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",

+ 5 - 5
package.json Целия файл

@@ -23,27 +23,28 @@
23 23
     "@ionic-native/core": "4.4.0",
24 24
     "@ionic-native/google-maps": "^4.5.3",
25 25
     "@ionic-native/launch-navigator": "^4.6.0",
26
+    "@ionic-native/local-notifications": "^4.7.0",
27
+    "@ionic-native/push": "^4.7.0",
26 28
     "@ionic-native/social-sharing": "^4.6.0",
27 29
     "@ionic-native/splash-screen": "4.4.0",
28 30
     "@ionic-native/status-bar": "4.4.0",
29 31
     "@ionic/storage": "^2.1.3",
30 32
     "cordova-android": "7.0.0",
31 33
     "cordova-plugin-actionsheet": "^2.3.3",
34
+    "cordova-plugin-badge": "^0.8.7",
32 35
     "cordova-plugin-device": "^2.0.1",
33 36
     "cordova-plugin-dialogs": "^2.0.1",
34 37
     "cordova-plugin-googlemaps": "^2.2.5",
35 38
     "cordova-plugin-ionic-keyboard": "^2.0.5",
36 39
     "cordova-plugin-ionic-webview": "^1.1.16",
40
+    "cordova-plugin-local-notification": "^0.9.0-beta.2",
37 41
     "cordova-plugin-splashscreen": "^5.0.2",
38 42
     "cordova-plugin-whitelist": "^1.3.3",
39
-    "cordova-plugin-x-socialsharing": "^5.3.2",
40 43
     "cordova-sqlite-storage": "^2.2.1",
41
-    "es6-promise-plugin": "^4.2.2",
42 44
     "ionic-angular": "3.9.2",
43 45
     "ionicons": "3.0.0",
44 46
     "rxjs": "5.5.2",
45 47
     "sw-toolbox": "3.6.0",
46
-    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.2.0",
47 48
     "zone.js": "0.8.18"
48 49
   },
49 50
   "devDependencies": {
@@ -64,8 +65,7 @@
64 65
         "ANDROID_SUPPORT_V4_VERSION": "24.1.0"
65 66
       },
66 67
       "cordova-sqlite-storage": {},
67
-      "cordova-plugin-x-socialsharing": {},
68
-      "uk.co.workingedge.phonegap.plugin.launchnavigator": {}
68
+      "cordova-plugin-local-notification": {}
69 69
     },
70 70
     "platforms": [
71 71
       "android"

+ 33 - 3
src/app/app.component.ts Целия файл

@@ -3,9 +3,12 @@ import { Platform, Nav, AlertController } from 'ionic-angular';
3 3
 import { StatusBar } from '@ionic-native/status-bar';
4 4
 import { SplashScreen } from '@ionic-native/splash-screen';
5 5
 import { Storage } from '@ionic/storage';
6
+import { VespotServiceProvider } from '../providers/vespot-service/vespot-service';
7
+import { ShareService } from '../services/share/share';
6 8
 
7 9
 import { HomePage } from '../pages/home/home';
8 10
 import { DevicesPage } from '../pages/devices/devices';
11
+import { Main } from '../pages/main/main';
9 12
 import { ConfigurationPage } from '../pages/configuration/configuration';
10 13
 
11 14
 @Component({
@@ -13,17 +16,44 @@ import { ConfigurationPage } from '../pages/configuration/configuration';
13 16
 })
14 17
 export class MyApp {
15 18
   @ViewChild(Nav) nav: Nav;
16
-  rootPage:any = HomePage;
19
+  //rootPage:any = HomePage;
17 20
 
18
-  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
21
+  constructor(platform: Platform,
22
+    statusBar: StatusBar,
23
+    splashScreen: SplashScreen,
19 24
     private alertCtrl: AlertController,
20
-  private storage: Storage) {
25
+  private storage: Storage,
26
+  public vespotService: VespotServiceProvider,
27
+  public shareService: ShareService) {
21 28
     /*platform.ready().then(() => {
22 29
       // Okay, so the platform is ready and our plugins are available.
23 30
       // Here you can do any higher level native things you might need.
24 31
       statusBar.styleDefault();
25 32
       splashScreen.hide();
26 33
     });*/
34
+    this.storage.get('remember').then((val)=>{
35
+        if(val) {
36
+          this.storage.get('authentication').then((valAuth)=>{
37
+              this.authenticateUser(valAuth);
38
+          });
39
+        } else {
40
+              this.nav.setRoot(HomePage);
41
+        }
42
+    });
43
+  }
44
+
45
+  authenticateUser(auth) {
46
+    this.vespotService.getDevices(auth)
47
+  	.subscribe(
48
+        (data) => { // Success
49
+          this.shareService.setDevices(data);
50
+          this.shareService.setAuthToken(auth);
51
+          this.nav.setRoot(Main);
52
+        },
53
+        (error) =>{
54
+          this.nav.setRoot(HomePage);
55
+        }
56
+      );
27 57
   }
28 58
 
29 59
   openDevicesPage() {

+ 3 - 5
src/app/app.module.ts Целия файл

@@ -6,8 +6,6 @@ import { StatusBar } from '@ionic-native/status-bar';
6 6
 import { HttpClientModule } from '@angular/common/http';
7 7
 import { GoogleMaps } from '@ionic-native/google-maps';
8 8
 import { IonicStorageModule } from '@ionic/storage';
9
-import { LaunchNavigator, LaunchNavigatorOptions } from '@ionic-native/launch-navigator';
10
-import { SocialSharing } from '@ionic-native/social-sharing';
11 9
 
12 10
 import { MyApp } from './app.component';
13 11
 import { HomePage } from '../pages/home/home';
@@ -15,6 +13,7 @@ import { Main } from '../pages/main/main';
15 13
 import { DevicesPage } from '../pages/devices/devices';
16 14
 import { ConfigurationPage } from '../pages/configuration/configuration';
17 15
 import { VespotServiceProvider } from '../providers/vespot-service/vespot-service';
16
+import { VespotNotificationProvider } from '../providers/vespot-notification/vespot-notification';
18 17
 import { ShareService } from '../services/share/share';
19 18
 
20 19
 @NgModule({
@@ -45,9 +44,8 @@ import { ShareService } from '../services/share/share';
45 44
     GoogleMaps,
46 45
     {provide: ErrorHandler, useClass: IonicErrorHandler},
47 46
     VespotServiceProvider,
48
-    ShareService,
49
-    LaunchNavigator,
50
-    SocialSharing
47
+    VespotNotificationProvider,
48
+    ShareService
51 49
   ]
52 50
 })
53 51
 export class AppModule {}

+ 12 - 1
src/pages/configuration/configuration.html Целия файл

@@ -20,13 +20,24 @@
20 20
       <ion-toggle checked="false" [(ngModel)]="startAlarm" (ionChange)="changeAlarm()"></ion-toggle>
21 21
     </ion-item>
22 22
     <ion-item>
23
-      <ion-label>Tiempo Actualización</ion-label>
23
+      <ion-label>Actualización de mapa a los...</ion-label>
24 24
       <ion-select [(ngModel)]="time" (ionChange)="changeTime()">
25 25
         <ion-option value="15">15 seg</ion-option>
26 26
         <ion-option value="30" selected="true">30 seg</ion-option>
27 27
         <ion-option value="60">60 seg</ion-option>
28 28
       </ion-select>
29 29
     </ion-item>
30
+
31
+    <ion-item>
32
+      <ion-label>Alarma Activa a los...</ion-label>
33
+      <ion-select [(ngModel)]="activeAlarm" (ionChange)="changeActiveAlarm()">
34
+        <ion-option value="2">2 min</ion-option>
35
+        <ion-option value="5" selected="true">5 min</ion-option>
36
+        <ion-option value="10">10 min</ion-option>
37
+        <ion-option value="15">15 min</ion-option>
38
+      </ion-select>
39
+    </ion-item>
40
+
30 41
   </ion-list>
31 42
 
32 43
 </ion-content>

+ 5 - 0
src/pages/configuration/configuration.ts Целия файл

@@ -18,6 +18,7 @@ export class ConfigurationPage {
18 18
 
19 19
   startAlarm: any;
20 20
   time: any;
21
+  activeAlarm: any;
21 22
 
22 23
   constructor(public navCtrl: NavController,
23 24
     public navParams: NavParams,
@@ -41,4 +42,8 @@ export class ConfigurationPage {
41 42
     this.storage.set('time', this.time);
42 43
   }
43 44
 
45
+  changeActiveAlarm() {
46
+    this.storage.set('activeAlarm', this.activeAlarm);
47
+  }
48
+
44 49
 }

+ 2 - 2
src/pages/home/home.ts Целия файл

@@ -21,13 +21,13 @@ export class HomePage {
21 21
 		public vespotService: VespotServiceProvider,
22 22
     public shareService: ShareService,
23 23
     private storage: Storage) {
24
-      this.storage.get('remember').then((val)=>{
24
+      /*this.storage.get('remember').then((val)=>{
25 25
           if(val) {
26 26
             this.storage.get('authentication').then((valAuth)=>{
27 27
                 this.authenticateUser(valAuth);
28 28
             });
29 29
           }
30
-      });
30
+      });*/
31 31
   }
32 32
 
33 33
   /*ionViewCanEnter() {

+ 1 - 5
src/pages/main/main.html Целия файл

@@ -10,11 +10,7 @@
10 10
 <ion-content padding>
11 11
   <div id="map_canvas">
12 12
     <ion-fab right bottom>
13
-      <button ion-fab color="primary"><ion-icon name="car"></ion-icon></button>
14
-      <ion-fab-list side="left">
15
-        <button ion-fab><ion-icon name="map" (click)="shareViaMaps()"></ion-icon></button>
16
-        <button ion-fab><ion-icon name="logo-whatsapp" (click)="shareViaWhatsapp()"></ion-icon></button>
17
-      </ion-fab-list>
13
+      <button ion-fab color="primary" (click)="getPosition()"><ion-icon name="car"></ion-icon></button>
18 14
     </ion-fab>-
19 15
   </div>
20 16
 </ion-content>

+ 1 - 24
src/pages/main/main.ts Целия файл

@@ -3,8 +3,6 @@ import { NavController } from 'ionic-angular';
3 3
 import { AlertController } from 'ionic-angular';
4 4
 import { interval } from 'rxjs/observable/interval';
5 5
 import { Storage } from '@ionic/storage';
6
-import { LaunchNavigator, LaunchNavigatorOptions } from '@ionic-native/launch-navigator';
7
-import { SocialSharing } from '@ionic-native/social-sharing';
8 6
 
9 7
 import { DevicesPage } from '../devices/devices'
10 8
 import { ConfigurationPage } from '../configuration/configuration'
@@ -40,9 +38,7 @@ export class Main {
40 38
   private googleMaps: GoogleMaps,
41 39
   private vespotService: VespotServiceProvider,
42 40
   public alertCtrl: AlertController,
43
-  private storage: Storage,
44
-  private launchNavigator: LaunchNavigator,
45
-  private socialSharing: SocialSharing) {
41
+  private storage: Storage) {
46 42
       this.devicesPage = DevicesPage;
47 43
       this.configurationPage = ConfigurationPage;
48 44
       this.devices = this.shareService.getDevices();
@@ -51,8 +47,6 @@ export class Main {
51 47
 
52 48
   }
53 49
 
54
-
55
-
56 50
   ionViewWillEnter() {
57 51
     if(typeof this.shareService.getRootDevice() == "undefined") {
58 52
       console.log('ionViewWillEnter: Entro al undefined');
@@ -175,21 +169,4 @@ export class Main {
175 169
         );
176 170
   }
177 171
 
178
-  shareViaMaps() {
179
-    let options: LaunchNavigatorOptions = {
180
-      start: 'Bogota, ON'
181
-    };
182
-
183
-    this.launchNavigator.navigate([this.rootPosition.latitude, this.rootPosition.longitude], options)
184
-    .then(
185
-      success => console.log('Launched navigator'),
186
-      error => console.log('Error launching navigator', error)
187
-    );
188
-  }
189
-
190
-  shareViaWhatsarpp() {
191
-    //http://maps.google.com/maps?&z={INSERT_MAP_ZOOM}&mrt={INSERT_TYPE_OF_SEARCH}&t={INSERT_MAP_TYPE}&q={INSERT_MAP_LAT_COORDINATES}+{INSERT_MAP_LONG_COORDINATES}
192
-    this.socialSharing.share('Posición de mi dispositivo', '', null, 'http://maps.google.com/maps?&z=15&mrt=yp&t=k&q=27.9879012+86.9253141')
193
-  }
194
-
195 172
 }

+ 4 - 0
src/providers/vespot-service/vespot-service.ts Целия файл

@@ -31,5 +31,9 @@ export class VespotServiceProvider {
31 31
 
32 32
   getPositionByDeviceId(auth, deviceId) {
33 33
     return this.http.get(this.URL + '/positions/lastdeviceposition?deviceId=' + deviceId, {headers: new HttpHeaders().set('Authorization', 'Basic ' + auth)});
34
+  }
35
+
36
+	getDeviceLastEvent(auth, deviceId) {
37
+    return this.http.get(this.URL + '/events/lastevent?deviceId=' + deviceId, {headers: new HttpHeaders().set('Authorization', 'Basic ' + auth)});
34 38
   }
35 39
 }