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);
}); });
}, },
......
...@@ -38,149 +38,149 @@ const router = new VueRouter({ ...@@ -38,149 +38,149 @@ const router = new VueRouter({
y: 0, y: 0,
}), }),
routes: [{ routes: [{
path: '/', path: '/',
name: 'Home', name: 'Home',
redirect: '/home', redirect: '/home',
component: DefaultContainer, component: DefaultContainer,
props: { props: {
level: level, level: level,
},
children: [{
path: '/home',
component: Home,
},
{
path: '/coursera',
redirect: '/coursera',
name: 'Coursera',
component: Platform,
children: [{
path: '/coursera',
name: '',
component: coursera.Courses,
}, {
path: '/coursera/:courseid',
name: 'CourseDetail',
component: coursera.CourseDetail,
meta: {
label: "Course Details",
},
}, },
{ children: [{
path: '/coursera/:courseid/compare/:course2id', path: '/home',
name: 'CourseComparison', component: Home,
component: coursera.CourseComparison,
meta: {
label: "Course Compare",
}, },
}, {
{ path: '/p/:platform',
path: '/coursera/:courseid/videos', redirect: '/p/:platform',
name: 'Videos', name: 'Coursera',
component: coursera.Videos, component: Platform,
}, children: [{
{ path: '/p/:platform',
path: '/coursera/:courseid/videos/:videoid', name: '',
name: 'VideoDetail', component: coursera.Courses,
component: coursera.VideoDetail, }, {
meta: { path: '/p/:platform/:courseid',
label: "Video Details", name: 'CourseDetail',
component: coursera.CourseDetail,
meta: {
label: "Course Details",
},
},
{
path: '/p/:platform/:courseid/compare/:course2id',
name: 'CourseComparison',
component: coursera.CourseComparison,
meta: {
label: "Course Compare",
},
},
{
path: '/p/:platform/:courseid/videos',
name: 'Videos',
component: coursera.Videos,
},
{
path: '/p/:platform/:courseid/videos/:videoid',
name: 'VideoDetail',
component: coursera.VideoDetail,
meta: {
label: "Video Details",
},
},
{
path: '/p/:platform/:courseid/quizzes',
name: 'Quizzes',
component: coursera.Quizzes,
},
{
path: '/p/:platform/:courseid/quizzes/:quizid',
name: 'QuizDetail',
component: coursera.QuizDetail,
meta: {
label: "Quiz Details",
},
},
{
path: '/p/:platform/:courseid/assignments',
name: 'Assignments',
component: coursera.Assignments,
},
{
path: '/p/:platform/:courseid/assignments/:assignmentid',
name: 'Assignment Details',
component: coursera.AssignmentDetail,
},
],
}, {
path: '/settings',
name: 'Settings',
component: Settings,
}, },
}, {
{ path: '/contact',
path: '/coursera/:courseid/quizzes', name: 'Contact',
name: 'Quizzes', component: Contact,
component: coursera.Quizzes,
},
{
path: '/coursera/:courseid/quizzes/:quizid',
name: 'QuizDetail',
component: coursera.QuizDetail,
meta: {
label: "Quiz Details",
}, },
},
{
path: '/coursera/:courseid/assignments',
name: 'Assignments',
component: coursera.Assignments,
},
{
path: '/coursera/:courseid/assignments/:assignmentid',
name: 'Assignment Details',
component: coursera.AssignmentDetail,
},
], ],
}, {
path: '/settings',
name: 'Settings',
component: Settings,
}, },
{ {
path: '/contact', path: '/pages',
name: 'Contact', redirect: '/pages/404',
component: Contact, name: 'Pages',
}, component: {
], render(c) {
}, return c('router-view')
{ },
path: '/pages',
redirect: '/pages/404',
name: 'Pages',
component: {
render(c) {
return c('router-view')
}, },
}, children: [{
children: [{ path: '404',
path: '404', name: 'Page404',
name: 'Page404', component: Page404,
component: Page404, },
}, {
{ path: '500',
path: '500', name: 'Page500',
name: 'Page500', component: Page500,
component: Page500, },
}, {
{ path: 'login',
path: 'login', name: 'Login',
name: 'Login', component: Login,
component: Login, },
}, {
{ path: 'resetpassword/:token/:id',
path: 'resetpassword/:token/:id', name: 'ResetPasswordReferrer',
name: 'ResetPasswordReferrer', component: ResetReferrer,
component: ResetReferrer, },
}, {
{ path: 'resetpassword',
path: 'resetpassword', name: 'ResetPassword',
name: 'ResetPassword', component: ResetPassword,
component: ResetPassword, },
}, {
{ path: 'forgotpassword',
path: 'forgotpassword', name: 'ForgotPassword',
name: 'ForgotPassword', component: ForgotPassword,
component: ForgotPassword, },
}, ],
],
},
{
path: '/admin',
name: 'Admin',
component: AdminPanel,
redirect: 'admin/home',
children: [{
path: 'home',
name: 'AdminHome',
component: AdminHome,
}, },
{ {
path: 'register', path: '/admin',
name: 'Register', name: 'Admin',
component: Register, component: AdminPanel,
redirect: 'admin/home',
children: [{
path: 'home',
name: 'AdminHome',
component: AdminHome,
},
{
path: 'register',
name: 'Register',
component: Register,
},
],
}, },
],
},
], ],
}) })
......
...@@ -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)