Browse Source

polling messages

alizalang 6 years ago
parent
commit
b8b9673d2b

+ 1
- 1
ZipTeamOrange-ionic-UI/.sourcemaps/main.js.map
File diff suppressed because it is too large
View File


+ 3
- 4
ZipTeamOrange-ionic-UI/ionic.config.json View File

1
 {
1
 {
2
   "name": "ionic-ZipTeamOrange",
2
   "name": "ionic-ZipTeamOrange",
3
-  "app_id": "",
4
-  "type": "ionic-angular",
5
   "integrations": {
3
   "integrations": {
6
     "cordova": {}
4
     "cordova": {}
7
-  }
8
-}
5
+  },
6
+  "type": "ionic-angular"
7
+}

+ 1
- 1
ZipTeamOrange-ionic-UI/package.json View File

34
     "zone.js": "0.8.26"
34
     "zone.js": "0.8.26"
35
   },
35
   },
36
   "devDependencies": {
36
   "devDependencies": {
37
-    "@ionic/app-scripts": "3.1.10",
37
+    "@ionic/app-scripts": "^3.1.10",
38
     "typescript": "~2.6.2"
38
     "typescript": "~2.6.2"
39
   },
39
   },
40
   "description": "An Ionic project"
40
   "description": "An Ionic project"

+ 1
- 1
ZipTeamOrange-ionic-UI/src/Classes/Messsage.ts View File

1
 import { Chat } from "./Chat";
1
 import { Chat } from "./Chat";
2
 import { User } from "./user";
2
 import { User } from "./user";
3
 
3
 
