tum 4 年 前
コミット
eadb43f992

+ 2 - 3
config.xml

@@ -1,9 +1,9 @@
1 1
 <?xml version='1.0' encoding='utf-8'?>
2
-<widget id="net.simplico.whitesports" version="1.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2
+<widget id="net.simplico.whitesports" version="1.4.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3 3
     <name>White Sports</name>
4 4
     <description>Virtual Run Mobile App</description>
5 5
     <author email="patumos@gmail.com" href="http://www.simplico.net/">Suebpong Sittimalairut</author>
6
-    <content original-src="index.html" src="http://localhost:8100" />
6
+    <content src="index.html" />
7 7
     <access origin="*" />
8 8
     <allow-intent href="http://*/*" />
9 9
     <allow-intent href="https://*/*" />
@@ -138,5 +138,4 @@
138 138
     <allow-navigation href="http://10.107.138.80:8100" />
139 139
     <allow-navigation href="http://203.159.52.44:8100" />
140 140
     <allow-navigation href="http://203.159.52.32:8100" />
141
-    <allow-navigation href="http://localhost:8100" sessionid="2f1d5c27" />
142 141
 </widget>

+ 10 - 1
src/pages/event-upload/event-upload.html

@@ -14,6 +14,15 @@
14 14
 
15 15
 
16 16
 <ion-content padding>
17
-     <button ion-button (click)="selectImage()" color="tertiary" size='small'>Upload</button>
17
+    <h2>{{ title }}</h2>
18
+    <button ion-button (click)="selectImage()" color="tertiary" size='small' block>{{ msg }}</button>
19
+     <div *ngIf="eventPhotos">
20
+        <ion-card *ngFor="let p of eventPhotos">
21
+            <img [src]="'https://hc.simplico.net/static/events/'+p.fileURL"/>
22
+            <ion-card-content>
23
+            <p>Created At: {{ p.created_at.$date | date :"medium" }}</p>
24
+            </ion-card-content>
25
+        </ion-card>
26
+     </div>
18 27
 
19 28
 </ion-content>

+ 14 - 7
src/pages/event-upload/event-upload.ts

