Commit b7a80152 authored by Cornee Traas's avatar Cornee Traas
Browse files

More progress towards fixing up the menu

parent 2da3c32d
Pipeline #2504 failed with stages
in 1 minute and 9 seconds
...@@ -486,8 +486,8 @@ export default { ...@@ -486,8 +486,8 @@ export default {
goUp: function() { goUp: function() {
// If course page route to home // If course page route to home
if ( if (
settings.platforms.filter(el => { this.$store.state.platforms.filter(el => {
return el.slug === this.$route.path.replace("/", ""); return el.id === this.$route.path.replace("/", "");
}).length > 0 }).length > 0
) { ) {
this.$router.push("home"); this.$router.push("home");
...@@ -517,13 +517,13 @@ export default { ...@@ -517,13 +517,13 @@ export default {
var split = path.split("/"); var split = path.split("/");
//Set dropdown menus to the correct value //Set dropdown menus to the correct value
if (this.level >= 1) { if (this.level >= 2) {
this.selectedPlatform = split[1]; this.selectedPlatform = split[2];
this.setCourses(this.courses.coursera, this.selectedPlatform); this.setCourses(this.courses.coursera, this.selectedPlatform);
this.selectedCourse = split[2]; this.selectedCourse = split[3];
this.$store.commit("setSelectedPlatform", this.selectedPlatform); this.$store.commit("setSelectedPlatform", this.selectedPlatform);
} }
if (this.level >= 2) { if (this.level >= 3) {
this.currentCourse = this.$store.state.user.courses.find( this.currentCourse = this.$store.state.user.courses.find(
x => x.course_slug === this.selectedCourse x => x.course_slug === this.selectedCourse
); );
...@@ -535,14 +535,14 @@ export default { ...@@ -535,14 +535,14 @@ export default {
if (this.level === 0) { if (this.level === 0) {
// Home level // Home level
this.selectedPlatform = settings.platform_default; this.selectedPlatform = settings.platform_default;
} else if (this.level === 1) { } else if (this.level === 2) {
// Course overview level. // Course overview level.
this.selectedCourse = settings.course_default; this.selectedCourse = settings.course_default;
this.$store.commit("setCourses", this.courses.coursera); this.$store.commit("setCourses", this.courses.coursera);
} else if (this.level === 2) { } else if (this.level === 3) {
// Course level // Course level
this.setCoursePages(path); this.setCoursePages(path);
} else if (this.level === 3) { } else if (this.level === 4) {
// Set subitem // Set subitem
this.selectedSubitem = split[3]; this.selectedSubitem = split[3];
if (this.selectedSubitem === "videos") { if (this.selectedSubitem === "videos") {
...@@ -600,11 +600,11 @@ export default { ...@@ -600,11 +600,11 @@ export default {
for (var platform of this.platforms) { for (var platform of this.platforms) {
this.top_nav[0].push({ this.top_nav[0].push({
name: platform.name, name: platform.name,
url: platform.url || "/" + platform.slug, url: "/p/" + platform.id,
icon: "fa fa-line-chart", icon: "fa fa-line-chart",
}); });
this.platformOptions.push({ this.platformOptions.push({
value: platform.slug, value: platform.id,
text: platform.name, text: platform.name,
}); });
} }
...@@ -616,7 +616,7 @@ export default { ...@@ -616,7 +616,7 @@ export default {
text: strings.select_course, text: strings.select_course,
}, },
]; ];
this.top_nav[1] = []; this.top_nav[2] = [];
for (var course of c) { for (var course of c) {
// Push to dropdown // Push to dropdown
this.courseOptions.push({ this.courseOptions.push({
...@@ -624,7 +624,7 @@ export default { ...@@ -624,7 +624,7 @@ export default {
text: course.name, text: course.name,
}); });
// Push to navbar // Push to navbar
this.top_nav[1].push({ this.top_nav[2].push({
name: course.name, name: course.name,
url: "/" + this.selectedPlatform + "/" + course.slug, url: "/" + this.selectedPlatform + "/" + course.slug,
icon: "fa fa-line-chart", icon: "fa fa-line-chart",
...@@ -632,9 +632,9 @@ export default { ...@@ -632,9 +632,9 @@ export default {
} }
}, },
setCoursePages() { setCoursePages() {
this.top_nav[2] = []; this.top_nav[3] = [];
for (var coursepPage of settings.course_pages) { for (var coursepPage of settings.course_pages) {
this.top_nav[2].push({ this.top_nav[3].push({
name: coursepPage.name, name: coursepPage.name,
icon: coursepPage.icon, icon: coursepPage.icon,
url: url:
...@@ -651,10 +651,10 @@ export default { ...@@ -651,10 +651,10 @@ export default {
util util
.getVideos(this.currentCourse.course_id, this.$store.state.filters) .getVideos(this.currentCourse.course_id, this.$store.state.filters)
.then(response => { .then(response => {
this.top_nav[3] = []; this.top_nav[4] = [];
for (var video of response.data) { for (var video of response.data) {
this.top_nav[3].push({ this.top_nav[4].push({
name: video.name, name: video.name,
url: url:
"/" + "/" +
...@@ -669,7 +669,7 @@ export default { ...@@ -669,7 +669,7 @@ export default {
} }
}) })
.catch(err => { .catch(err => {
this.top_nav[3] = []; this.top_nav[4] = [];
console.log(err); console.log(err);
}); });
}, },
...@@ -677,9 +677,9 @@ export default { ...@@ -677,9 +677,9 @@ export default {
util util
.getQuizzes(this.currentCourse.course_id, this.$store.state.filters) .getQuizzes(this.currentCourse.course_id, this.$store.state.filters)
.then(response => { .then(response => {
this.top_nav[3] = []; this.top_nav[4] = [];
for (var quiz of response.data) { for (var quiz of response.data) {
this.top_nav[3].push({ this.top_nav[4].push({
name: quiz.name, name: quiz.name,
url: url:
"/" + "/" +
...@@ -696,7 +696,7 @@ export default { ...@@ -696,7 +696,7 @@ export default {
} }
}) })
.catch(err => { .catch(err => {
this.top_nav[3] = []; this.top_nav[4] = [];
console.log(err); console.log(err);
}); });
}, },
...@@ -704,12 +704,12 @@ export default { ...@@ -704,12 +704,12 @@ export default {
util util
.getAssignments(this.currentCourse.course_id, this.$store.state.filters) .getAssignments(this.currentCourse.course_id, this.$store.state.filters)
.then(response => { .then(response => {
this.top_nav[3] = []; this.top_nav[4] = [];
if (response.data.length == 0) { if (response.data.length == 0) {
this.$forceUpdate(); this.$forceUpdate();
} else } else
for (var assignment of response.data) { for (var assignment of response.data) {
this.top_nav[3].push({ this.top_nav[4].push({
name: assignment.name, name: assignment.name,
url: url:
"/" + "/" +
...@@ -724,7 +724,7 @@ export default { ...@@ -724,7 +724,7 @@ export default {
} }
}) })
.catch(err => { .catch(err => {
this.top_nav[3] = []; this.top_nav[4] = [];
console.log(err); console.log(err);
}); });
}, },
......
...@@ -50,16 +50,16 @@ const router = new VueRouter({ ...@@ -50,16 +50,16 @@ const router = new VueRouter({
component: Home, component: Home,
}, },
{ {
path: '/coursera', path: '/p/:platform',
redirect: '/coursera', redirect: '/p/:platform',
name: 'Coursera', name: 'Coursera',
component: Platform, component: Platform,
children: [{ children: [{
path: '/coursera', path: '/p/:platform',
name: '', name: '',
component: coursera.Courses, component: coursera.Courses,
}, { }, {
path: '/coursera/:courseid', path: '/p/:platform/:courseid',
name: 'CourseDetail', name: 'CourseDetail',
component: coursera.CourseDetail, component: coursera.CourseDetail,
meta: { meta: {
...@@ -67,7 +67,7 @@ const router = new VueRouter({ ...@@ -67,7 +67,7 @@ const router = new VueRouter({
}, },
}, },
{ {
path: '/coursera/:courseid/compare/:course2id', path: '/p/:platform/:courseid/compare/:course2id',
name: 'CourseComparison', name: 'CourseComparison',
component: coursera.CourseComparison, component: coursera.CourseComparison,
meta: { meta: {
...@@ -75,12 +75,12 @@ const router = new VueRouter({ ...@@ -75,12 +75,12 @@ const router = new VueRouter({
}, },
}, },
{ {
path: '/coursera/:courseid/videos', path: '/p/:platform/:courseid/videos',
name: 'Videos', name: 'Videos',
component: coursera.Videos, component: coursera.Videos,
}, },
{ {
path: '/coursera/:courseid/videos/:videoid', path: '/p/:platform/:courseid/videos/:videoid',
name: 'VideoDetail', name: 'VideoDetail',
component: coursera.VideoDetail, component: coursera.VideoDetail,
meta: { meta: {
...@@ -88,12 +88,12 @@ const router = new VueRouter({ ...@@ -88,12 +88,12 @@ const router = new VueRouter({
}, },
}, },
{ {
path: '/coursera/:courseid/quizzes', path: '/p/:platform/:courseid/quizzes',
name: 'Quizzes', name: 'Quizzes',
component: coursera.Quizzes, component: coursera.Quizzes,
}, },
{ {
path: '/coursera/:courseid/quizzes/:quizid', path: '/p/:platform/:courseid/quizzes/:quizid',
name: 'QuizDetail', name: 'QuizDetail',
component: coursera.QuizDetail, component: coursera.QuizDetail,
meta: { meta: {
...@@ -101,12 +101,12 @@ const router = new VueRouter({ ...@@ -101,12 +101,12 @@ const router = new VueRouter({
}, },
}, },
{ {
path: '/coursera/:courseid/assignments', path: '/p/:platform/:courseid/assignments',
name: 'Assignments', name: 'Assignments',
component: coursera.Assignments, component: coursera.Assignments,
}, },
{ {
path: '/coursera/:courseid/assignments/:assignmentid', path: '/p/:platform/:courseid/assignments/:assignmentid',
name: 'Assignment Details', name: 'Assignment Details',
component: coursera.AssignmentDetail, component: coursera.AssignmentDetail,
}, },
......
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
// Constants // Constants
quiz_id: 5, quiz_id: 5,
video_id: 1, video_id: 1,
max_nav_level: 3, max_nav_level: 4,
course_default: "course-select", course_default: "course-select",
platform_default: "platform-select", platform_default: "platform-select",
roles: [{ roles: [{
......
...@@ -175,7 +175,7 @@ export default { ...@@ -175,7 +175,7 @@ export default {
}) })
}, },
getCoursesData(platform, filters) { getCoursesData(filters, platform = store.state.selectedPlatform) {
return axios return axios
.get(this.platformUrl(platform) + `/course-analytics/` + this.getQueryParams(filters), { .get(this.platformUrl(platform) + `/course-analytics/` + this.getQueryParams(filters), {
headers: this.authHeader(), headers: this.authHeader(),
...@@ -244,21 +244,21 @@ export default { ...@@ -244,21 +244,21 @@ export default {
// Actions API calls // Actions API calls
getActions(platformId, courseId, filters) { getActions(platformId, courseId, filters) {
return axios return axios
.get(this.platformUrl() + `/actions/${courseId}/` + this.getQueryParams(filters), { .get(this.apiUrl() + `/actions/${store.state.selectedPlatform}/${courseId}/` + this.getQueryParams(filters), {
headers: this.authHeader(), headers: this.authHeader(),
}) })
}, },
saveAction(action) { saveAction(action) {
return axios return axios
.post(this.platformUrl() + `/actions/`, action, { .post(this.apiUrl() + `/actions/${store.state.selectedPlatform}/`, action, {
headers: this.authHeader(), headers: this.authHeader(),
}) })
}, },
deleteAction(pk) { deleteAction(pk) {
return axios return axios
.delete(this.platformUrl() + `/actions/${pk}` + '/', { .delete(this.apiUrl() + `/actions/${pk}/`, {
headers: this.authHeader(), headers: this.authHeader(),
}) })
}, },
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
> >
<b-card class="bg" no-body> <b-card class="bg" no-body>
<b-card-header> <b-card-header>
<router-link :to="platform.name.toLowerCase()"> <router-link :to="'/p/' + platform.id">
<h4>{{platform.name}}</h4> <h4>{{platform.name}}</h4>
</router-link> </router-link>
</b-card-header> </b-card-header>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<b-card no-body> <b-card no-body>
<b-card-header class="bg-primary"> <b-card-header class="bg-primary">
<router-link <router-link
:to="'/coursera/'+course.slug" :to="'/p/'+platform.id+'/'+course.slug"
class="link-light font-weight-bold" class="link-light font-weight-bold"
>{{ course.name }}</router-link> >{{ course.name }}</router-link>
</b-card-header> </b-card-header>
...@@ -189,7 +189,7 @@ export default { ...@@ -189,7 +189,7 @@ export default {
beforeMount() { beforeMount() {
for (let platform of this.$store.state.platforms) { for (let platform of this.$store.state.platforms) {
util util
.getCoursesData(platform.id, this.$store.state.filters) .getCoursesData(this.$store.state.filters, platform.id)
.then(response => { .then(response => {
this.$set(this.coursesCoursera, platform.id, response.data); this.$set(this.coursesCoursera, platform.id, response.data);
this.$set( this.$set(
......
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