Skip to content
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

Issues 50, 65 #181

Merged
merged 3 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2 id="detailHeading">
<label for="numInput">Course #: </label>
<input id="numInput" class="form-control" [(ngModel)]="course.number" placeholder="num" #newNum>
</div>

</div>
<div class="form-row">
<div id="nameField" class="form-group form-inline">
Expand Down Expand Up @@ -42,7 +42,7 @@ <h2 id="detailHeading">
</div>

<div id="buttonHolder">
<!-- These are intentionally left without a (click) function
<!-- These are intentionally left without a (click) function
for now, TODO implement functionality -->
<button class="btn btn-search" id="save" (click)="saveCourse()">Save Changes</button>
<button class="btn btn-search" id="cancel" (click)="goBack()">Cancel</button>
Expand Down
13 changes: 11 additions & 2 deletions yacs-admin-angular/src/app/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ import { School } from './school/school';
import { Department } from './department/department';
import { Course } from './course/course';
import { Section } from './section/section';
import { Period } from './section/period';

export const SECTIONS: Section[] = [
{id: 1, course_id: 1, name: '01', crn: 87654, instructors: ["Goldschmidt", "Krishnamoorthy"],
seats: 10, seats_taken: 5, conflicts: [1, 2, 3], num_periods: 2},
seats: 10, seats_taken: 5, conflicts: [1, 2, 3],
periods: [
new Period(800, 950, 2),
new Period(800, 950, 5),
], num_periods: 2},
{id: 2, course_id: 1, name: '02', crn: 87655, instructors: ["Goldschmidt"],
seats: 10, seats_taken: 3, conflicts: [1, 2, 3], num_periods: 2},
seats: 10, seats_taken: 3, conflicts: [1, 2, 3],
periods: [
new Period(1600, 1750, 1),
new Period(1600, 1750, 4),
], num_periods: 2},
];

