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

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
     <allow-navigation href="http://192.168.0.7:8100" />
90
     <allow-navigation href="http://192.168.0.7:8100" />
91
     <plugin name="cordova-sqlite-storage" spec="^2.2.1" />
91
     <plugin name="cordova-sqlite-storage" spec="^2.2.1" />
92
     <allow-navigation href="http://192.168.43.167:8100" />
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
 </widget>
93
 </widget>

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

106
       "resolved": "https://registry.npmjs.org/@ionic-native/launch-navigator/-/launch-navigator-4.6.0.tgz",
106
       "resolved": "https://registry.npmjs.org/@ionic-native/launch-navigator/-/launch-navigator-4.6.0.tgz",
107
       "integrity": "sha512-4BO2r/E1rnar+H/KIPbzBDwfsgUOVduFDfcU9Jx/bkB31FRbZKeW268jBFzZlPxOrg+hazmjs0w11ibgItDP9w=="
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
     "@ionic-native/social-sharing": {
114
     "@ionic-native/social-sharing": {
110
       "version": "4.6.0",
115
       "version": "4.6.0",
111
       "resolved": "https://registry.npmjs.org/@ionic-native/social-sharing/-/social-sharing-4.6.0.tgz",
116
       "resolved": "https://registry.npmjs.org/@ionic-native/social-sharing/-/social-sharing-4.6.0.tgz",
1364
       "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.3.tgz",
1369
       "resolved": "https://registry.npmjs.org/cordova-plugin-whitelist/-/cordova-plugin-whitelist-1.3.3.tgz",
1365
       "integrity": "sha1-tehezbv+Wu3tQKG/TuI3LmfZb7Q="
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
     "cordova-sqlite-storage": {
1372
     "cordova-sqlite-storage": {
1373
       "version": "2.2.1",
1373
       "version": "2.2.1",
1374
       "resolved": "https://registry.npmjs.org/cordova-sqlite-storage/-/cordova-sqlite-storage-2.2.1.tgz",
1374
       "resolved": "https://registry.npmjs.org/cordova-sqlite-storage/-/cordova-sqlite-storage-2.2.1.tgz",
1757
         "event-emitter": "0.3.5"
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
     "es6-set": {
1760
     "es6-set": {
1766
       "version": "0.1.5",
1761
       "version": "0.1.5",
1767
       "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
1762
       "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz",
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
     "ultron": {
6262
     "ultron": {
6273
       "version": "1.1.1",
6263
       "version": "1.1.1",
6274
       "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",
6264
       "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",

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

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

+ 33 - 3
src/app/app.component.ts Просмотреть файл

3
 import { StatusBar } from '@ionic-native/status-bar';
3
 import { StatusBar } from '@ionic-native/status-bar';
4
 import { SplashScreen } from '@ionic-native/splash-screen';
4
 import { SplashScreen } from '@ionic-native/splash-screen';
5
 import { Storage } from '@ionic/storage';
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
 import { HomePage } from '../pages/home/home';
9
 import { HomePage } from '../pages/home/home';
8
 import { DevicesPage } from '../pages/devices/devices';
10
 import { DevicesPage } from '../pages/devices/devices';
11
+import { Main } from '../pages/main/main';
9
 import { ConfigurationPage } from '../pages/configuration/configuration';
12
 import { ConfigurationPage } from '../pages/configuration/configuration';
10
 
13
 
11
 @Component({
14
 @Component({
13
 })
16
 })
14
 export class MyApp {
17
 export class MyApp {
15
   @ViewChild(Nav) nav: Nav;
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
     private alertCtrl: AlertController,
24
     private alertCtrl: AlertController,
20
-  private storage: Storage) {
25
+  private storage: Storage,
26
+  public vespotService: VespotServiceProvider,
27
+  public shareService: ShareService) {
21
     /*platform.ready().then(() => {
28
     /*platform.ready().then(() => {
22
       // Okay, so the platform is ready and our plugins are available.
29
       // Okay, so the platform is ready and our plugins are available.
23
       // Here you can do any higher level native things you might need.
30
       // Here you can do any higher level native things you might need.
24
       statusBar.styleDefault();
31
       statusBar.styleDefault();
25
       splashScreen.hide();
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
   openDevicesPage() {
59
   openDevicesPage() {

+ 1 - 5
src/app/app.module.ts Просмотреть файл

6
 import { HttpClientModule } from '@angular/common/http';
6
 import { HttpClientModule } from '@angular/common/http';
7
 import { GoogleMaps } from '@ionic-native/google-maps';
7
 import { GoogleMaps } from '@ionic-native/google-maps';
8
 import { IonicStorageModule } from '@ionic/storage';
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
 import { MyApp } from './app.component';
10
 import { MyApp } from './app.component';
13
 import { HomePage } from '../pages/home/home';
11
 import { HomePage } from '../pages/home/home';
45
     GoogleMaps,
43
     GoogleMaps,
46
     {provide: ErrorHandler, useClass: IonicErrorHandler},
44
     {provide: ErrorHandler, useClass: IonicErrorHandler},
47
     VespotServiceProvider,
45
     VespotServiceProvider,
48
-    ShareService,
49
-    LaunchNavigator,
50
-    SocialSharing
46
+    ShareService
51
   ]
47
   ]
52
 })
48
 })
53
 export class AppModule {}
49
 export class AppModule {}

+ 2 - 2
src/pages/home/home.ts Просмотреть файл

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

+ 1 - 5
src/pages/main/main.html Просмотреть файл

10
 <ion-content padding>
10
 <ion-content padding>
11
   <div id="map_canvas">
11
   <div id="map_canvas">
12
     <ion-fab right bottom>
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
     </ion-fab>-
14
     </ion-fab>-
19
   </div>
15
   </div>
20
 </ion-content>
16
 </ion-content>

+ 1 - 24
src/pages/main/main.ts Просмотреть файл

3
 import { AlertController } from 'ionic-angular';
3
 import { AlertController } from 'ionic-angular';
4
 import { interval } from 'rxjs/observable/interval';
4
 import { interval } from 'rxjs/observable/interval';
5
 import { Storage } from '@ionic/storage';
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
 import { DevicesPage } from '../devices/devices'
7
 import { DevicesPage } from '../devices/devices'
10
 import { ConfigurationPage } from '../configuration/configuration'
8
 import { ConfigurationPage } from '../configuration/configuration'
40
   private googleMaps: GoogleMaps,
38
   private googleMaps: GoogleMaps,
41
   private vespotService: VespotServiceProvider,
39
   private vespotService: VespotServiceProvider,
42
   public alertCtrl: AlertController,
40
   public alertCtrl: AlertController,
43
-  private storage: Storage,
44
-  private launchNavigator: LaunchNavigator,
45
-  private socialSharing: SocialSharing) {
41
+  private storage: Storage) {
46
       this.devicesPage = DevicesPage;
42
       this.devicesPage = DevicesPage;
47
       this.configurationPage = ConfigurationPage;
43
       this.configurationPage = ConfigurationPage;
48
       this.devices = this.shareService.getDevices();
44
       this.devices = this.shareService.getDevices();
51
 
47
 
52
   }
48
   }
53
 
49
 
54
-
55
-
56
   ionViewWillEnter() {
50
   ionViewWillEnter() {
57
     if(typeof this.shareService.getRootDevice() == "undefined") {
51
     if(typeof this.shareService.getRootDevice() == "undefined") {
58
       console.log('ionViewWillEnter: Entro al undefined');
52
       console.log('ionViewWillEnter: Entro al undefined');
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
 }