backend Schedule
This commit is contained in:
		@ -1,7 +1,12 @@
 | 
			
		||||
<script setup>
 | 
			
		||||
  import { ref } from 'vue'
 | 
			
		||||
  import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../schedule.js'
 | 
			
		||||
 
 | 
			
		||||
  import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../scheduleFunctions.js'
 | 
			
		||||
  import {getAllSchedule} from "@/rest/scheduleRest.js";
 | 
			
		||||
 | 
			
		||||
  const test = await getAllSchedule();
 | 
			
		||||
 | 
			
		||||
  console.log(test);
 | 
			
		||||
 | 
			
		||||
  const schedule = [
 | 
			
		||||
    {
 | 
			
		||||
     course:{
 | 
			
		||||
 | 
			
		||||
@ -8,8 +8,6 @@ import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
 | 
			
		||||
 * Create a new course
 | 
			
		||||
 */
 | 
			
		||||
export async function createCourse(name, credits, owner){
 | 
			
		||||
  console.log(owner);
 | 
			
		||||
  
 | 
			
		||||
	return restPost("/course", {title: name, credits: credits, owner} )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										65
									
								
								frontend/src/rest/lessonSchedule.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								frontend/src/rest/lessonSchedule.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,65 @@
 | 
			
		||||
import {restGet,restPatch,restPost,restDelete} from "@/rest/restConsumer.js";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a new lesson
 | 
			
		||||
 */
 | 
			
		||||
export async function createLesson(course, start, end, color, local){
 | 
			
		||||
    return restPost("/lesson", {course: course , start: start, end: end, color : color , local : local} )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Delete a lesson
 | 
			
		||||
 */
 | 
			
		||||
export async function deleteLesson(id){
 | 
			
		||||
    return restDelete("/lesson/" + id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get information on a particular course
 | 
			
		||||
 *
 | 
			
		||||
 * @return all attribute of the lesson
 | 
			
		||||
 *  - course
 | 
			
		||||
 *  - start
 | 
			
		||||
 *  - end
 | 
			
		||||
 *  - color
 | 
			
		||||
 *  - local
 | 
			
		||||
 */
 | 
			
		||||
export async function getLesson(id){
 | 
			
		||||
    return restGet("/lesson/" + id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get the list of courses to display on secretary's option
 | 
			
		||||
 *
 | 
			
		||||
 * @return list of courses of the form
 | 
			
		||||
 * - id
 | 
			
		||||
 * - name
 | 
			
		||||
 * - credits
 | 
			
		||||
 * - facutly
 | 
			
		||||
 * - teacher
 | 
			
		||||
 * - Assistants
 | 
			
		||||
 */
 | 
			
		||||
export async function getLessons(role){
 | 
			
		||||
    if(role==="Teacher"){
 | 
			
		||||
        return restGet("/lessons/owned")
 | 
			
		||||
    }
 | 
			
		||||
    return restGet("/lessons")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Change the options of a course
 | 
			
		||||
 *
 | 
			
		||||
 * @param id the id of the course
 | 
			
		||||
 * @param changes Object with value to changes
 | 
			
		||||
 *
 | 
			
		||||
 * The changes object can contain:
 | 
			
		||||
 *  - name
 | 
			
		||||
 *  - credits
 | 
			
		||||
 *  - faculty
 | 
			
		||||
 *  - teacher
 | 
			
		||||
 *  - assistants: should be a list and will replace all assistants
 | 
			
		||||
 */
 | 
			
		||||
export async function alterLesson(id, changes){
 | 
			
		||||
    return restPatch("/course/" + id, changes);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								frontend/src/rest/scheduleRest.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								frontend/src/rest/scheduleRest.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
import {restGet,restPost,restPatch} from "@/rest/restConsumer.js";
 | 
			
		||||
 | 
			
		||||
export async function getAllSchedule(){
 | 
			
		||||
    return restGet('/schedules');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getOwnSchedule(){
 | 
			
		||||
    return restGet('/schedule')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function createSchedule(curriculum) {
 | 
			
		||||
    return restPost('/schedule',{curriculum : curriculum})
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user