diff --git a/src/app/components/shared/header/header.component.html b/src/app/components/shared/header/header.component.html index a509253bb3ed1ccb3452e24ac22fd01b6a706fee..710516cdbe302118f37f360760061a1e67a4571c 100644 --- a/src/app/components/shared/header/header.component.html +++ b/src/app/components/shared/header/header.component.html @@ -29,6 +29,12 @@ <p class="userActivityTxt">{{userActivity}}</p> </div> + <span *ngIf="isInRouteWithRoles && user && user.role !== userRole"> + <mat-icon style="color: red; margin-top: 8px" [matTooltip]="'header.not-in-own-view' | translate"> + group + </mat-icon> + </span> + <h2 class="oldtypo-h2" *ngIf="router.url.endsWith('/moderator/comments') && deviceType === 'desktop'"> {{'header.moderation-warning'|translate}} @@ -291,6 +297,15 @@ <!-- General Options --> + <button mat-menu-item + *ngIf="isInRouteWithRoles && user && user.role > 0" + (click)="navigateToOtherView()" + tabindex="0"> + <mat-icon>group</mat-icon> + <span *ngIf="userRole === user.role">{{'header.regular-user-view' | translate}}</span> + <span *ngIf="userRole !== user.role">{{'header.own-view' | translate}}</span> + </button> + <button mat-menu-item *ngIf="userRole == 0 && !router.url.endsWith('/tagcloud') && !router.url.endsWith('/quiz')" (click)="openUserBonusTokenDialog()" diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts index 343a6de9a2e99e0fe6f9b4f0ae5522c9ca22f6ad..efb9c975f7f531d1702678474c55f7d410f04ea3 100644 --- a/src/app/components/shared/header/header.component.ts +++ b/src/app/components/shared/header/header.component.ts @@ -54,6 +54,7 @@ export class HeaderComponent implements OnInit, AfterViewInit { toggleUserActivity = false; userActivity = 0; deviceType = localStorage.getItem('deviceType'); + isInRouteWithRoles = false; private _subscriptionRoomService = null; constructor(public location: Location, @@ -87,12 +88,16 @@ export class HeaderComponent implements OnInit, AfterViewInit { const url = e.url.toLowerCase(); if (url.startsWith('/participant/')) { this.userRole = UserRole.PARTICIPANT; + this.isInRouteWithRoles = true; } else if (url.startsWith('/moderator/')) { this.userRole = UserRole.EXECUTIVE_MODERATOR; + this.isInRouteWithRoles = true; } else if (url.startsWith('/creator/')) { this.userRole = UserRole.CREATOR; + this.isInRouteWithRoles = true; } else { this.userRole = this.user ? this.user.role : UserRole.PARTICIPANT; + this.isInRouteWithRoles = false; } } }); @@ -374,6 +379,15 @@ export class HeaderComponent implements OnInit, AfterViewInit { this.eventService.broadcast('navigate', 'moderatorSettings'); } + public navigateToOtherView() { + const url = this.router.url; + let newRoute = '/participant/'; + if (this.userRole !== this.user.role) { + newRoute = this.user.role === UserRole.CREATOR ? '/creator/' : '/moderator/'; + } + this.router.navigate([url.replace(/^\/[^\/]+\//gmi, newRoute)]); + } + public navigateTopicCloud() { const confirmDialogRef = this.confirmDialog.open(TopicCloudFilterComponent, { autoFocus: false diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index def3a9e09f76f7b6b0559902d13781810ddf71de..064cccb254e271ad1bd83d9501aaa95b5472672a 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -130,7 +130,10 @@ "overview-admin-config-enabled": "Themenbeschränkung aktiv", "quiz-now": "antworte✦jetzt", "moderation-warning": "Moderationsboard mit nicht freigegebenen Fragen", - "tour": "Tour" + "tour": "Tour", + "own-view": "Zur eigenen Ansicht", + "regular-user-view": "Zur normalen Benutzeransicht", + "not-in-own-view": "Die aktuelle Ansicht bietet nicht alle Funktionen. Wechsle in den Optionen zu deiner Ansicht." }, "help": { "cancel": "Schließen", diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index dfb90e29487138271e9839366d8931d75e5ff058..0ea26c10436d8de3da2d25e0d658e188da6ed4c1 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -117,7 +117,10 @@ "overview-admin-config-enabled": "Themes requirement active", "quiz-now": "antworte✦jetzt", "moderation-warning": "Moderation board with unreleased questions", - "tour": "Tour" + "tour": "Tour", + "own-view": "To own view", + "regular-user-view": "To the regular user view", + "not-in-own-view": "The current view does not offer all functions. Switch to your view in the options." }, "help": { "cancel": "Close",