user-list.component.ts 1.13 KB
Newer Older
1
2
import Vue from 'vue';
import Component from 'vue-class-component';
Kevin Robert's avatar
Kevin Robert committed
3
import Toolbar from '@/components/toolbar/toolbar.vue';
4
import { Inject } from 'vue-property-decorator';
5
import UserManagementService from '@/services/user-management.service';
6
import HeaderService from '@/shared/service/header-service';
7
import { TABS } from '@/shared/service/tabs-constants';
8

Kevin Robert's avatar
Kevin Robert committed
9
10
@Component({
  components: {
11
12
    Toolbar,
  },
Kevin Robert's avatar
Kevin Robert committed
13
})
14
export default class UserList extends Vue {
Kevin Robert's avatar
Kevin Robert committed
15
16
17
  @Inject('userService')
  private userManagementService: () => UserManagementService;

18
19
20
21
22
23
  /**
   * Service du header.
   */
  @Inject('headerService')
  private headerService: () => HeaderService;

Kevin Robert's avatar
Kevin Robert committed
24
25
  public users: any[] = [];

26
27
  beforeRouteEnter(to, from, next) {
    next(vm => {
28
      vm.headerService().filArianeForHome();
29
      vm.headerService().updateTabsForAdmin(TABS.KEY_USERS);
30
31
32
    });
  }

Kevin Robert's avatar
Kevin Robert committed
33
34
35
36
37
38
39
40
41
42
43
  public mounted(): void {
    this.loadAll();
  }

  public loadAll(): void {
    this.userManagementService()
      .retrieveAllManagedUsers()
      .then(res => {
        this.users = res.data;
      });
  }
44

45
  public getUserEditLink(userId: string) {
46
47
    return `/admin/user/${userId}/edit`;
  }
48
}