Projekt

Obecné

Profil

« Předchozí | Další » 

Revize cbb91c90

Přidáno uživatelem Jakub Hlaváč před téměř 4 roky(ů)

Re #8915 - Zapracování požadavků ze schůzky

+ sensor edit under edit button in menu
  • request for sensor data only for first time, then after button click
    + sensor group names
    + adding information to unit and sensor
    + commenting
    + code refactor

Zobrazit rozdíly:

src/app/login/components/login.component.ts
1
import {Component, OnInit} from '@angular/core';
1
import {Component, OnDestroy, OnInit} from '@angular/core';
2 2
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3 3
import {switchMap} from 'rxjs/operators';
4 4
import {of, Subscription} from 'rxjs';
......
10 10
  templateUrl: './login.component.html',
11 11
  styleUrls: ['./login.component.scss']
12 12
})
13
export class LoginComponent implements OnInit {
13
export class LoginComponent implements OnInit, OnDestroy {
14 14

  
15 15
  loginForm: FormGroup;
16 16
  subscription: Subscription[] = [];
......
22 22
  ) {
23 23
  }
24 24

  
25
  /**
26
   * Unsubscribe after leaving
27
   */
28
  ngOnDestroy(): void {
29
    this.subscription.forEach(subs => subs.unsubscribe());
30
  }
31

  
25 32
  ngOnInit(): void {
26 33
    this.loginForm = this.formBuilder.group({
27 34
      username: ['', [Validators.required]],
......
30 37
    this.userRedirect();
31 38
  }
32 39

  
40
  /**
41
   * Process login
42
   */
33 43
  doLogin(): void {
34 44
    if (this.loginForm.valid) {
35 45
      this.subscription[2] = this.authService.doLogin({
......
38 48
      })
39 49
        .pipe(
40 50
          switchMap(res => {
41
            console.log(res);
42 51
            if (res) {
43 52
              console.log('Login getUserState');
44 53
              return this.authService.getUserState();
......
48 57
          })
49 58
        ).subscribe(
50 59
          res => {
51
            console.log(res);
52 60
            if (res) {
53 61
              this.subscription[2].unsubscribe();
54 62
              this.router.navigate(['/dashboard'])
......
58 66
    }
59 67
  }
60 68

  
69
  /**
70
   * If user already logged with valid sessionId redirect to dashboard
71
   */
61 72
  userRedirect(): void {
62 73
    console.log('Login redirect');
63 74
    if (this.authService.getUser()){
64
      console.log('Redirect to dashboard!');
65 75
      this.router.navigate(['/dashboard']);
66 76
    }
67 77
  }

Také k dispozici: Unified diff