mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-15 18:25:13 +00:00
feat: rehauled console (#3525)
* new console * move npm ci to angular build * rel path for assets * local grpc copy * login policy, rm clear views, features rel path * lock Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
parent
00f7dbe875
commit
08ae39ae19
+21
-25
@@ -1,28 +1,24 @@
|
||||
<form>
|
||||
<cnsl-form-field appearance="outline" class="full-width">
|
||||
<cnsl-label>Project Name</cnsl-label>
|
||||
<input cnslInput *ngIf="singleOutput" type="text" placeholder="Search for the project name" #nameInput
|
||||
[formControl]="myControl" [matAutocomplete]="auto" />
|
||||
<cnsl-form-field appearance="outline" class="full-width">
|
||||
<cnsl-label>{{'USER.GRANTS.PROJECTNAME' | translate}}</cnsl-label>
|
||||
<input cnslInput type="text" placeholder="Project XY" #nameInput [formControl]="myControl"
|
||||
[matAutocomplete]="auto" />
|
||||
|
||||
<mat-chip-list *ngIf="!singleOutput" #chipList aria-label="name selection">
|
||||
<mat-chip class="chip" *ngFor="let selectedProject of projects" [selectable]="selectable"
|
||||
[removable]="removable" (removed)="remove(selectedProject)">
|
||||
{{selectedProject?.name ? selectedProject.name + ' (owned)' : selectedProject?.projectName ? selectedProject.projectName + ' (granted)': ''}}
|
||||
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
|
||||
</mat-chip>
|
||||
<input cnslInput placeholder="{{'PROJECT.NAME' | translate}}" #nameInput [formControl]="myControl"
|
||||
[matAutocomplete]="auto" [matChipInputFor]="chipList"
|
||||
[matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur"
|
||||
(matChipInputTokenEnd)="add($event)" />
|
||||
</mat-chip-list>
|
||||
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" [displayWith]="displayFn">
|
||||
<mat-option *ngIf="isLoading" class="is-loading">
|
||||
<mat-spinner diameter="30"></mat-spinner>
|
||||
</mat-option>
|
||||
<mat-option *ngFor="let project of filteredProjects" [value]="project">
|
||||
{{project?.name ? project.name + ' (owned)' : project?.projectName ? project.projectName + ' (granted)': ''}}
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</cnsl-form-field>
|
||||
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event)" [displayWith]="displayFn">
|
||||
<mat-option *ngIf="isLoading" class="is-loading">
|
||||
<mat-spinner diameter="30"></mat-spinner>
|
||||
</mat-option>
|
||||
<mat-option *ngFor="let project of filteredProjects" [value]="project">
|
||||
<div class="project-option">
|
||||
<div class="project-option-column">
|
||||
<span>{{project?.name ? project?.name : project?.projectName ? project?.projectName : ''}}</span>
|
||||
<span class="fill-space"></span>
|
||||
<span class="smaller cnsl-secondary-text">{{(project.name ? 'USER.GRANTS.PROJECT-OWNED' :
|
||||
project?.projectName ? 'USER.GRANTS.PROJECT-GRANTED' : '') |
|
||||
translate}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</cnsl-form-field>
|
||||
</form>
|
||||
+25
@@ -5,3 +5,28 @@
|
||||
input {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.project-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.project-option-column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
|
||||
span {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.fill-space {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.smaller {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-28
@@ -10,6 +10,7 @@ import { TextQueryMethod } from 'src/app/proto/generated/zitadel/object_pb';
|
||||
import { GrantedProject, Project, ProjectNameQuery, ProjectQuery } from 'src/app/proto/generated/zitadel/project_pb';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
|
||||
import { ProjectType } from '../project-members/project-members-datasource';
|
||||
|
||||
export enum ProjectAutocompleteType {
|
||||
PROJECT_OWNED = 0,
|
||||
@@ -33,14 +34,11 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
public isLoading: boolean = false;
|
||||
@ViewChild('nameInput') public nameInput!: ElementRef<HTMLInputElement>;
|
||||
@ViewChild('auto') public matAutocomplete!: MatAutocomplete;
|
||||
@Input() public singleOutput: boolean = false;
|
||||
@Input() public autocompleteType!: ProjectAutocompleteType;
|
||||
@Output() public selectionChanged: EventEmitter<
|
||||
GrantedProject.AsObject[]
|
||||
| GrantedProject.AsObject
|
||||
| Project.AsObject
|
||||
| Project.AsObject[]
|
||||
> = new EventEmitter();
|
||||
@Output() public selectionChanged: EventEmitter<{
|
||||
project: Project.AsObject | GrantedProject.AsObject;
|
||||
type: ProjectType;
|
||||
}> = new EventEmitter();
|
||||
|
||||
private unsubscribed$: Subject<void> = new Subject();
|
||||
constructor(private mgmtService: ManagementService) {
|
||||
@@ -48,8 +46,8 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
.pipe(
|
||||
takeUntil(this.unsubscribed$),
|
||||
debounceTime(200),
|
||||
tap(() => this.isLoading = true),
|
||||
switchMap(value => {
|
||||
tap(() => (this.isLoading = true)),
|
||||
switchMap((value) => {
|
||||
const query = new ProjectQuery();
|
||||
const nameQuery = new ProjectNameQuery();
|
||||
nameQuery.setName(value);
|
||||
@@ -68,7 +66,8 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
]);
|
||||
}
|
||||
}),
|
||||
).subscribe((returnValue) => {
|
||||
)
|
||||
.subscribe((returnValue) => {
|
||||
switch (this.autocompleteType) {
|
||||
case ProjectAutocompleteType.PROJECT_GRANTED:
|
||||
this.isLoading = false;
|
||||
@@ -81,10 +80,8 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
default:
|
||||
this.isLoading = false;
|
||||
this.filteredProjects = [
|
||||
...(returnValue as (ListProjectsResponse.AsObject | ListProjectGrantsResponse.AsObject)[])[0]
|
||||
.resultList,
|
||||
...(returnValue as (ListProjectsResponse.AsObject | ListProjectGrantsResponse.AsObject)[])[1]
|
||||
.resultList,
|
||||
...(returnValue as (ListProjectsResponse.AsObject | ListProjectGrantsResponse.AsObject)[])[0].resultList,
|
||||
...(returnValue as (ListProjectsResponse.AsObject | ListProjectGrantsResponse.AsObject)[])[1].resultList,
|
||||
];
|
||||
break;
|
||||
}
|
||||
@@ -96,8 +93,7 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
public displayFn(project?: any): string {
|
||||
return (project && project.projectName) ? `${project.projectName}` :
|
||||
(project && project.name) ? `${project.name}` : '';
|
||||
return project && project.projectName ? `${project.projectName}` : project && project.name ? `${project.name}` : '';
|
||||
}
|
||||
|
||||
public add(event: MatChipInputEvent): void {
|
||||
@@ -139,18 +135,16 @@ export class SearchProjectAutocompleteComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
public selected(event: MatAutocompleteSelectedEvent): void {
|
||||
if (this.singleOutput) {
|
||||
this.selectionChanged.emit(event.option.value);
|
||||
} else {
|
||||
if (this.projects && this.projects.length > 0) {
|
||||
this.projects.push(event.option.value);
|
||||
} else {
|
||||
this.projects = [event.option.value];
|
||||
}
|
||||
this.selectionChanged.emit(this.projects);
|
||||
const p: Project.AsObject | GrantedProject.AsObject = event.option.value;
|
||||
const type = (p as Project.AsObject).id
|
||||
? ProjectType.PROJECTTYPE_OWNED
|
||||
: (p as GrantedProject.AsObject).projectId
|
||||
? ProjectType.PROJECTTYPE_GRANTED
|
||||
: ProjectType.PROJECTTYPE_OWNED;
|
||||
|
||||
this.nameInput.nativeElement.value = '';
|
||||
this.myControl.setValue(null);
|
||||
}
|
||||
this.selectionChanged.emit({
|
||||
project: p,
|
||||
type: type,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user