Vue.component('profil-card', {
template: `
exit_to_app
Logout
{{ auth.name }}
{{ labelMajorOrFaculty }}
{{ majorOrFaculty }}
`,
data: function () {
return {
auth: auth,
abos: auth.abos ? auth.abos.length : '-',
bookmarks: auth.bookmarks ? auth.bookmarks.length : '-',
isCardModalActive: false,
};
},
computed: {
majorOrFaculty: function() {
// e.g. ST@B-ME;ST@EFI;
if (auth.roles.author) {
var facultyID = auth.type.split(';');
console.info(facultyID[facultyID.length-2]);
facultyID = facultyID[facultyID.length-2].split('@')[1];
var facultyName = '';
facultyList.forEach(function(faculty) {
if (faculty.id == facultyID) {
facultyName = faculty.name;
}
});
return facultyName;
} else {
var majorID = auth.type.split(';')[0].split('@')[1];
//console.info(majorID);
//console.info(majorList);
var majorName = 'Studiengang Unbekannt';
majorList.forEach(function(major) {
if (major.id == majorID) {
majorName = major.name;
}
});
return majorName;
}
},
labelMajorOrFaculty: function() {
if (auth.roles.author) {
return 'Fakultät:'
} else {
return 'Studiengang:'
}
}
},
methods: {
logout: function() {
clearAuthState();
$.ajax({ url: "api/logout", method: "POST" });
vueForceRender('key');
router.push('/profil');
},
}
});