diff --git a/client/imports/ui/components/explore/search.ts b/client/imports/ui/components/explore/search.ts index d93998bd..53a70f2c 100644 --- a/client/imports/ui/components/explore/search.ts +++ b/client/imports/ui/components/explore/search.ts @@ -36,7 +36,7 @@ viewProviders: [ MdIconRegistry ], encapsulation: ViewEncapsulation.None }) - + // Export Explore Class export class SearchView extends MeteorComponent { @@ -47,29 +47,30 @@ export class SearchView extends MeteorComponent { totalItems: this.courses.length }; pagedCourses: Array = []; - + constructor(mdIconRegistry: MdIconRegistry) { super(); - + // Create Icon Font mdIconRegistry.registerFontClassAlias('tux', 'tuxicon'); mdIconRegistry.setDefaultFontSetClass('tuxicon'); - - // Subscribe Courses Database + + // Subscribe Courses Database + //this.getCourses(); this.subscribe('all-courses', () => { this.courses = courses.find().fetch(); this.pagination.totalItems = this.courses.length; this.refreshCourses(); }, true); } - + // Refresh Courses List refreshCourses() { let start = (this.pagination.currentPage - 1) * this.pagination.itemsPerPage; let end = start + this.pagination.itemsPerPage; this.pagedCourses = this.courses.slice(start, end); } - + // Display the infomation of current state of pagination getCurrentInfo() { // This is the number of the first item on the current page @@ -87,29 +88,29 @@ export class SearchView extends MeteorComponent { return start.toString() + "-" + end.toString() + " of " + this.pagination.totalItems.toString(); } - + // Go to next page function nextPage() { - + // Get the current page let currentPage = this.pagination.currentPage; - + // Get the last possible page let lastPage = Math.ceil(this.pagination.totalItems / this.pagination.itemsPerPage); - + // Check if the current page is the last page if (currentPage !== lastPage) { this.pagination.currentPage ++; this.refreshCourses(); } } - + // Go to previous page function prevPage() { - + // Get the current page let currentPage = this.pagination.currentPage; - + // Check if the current page is the first page if (currentPage !== 1) { this.pagination.currentPage --; @@ -117,3 +118,4 @@ export class SearchView extends MeteorComponent { } } } + diff --git a/collections/README.md b/collections/README.md index ae9cc73b..e99abd57 100644 --- a/collections/README.md +++ b/collections/README.md @@ -60,8 +60,6 @@ The following document describes the MongoDB Schema used by the TuxLab app: course_number: "15-131", course_name: "Great Practical Ideas for Computer Scientists", instructor_name: "Tom Cortina", - hidden: true, // Course is invisible to students. Default is true. - disabled: false, // Enrollment in course is still open. Default is true. course_description: { content: "This is the course description.", syllabus: "This is the course syllabus" diff --git a/server/imports/lab/methods.ts b/server/imports/lab/methods.ts index 7de5eec5..9cf5af26 100644 --- a/server/imports/lab/methods.ts +++ b/server/imports/lab/methods.ts @@ -1,28 +1,10 @@ -import { Meteor } from 'meteor/meteor'; -import { Mongo } from 'meteor/mongo'; -import { check } from 'meteor/check'; - declare var Collections : any; - Meteor.methods({ 'prepareLab': function(courseId : String,labId : Number){ console.log("here"); // var course = Collections.courses.findOne({_id: courseId}).fetch(); //var t = require('../api/labExec.js'); // return course.labs.find((l) => { return l._id == labId; }); - }, - 'search_courses': function(text : String){ - var courses = Collections.courses; - - var search_pattern = new RegExp(text,"i"); - - var number_search = {"course_number" : search_pattern}; - var alternate_number_search = {$where: "this.course_number.replace(/[ .-]/g,'') == '"+text+"'"}; - var name_results = {"course_name" : search_pattern}; - - var results = courses.find({$and : [{"visible" : true}, {$or : [number_search, alternate_number_search, name_results]}}).limit(15); - - return results; - } + } });