4
-export class Message{
4
+export class Message {
5
     id: number;
5
     id: number;
6
     message: String;
6
     message: String;
7
     private chat: Chat;
7
     private chat: Chat;

+ 5
- 4
ZipTeamOrange-ionic-UI/src/pages/chat/chat.html View File

14
 <!-- *ngFor="let m of msg">{{ m }} -->
14
 <!-- *ngFor="let m of msg">{{ m }} -->
15
 
15
 
16
 <ion-content padding >
16
 <ion-content padding >
17
-  <div *ngFor="let m of msg">
18
-    {{ m.message }}
17
+  <div *ngFor="let m of msg" class="message-wrapper">
18
+    <div class="name">Nhu <span class="timestamp">4/10</span></div>
19
+    <div class="message">{{m.message}}</div>
19
   </div>
20
   </div>
20
 
21
 
21
   <form  #test1="ngForm" ng-submit="send(test1.value)">
22
   <form  #test1="ngForm" ng-submit="send(test1.value)">
22
-    <ion-textarea  type="text" name="message" [(ngModel)]="test" ></ion-textarea>
23
-    <button ion-button (click)="send(test1.value)"(click)="getMessages()">send</button>
23
+    <ion-textarea  type="text" name="message" [(ngModel)]="test" class="user-message"></ion-textarea>
24
+    <button ion-button (click)="send(test1.value)" >send</button>
24
   </form>
25
   </form>
25
 </ion-content>
26
 </ion-content>

+ 4
- 0
ZipTeamOrange-ionic-UI/src/pages/chat/chat.scss View File

1
 page-chat {
1
 page-chat {
2
+    .user-message {
3
+        border: 1px solid #CCC;
4
+    }
2
 
5
 
6
+    
3
 }
7
 }

+ 24
- 14
ZipTeamOrange-ionic-UI/src/pages/chat/chat.ts View File

1
-import { Component } from '@angular/core';
1
+import { Component, OnInit, Input } from '@angular/core';
2
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
2
 import { IonicPage, NavController, NavParams } from 'ionic-angular';
3
 import { NgForm } from '../../../node_modules/@angular/forms';
3
 import { NgForm } from '../../../node_modules/@angular/forms';
4
 import { MessageServiceProvider } from '../../providers/message-service/message-service';
4
 import { MessageServiceProvider } from '../../providers/message-service/message-service';
5
 import { Message } from '../../../node_modules/@angular/compiler/src/i18n/i18n_ast';
5
 import { Message } from '../../../node_modules/@angular/compiler/src/i18n/i18n_ast';
6
+// import {OnInit} from '@angular/core';
7
+// import { interval } from '../../../node_modules/rxjs/observable/interval';
8
+// import { startWith } from '../../../node_modules/rxjs/operators';
9
+// import { switchMap } from '../../../node_modules/rxjs/operator/switchMap';
6
 
10
 
7
-/**
8
- * Generated class for the ChatPage page.
9
- *
10
- * See https://ionicframework.com/docs/components/#navigation for more info on
11
- * Ionic pages and navigation.
12
- */
13
 
11
 
14
 @IonicPage()
12
 @IonicPage()
15
 @Component({
13
 @Component({
19
 export class ChatPage {
17
 export class ChatPage {
20
   test: any;
18
   test: any;
21
   msg: any;
19
   msg: any;
20
+  @Input()
22
   messages: Message [];
21
   messages: Message [];
22
+  mApi: any;
23
+
23
   constructor(public navCtrl: NavController, public navParams: NavParams, public messageApi: MessageServiceProvider) {
24
   constructor(public navCtrl: NavController, public navParams: NavParams, public messageApi: MessageServiceProvider) {
25
+  this.mApi = messageApi;
24
   }
26
   }
25
 
27
 
26
   ionViewDidLoad() {
28
   ionViewDidLoad() {
27
     console.log('ionViewDidLoad ChatPage');
29
     console.log('ionViewDidLoad ChatPage');
28
-    this.getMessages();
30
+    this.getMessages(this);
29
   }
31
   }
30
 
32
 
31
   send(createAccountInfo: NgForm){
33
   send(createAccountInfo: NgForm){
32
     console.log("clicked");
34
     console.log("clicked");
33
     console.log(createAccountInfo)
35
     console.log(createAccountInfo)
34
     this.messageApi.saveMessage(createAccountInfo).subscribe(console.log);
36
     this.messageApi.saveMessage(createAccountInfo).subscribe(console.log);
35
-    this.getMessages()
37
+    this.test = '';
38
+    this.getMessages(this);
36
   }
39
   }
37
 
40
 
38
-  getMessages(){
39
-    this.messageApi.getMessages().subscribe(data => {
40
-      this.msg = data
41
-      console.log(data)
41
+  getMessages(chatPage){
42
+    chatPage.messageApi.getMessages().subscribe(data => {
43
+      this.msg = data;
44
+      console.log(this.msg);
42
     });
45
     });
43
-    this.test = this.messageApi.getCurrentMessage();
46
+ }
47
+
48
+  ngOnInit() {
49
+    setInterval(() => {this.getMessages(this)}, 500);
44
   }
50
   }
45
 
51
 
52
+
53
+
54
+
55
+
46
 }
56
 }

+ 1
- 1
ZipTeamOrange-ionic-UI/src/providers/message-service/message-service.ts View File

29
     return this.http.post(`http://localhost:8080/message/add`, createAccountInfo);
29
     return this.http.post(`http://localhost:8080/message/add`, createAccountInfo);
30
   }
30
   }
31
 
31
 
32
-}
32
+}

+ 4
- 0
ZipTeamOrange-ionic-UI/www/build/main.css View File

25677
   min-height: calc(46px + constant(safe-area-inset-bottom));
25677
   min-height: calc(46px + constant(safe-area-inset-bottom));
25678
   min-height: calc(46px + env(safe-area-inset-bottom));
25678
   min-height: calc(46px + env(safe-area-inset-bottom));
25679
 }
25679
 }
25680
+
25681
+page-chat .user-message {
25682
+  border: 1px solid #CCC;
25683
+}

+ 22
- 17
ZipTeamOrange-ionic-UI/www/build/main.js View File

20
 
20
 
21
 
21
 
22
 
22
 
