Skip to content

Revert "Labfile markdown" #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions client/imports/ui/components/explore/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
viewProviders: [ MdIconRegistry ],
encapsulation: ViewEncapsulation.None
})

// Export Explore Class
export class SearchView extends MeteorComponent {

Expand All @@ -47,29 +47,30 @@ export class SearchView extends MeteorComponent {
totalItems: this.courses.length
};
pagedCourses: Array<any> = [];

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
Expand All @@ -87,33 +88,34 @@ 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 --;
this.refreshCourses();
}
}
}

2 changes: 0 additions & 2 deletions collections/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 1 addition & 19 deletions server/imports/lab/methods.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
});