bitwarden-estensione-browser/src/app/organizations/manage/groups.component.ts

42 lines
1.2 KiB
TypeScript
Raw Normal View History

import {
Component,
OnInit,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { ApiService } from 'jslib/abstractions/api.service';
2018-07-06 20:22:20 +02:00
import { I18nService } from 'jslib/abstractions/i18n.service';
2018-07-06 18:55:59 +02:00
import { GroupResponse } from 'jslib/models/response/groupResponse';
2018-07-06 16:21:08 +02:00
2018-07-06 21:01:23 +02:00
import { Utils } from 'jslib/misc/utils';
2018-07-06 16:21:08 +02:00
@Component({
selector: 'app-org-groups',
templateUrl: 'groups.component.html',
})
export class GroupsComponent implements OnInit {
loading = true;
organizationId: string;
groups: GroupResponse[];
searchText: string;
2018-07-06 20:22:20 +02:00
constructor(private apiService: ApiService, private route: ActivatedRoute,
private i18nService: I18nService) { }
async ngOnInit() {
this.route.parent.parent.params.subscribe(async (params) => {
this.organizationId = params.organizationId;
});
await this.load();
}
async load() {
const response = await this.apiService.getGroups(this.organizationId);
2018-07-06 20:22:20 +02:00
const groups = response.data != null && response.data.length > 0 ? response.data : [];
2018-07-06 21:01:23 +02:00
groups.sort(Utils.getSortFunction(this.i18nService, 'name'));
2018-07-06 20:22:20 +02:00
this.groups = groups;
this.loading = false;
}
}