2 次代码提交

作者 SHA1 备注 提交日期
  rjsmall90 8ebd30630e search and school compatible 6 年前
  rjsmall90 e8658406c6 search functionality updtd 6 年前

+ 2
- 0
src/app/app.component.ts 查看文件

@@ -3,6 +3,7 @@ import { Nav, Platform } from 'ionic-angular';
3 3
 import { StatusBar } from '@ionic-native/status-bar';
4 4
 import { SplashScreen } from '@ionic-native/splash-screen';
5 5
 
6
+
6 7
 import { HomePage } from '../pages/home/home';
7 8
 import { ListPage } from '../pages/list/list';
8 9
 import { NewProfilePage } from '../pages/registerUser/registerUser';
@@ -10,6 +11,7 @@ import { TeacherRegistrationPage } from '../pages/registerTeacher/registerTeache
10 11
 import { SearchPage } from '../pages/search/search';
11 12
 
12 13
 
14
+
13 15
 @Component({
14 16
   templateUrl: 'app.html'
15 17
 })

+ 5
- 0
src/app/app.module.ts 查看文件

@@ -9,11 +9,13 @@ import { ListPage } from '../pages/list/list';
9 9
 import { NewProfilePage } from '../pages/registerUser/registerUser';
10 10
 import { TeacherRegistrationPage } from '../pages/registerTeacher/registerTeacher';
11 11
 import { SearchPage } from '../pages/search/search';
12
+import { SchoolPage } from '../pages/schools/schools';
12 13
 
13 14
 
14 15
 import { StatusBar } from '@ionic-native/status-bar';
15 16
 import { SplashScreen } from '@ionic-native/splash-screen';
16 17
 import { ConnectionProvider } from '../providers/connection/connection';
18
+import { DistrictProvider } from '../providers/connection/district';
17 19
 