export const COURSES: Course[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<h2 id="detailHeading">{{school.name}} Details</h2>
<div id="nameField" class="form-group">
<label for="nameInput">Name: </label>
<input id="nameInput" class="form-control" [(ngModel)]="school.name" placeholder="name" #newName/>
<input id="nameInput" class="form-control" [(ngModel)]="school.name" placeholder="name" #newName/>
</div>

<div id="buttonHolder">
<button class="btn btn-search" id="save" (click) ="save(newName)">Save Changes</button>
<button class="btn btn-search" id="cancel" (click)="cancel(newName)" >Cancel</button>
</div>
</div>"
</div>
11 changes: 8 additions & 3 deletions yacs-admin-angular/src/app/section/period.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export class Period {
type: string;
day: number;
// start and end are in MINUTES SINCE START OF THE WEEK // no?
//type: string;
start: number;
end: number;
day: number;

constructor(start, end, day) {
this.start = start;
this.end = end;
this.day = day;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<div id ="sectionDetail" *ngIf="section">
<h2 id="detailHeading">{{section.name}} Details</h2>
<div id="nameField" class="form-group">
<h2 id="detailHeading">
Section {{section.department_code}} {{section.number}} {{section.name}} Details
</h2>

<div id="nameField" class="form-group form-inline">
<label for="nameInput">Name: </label>
<input id="nameInput" class="form-control" [(ngModel)]="section.name" placeholder="name" #newName/>
</div>

<div id = "crnField" class="form-group form-inline">
<label for = "crnField">CRN: &nbsp;</label>
<input id ="crnField" class="form-control" style="width:100px !important;" [(ngModel)]="section.crn" placeholder="crn" #newCode/>
</div>

<div id = "instructorField" class="form-group form-inline">
<label for="instructorInput">Instructor(s): </label>
<input id ="instructorField" class="form-control" [(ngModel)]="section.instructors" placeholder="instructors" #newInstructors/>
</div>

<div id="buttonHolder">
<button class="btn btn-search" id="save" (click) ="save(newName)">Save Changes</button>
<button class="btn btn-search" id="cancel" (click)="cancel(newName)" >Cancel</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,24 @@ <h2 *ngIf="selectedCourse">Sections of {{selectedCourse.name}}</h2>
</thead>

<tbody>
<tr *ngFor="let section of sections">
<tr *ngFor="let section of sections" style="display: block">
<td class="id">{{section.id}}</td>
<td class="id">{{section.name}}</td>
<td class="code">{{section.crn}}</td>
<td>{{ section.instructors.join(', ') }}</td>
<td class="code">{{ section.seats-section.seats_taken }}/{{section.seats}}</td>
<td class="code">{{section.seats-section.seats_taken}}/{{section.seats}}</td>
<td class="id" style="text-align: center !important;"><a routerLink="{{section.id}}">Details</a></td>
<td class="id" style="text-align: center !important;"><a routerLink="/sections" [queryParams]="{section_id: section.id }">Show Periods</a></td>
<td class="id" style="text-align: center !important;"><a class="delete" (click)="deleteSection(section)" >Delete</a></td>
<td class="id" style="text-align: center !important;"><a (click)="showPeriods(section)">Show Periods</a></td>
<td class="id" style="text-align: center !important;"><a class="delete" (click)="deleteSection(section)">Delete</a></td>

<ng-container *ngIf="section === selectedSection">
<table style="margin: 5px;">
<b>Periods</b>
<td *ngFor="let period of section.periods">
Start: {{period.start}} End: {{period.end}} Day: {{getDay(period)}}
</td>
</table>
</ng-container>
</tr>

</tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnInit } from '@angular/core';
import { YacsService } from '../../services/yacs.service';
import { Section } from '../section';
import { Course } from '../../course/course';
import { Section } from '../section';
import { Period } from '../period';
import { ActivatedRoute } from '@angular/router';
const SHORT_DAYS: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
Expand All @@ -13,15 +13,12 @@ const SHORT_DAYS: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
})
export class SectionListComponent implements OnInit{
sections: Section[];
test_periods: Period[];
selectedSection: Section;
selectedCourse: Course;
course_id: number;
constructor(private route: ActivatedRoute, private yacsService: YacsService) { }

getSections(): void{
this.yacsService.getSections()
.subscribe(sections => this.sections = sections);
}

ngOnInit() {
this.setCourseId();
//this.getSelectedCourse(0);
Expand All @@ -33,6 +30,10 @@ export class SectionListComponent implements OnInit{
else{
this.getSections();
}
this.test_periods = [
{start:800, end:950, day:2},
{start:800, end:950, day:5},
];
}

setCourseId(): void{
Expand All @@ -43,6 +44,11 @@ export class SectionListComponent implements OnInit{
});
}

getSections(): void{
this.yacsService.getSections()
.subscribe(sections => this.sections = sections);
}

getCourseSections(course_id: number): void{
this.yacsService.getSectionsByCourseID(course_id)
.subscribe(sections => {
Expand Down Expand Up @@ -77,6 +83,11 @@ export class SectionListComponent implements OnInit{

}

showPeriods(section): void{
this.selectedSection = section;
console.log(section.periods);
}


public getDay(period: Period) : string {
return SHORT_DAYS[period.day];
Expand Down
6 changes: 3 additions & 3 deletions yacs-admin-angular/src/app/section/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export class Section {
seats: number;
seats_taken: number;
conflicts: number[];
//periods: Period[];
periods: Period[];
num_periods: number;

constructor(id, course_id, name, crn, instructors, seats, seats_taken, conflicts, num_periods) {
constructor(id, course_id, name, crn, instructors, seats, seats_taken, conflicts, periods, num_periods) {
this.id = id;
this.course_id = course_id;
this.name = name;
Expand All @@ -25,7 +25,7 @@ export class Section {
this.seats = seats;
this.seats_taken = seats_taken;
this.conflicts = conflicts;
//this.periods = periods;
this.periods = periods;
this.num_periods = num_periods;
}
}
12 changes: 11 additions & 1 deletion yacs-admin-angular/src/app/services/in-memory-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ export class InMemoryDataService implements InMemoryDbService {
createDb(){
const sections= [
{id: 1, course_id: 1, name: '01', crn: 87654, instructors: ["Goldschmidt", "Krishnamoorthy"],
seats: 10, seats_taken: 5, conflicts: [1, 2, 3], num_periods: 2},
seats: 10, seats_taken: 5, conflicts: [1, 2, 3],
periods: [
{start: 800, end: 950, day: 2},
{start: 800, end: 950, day: 5},
], num_periods: 2},
{id: 2, course_id: 1, name: '02', crn: 87655, instructors: ["Goldschmidt", "Krishnamoorthy"],
seats: 10, seats_taken: 3, conflicts: [1, 2, 3],
periods: [
{start: 1600, end: 1750, day: 1},
{start: 1600, end: 1750, day: 4},
], num_periods: 2},
];
const courses = [
{id: 1, name: 'Stars, Galaxies and the Cosmos', number: '1960', department_code: 'ASTR',
Expand Down