@@ -26,19 +26,25 @@ export class EventUploadPage {
26 26
      croppedImagePath:string = "";
27 27
 
28 28
      photoURL: any;
29
-     msg:string = "Upload Your Photo";
29
+    eventPhotos: Array<any>;
30
+     msg:string = "Upload Stat Photo";
31
+    eventId:string;
32
+    title: string;
30 33
 
31 34
     constructor(public navCtrl: NavController, public navParams: NavParams, private camera: Camera,   public actionSheetController: ActionSheetController, private hp: HealthProvider) {
32
-        let eventId = navParams.get('eventId');
33
-        console.log("eventId "+eventId);
35
+        this.eventId = navParams.get('eventId');
36
+        this.title = navParams.get('title');
37
+        //console.log("eventId "+eventId);
34 38
     }
35 39
 
36
-    ionViewDidLoad() {
40
+    async ionViewDidEnter() {
37 41
         console.log('ionViewDidLoad EventUploadPage');
42
+        this.eventPhotos = await this.hp.getEventPhotos(this.eventId);
43
+        console.log(JSON.stringify(this.eventPhotos));
38 44
     }
39 45
       async selectImage() {
40 46
          const actionSheet = await this.actionSheetController.create({
41
-             header: "Select Image source",
47
+             title: "Select Image source",
42 48
              buttons: [{
43 49
                  text: 'Load from Library',
44 50
                  handler: () => {
@@ -73,8 +79,9 @@ export class EventUploadPage {
73 79
 
74 80
             console.log(this.croppedImagePath);
75 81
             this.msg = "Uploading ...";
76
-            let r0  = await this.hp.uploadPhoto(imageData);
77
-            this.photoURL = await this.hp.getPhoto();
82
+            let r0  = await this.hp.uploadPhoto(this.eventId, imageData);
83
+            this.eventPhotos = await this.hp.getEventPhotos(this.eventId);
84
+            //this.photoURL = await this.hp.getPhoto();
78 85
             this.msg = "Upload Your Photo";
79 86
             console.log("r0");
80 87
             console.log(r0);

+ 2 - 2
src/pages/event/event.html

@@ -31,9 +31,9 @@
31 31
       </button>
32 32
     </ion-col>
33 33
     <ion-col>
34
-      <button ion-button icon-start color='success' block (click)="joinEvent(p.id)">
34
+      <button ion-button icon-start color='success' block (click)="joinEvent(p.id, p.title.rendered)">
35 35
         <ion-icon name="text"></ion-icon>
36
-        <div>Join</div>
36
+        <div>Upload</div>
37 37
       </button>
38 38
     </ion-col>
39 39
   </ion-row>

+ 8 - 3
src/pages/event/event.ts

@@ -8,6 +8,7 @@ import { HumanizePipe  } from 'angular2-humanize';
8 8
 import { NativeStorage } from '@ionic-native/native-storage';
9 9
 import { InAppBrowser } from '@ionic-native/in-app-browser';
10 10
 import { EventUploadPage }  from '../event-upload/event-upload';
11
+import { LoginPage }  from '../login/login';
11 12
 /**
12 13
  * Generated class for the EventPage page.
13 14
  *
@@ -190,8 +191,12 @@ export class EventPage {
190 191
     openLink(link: string) {
191 192
          this.ab.create(link, '_blank');
192 193
     }
193
-    joinEvent(id) {
194
-        console.log("join "+id);
195
-        this.navCtrl.push(EventUploadPage, { eventId: id });
194
+    async joinEvent(id, title) {
195
+        if(await this.hp.isLogin() == false ) {
196
+            this.navCtrl.parent.select(3);
197
+            console.log("token");
198
+        }else {
199
+            this.navCtrl.push(EventUploadPage, { eventId: id , title: title});
200
+        }
196 201
     }
197 202
 }

+ 18 - 2
src/pages/login/login.html

@@ -65,6 +65,13 @@
65 65
                                     <ion-card-title>
66 66
                                         {{ profileObject.firstname }} {{ profileObject.lastname }}
67 67
                                     </ion-card-title>
68
+                                    <br/>
69
+                                    <p>
70
+                                    
71
+                                    Bib No.:
72
+                                    <span style='background-color:#f00; color:#fff; font-weight:bold; font-size:large;padding:0.5em'>
73
+                                       {{ profileObject.athId }}
74
+                                    </span></p>
68 75
                                     <p>
69 76
                                     {{ profileObject.city }} {{ profileObject.state }} {{ profileObject.country }}<br>
70 77
                                     {{ profileObject.description }}
@@ -85,12 +92,21 @@
85 92
                                         </div>
86 93
                                     </ion-label>
87 94
                                     <ion-input placeholder="Enter Tel." [(ngModel)]="profile.tel" required name='tel' #tel="ngModel"></ion-input>
88
-
89 95
                                     <ion-label color="danger" *ngIf="tel.invalid && (tel.dirty || tel.touched)">
90 96
                                         <div *ngIf="tel.errors.required">
91 97
                                             Tel. is required.
92 98
                                         </div>
93 99
                                     </ion-label>
100
+                                    <ion-item>
101
+                                        <ion-label>Birthdate: </ion-label>
102
+                                        <ion-datetime displayFormat="DD/MM/YYYY" [(ngModel)]="profile.birthDate" required name='birthDate' #birthDate="ngModel" placeholder="Enter Your Birthdate"></ion-datetime>
103
+
104
+                                    <ion-label color="danger" *ngIf="birthDate.invalid && (birthDate.dirty || birthDate.touched)">
105
+                                        <div *ngIf="birthDate.errors.required">
106
+                                            Birthdate. is required.
107
+                                        </div>
108
+                                    </ion-label>
109
+                                    </ion-item>
94 110
                                      <ion-textarea placeholder="Enter Your Address" [(ngModel)]="profile.address" required name='address' #address="ngModel"></ion-textarea>
95 111
 
96 112
                                     <ion-label color="danger" *ngIf="address.invalid && (address.dirty || address.touched)">
@@ -99,7 +115,7 @@
99 115
                                         </div>
100 116
                                     </ion-label>
101 117
                                         <button ion-button  color="primary" name='updateProfile' type='submit' block>
102
-                                            <ion-icon name='save'></ion-icon>
118
+                                            <ion-icon name='create'></ion-icon>
103 119
                                             Update Profile
104 120
                                         </button>
105 121
                                         <!--

+ 5 - 0
src/pages/login/login.ts

@@ -25,6 +25,7 @@ class Profile {
25 25
     email: string;
26 26
     tel: string;
27 27
     address: string;
28
+    birthDate: string;
28 29
 }
29 30
 //@IonicPage()
30 31
 
@@ -81,6 +82,8 @@ export class LoginPage {
81 82
                                 console.dir(acts.output.firstname, acts.output.lastname);
82 83
                                 this.nativeStorage.setItem('profileObject', acts.output);
83 84
                                 this.profileObject = acts.output;
85
+
86
+                                this.nativeStorage.setItem('athId', this.profileObject.athId);
84 87
                                 this.hp.getWSProfile(this.profileObject.athId,this.token)
85 88
                                     .subscribe( wsdata => {
86 89
                                         console.log(JSON.stringify(wsdata));
@@ -88,6 +91,7 @@ export class LoginPage {
88 91
                                         this.profile.tel = wsdata['output']['tel'];
89 92
                                         this.profile.email = wsdata['output']['email'];
90 93
                                         this.profile.address = wsdata['output']['address'];
94
+                                        this.profile.birthDate = (new Date(wsdata['output']['birthDate']['$date'])).toISOString();
91 95
                                         console.log(JSON.stringify(this.profile));
92 96
                                     }, error => {
93 97
                                         console.log("error "+error);
@@ -180,6 +184,7 @@ export class LoginPage {
180 184
                 tel: f.value.tel,
181 185
                 address: f.value.address,
182 186
                 token: this.token,
187
+                birthDate: f.value.birthDate
183 188
             };
184 189
             this.hp.saveWSProfile(profile)
185 190
                 .subscribe(

+ 63 - 2
src/providers/health/health.ts

@@ -7,6 +7,7 @@ import { HTTP, HTTPResponse } from '@ionic-native/http';
7 7
 import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer';
8 8
 import { NativeStorage } from '@ionic-native/native-storage';
9 9
 
10
+
10 11
 /*
11 12
   Generated class for the HealthProvider provider.
12 13
 
@@ -22,6 +23,7 @@ const QR_URL = HOSTBASE + "/static/";
22 23
 const REDEEM_API = HOSTBASE + "/coredata/api/redeem";
23 24
 const SV_API = HOSTBASE + "/strava/api";
24 25
 const UPLOAD_API = HOSTBASE + "/strava/uploadPhoto";
26
+const GET_EVENT_PHOTO_API = HOSTBASE + "/strava/getEventPhotos";
25 27
 const WP = "https://whitesports.net/wp-json/wp/v2/";
26 28
 
27 29
 @Injectable()
@@ -61,6 +63,20 @@ export class HealthProvider {
61 63
         return this.http.post(COREAPI, {token: token, action: "HISTORY"});
62 64
     }
63 65
 
66
+    async isLogin(){
67
+        return await this.storage.getItem('token')
68
+            .then(
69
+                data => { return data;  }, 
70
+                error => { return false;  }
71
+            );
72
+    }
73
+    async getAthId(){
74
+        return await this.storage.getItem('athId')
75
+            .then(
76
+                data => { return data;  }, 
77
+                error => { return false;  }
78
+            );
79
+    }
64 80
     totalCal(): Observable<any> {
65 81
         return this.http.post(COREAPI, {action: "TOTALCAL"});
66 82
     }
@@ -111,9 +127,30 @@ export class HealthProvider {
111 127
         console.log("get ath ", athId);
112 128
         return this.http.post(COREAPI, {action: "GETRUNNER", athId: athId});
113 129
     }
130
+    async getEventPhotos(eventId) {
131
+         let athId = await this.getAthId();
132
+        console.log(GET_EVENT_PHOTO_API)
133
+        let photos = await this.nhttp.get(GET_EVENT_PHOTO_API+"?athId="+athId+"&eventId="+ eventId,{}, {}).then(
134
+            res => {
135
+                console.log("res ", JSON.stringify(res));
136
+                let data = JSON.parse(res.data);
137
+                return data.output;
138
+            },
139
+            error => {
140
+                console.log(JSON.stringify(error));
141
+                return null;
142
+            }
143
+        );
144
+        return photos;
145
+    }
114 146
     saveWSProfile(profile) {
115
-        return this.http.post(SV_API, {action: "UPDATE_PROFILE", athId: profile['athId'],  fullName: profile['fullName'], email: profile['email'], tel: profile['tel'], address: profile['address'], token: profile['token']});
147
+        let d = new Date(profile['birthDate']);
148
+        console.log(d.getMonth())
149
+        let fd = d.getFullYear()  + "-" + (d.getMonth() + 1) + "-" +d.getDate();
150
+
151
+        return this.http.post(SV_API, {action: "UPDATE_PROFILE", athId: profile['athId'],  fullName: profile['fullName'], email: profile['email'], tel: profile['tel'], address: profile['address'], token: profile['token'], birthDate: fd});
116 152
     }
153
+
117 154
     getWSProfile(athId, token) {
118 155
         return this.http.post(SV_API, {action: "GET_WS_PROFILE", athId: athId,   token: token });
119 156
     }
@@ -147,7 +184,31 @@ export class HealthProvider {
147 184
         let url = UPLOAD_API + "?eventId="+eventId+"&athId="+athId;
148 185
         return url;
149 186
     }
150
-     async uploadPhoto(filePath) {
187
+    
188
+     async uploadPhoto(eventId, filePath) {
189
+         let athId = await this.getAthId();
190
+
191
+         if( athId ) {
192
+             const fileTransfer: FileTransferObject = this.transfer.create();
193
+
194
+             let options: FileUploadOptions = {
195
+                 fileKey: 'file',
196
+                 //fileName: 'name.jpg',
197
+             }
198
+
199
+             return fileTransfer.upload(filePath, this.uploadPhotoUrl(eventId, athId), options)
200
+                 .then((data) => {
201
+                     // success
202
+                     console.log("from tranfer");
203
+                     console.log(data);
204
+                     return JSON.parse(data.response);
205
+                 }, (err) => {
206
+                     // error
207
+                     return err;
208
+                 })
209
+         } else {
210
+             return null;
211
+         }
151 212
 
152 213
          /*
153 214
          let info = await this.kohaService.getPatronInfo();