Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

profilCard.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. Vue.component('profil-card', {
  2. template: `
  3. <div class="profil-card card">
  4. <img class="prof-image" src="img/profil_icon.png" alt="Card image cap">
  5. <div class="logout-item" style="float: right;">
  6. <b-button type="button" class="btn btn-primary" data-dismiss="modal" @click.prevent="logout">
  7. <i class="material-icons" style="float: left; margin: -0.1rem 0.2rem 0 -0.2rem;" @click.prevent="logout">exit_to_app</i>
  8. Logout</b-button>
  9. </div>
  10. <div class="profil-text">
  11. <span style="font-size:120%; display:inline-block; margin: 0.8rem 0 0 0;"><b>{{ auth.name }}</b></span><br><br>
  12. <span style="font-size:100%; display:inline-block; margin: 0 0 0.8rem 0;"><b>{{ labelMajorOrFaculty }}</b></span>
  13. <br>
  14. <span style="font-size:90%; display:inline-block; margin: 0 0 0.8rem 0;"><b>{{ majorOrFaculty }}</b></span>
  15. <br><br>
  16. </div>
  17. <hr class="first">
  18. <div class="btnprofil">
  19. <button @click="isCardModalActive = true"><b>Abonniert: <br/>{{ abos }}</b> <br/></button>
  20. <button @click="$router.push('/bookmark')"><b>Gespeichert:<br/> {{ bookmarks }}</b><br/></button>
  21. </div>
  22. <section>
  23. <b-modal :active.sync="isCardModalActive" :width="600" scroll="keep">
  24. <div class="card">
  25. <header class="modal-card-head">
  26. <p class="modal-card-title">Abonnierte Tags</p>
  27. </header>
  28. <div class="card-content">
  29. <div class="content">
  30. <ul>
  31. <li></li>
  32. <li></li>
  33. <li></li>
  34. <li></li>
  35. <li></li>
  36. <li></li>
  37. <li></li>
  38. </ul>
  39. </div>
  40. </div>
  41. <footer class="modal-card-foot">
  42. <b-button size="is-medium" @click="isCardModalActive = false">Close</b-button>
  43. </footer>
  44. </div>
  45. </b-modal>
  46. </section>
  47. </div>`,
  48. data: function () {
  49. return {
  50. auth: auth,
  51. abos: auth.abos ? auth.abos.length : '-',
  52. bookmarks: auth.bookmarks ? auth.bookmarks.length : '-',
  53. isCardModalActive: false,
  54. };
  55. },
  56. computed: {
  57. majorOrFaculty: function() {
  58. // e.g. ST@B-ME;ST@EFI;
  59. if (auth.roles.author) {
  60. var facultyID = auth.type.split(';');
  61. console.info(facultyID[facultyID.length-2]);
  62. facultyID = facultyID[facultyID.length-2].split('@')[1];
  63. var facultyName = '';
  64. facultyList.forEach(function(faculty) {
  65. if (faculty.id == facultyID) {
  66. facultyName = faculty.name;
  67. }
  68. });
  69. return facultyName;
  70. } else {
  71. var majorID = auth.type.split(';')[0].split('@')[1];
  72. //console.info(majorID);
  73. //console.info(majorList);
  74. var majorName = 'Studiengang Unbekannt';
  75. majorList.forEach(function(major) {
  76. if (major.id == majorID) {
  77. majorName = major.name;
  78. }
  79. });
  80. return majorName;
  81. }
  82. },
  83. labelMajorOrFaculty: function() {
  84. if (auth.roles.author) {
  85. return 'Fakultät:'
  86. } else {
  87. return 'Studiengang:'
  88. }
  89. }
  90. },
  91. methods: {
  92. logout: function() {
  93. clearAuthState();
  94. $.ajax({ url: "api/logout", method: "POST" });
  95. vueForceRender('key');
  96. router.push('/profil');
  97. },
  98. }
  99. });