Skip to content

Commit b55fd39

Browse files
sandershihackerDerekTBrown
authored andcommitted
Search Functionality Complete #37 (#139)
* Updated Schemas * Load Screen * Loading Screen * publish subscribe and dynamic explore page * deleted swap file * publish subscribe * template fixes * added start for reactive publication * template issue * . * . * course_records publish * course_records reactively publish * revert meteor update * publish subscribe and lineheight for searchpage icons * fixed indentation and removed test file * indentation * indentation * Accounts page and fixed random erro * toolbar for mobile devices * toolbar * account.html fixes * Toolbar made responsive * Responsive toolbar fixes * created userlist component * course_records course_id validation * indentation * markdown * import changes * validation addition * Forms Module Deprecated Warning. Issue #110 * indentation * Use routerLink * api changes (#126) * issue 32 fixed * removed swp * fixed nconf issues * issue 82, 84 fixes * fixed #82 * isse #77 * fixed tests * fixed files * fixed tests master * fixed comment * moved validator * removed duplicate file * fixed tests, removed duplicate underscore, publish * changes * fixed methods.ts import * fixed issues w methods * fixes * minor fixes * A * api changes * fixed api * comments * minor changes * minor fixes * method implementations (#127) * issue 32 fixed * removed swp * fixed nconf issues * issue 82, 84 fixes * fixed #82 * isse #77 * fixed tests * fixed files * fixed tests master * fixed comment * moved validator * removed duplicate file * fixed tests, removed duplicate underscore, publish * changes * fixed methods.ts import * fixed issues w methods * fixes * minor fixes * A * api changes * fixed api * comments * minor changes * minor fixes * method implementations * course pages now uses Child Routing * deleted LabData class * school name * search function dashboard pull data from database fix inappropriate file naming for gradelist and lablist more templating issues
1 parent bc11bd2 commit b55fd39

30 files changed

+482
-582
lines changed
Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,45 @@
11
<div class="tuxlab-searchview">
2-
<div class="md-whiteframe-5dp course-search-list">
3-
4-
<h2 id="search-string">Search Results for '{{ searchQuery }}'</h2>
5-
6-
<div class="selector">
7-
<button md-button (click)="prevPage()" class="right">
8-
<md-icon fontIcon="tuxicon-left"></md-icon>
9-
Prev
10-
</button>
11-
<!--
12-
<span [innerHTML]="getCurrentInfo()"></span>
13-
-->
14-
<button md-button (click)="nextPage()" class="right">
15-
Next
16-
<md-icon fontIcon="tuxicon-right"></md-icon>
17-
</button>
18-
</div>
19-
20-
<hr>
21-
<md-data-table layout-fill>
22-
<thead>
23-
<tr>
24-
<th class="md-text-cell">Course Number</th>
25-
<th class="md-text-cell">Course Name</th>
26-
<th>Instructor</th>
27-
</tr>
28-
</thead>
29-
<tbody>
30-
<tr *ngFor="let course of searchResults">
31-
<td class="md-text-cell">{{ course.course_number }}</td>
32-
<td class="md-text-cell">{{ course.course_name }}</td>
33-
<td>{{ course.instructor_name }}</td>
34-
</tr>
35-
</tbody>
36-
</md-data-table>
37-
<hr>
38-
39-
<div class="selector">
40-
<button md-button (click)="prevPage()" class="right">
41-
<md-icon fontIcon="tuxicon-left"></md-icon>
42-
Prev
43-
</button>
44-
<!--
45-
<span [innerHTML]="getCurrentInfo()"></span>
46-
-->
47-
<button md-button (click)="nextPage()" class="right">
48-
Next
49-
<md-icon fontIcon="tuxicon-right"></md-icon>
50-
</button>
51-
</div>
52-
53-
</div>
54-
</div>
2+
<div class="md-whiteframe-5dp course-search-list">
3+
<h2 id="search-string">Search Results for '{{ searchQuery }}'</h2>
4+
<div class="selector">
5+
<button md-button (click)="prevPage()" class="right">
6+
<md-icon fontIcon="tuxicon-left"></md-icon>
7+
Prev
8+
</button>
9+
<span [innerHTML]="getCurrentInfo()"></span>
10+
<button md-button (click)="nextPage()" class="right">
11+
Next
12+
<md-icon fontIcon="tuxicon-right"></md-icon>
13+
</button>
14+
</div>
15+
<hr>
16+
<md-data-table layout-fill>
17+
<thead>
18+
<tr>
19+
<th class="md-text-cell">Course Number</th>
20+
<th class="md-text-cell">Course Name</th>
21+
<th>Instructor</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
<tr *ngFor="let course of searchResults">
26+
<td class="md-text-cell">{{ course.course_number }}</td>
27+
<td class="md-text-cell">{{ course.course_name }}</td>
28+
<td>{{ course.instructor_ids }}</td>
29+
</tr>
30+
</tbody>
31+
</md-data-table>
32+
<hr>
33+
<div class="selector">
34+
<button md-button (click)="prevPage()" class="right">
35+
<md-icon fontIcon="tuxicon-left"></md-icon>
36+
Prev
37+
</button>
38+
<span [innerHTML]="getCurrentInfo()"></span>
39+
<button md-button (click)="nextPage()" class="right">
40+
Next
41+
<md-icon fontIcon="tuxicon-right"></md-icon>
42+
</button>
43+
</div>
44+
</div>
45+
</div>

