Skip to content

Commit

Permalink
TimeTableGenerationService completed, added to main app module and in…
Browse files Browse the repository at this point in the history
…jected into timetable component.
  • Loading branch information
RbkGh committed Mar 17, 2017
1 parent 126d148 commit ad36ca8
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {ProgrammeGroupService} from "./services/programme-group.service";
import {TutorFiltrationService} from "./services/tutor-filtration.service";
import {ProgrammeGroupFiltrationService} from "./services/programme-group-filtration.service";
import {SubjectFiltrationService} from "./services/subject-filtration.service";
import {TimeTableGenerationService} from "./services/time-table-generation.service";

const appRoutes: Routes = [
{
Expand Down Expand Up @@ -102,7 +103,9 @@ const appRoutes: Routes = [
ProgrammeGroupService,
TutorFiltrationService,
ProgrammeGroupFiltrationService,
SubjectFiltrationService],
SubjectFiltrationService,
TimeTableGenerationService
],
bootstrap: [AppComponent]
})
export class AppModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from "@angular/core";
import {TimeTableGenerationService} from "../../../services/time-table-generation.service";
import {FormBuilder} from "@angular/forms";

@Component({
selector: 'app-time-table',
templateUrl: './time-table.component.html',
styleUrls: ['./time-table.component.css']
styleUrls: ['./time-table.component.css'],
providers: [TimeTableGenerationService]
})
export class TimeTableComponent implements OnInit {

constructor() { }
constructor(private timeTableGenerationService: TimeTableGenerationService,
private formBuilder: FormBuilder) {
}

ngOnInit() {
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/helpers/url-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ export class UrlEndpoints {
public static SUBJECT_ENDPOINT : string=UrlEndpoints.BASE_URL+"/subject";
public static SUBJECT_ALLOCATION_ENDPOINT : string=UrlEndpoints.SUBJECT_ENDPOINT+"/allocation";
public static PROGRAMME_GROUP_ENDPOINT : string=UrlEndpoints.BASE_URL+"/programmegroup";

/**
* timetable generation base url endpoint.
* @type {string}
*/
public static TIMETABLE_GENERATION_ENDPOINT : string = UrlEndpoints.BASE_URL+"/timetable";
}
8 changes: 6 additions & 2 deletions src/app/models/general-response-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
*/
export class GeneralResponsePayload{



/**
*
* @param status
* @param message
* @param responseObject
*/
constructor(public status: number, public message: string,public responseObject) {

}
Expand Down
23 changes: 23 additions & 0 deletions src/app/models/period-or-lecture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export class PeriodOrLecture {

/**
*
* @param periodName
* @param periodNumber
* @param periodStartandEndTime
* @param isAllocated
* @param subjectUniqueIdInDb
* @param subjectFullName
* @param tutorUniqueId
* @param tutorFullName
*/
constructor(public periodName: string,
public periodNumber: number,
public periodStartandEndTime: string,
public isAllocated: boolean,
public subjectUniqueIdInDb: string,
public subjectFullName: string,
public tutorUniqueId: string,
public tutorFullName: string) {
}
}
7 changes: 7 additions & 0 deletions src/app/models/programme-day.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {PeriodOrLecture} from "./period-or-lecture";
export class ProgrammeDay {
constructor(public dayName: string,
public periodList: Array<PeriodOrLecture>) {

}
}
9 changes: 9 additions & 0 deletions src/app/models/programme-group-personal-time-table-entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {ProgrammeDay} from "./programme-day";
export class ProgrammeGroupPersonalTimeTableEntity {

constructor(public programmeCode: string,
public programmeDaysList: Array<ProgrammeDay>) {

}
}

11 changes: 11 additions & 0 deletions src/app/models/time-table-generation-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class TimeTableGenerationRequest {

/**
*
* @param timeTableName
* @param yearGroup
*/
constructor(public timeTableName: string,
public yearGroup: number) {
}
}
11 changes: 11 additions & 0 deletions src/app/models/time-table-main-entity-array-response-payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {GeneralResponsePayload} from "./general-response-payload";
import {TimeTableMainEntity} from "./time-table-main-entity";
/**
* array of {@link TimeTableMainEntity} payload
*/
export class TimeTableMainEntityArrayResponsePayload extends GeneralResponsePayload {

constructor(status: number, message: string, responseObject: Array<TimeTableMainEntity>) {
super(status, message, responseObject);
}
}
9 changes: 9 additions & 0 deletions src/app/models/time-table-main-entity-response-payload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {GeneralResponsePayload} from "./general-response-payload";
import {TimeTableMainEntity} from "./time-table-main-entity";
export class TimeTableMainEntityResponsePayload extends GeneralResponsePayload {


constructor(status: number, message: string, responseObject: TimeTableMainEntity) {
super(status, message, responseObject);
}
}
16 changes: 16 additions & 0 deletions src/app/models/time-table-main-entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {TutorPersonalTimeTableEntity} from "./tutor-personal-time-table-entity";
import {ProgrammeGroupPersonalTimeTableEntity} from "./programme-group-personal-time-table-entity";
export class TimeTableMainEntity {
/**
*
* @param year
* @param timeTableName
* @param tutorPersonalTimeTableDocs
* @param programmeGroupPersonalTimeTableDocs
*/
constructor(public year: number,
public timeTableName: string,
public tutorPersonalTimeTableDocs: TutorPersonalTimeTableEntity,
public programmeGroupPersonalTimeTableDocs: ProgrammeGroupPersonalTimeTableEntity) {
}
}
12 changes: 12 additions & 0 deletions src/app/models/tutor-personal-time-table-entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {ProgrammeDay} from "./programme-day";
export class TutorPersonalTimeTableEntity {

/**
*
* @param tutorUniqueIdInDb
* @param programmeDaysList
*/
constructor(public tutorUniqueIdInDb: string,
public programmeDaysList: Array<ProgrammeDay>) {
}
}
16 changes: 16 additions & 0 deletions src/app/services/time-table-generation.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* tslint:disable:no-unused-variable */

import { TestBed, async, inject } from '@angular/core/testing';
import { TimeTableGenerationService } from './time-table-generation.service';

describe('TimeTableGenerationService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [TimeTableGenerationService]
});
});

