Просмотр исходного кода

Changes in the initialization of the app

Jorge Baquero 7 лет назад
Родитель
Сommit
f4ba96fd27
8 измененных файлов: 45 добавлений и 62 удалений
  1. 0 2
      config.xml
  2. 5 15
      package-lock.json
  3. 2 6
      package.json
  4. 33 3
      src/app/app.component.ts
  5. 1 5
      src/app/app.module.ts
  6. 2 2
      src/pages/home/home.ts
  7. 1 5
      src/pages/main/main.html
  8. 1 24
      src/pages/main/main.ts

+ 0 - 2
config.xml Просмотреть файл

@@ -90,6 +90,4 @@
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" />
95 93
 </widget>

+ 5 - 15
package-lock.json Просмотреть файл

@@ -106,6 +106,11 @@
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/push": {
110
+      "version": "4.7.0",
111
+      "resolved": "https://registry.npmjs.org/@ionic-native/push/-/push-4.7.0.tgz",
112
+      "integrity": "sha512-ynucoNm2Kg30rYAdgOv0h9oGGjVLz+AugL7O1/ng5piMFhC46O/eIUDJPTwkPqyM1USR/d99zbosttRo9aNgLg=="
113
+    },
109 114
     "@ionic-native/social-sharing": {
110 115
       "version": "4.6.0",
111 116
       "resolved": "https://registry.npmjs.org/@ionic-native/social-sharing/-/social-sharing-4.6.0.tgz",
@@ -1364,11 +1369,6 @@
1364 1369
       "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.3.tgz",
1365 1370
       "integrity": "sha1-tehezbv+Wu3tQKG/TuI3LmfZb7Q="
1366 1371
     },
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 1372
     "cordova-sqlite-storage": {
1373 1373
       "version": "2.2.1",
1374 1374
       "resolved": "https://registry.npmjs.org/cordova-sqlite-storage/-/cordova-sqlite-storage-2.2.1.tgz",
@@ -1757,11 +1757,6 @@
1757 1757
         "event-emitter": "0.3.5"
1758 1758
       }
1759 1759
     },
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 1760
     "es6-set": {
1766 1761
       "version": "0.1.5",
1767 1762
       "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
@@ -6264,11 +6259,6 @@
6264 6259
         }
6265 6260
       }
6266 6261
     },
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 6262
     "ultron": {
6273 6263
       "version": "1.1.1",
6274 6264
       "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",

+ 2 - 6
package.json Просмотреть файл

@@ -23,6 +23,7 @@
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/push": "^4.7.0",
26 27
     "@ionic-native/social-sharing": "^4.6.0",
27 28
     "@ionic-native/splash-screen": "4.4.0",
28 29
     "@ionic-native/status-bar": "4.4.0",
@@ -36,14 +37,11 @@
36 37
     "cordova-plugin-ionic-webview": "^1.1.16",
37 38
     "cordova-plugin-splashscreen": "^5.0.2",
38 39
     "cordova-plugin-whitelist": "^1.3.3",
39
-    "cordova-plugin-x-socialsharing": "^5.3.2",
40 40
     "cordova-sqlite-storage": "^2.2.1",
41
-    "es6-promise-plugin": "^4.2.2",
42 41
     "ionic-angular": "3.9.2",
43 42
     "ionicons": "3.0.0",
44 43
     "rxjs": "5.5.2",
45 44
     "sw-toolbox": "3.6.0",
46
-    "uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.2.0",
47 45
     "zone.js": "0.8.18"
48 46
   },
49 47
   "devDependencies": {
@@ -63,9 +61,7 @@
63 61
         "PLAY_SERVICES_VERSION": "11.8.0",
64 62
         "ANDROID_SUPPORT_V4_VERSION": "24.1.0"
65 63
       },
66
-      "cordova-sqlite-storage": {},
67
-      "cordova-plugin-x-socialsharing": {},
68
-      "uk.co.workingedge.phonegap.plugin.launchnavigator": {}
64
+      "cordova-sqlite-storage": {}
69 65
     },
70 66
     "platforms": [
71 67
       "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() {

+ 1 - 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';
@@ -45,9 +43,7 @@ import { ShareService } from '../services/share/share';
45 43
     GoogleMaps,
46 44
     {provide: ErrorHandler, useClass: IonicErrorHandler},
47 45
     VespotServiceProvider,
48
-    ShareService,
49
-    LaunchNavigator,
50
-    SocialSharing
46
+    ShareService
51 47
   ]
52 48
 })
53 49
 export class AppModule {}

+ 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
 }