mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
check group access on collection edit page
This commit is contained in:
parent
9aa8699617
commit
a25f6dee73
@ -15,45 +15,47 @@
|
|||||||
<label for="name">{{'name' | i18n}}</label>
|
<label for="name">{{'name' | i18n}}</label>
|
||||||
<input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required>
|
<input id="name" class="form-control" type="text" name="Name" [(ngModel)]="name" required>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="mt-4 d-flex mb-0">
|
<ng-container *ngIf="accessGroups">
|
||||||
{{'groupAccess' | i18n}}
|
<h3 class="mt-4 d-flex mb-0">
|
||||||
<div class="ml-auto" *ngIf="groups && groups.length">
|
{{'groupAccess' | i18n}}
|
||||||
<button type="button" (click)="selectAll(true)" class="btn btn-link btn-sm py-0">
|
<div class="ml-auto" *ngIf="groups && groups.length">
|
||||||
{{'selectAll' | i18n}}
|
<button type="button" (click)="selectAll(true)" class="btn btn-link btn-sm py-0">
|
||||||
</button>
|
{{'selectAll' | i18n}}
|
||||||
<button type="button" (click)="selectAll(false)" class="btn btn-link btn-sm py-0">
|
</button>
|
||||||
{{'unselectAll' | i18n}}
|
<button type="button" (click)="selectAll(false)" class="btn btn-link btn-sm py-0">
|
||||||
</button>
|
{{'unselectAll' | i18n}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</h3>
|
||||||
|
<div *ngIf="!groups || !groups.length">
|
||||||
|
{{'noGroupsInList' | i18n}}
|
||||||
</div>
|
</div>
|
||||||
</h3>
|
<table class="table table-hover table-list mb-0" *ngIf="groups && groups.length">
|
||||||
<div *ngIf="!groups || !groups.length">
|
<thead>
|
||||||
{{'noGroupsInList' | i18n}}
|
<tr>
|
||||||
</div>
|
<th> </th>
|
||||||
<table class="table table-hover table-list mb-0" *ngIf="groups && groups.length">
|
<th>{{'name' | i18n}}</th>
|
||||||
<thead>
|
<th width="100" class="text-center">{{'readOnly' | i18n}}</th>
|
||||||
<tr>
|
</tr>
|
||||||
<th> </th>
|
</thead>
|
||||||
<th>{{'name' | i18n}}</th>
|
<tbody>
|
||||||
<th width="100" class="text-center">{{'readOnly' | i18n}}</th>
|
<tr *ngFor="let g of groups; let i = index">
|
||||||
</tr>
|
<td class="table-list-checkbox" (click)="check(g)">
|
||||||
</thead>
|
<input type="checkbox" [(ngModel)]="g.checked" name="Groups[{{i}}].Checked" [disabled]="g.accessAll">
|
||||||
<tbody>
|
</td>
|
||||||
<tr *ngFor="let g of groups; let i = index">
|
<td (click)="check(g)">
|
||||||
<td class="table-list-checkbox" (click)="check(g)">
|
<span appStopProp>
|
||||||
<input type="checkbox" [(ngModel)]="g.checked" name="Groups[{{i}}].Checked" [disabled]="g.accessAll">
|
{{g.name}}
|
||||||
</td>
|
<i class="fa fa-th text-muted fa-fw" *ngIf="g.accessAll" title="This group can access all items"></i>
|
||||||
<td (click)="check(g)">
|
</span>
|
||||||
<span appStopProp>
|
</td>
|
||||||
{{g.name}}
|
<td class="text-center">
|
||||||
<i class="fa fa-th text-muted fa-fw" *ngIf="g.accessAll" title="This group can access all items"></i>
|
<input type="checkbox" [(ngModel)]="g.readOnly" name="Groups[{{i}}].ReadOnly" [disabled]="!g.checked || g.accessAll">
|
||||||
</span>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
<td class="text-center">
|
</tbody>
|
||||||
<input type="checkbox" [(ngModel)]="g.readOnly" name="Groups[{{i}}].ReadOnly" [disabled]="!g.checked || g.accessAll">
|
</table>
|
||||||
</td>
|
</ng-container>
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
|
||||||
|
@ -13,6 +13,7 @@ import { ApiService } from 'jslib/abstractions/api.service';
|
|||||||
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
import { CryptoService } from 'jslib/abstractions/crypto.service';
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||||
|
import { UserService } from 'jslib/abstractions/user.service';
|
||||||
|
|
||||||
import { CipherString } from 'jslib/models/domain/cipherString';
|
import { CipherString } from 'jslib/models/domain/cipherString';
|
||||||
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
|
import { SymmetricCryptoKey } from 'jslib/models/domain/symmetricCryptoKey';
|
||||||
@ -34,6 +35,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
editMode: boolean = false;
|
editMode: boolean = false;
|
||||||
|
accessGroups: boolean = false;
|
||||||
title: string;
|
title: string;
|
||||||
name: string;
|
name: string;
|
||||||
groups: GroupResponse[] = [];
|
groups: GroupResponse[] = [];
|
||||||
@ -44,12 +46,17 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private apiService: ApiService, private i18nService: I18nService,
|
constructor(private apiService: ApiService, private i18nService: I18nService,
|
||||||
private analytics: Angulartics2, private toasterService: ToasterService,
|
private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService) { }
|
private platformUtilsService: PlatformUtilsService, private cryptoService: CryptoService,
|
||||||
|
private userService: UserService) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
const organization = await this.userService.getOrganization(this.organizationId);
|
||||||
|
this.accessGroups = organization.useGroups;
|
||||||
this.editMode = this.loading = this.collectionId != null;
|
this.editMode = this.loading = this.collectionId != null;
|
||||||
const groupsResponse = await this.apiService.getGroups(this.organizationId);
|
if (this.accessGroups) {
|
||||||
this.groups = groupsResponse.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'name'));
|
const groupsResponse = await this.apiService.getGroups(this.organizationId);
|
||||||
|
this.groups = groupsResponse.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'name'));
|
||||||
|
}
|
||||||
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||||
|
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
@ -58,7 +65,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const collection = await this.apiService.getCollectionDetails(this.organizationId, this.collectionId);
|
const collection = await this.apiService.getCollectionDetails(this.organizationId, this.collectionId);
|
||||||
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
||||||
if (collection.groups != null && this.groups != null) {
|
if (collection.groups != null && this.groups.length > 0) {
|
||||||
collection.groups.forEach((s) => {
|
collection.groups.forEach((s) => {
|
||||||
const group = this.groups.filter((g) => !g.accessAll && g.id === s.id);
|
const group = this.groups.filter((g) => !g.accessAll && g.id === s.id);
|
||||||
if (group != null && group.length > 0) {
|
if (group != null && group.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user