mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-17 19:05: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
+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