23
-/**
24
- * Generated class for the ChatPage page.
25
- *
26
- * See https://ionicframework.com/docs/components/#navigation for more info on
27
- * Ionic pages and navigation.
28
- */
23
+// import {OnInit} from '@angular/core';
24
+// import { interval } from '../../../node_modules/rxjs/observable/interval';
25
+// import { startWith } from '../../../node_modules/rxjs/operators';
26
+// import { switchMap } from '../../../node_modules/rxjs/operator/switchMap';
29
 var ChatPage = /** @class */ (function () {
27
 var ChatPage = /** @class */ (function () {
30
     function ChatPage(navCtrl, navParams, messageApi) {
28
     function ChatPage(navCtrl, navParams, messageApi) {
31
         this.navCtrl = navCtrl;
29
         this.navCtrl = navCtrl;
32
         this.navParams = navParams;
30
         this.navParams = navParams;
33
         this.messageApi = messageApi;
31
         this.messageApi = messageApi;
32
+        this.mApi = messageApi;
34
     }
33
     }
35
     ChatPage.prototype.ionViewDidLoad = function () {
34
     ChatPage.prototype.ionViewDidLoad = function () {
36
         console.log('ionViewDidLoad ChatPage');
35
         console.log('ionViewDidLoad ChatPage');
37
-        this.getMessages();
36
+        this.getMessages(this);
38
     };
37
     };
39
     ChatPage.prototype.send = function (createAccountInfo) {
38
     ChatPage.prototype.send = function (createAccountInfo) {
40
         console.log("clicked");
39
         console.log("clicked");
41
         console.log(createAccountInfo);
40
         console.log(createAccountInfo);
42
         this.messageApi.saveMessage(createAccountInfo).subscribe(console.log);
41
         this.messageApi.saveMessage(createAccountInfo).subscribe(console.log);
43
-        this.getMessages();
42
+        this.test = '';
43
+        this.getMessages(this);
44
     };
44
     };
45
-    ChatPage.prototype.getMessages = function () {
45
+    ChatPage.prototype.getMessages = function (chatPage) {
46
         var _this = this;
46
         var _this = this;
47
-        this.messageApi.getMessages().subscribe(function (data) {
47
+        chatPage.messageApi.getMessages().subscribe(function (data) {
48
             _this.msg = data;
48
             _this.msg = data;
49
-            console.log(data);
49
+            console.log(_this.msg);
50
         });
50
         });
51
-        this.test = this.messageApi.getCurrentMessage();
52
     };
51
     };
52
+    ChatPage.prototype.ngOnInit = function () {
53
+        var _this = this;
54
+        setInterval(function () { _this.getMessages(_this); }, 500);
55
+    };
56
+    __decorate([
57
+        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["D" /* Input */])(),
58
+        __metadata("design:type", Array)
59
+    ], ChatPage.prototype, "messages", void 0);
53
     ChatPage = __decorate([
60
     ChatPage = __decorate([
54
         Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["m" /* Component */])({
61
         Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["m" /* Component */])({
55
-            selector: 'page-chat',template:/*ion-inline-start:"/Users/alizalang/Desktop/ZipTeam/ZipTeamOrange-ionic-UI/src/pages/chat/chat.html"*/'<!--\n  Generated template for the ChatPage page.\n\n  See http://ionicframework.com/docs/components/#navigation for more info on\n  Ionic pages and navigation.\n-->\n<ion-header>\n\n  <ion-navbar>\n    <ion-title>chatPage</ion-title>\n  </ion-navbar>\n\n</ion-header>\n<!-- *ngFor="let m of msg">{{ m }} -->\n\n<ion-content padding >\n  <div *ngFor="let m of msg">\n    {{ m.message }}\n  </div>\n\n  <form  #test1="ngForm" ng-submit="send(test1.value)">\n    <ion-textarea  type="text" name="message" [(ngModel)]="test" ></ion-textarea>\n    <button ion-button (click)="send(test1.value)"(click)="getMessages()">send</button>\n  </form>\n</ion-content>\n'/*ion-inline-end:"/Users/alizalang/Desktop/ZipTeam/ZipTeamOrange-ionic-UI/src/pages/chat/chat.html"*/,
62
+            selector: 'page-chat',template:/*ion-inline-start:"/Users/alizalang/Desktop/ZipTeam/ZipTeamOrange-ionic-UI/src/pages/chat/chat.html"*/'<!--\n  Generated template for the ChatPage page.\n\n  See http://ionicframework.com/docs/components/#navigation for more info on\n  Ionic pages and navigation.\n-->\n<ion-header>\n\n  <ion-navbar>\n    <ion-title>chatPage</ion-title>\n  </ion-navbar>\n\n</ion-header>\n<!-- *ngFor="let m of msg">{{ m }} -->\n\n<ion-content padding >\n  <div *ngFor="let m of msg" class="message-wrapper">\n    <div class="name">Nhu <span class="timestamp">4/10</span></div>\n    <div class="message">{{m.message}}</div>\n  </div>\n\n  <form  #test1="ngForm" ng-submit="send(test1.value)">\n    <ion-textarea  type="text" name="message" [(ngModel)]="test" class="user-message"></ion-textarea>\n    <button ion-button (click)="send(test1.value)" >send</button>\n  </form>\n</ion-content>\n'/*ion-inline-end:"/Users/alizalang/Desktop/ZipTeam/ZipTeamOrange-ionic-UI/src/pages/chat/chat.html"*/,
56
         }),
63
         }),
57
-        __metadata("design:paramtypes", [typeof (_a = typeof __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["e" /* NavController */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["e" /* NavController */]) === "function" && _a || Object, typeof (_b = typeof __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["f" /* NavParams */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["f" /* NavParams */]) === "function" && _b || Object, typeof (_c = typeof __WEBPACK_IMPORTED_MODULE_2__providers_message_service_message_service__["a" /* MessageServiceProvider */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_2__providers_message_service_message_service__["a" /* MessageServiceProvider */]) === "function" && _c || Object])
64
+        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["e" /* NavController */], __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["f" /* NavParams */], __WEBPACK_IMPORTED_MODULE_2__providers_message_service_message_service__["a" /* MessageServiceProvider */]])
58
     ], ChatPage);
65
     ], ChatPage);
59
     return ChatPage;
66
     return ChatPage;
60
-    var _a, _b, _c;
61
 }());
