Elffuss BraidHub

kikocis/dataspace-portal public

main · 1.4 KiBRawPermalink
1/*
2 * Copyright (c) 2024 sovity GmbH
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Apache License, Version 2.0 which is available at
6 * https://www.apache.org/licenses/LICENSE-2.0
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 *
10 * Contributors:
11 * sovity GmbH - initial implementation
12 */
13import {Component, Inject} from '@angular/core';
14import {Store} from '@ngxs/store';
15import {
16 RefreshUserInfo,
17 SwitchE2eDevUser,
18} from 'src/app/core/global-state/global-state-actions';
19import {RouteConfigService} from 'src/app/core/global-state/routes/route-config-service';
20import {APP_CONFIG, AppConfig} from 'src/app/core/services/config/app-config';
21import {E2eDevUser} from './e2e-dev-user';
22import {E2E_DEV_USERS} from './e2e-dev-users';
23
24@Component({
25 selector: 'app-e2e-dev-user-switcher',
26 templateUrl: './e2e-dev-user-switcher.component.html',
27})
28export class E2EDevUserSwitcherComponent {
29 minimize = true;
30
31 // another option would be state
32 currentUser = E2E_DEV_USERS[0].user;
33
34 users = E2E_DEV_USERS;
35
36 constructor(
37 @Inject(APP_CONFIG) public appConfig: AppConfig,
38 public store: Store,
39 private routeConfig: RouteConfigService,
40 ) {}
41
42 setUser(user: E2eDevUser) {
43 this.store.dispatch(new SwitchE2eDevUser(user));
44 this.currentUser = user.user;
45 this.store.dispatch(RefreshUserInfo);
46 this.routeConfig.forceRefreshCurrentRoute();
47 }
48
49 hide() {
50 this.minimize = !this.minimize;
51 }
52}