18 20
 @NgModule({
19 21
   declarations: [
@@ -23,6 +25,7 @@ import { ConnectionProvider } from '../providers/connection/connection';
23 25
     NewProfilePage,
24 26
     TeacherRegistrationPage,
25 27
     SearchPage,
28
+    SchoolPage,
26 29
   ],
27 30
   imports: [
28 31
     BrowserModule,
@@ -37,11 +40,13 @@ import { ConnectionProvider } from '../providers/connection/connection';
37 40
     NewProfilePage,
38 41
     TeacherRegistrationPage,
39 42
     SearchPage,
43
+    SchoolPage, 
40 44
   ],
41 45
   providers: [
42 46
     StatusBar,
43 47
     SplashScreen,
44 48
     ConnectionProvider,
49
+    DistrictProvider, 
45 50
     {provide: ErrorHandler, useClass: IonicErrorHandler}
46 51
     
47 52
   ]

+ 7
- 0
src/app/component/school.ts 查看文件

@@ -0,0 +1,7 @@
1
+export class School {
2
+
3
+
4
+    constructor(public name: string) {
5
+
6
+    }
7
+}

+ 2
- 2
src/pages/registerUser/registerUser.html 查看文件

@@ -60,14 +60,14 @@
60 60
         <ion-label>
61 61
           Password
62 62
         </ion-label>
63
-        <ion-input type="text" placeholder="" [(ngModel)]="user.password" name="password"></ion-input>
63
+        <ion-input type="password" placeholder="" [(ngModel)]="user.password" name="password"></ion-input>
64 64
       </ion-item>
65 65
     </ion-list>
66 66
     <ion-item id="newProfile-input13">
67 67
       <ion-label>
68 68
         Verify Password
69 69
       </ion-label>
70
-      <ion-input type="text" placeholder="" [(ngModel)]="user.password" name="password">></ion-input>
70
+      <ion-input type="password" placeholder="" [(ngModel)]="user.password" name="password">></ion-input>
71 71
     </ion-item>
72 72
     <div class="spacer" style="width:299.514px;height:55.9757px;" id="newProfile-spacer4"></div>
73 73
     <button id="newProfile-button9" ion-button color="balanced" full on-click="register()">

+ 24
- 0
src/pages/schools/schools.html 查看文件

@@ -0,0 +1,24 @@
1
+<ion-header>
2
+  <ion-navbar>
3
+    <button ion-button menuToggle>
4
+      <ion-icon name="menu"></ion-icon>
5
+    </button>
6
+    <ion-title>
7
+      Select Teacher OR Rate School!
8
+    </ion-title>
9
+  </ion-navbar>
10
+</ion-header>
11
+<ion-content padding style="background:url(assets/imgs/final_spitball.jpg) no-repeat center;background-size:cover" id="page14">
12
+  <h1 id="teacherSelectPage-heading5" style="color:#000000;text-align:center;">
13
+  {{school.name}}
14
+  </h1>
15
+      <ion-item color="none" id="teacherSelectPage-list-item52">
16
+      <ion-thumbnail item-left>
17
+      <img
18
+        <img />
19
+      </ion-thumbnail>
20
+      <h2>
21
+        School Aggregate Score
22
+      </h2>
23
+    </ion-item>
24
+</ion-content>

+ 18
- 0
src/pages/schools/schools.ts 查看文件

@@ -0,0 +1,18 @@
1
+import { Component } from '@angular/core';
2
+import { NavController, NavParams } from 'ionic-angular';
3
+import { SearchPage } from '../../pages/search/search'
4
+
5
+
6
+@Component({
7
+  selector: 'page-school-page',
8
+  templateUrl: 'schools.html'
9
+})
10
+export class SchoolPage {
11
+    public school; 
12
+
13
+  constructor(public navCtrl: NavController, public navParams: NavParams) {
14
+
15
+      this.school = this.navParams.get("school");
16
+  }
17
+
18
+}

+ 11
- 4
src/pages/search/search.html 查看文件

@@ -8,10 +8,17 @@
8 8
     </ion-title>
9 9
   </ion-navbar>
10 10
 </ion-header>
11
-<ion-content padding style="background:url(assets/img/XevfnYbMSbmzquaF2tvl_final_spitball.jpg) no-repeat center;background-size:cover;" id="page3">
12
-  <form id="searchHomePage-form3">
13
-    <ion-searchbar placeholder="Enter Name or School Here" name="" id="searchHomePage-search1"></ion-searchbar>
14
-  </form>
11
+<ion-content padding style="background:url(assets/imgs/final_spitball.jpg) no-repeat center;background-size:cover;" id="page3">
12
+    <ion-searchbar 
13
+    placeholder="Enter Teacher Name or School Here" name="" id="searchHomePage-search1"
14
+    (ionInput)="getSchool($event)"
15
+    [spellcheck]="true">
16
+    </ion-searchbar>
17
+    <ion-list *ngFor= "let school of filterSchools" on-click="goToSchoolPage(school)">
18
+    <ion-list-header>
19
+        {{school.name}}
20
+    </ion-list-header>
21
+</ion-list>
15 22
   <h4 id="searchHomePage-heading2" style="color:#FF0000;"></h4>
16 23
   <form id="searchHomePage-form8">
17 24
     <ion-item id="searchHomePage-textarea1">

+ 45
- 2
src/pages/search/search.ts 查看文件

@@ -1,13 +1,56 @@
1 1
 import { Component } from '@angular/core';
2 2
 import { NavController } from 'ionic-angular';
3
+import { SchoolPage } from './../../pages/schools/schools';
4
+import { ConnectionProvider } from './../../providers/connection/connection';
5
+import { DistrictProvider } from './../../providers/connection/district';
6
+import { School } from './../../app/component/school'
7
+
8
+
3 9
 
4 10
 @Component({
5 11
   selector: 'page-search',
6 12
   templateUrl: 'search.html'
7 13
 })
8 14
 export class SearchPage {
15
+    listOfSchools: any; 
16
+    filterSchools: any;
17
+
18
+  constructor(public navCtrl: NavController, public conn: ConnectionProvider, public dist: DistrictProvider) {
19
+  }
20
+    ngOnInit(): void {
21
+        //Called after the constructor, initializing input properties, and the first call to ngOnChanges.
22
+        //Add 'implements OnInit' to the class.
23
+        this.dist.getAllSchools().subscribe(data => this.setData(data))
24
+    }
25
+
26
+    setData(data: any) {
27
+        this.listOfSchools = this.dist.parseData(data);
28
+        this.filterSchools = this.listOfSchools;
29
+    }
30
+
31
+    getSchool(event: any) {
32
+        this.filterSchools = this.listOfSchools
33
+        let val = event.target.value;
34
+
35
+        if (val && val.trim() != '') {
36
+            this.filterSchools = this.filterSchools.filter((item) => {
37
+             return (item.name.toLowerCase().indexOf(val.toLowerCase()) > -1);
38
+            });
39
+        }
9 40
 
10
-  constructor(public navCtrl: NavController) {
41
+    }
42
+    
43
+    goToSchoolPage(school: School){
44
+    this.navCtrl.push(SchoolPage, {
45
+        school: school
46
+    });
11 47
   }
48
+
49
+}
50
+
51
+
52
+
53
+    
54
+
55
+  
12 56
   
13
-}

+ 5
- 1
src/providers/connection/connection.ts 查看文件

@@ -10,7 +10,7 @@ import { Injectable } from '@angular/core';
10 10
 @Injectable()
11 11
 export class ConnectionProvider {
12 12
 public apiUrl = 'http://localhost:8080/';
13
-public user = this.apiUrl + '/user_profile';
13
+
14 14
 
15 15
   constructor(public http: HttpClient) {
16 16
     console.log('Hello ConnectionProvider Provider');
@@ -20,6 +20,10 @@ post(partialPath: string, data: any) {
20 20
   return this.http.post(this.apiUrl + partialPath, data);
21 21
 }
22 22
 
23
+get(partialPath: string, data: any) {
24
+  return this.http.get(this.apiUrl + partialPath, data);
25
+}
26
+
23 27
 
24 28
 
25 29
 }

+ 31
- 0
src/providers/connection/district.ts 查看文件

@@ -0,0 +1,31 @@
1
+import { HttpClient } from '@angular/common/http';
2
+import { Injectable } from '@angular/core';
3
+import { School } from './../../app/component/school'
4
+
5
+@Injectable()
6
+export class DistrictProvider {
7
+
8
+    public districtAPI = 'https://data.delaware.gov/api/views/wky5-77bt/rows.json?accessType=DOWNLOAD'
9
+
10
+    constructor(public http: HttpClient) {
11
+            console.log('Hello DistrictProvider Provider');
12
+
13
+    }
14
+
15
+    getAllSchools() {
16
+
17
+        return this.http.get(this.districtAPI) //.map((response: any) => {
18
+            // if (response.data.length > 0) {
19
+            //     return response.data[0].images.original.url;
20
+            // } else {
21
+            //     return console.log('error');
22
+        //     }
23
+        // });
24
+    }
25
+
26
+    parseData(data: any) {
27
+        return data["data"].map(school => new School(school[13]))
28
+    }
29
+
30
+
31
+}