summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole3/frontend/src/app/pages/profile/profile.component.ts
blob: da6859c287ac3070982a338cb0085f43af1d4246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {Component, OnInit} from '@angular/core';

import { UserService } from 'src/app/api/user.service';
import {User, UserPreferences} from 'src/app/model/user';
import {OgCommonService} from '../../service/og-common.service';
import {AuthModule} from 'globunet-angular/core';
import {ToasterService} from '../../service/toaster.service';
import {TranslateService} from '@ngx-translate/core';
import {LayoutStore} from 'angular-admin-lte';
import {AdminLteConf} from '../../admin-lte.conf';

@Component({
  selector: 'app-profile',
  templateUrl: './profile.component.html',
  styleUrls: [ './profile.component.scss' ]
})
export class ProfileComponent implements OnInit {
  public user: User;
  public app: any;
  public constants: any;

  // this tells the tabs component which Pages
  // should be each tab's root Page
  constructor(private layoutStore: LayoutStore,
              private adminLteConfig: AdminLteConf,
              public userService: UserService,
              public ogCommonService: OgCommonService,
              private authModule: AuthModule,
              private toaster: ToasterService,
              private translate: TranslateService) {
  }

  ngOnInit(): void {
    this.ogCommonService.loadEngineConfig().subscribe(
        data => {
          this.constants = data.constants;
        }
    )
    // @ts-ignore
    this.user  = this.authModule.getLoggedUser();
    this.user.preferences = this.user.preferences || new UserPreferences();
  }

  changeTheme() {
    this.layoutStore.setSkin(this.user.preferences.theme);
  }

   save() {
    this.ogCommonService.saveUserPreferences();
    this.toaster.pop({type: 'success', title: 'success', body: this.translate.instant('successfully_saved')});
  }

}