Skip to content

Commit

Permalink
Modified hostel-activePage to give infomation on selected hostel and …
Browse files Browse the repository at this point in the history
…number of people moving to that hostel
  • Loading branch information
maaddae committed May 7, 2017
1 parent ff8bcc4 commit aaa214e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/pages/hostel-active/hostel-active.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ion-navbar text-center>
<ion-title>
<p><ion-icon name="home"></ion-icon> Hostel Name</p></ion-title>
<p><ion-icon name="home"></ion-icon> {{this.data.hname}} Hostel</p></ion-title>
</ion-navbar>

</ion-header>
Expand All @@ -18,16 +18,16 @@
<ion-grid >
<ion-row text-center>
<ion-col class="movingInfo">
<span>50 people</span> are headed to [hosetl name]
<span>{{this.data.mcount}} people</span> are headed to {{this.data.hname}}
</ion-col>
</ion-row>

<ion-row text-center>
<ion-col>
<button ion-button (click) = "pushPage()"class="goingButton">
Join Them!
</button>
</ion-col>
<button ion-button (click) = "joinGroup()"class="goingButton">
Join Them!
</button>
</ion-col>

</ion-row>
</ion-grid>
Expand Down
111 changes: 107 additions & 4 deletions src/pages/hostel-active/hostel-active.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {UserActionPage} from '../user-action/user-action';
import { Http, Headers, RequestOptions } from '@angular/http';
import {UserActionPage} from '../user-action/user-action';
import 'rxjs/add/operator/map';

/*
Generated class for the HostelActive page.
Expand All @@ -13,13 +15,114 @@ import {UserActionPage} from '../user-action/user-action';
templateUrl: 'hostel-active.html'
})
export class HostelActivePage {
public data: any;
public items: any = [];
public post: any;

constructor(public navCtrl: NavController, public navParams: NavParams) {}
constructor(public navCtrl: NavController, public navParams: NavParams, public http: Http) {
this.data = {};
this.data.mid = "";
this.data.sid = this.navParams.get("sId");
this.data.hid = this.navParams.get("hId");
this.data.gid = this.navParams.get("gId");
//console.log('sId: '+ this.data.sid);
//console.log('hId: '+ this.data.hid);
//console.log('gId: '+ this.data.gid);
}

ionViewDidLoad() {
if(this.navParams.get("record")) {
this.getID(this.navParams.get("record"));
this.groupCount(this.data.gid);
this.getHname(this.data.hid);
//this.joinGroup(this.data.gid,this.data.sid)
}
console.log('ionViewDidLoad HostelActivePage');
}
pushPage(){
this.navCtrl.setRoot(UserActionPage);

// Assign the navigation retrieved data to properties
// used as models on the page's HTML form
getID(item){
this.data.mid = item.mId;
console.log('mId: '+ this.data.mid);
//this.parameter1 = this.navParams.get('param1');
//console.log('sId: '+ this.parameter1);
}

getHname(hId) {
let body : string = "key=hname&hId=" + hId,
type : string = "application/x-www-form-urlencoded; charset=UTF-8",
headers : any = new Headers({ 'Content-Type': type}),
options : any = new RequestOptions({ headers: headers }),
url : any = "http://nibbles/webfiles/safetekApp/retreive-groups.php";

this.http.post(url, body, options)
.map(res => res.json())
.subscribe(data =>
{
this.post = JSON.stringify(data);
this.initializeItems();
this.data.hname = this.items.replace(/\"/g, "");
//console.log('hname: '+this.post.name)
//console.log('hname: '+this.items.replace(/\"/g, ""))
//console.log("getGroup success");
});

}

groupCount(gId) {
let body : string = "key=tmembers&gId=" + gId,
type : string = "application/x-www-form-urlencoded; charset=UTF-8",
headers : any = new Headers({ 'Content-Type': type}),
options : any = new RequestOptions({ headers: headers }),
url : any = "http://nibbles/webfiles/safetekApp/retreive-groups.php";

this.http.post(url, body, options)
.map(res => res.json())
.subscribe(data =>
{
this.post = JSON.stringify(data);
this.initializeItems();
this.data.mcount = this.items.replace(/\"/g, "");
//console.log('count: '+this.items)
//console.log('count: '+this.items.replace(/\"/g, ""))
//console.log("getGroup success");
});

}

gUpdate(gId,sId){
let body : string = "key=update&gId=" + gId + "&sId=" + sId,
type : string = "application/x-www-form-urlencoded; charset=UTF-8",
headers : any = new Headers({ 'Content-Type': type}),
options : any = new RequestOptions({ headers: headers }),
url : any = "http://nibbles/webfiles/safetekApp/retreive-groups.php";

this.http.post(url, body, options)
.map(res => res.json())
.subscribe(data =>
{
this.post = JSON.stringify(data);
this.initializeItems();
//this.data.mcount = this.items.replace(/\"/g, "");
//console.log('update: '+this.items)
//console.log('count: '+this.items.replace(/\"/g, ""))
//console.log("getGroup success");
});
}

joinGroup(){
this.gUpdate(this.data.gid,this.data.sid);
this.navCtrl.push(UserActionPage,{sId: this.data.sid, hId: this.data.hid, gId: this.data.gid, mId: this.data.mid });
}

viewEntry(param) {
this.navCtrl.push(param);
}

initializeItems() {
this.items = this.post;
}


}
2 changes: 1 addition & 1 deletion src/pages/signup/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<ion-row center>
<ion-col>
<p>Already have an account? <a href="#">Login</a>!</p>
<p>Already have an account? <a (click)="pushPage2()">Login</a>!</p>
</ion-col>
</ion-row>
</ion-grid>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/signup/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export class SignupPage {
this.navCtrl.setRoot(LoginPage);
}

pushPage2() {
this.navCtrl.setRoot(LoginPage);
}

}

0 comments on commit aaa214e

Please sign in to comment.