client/imports/ui/components/explore/search.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
export class SearchView extends MeteorComponent {
4242
@Input() searchQuery;
4343
@Input() searchResults;
44-
currentPage = 1;
45-
resultsPerPage = 2;
44+
@Input() courseCount;
45+
@Input() currentPage;
46+
resultsPerPage = 15;
4647
constructor(mdIconRegistry: MdIconRegistry) {
4748
super();
4849
// Create Icon Font
@@ -53,15 +54,17 @@ export class SearchView extends MeteorComponent {
5354
// Go to next page function
5455
nextPage() {
5556
let self = this;
56-
this.currentPage++;
57-
Meteor.call('search_courses', this.searchQuery, this.resultsPerPage, this.currentPage, function(error, result) {
58-
if(error) {
59-
console.log(error);
60-
}
61-
else {
62-
self.searchResults = result;
63-
}
64-
});
57+
if (this.currentPage * this.resultsPerPage < this.courseCount) {
58+
this.currentPage++;
59+
Meteor.call('search_courses', this.searchQuery, this.resultsPerPage, this.currentPage, function(error, result) {
60+
if(error) {
61+
console.log(error);
62+
}
63+
else {
64+
self.searchResults = result.course_results;
65+
}
66+
});
67+
}
6568
}
6669

6770
// Go to previous page function
@@ -74,9 +77,29 @@ export class SearchView extends MeteorComponent {
7477
console.log(error);
7578
}
7679
else {
77-
self.searchResults = result;
80+
self.searchResults = result.course_results;
7881
}
7982
});
8083
}
8184
}
85+
86+
getCurrentInfo() {
87+
var first = ((this.currentPage - 1) * this.resultsPerPage + 1);
88+
var last;
89+
if((first + this.resultsPerPage - 1) > this.courseCount) {
90+
last = this.courseCount;
91+
}
92+
else {
93+
last = first + this.resultsPerPage - 1;
94+
}
95+
if(first > last) {
96+
this.currentPage = 1;
97+
first = 1;
98+
}
99+
if(this.courseCount === 0) {
100+
first = 0;
101+
}
102+
return first + "-" + last + " of " + this.courseCount;
103+
}
104+
82105
}

client/imports/ui/components/gradelist/gradelist.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.

client/imports/ui/components/lablist/lablist.ts

Lines changed: 0 additions & 95 deletions
This file was deleted.

client/imports/ui/components/markdown/markdown.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
<!--Markdown-->
2121
<div class="markdown-content">
22-
<div id="task-markdown" [innerHTML]="convertedData">Task loading...</div>
22+
<div id="task-markdown" [innerHTML]="convert(mdData)"></div>
2323
</div>
2424
</div>

0 commit comments

Comments
 (0)