File

src/app/app-root/status-card/status-card.component.ts

Implements

OnInit

Metadata

selector status-card
templateUrl ./status-card.component.html

Index

Properties
Methods

Constructor

constructor(mds: MainDataService)
Parameters :
Name Type Optional
mds MainDataService No

Methods

ngOnInit
ngOnInit()
Returns : void

Properties

loginAuthority
Type : string[]
Default value : []
loginName
Type : string
Default value : ''
Public mds
Type : MainDataService
import { Component, OnInit } from '@angular/core';
import { MainDataService } from '../../maindata.service';
import { AuthAccessKeyType, AuthData, AuthFlagType } from '../../app.interfaces';

@Component({
  selector: 'status-card',
  templateUrl: './status-card.component.html'
})
export class StatusCardComponent implements OnInit {
  loginName = '';
  loginAuthority: string[] = [];

  constructor(
    public mds: MainDataService
  ) { }

  ngOnInit(): void {
    this.mds.authData$.subscribe((authData: AuthData) => {
      this.loginAuthority = [];
      this.loginName = '';
      if (!authData) {
        return;
      }
      this.loginName = authData.displayName;
      if (authData.access[AuthAccessKeyType.WORKSPACE_ADMIN]) {
        this.loginAuthority.push('Verwaltung von Testinhalten');
      }
      if (authData.access[AuthAccessKeyType.SUPER_ADMIN]) {
        this.loginAuthority.push('Verwaltung von Nutzerrechten und von grundsätzlichen Systemeinstellungen');
      }
      if (authData.access[AuthAccessKeyType.TEST]) {
        if (authData.access[AuthAccessKeyType.TEST].length > 1) {
          this.loginAuthority.push('Ausführung/Ansicht von Befragungen oder Testheften');
        } else {
          this.loginAuthority.push('Ausführung/Ansicht einer Befragung oder eines Testheftes');
        }
      }
      if (authData.access[AuthAccessKeyType.WORKSPACE_MONITOR]) {
        if (authData.access[AuthAccessKeyType.WORKSPACE_MONITOR].length > 1) {
          this.loginAuthority.push('Beobachtung/Prüfung der Durchführung von Befragungen oder Kompetenztests');
        } else {
          this.loginAuthority.push('Beobachtung/Prüfung der Durchführung einer Befragung oder eines Kompetenztests');
        }
      }
      if (authData.access[AuthAccessKeyType.TEST_GROUP_MONITOR]) {
        this.loginAuthority.push('Beobachtung/Prüfung einer Testgruppe');
      }
      if (authData.flags.indexOf(AuthFlagType.CODE_REQUIRED) >= 0) {
        this.loginAuthority.push('Code-Eingabe erforderlich');
      }
    });
  }
}
<div fxLayout="column">
  <div *ngIf="loginName">
    <p><b>Status: Angemeldet als "{{loginName}}"</b></p>
    <p style="margin-bottom: 0;">
      <b *ngIf="loginAuthority.length > 1">Berechtigungen:</b>
      <b *ngIf="loginAuthority.length === 1">Berechtigung:</b>
    </p>
    <ul style="margin: 0;">
      <li *ngFor="let loginAuth of loginAuthority">{{loginAuth}}</li>
    </ul>
  </div>
  <p *ngIf="!loginName"><b>Status: Derzeit nicht angemeldet.</b></p>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""