it('should ...', inject([TimeTableGenerationService], (service: TimeTableGenerationService) => {
expect(service).toBeTruthy();
}));
});
32 changes: 32 additions & 0 deletions src/app/services/time-table-generation.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Injectable} from "@angular/core";
import {Http, RequestOptions, Headers, Response} from "@angular/http";
import {Observable} from "rxjs";
import {UrlEndpoints} from "../helpers/url-endpoints";
import {TimeTableGenerationRequest} from "../models/time-table-generation-request";
import {TimeTableMainEntityResponsePayload} from "../models/time-table-main-entity-response-payload";
import {TimeTableMainEntityArrayResponsePayload} from "../models/time-table-main-entity-array-response-payload";

@Injectable()
export class TimeTableGenerationService {

constructor(private http : Http) { }

generateTimeTable(timetableGenerationRequest: TimeTableGenerationRequest): Observable<TimeTableMainEntityResponsePayload> {
let timeTableGenerationEndpoint:string = UrlEndpoints.TIMETABLE_GENERATION_ENDPOINT;
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.post(timeTableGenerationEndpoint, timetableGenerationRequest, options).map(
(response: Response) => response.json())
.catch((e: any) => Observable.throw(e.json() || "server Error"));
}

getAllGeneratedTimeTables(): Observable<TimeTableMainEntityArrayResponsePayload> {
let timeTableGenerationEndpoint = UrlEndpoints.TIMETABLE_GENERATION_ENDPOINT;
let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers});
return this.http.get(timeTableGenerationEndpoint, options).map(
(response: Response) => response.json())
.catch((e: any) => Observable.throw(e.json() || "server Error"));
}

}

0 comments on commit ad36ca8

Please sign in to comment.