67
 }());
62
 
68
 
63
 //# sourceMappingURL=chat.js.map
69
 //# sourceMappingURL=chat.js.map
288
     };
294
     };
289
     MessageServiceProvider = __decorate([
295
     MessageServiceProvider = __decorate([
290
         Object(__WEBPACK_IMPORTED_MODULE_1__angular_core__["A" /* Injectable */])(),
296
         Object(__WEBPACK_IMPORTED_MODULE_1__angular_core__["A" /* Injectable */])(),
291
-        __metadata("design:paramtypes", [typeof (_a = typeof __WEBPACK_IMPORTED_MODULE_0__angular_common_http__["a" /* HttpClient */] !== "undefined" && __WEBPACK_IMPORTED_MODULE_0__angular_common_http__["a" /* HttpClient */]) === "function" && _a || Object])
297
+        __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_0__angular_common_http__["a" /* HttpClient */]])
292
     ], MessageServiceProvider);
298
     ], MessageServiceProvider);
293
     return MessageServiceProvider;
299
     return MessageServiceProvider;
294
-    var _a;
295
 }());
300
 }());
296
 
301
 
297
 //# sourceMappingURL=message-service.js.map
302
 //# sourceMappingURL=message-service.js.map

+ 1
- 1
ZipTeamOrange-ionic-UI/www/build/main.js.map
File diff suppressed because it is too large
View File


+ 1
- 1
ZipTeamOrange-ionic-UI/www/build/vendor.js.map
File diff suppressed because it is too large
View File