feat(console): authorizations from user context, add grants to auth user view, fix app saving (#895)

* user grant on project

* grant in auth user, enable creation, fix inv regex

* use autocomplete solutions, section for usre ctx

* user grant create for user context

* fix edit from table

* fix create context

* fix authorization to write

* grant overview component

* fix user grants without context

* lint

* turn table highlighting off, rm logs

* fix app name saving

* fix table refresh for project grants

* translate toast

* i18n

* lint

* Update console/src/assets/i18n/de.json

Co-authored-by: Florian Forster <[email protected]>

Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
Max Peintner
2020-10-27 10:29:14 +01:00
committed by GitHub
co-authored by Florian Forster
parent afa38aa2c2
commit 78e5c26015
41 changed files with 483 additions and 178 deletions
@@ -1,5 +1,5 @@
<form>
<mat-form-field *ngIf="target == UserTarget.SELF" appearance="outline" class="full-width">
<mat-form-field *ngIf="target && target == UserTarget.SELF" appearance="outline" class="full-width">
<mat-label>Organizations User Loginname</mat-label>
<input matInput *ngIf="singleOutput" type="text" placeholder="Search for the user loginname" #usernameInput
@@ -28,12 +28,21 @@
<small>{{user.preferredLoginName}}</small>
</mat-option>
</mat-autocomplete>
<mat-hint class="target-desc">
{{'USER.TARGET.SELF'| translate}}
<a (click)="changeTarget()">{{'USER.TARGET.CLICKHERE' | translate}}</a>
</mat-hint>
</mat-form-field>
<div *ngIf="target == UserTarget.EXTERNAL" class="line">
<div *ngIf="target && target == UserTarget.EXTERNAL" class="line">
<mat-form-field class="form-field" appearance="outline">
<mat-label>Global User Loginname</mat-label>
<input matInput type="text" [formControl]="globalLoginNameControl" />
<mat-hint class="target-desc">
{{(target == UserTarget.SELF ? 'USER.TARGET.SELF' : 'USER.TARGET.EXTERNAL') | translate}}
<a (click)="changeTarget()">{{'USER.TARGET.CLICKHERE' | translate}}</a>
</mat-hint>
</mat-form-field>
<button color="primary" mat-icon-button (click)="getGlobalUser()">
@@ -41,17 +50,25 @@
</button>
</div>
<div *ngIf="target == UserTarget.EXTERNAL && users.length > 0">
<div class="found" *ngIf="target == UserTarget.EXTERNAL && users.length > 0">
<span class="found-label">{{'USER.SEARCH.FOUND' | translate}}:</span>
<div class="found-user-row" *ngFor="let user of users; index as i">
<div class="circle">
<app-avatar
*ngIf="user.human && user.human.displayName && user.human?.firstName && user.human?.lastName; else cog"
class="avatar" [name]="user.human.displayName" [size]="32">
</app-avatar>
<ng-template #cog>
<div class="sa-icon">
<i class="las la-user-cog"></i>
</div>
</ng-template>
</div>
<span>{{user.preferredLoginName}}</span>
<button mat-icon-button>
<button mat-icon-button color="warn">
<i class="las la-minus-circle" (click)="users.splice(i, 1)"></i>
</button>
</div>
</div>
<p class="target-desc">{{(target == UserTarget.SELF ? 'USER.TARGET.SELF' : 'USER.TARGET.EXTERNAL') | translate}}
<a (click)="changeTarget()">{{'USER.TARGET.CLICKHERE' | translate}}</a>
</p>
</form>
@@ -3,11 +3,6 @@
}
.target-desc {
color: var(--grey);
font-size: .8rem;
margin: 0;
margin-bottom: 1rem;
a {
color: #4072b4;
@@ -37,12 +32,35 @@
font-size: .8rem;
}
.found-user-row {
display: flex;
align-items: center;
.found {
margin: .5rem 0;
background: #4072b410;
border-radius: .5rem;
padding: .5rem;
.found-user-row {
padding: .5rem 0;
display: flex;
align-items: center;
min-height: 56px;
button {
visibility: hidden;
}
&:hover {
button {
visibility: visible;
}
}
}
.found-label {
font-size: .9rem;
color: var(--grey);
}
}
.found-label {
font-size: .9rem;
color: var(--grey);
.circle {
margin-right: .5rem;
}
@@ -1,5 +1,15 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import {
AfterContentChecked,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Input,
OnInit,
Output,
ViewChild,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatAutocomplete, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
import { MatChipInputEvent } from '@angular/material/chips';
@@ -19,7 +29,7 @@ export enum UserTarget {
templateUrl: './search-user-autocomplete.component.html',
styleUrls: ['./search-user-autocomplete.component.scss'],
})
export class SearchUserAutocompleteComponent {
export class SearchUserAutocompleteComponent implements OnInit, AfterContentChecked {
public selectable: boolean = true;
public removable: boolean = true;
public addOnBlur: boolean = true;
@@ -32,7 +42,7 @@ export class SearchUserAutocompleteComponent {
@Input() public users: Array<UserView.AsObject> = [];
public filteredUsers: Array<UserView.AsObject> = [];
public isLoading: boolean = false;
public target: UserTarget = UserTarget.SELF;
@Input() public target: UserTarget = UserTarget.SELF;
public hint: string = '';
public UserTarget: any = UserTarget;
@ViewChild('usernameInput') public usernameInput!: ElementRef<HTMLInputElement>;
@@ -41,8 +51,19 @@ export class SearchUserAutocompleteComponent {
@Input() public singleOutput: boolean = false;
private unsubscribed$: Subject<void> = new Subject();
constructor(private userService: ManagementService, private toast: ToastService) {
this.getFilteredResults();
constructor(private userService: ManagementService, private toast: ToastService, private cdref: ChangeDetectorRef) { }
public ngOnInit(): void {
if (this.target === UserTarget.EXTERNAL) {
this.filteredUsers = [];
this.unsubscribed$.next(); // clear old subscription
} else if (this.target === UserTarget.SELF) {
this.getFilteredResults(); // new subscription
}
}
public ngAfterContentChecked(): void {
this.cdref.detectChanges();
}
private getFilteredResults(): void {
@@ -143,10 +164,11 @@ export class SearchUserAutocompleteComponent {
public getGlobalUser(): void {
this.userService.GetUserByLoginNameGlobal(this.globalLoginNameControl.value).then(user => {
this.users = [user.toObject()];
if (this.singleOutput) {
this.users = [user.toObject()];
this.selectionChanged.emit(this.users[0]);
} else {
this.users.push(user.toObject());
this.selectionChanged.emit(this.users);
}
}).catch(error => {
@@ -11,6 +11,7 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core';
import { AvatarModule } from '../avatar/avatar.module';
import { SearchUserAutocompleteComponent } from './search-user-autocomplete.component';
@@ -29,6 +30,7 @@ import { SearchUserAutocompleteComponent } from './search-user-autocomplete.comp
FormsModule,
TranslateModule,
MatSelectModule,
AvatarModule,
],
exports: [SearchUserAutocompleteComponent],
})