Commit d0108f0a authored by Alexander Dietmüller's avatar Alexander Dietmüller

Frontend: Integrate actual API requests into CourseView

parent 1e2deb32
import PvkList from './PvkList';
const m = require('mithril');
const { Courses, UserCourses } = require('./api.js');
const { Courses } = require('./api.js');
module.exports = {
oninit() { Courses.load(); },
view() {
<<<<<<< HEAD
return m('div', [m(PvkList)]);
=======
// return m('div', 'Hellooo!');
return m('ul', [
Courses.list.map(course =>
m('li', [
m('p', `${course.lecture.title}, ${course.assistant}`),
m(
'button',
{ onclick() { UserCourses.select(course); } },
'Add Course',
),
])),
return m('table', [
m('thead', [
m('tr', [
m('th', 'Course'),
m('th', 'Department'),
m('th', 'Name'),
m('th', 'Starting time'),
m('th', 'Ending time'),
]),
]),
m('tbody', Courses.list.map(course =>
m('tr', [
m('td', course.lecture.title),
m('td', course.lecture.department),
m('td', course.assistant.name),
course.datetimes.map(timeslot => [
m('td', timeslot.start),
m('td', timeslot.end),
]),
m('td', m('button', 'add course')),
]))),
]);
// m('button', { onclick() { Courses.select(); } }, 'Add Course');
>>>>>>> Frontend: Talk to backend and display courses in sidebar
},
};
import m from 'mithril';
class Pvk {
constructor() {
this.list = [];
}
loadlist() {
// todo: this is just a mock request and has to be replaced with the proper one
// request is needed to force mithrijs to update shared objects
m.request({
method: 'GET',
// url: `${apiUrl}`,
}).then(() => {
this.list = [{
lecture: {
title: 'lecture1',
department: 'depart1',
year: 17,
},
assistant: {
nethz: 'nethzmail',
name: 'assi name',
},
datetimes: [{
start: '2017-10-15T16:15:20Z',
end: '2017-10-16T16:15:20Z',
}],
spots: 15,
selected: true,
reserved: true,
payed: true,
}, {
lecture: {
title: 'lecture1',
department: 'depart1',
year: 17,
},
assistant: {
nethz: 'nethzmail',
name: 'assi name',
},
datetimes: [{
start: '2017-10-15T16:15:20Z',
end: '2017-10-16T16:15:20Z',
}],
spots: 15,
selected: false,
reserved: false,
payed: false,
}];
});
}
}
export default new Pvk();
import m from 'mithril';
import Pvk from './Pvk';
module.exports = {
oninit() {
Pvk.loadlist();
m.redraw();
},
view() {
return m('table', [
m('thead', [
m('tr', [
m('th', 'Course'),
m('th', 'Department'),
m('th', 'Name'),
m('th', 'Starting time'),
m('th', 'Ending time'),
]),
]),
m('tbody', Pvk.list.map(pvk =>
m('tr', [
m('td', pvk.lecture.title),
m('td', pvk.lecture.department),
m('td', pvk.assistant.name),
pvk.datetimes.map(timeslot => [
m('td', timeslot.start),
m('td', timeslot.end),
]),
m('td', m('button', 'add course')),
]))),
]);
},
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment