fix: console build (#194)

* grpc gen, headers

* add auth headers

* resolve build errors

* lint

* project grant changes

* project detail

* owned projects

* fix undefined
This commit is contained in:
Max Peintner
2020-06-09 17:12:35 +02:00
committed by GitHub
parent 25b97b1bcc
commit ef9b03cc84
34 changed files with 8916 additions and 3729 deletions

View File

@@ -3,7 +3,7 @@ import { Location } from '@angular/common';
import { Component } from '@angular/core';
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { CreateOrgRequest, Gender, OrgSetUpResponse, RegisterUserRequest } from 'src/app/proto/generated/admin_pb';
import { CreateOrgRequest, CreateUserRequest, Gender, OrgSetUpResponse } from 'src/app/proto/generated/admin_pb';
import { AdminService } from 'src/app/services/admin.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -77,7 +77,7 @@ export class OrgCreateComponent {
createOrgRequest.setName(this.name?.value);
createOrgRequest.setDomain(this.domain?.value);
const registerUserRequest: RegisterUserRequest = new RegisterUserRequest();
const registerUserRequest: CreateUserRequest = new CreateUserRequest();
registerUserRequest.setEmail(this.email?.value);
registerUserRequest.setFirstName(this.firstName?.value);
registerUserRequest.setLastName(this.lastName?.value);

View File

@@ -5,7 +5,7 @@ import { BehaviorSubject, from, of } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { User } from 'src/app/proto/generated/auth_pb';
import {
Project,
GrantedProject,
ProjectMember,
ProjectMemberSearchResponse,
ProjectState,
@@ -25,7 +25,7 @@ import {
styleUrls: ['./project-contributors.component.scss'],
})
export class ProjectContributorsComponent implements OnInit {
@Input() public project!: Project.AsObject;
@Input() public project!: GrantedProject.AsObject;
@Input() public disabled: boolean = false;
public totalResult: number = 0;
@@ -40,7 +40,7 @@ export class ProjectContributorsComponent implements OnInit {
public ngOnInit(): void {
const promise: Promise<ProjectMemberSearchResponse> | undefined =
this.project.type === ProjectType.PROJECTTYPE_SELF ?
this.project.type === ProjectType.PROJECTTYPE_OWNED ?
this.projectService.SearchProjectMembers(this.project.id, 100, 0) :
this.project.type === ProjectType.PROJECTTYPE_GRANTED ?
this.projectService.SearchProjectGrantMembers(this.project.id, this.project.grantId, 100, 0) : undefined;
@@ -64,7 +64,7 @@ export class ProjectContributorsComponent implements OnInit {
data: {
creationType: this.project.type ===
ProjectType.PROJECTTYPE_GRANTED ? CreationType.PROJECT_GRANTED :
ProjectType.PROJECTTYPE_SELF ? CreationType.PROJECT_OWNED : undefined,
ProjectType.PROJECTTYPE_OWNED ? CreationType.PROJECT_OWNED : undefined,
projectId: this.project.id,
},
width: '400px',

View File

@@ -6,11 +6,11 @@
</a>
<h1>{{ 'PROJECT.PAGES.TITLE' | translate }} {{project?.name}}</h1>
<ng-template appHasRole [appHasRole]="['project.write:'+projectId, 'project.write']">
<button *ngIf="project?.type == ProjectType.PROJECTTYPE_SELF" mat-icon-button
<!-- <button *ngIf="project?.type == ProjectType.PROJECTTYPE_OWNED" mat-icon-button
(click)="editstate = !editstate" aria-label="Edit project name">
<mat-icon *ngIf="!editstate">edit</mat-icon>
<mat-icon *ngIf="editstate">close</mat-icon>
</button>
</button> -->
</ng-template>
<div class="full-width">
@@ -35,7 +35,7 @@
</div>
<!-- show only on owned projects-->
<ng-container *ngIf="project?.type === ProjectType.PROJECTTYPE_SELF; else granteddetail">
<ng-container *ngIf="project && projectType == ProjectType.PROJECTTYPE_OWNED; else granteddetail">
<ng-template appHasRole [appHasRole]="['project.app.read:' + project.id, 'project.app.read']">
<app-project-application-grid *ngIf="grid"
[disabled]="project?.state !== ProjectState.PROJECTSTATE_ACTIVE" (changeView)="grid = false"
@@ -65,7 +65,7 @@
<app-card title="{{ 'PROJECT.ROLE.TITLE' | translate }}"
description="{{ 'PROJECT.ROLE.DESCRIPTION' | translate }}">
<app-project-roles [disabled]="project?.state !== ProjectState.PROJECTSTATE_ACTIVE"
[actionsVisible]="project?.type == ProjectType.PROJECTTYPE_SELF" [projectId]="projectId">
[actionsVisible]="true" [projectId]="projectId">
</app-project-roles>
</app-card>
</ng-template>
@@ -85,7 +85,7 @@
<div class="details">
<div class="row">
<span class="first">{{'PROJECT.TYPE.TITLE' | translate}}:</span>
<span class="second" *ngIf="project?.type">{{'PROJECT.TYPE.'+ project.type | translate}}</span>
<span class="second" *ngIf="projectType">{{'PROJECT.TYPE.'+ projectType | translate}}</span>
</div>
<div class="row">
<span class="first">{{'PROJECT.STATE.TITLE' | translate}}:</span>
@@ -94,7 +94,7 @@
</div>
</div>
<ng-container *ngIf="project?.type === ProjectType.PROJECTTYPE_SELF; else grantedmeta">
<ng-container *ngIf="projectType === ProjectType.PROJECTTYPE_OWNED; else grantedmeta">
<mat-tab-group mat-stretch-tabs class="tab-group" disablePagination="true">
<mat-tab label="Details">
<app-project-contributors *ngIf="project"

View File

@@ -29,7 +29,9 @@ import { ToastService } from 'src/app/services/toast.service';
})
export class ProjectDetailComponent implements OnInit, OnDestroy {
public projectId: string = '';
public project!: Project.AsObject;
public grantId: string = '';
public project!: Project.AsObject; // ProjectGrant.AsObject;
public projectType: ProjectType = ProjectType.PROJECTTYPE_OWNED;
public pageSizeRoles: number = 10;
public roleDataSource: MatTableDataSource<ProjectRole.AsObject> = new MatTableDataSource<ProjectRole.AsObject>();
@@ -75,26 +77,40 @@ export class ProjectDetailComponent implements OnInit, OnDestroy {
this.subscription?.unsubscribe();
}
private async getData({ id }: Params): Promise<void> {
private async getData({ id, grantId }: Params): Promise<void> {
this.projectId = id;
this.projectService.GetProjectById(id).then(proj => {
this.project = proj.toObject();
if (this.project.type !== ProjectType.PROJECTTYPE_SELF ||
this.project.state === ProjectState.PROJECTSTATE_INACTIVE ||
this.project.state === ProjectState.PROJECTSTATE_UNSPECIFIED) {
}
this.grantId = grantId;
this.isZitadel$ = from(this.projectService.SearchApplications(this.project.id, 100, 0).then(appsResp => {
const ret = appsResp.toObject().resultList
.filter(app => app.oidcConfig?.clientId === this.grpcService.clientid).length > 0;
return ret;
})); // TODO: replace with prettier thing
}).catch(error => {
this.toast.showError(error.message);
});
if (grantId) {
// this.projectService.GetGrantedProjectGrantByID(id, this.grantId).then(proj => {
// this.projectGrant = proj.toObject();
// this.isZitadel$ = from(this.projectService.SearchApplications(this.project.id, 100, 0).then(appsResp => {
// const ret = appsResp.toObject().resultList
// .filter(app => app.oidcConfig?.clientId === this.grpcService.clientid).length > 0;
// return ret;
// })); // TODO: replace with prettier thing
// }).catch(error => {
// this.toast.showError(error.message);
// });
} else {
this.projectService.GetProjectById(id).then(proj => {
this.project = proj.toObject();
// if (this.project.type !== ProjectType.PROJECTTYPE_SELF ||
// this.project.state === ProjectState.PROJECTSTATE_INACTIVE ||
// this.project.state === ProjectState.PROJECTSTATE_UNSPECIFIED) {
// }
this.isZitadel$ = from(this.projectService.SearchApplications(this.project.id, 100, 0).then(appsResp => {
const ret = appsResp.toObject().resultList
.filter(app => app.oidcConfig?.clientId === this.grpcService.clientid).length > 0;
return ret;
})); // TODO: replace with prettier thing
}).catch(error => {
this.toast.showError(error.message);
});
}
}
public changeState(newState: ProjectState): void {
if (newState === ProjectState.PROJECTSTATE_ACTIVE) {
this.projectService.ReactivateProject(this.projectId).then(() => {

View File

@@ -1,7 +1,7 @@
import { DataSource } from '@angular/cdk/collections';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { Project, ProjectMember } from 'src/app/proto/generated/management_pb';
import { GrantedProject, ProjectMember } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
/**
@@ -19,7 +19,7 @@ export class ProjectGrantMembersDataSource extends DataSource<ProjectMember.AsOb
super();
}
public loadMembers(project: Project.AsObject, pageIndex: number, pageSize: number, sortDirection?: string): void {
public loadMembers(project: GrantedProject.AsObject, pageIndex: number, pageSize: number, sortDirection?: string): void {
const offset = pageIndex * pageSize;
this.loadingSubject.next(true);

View File

@@ -5,7 +5,7 @@ import { MatPaginator } from '@angular/material/paginator';
import { MatTable } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';
import { tap } from 'rxjs/operators';
import { Project, ProjectMember, User } from 'src/app/proto/generated/management_pb';
import { GrantedProject, ProjectMember, User } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -21,7 +21,7 @@ import { ProjectGrantMembersDataSource } from './project-grant-members-datasourc
styleUrls: ['./project-grant-members.component.scss'],
})
export class ProjectGrantMembersComponent implements AfterViewInit, OnInit {
@Input() public project!: Project.AsObject;
@Input() public project!: GrantedProject.AsObject;
public disabled: boolean = false;
@ViewChild(MatPaginator) public paginator!: MatPaginator;
@ViewChild(MatTable) public table!: MatTable<ProjectMember.AsObject>;

View File

@@ -23,16 +23,14 @@
<mat-icon matTooltip="select item" (click)="selection.toggle(item)" class="selection-icon">
check_circle</mat-icon>
<div class="text-part">
<!-- <span *ngIf="item?.creationDate"
class="top">{{item?.creationDate?.toDate() | date: 'dd. MMM, HH:mm'}}</span> -->
<span *ngIf="item.changeDate" class="top">last modified on
{{
dateFromTimestamp(item.changeDate) | date: 'EEE dd. MMM, HH:mm'
}}</span>
<span class="name" *ngIf="item.name">{{ item.name }}</span>
<span class="description" *ngIf="item.state">{{'PROJECT.STATE.'+item.state | translate}}</span>
<span class="description" *ngIf="item.type">{{'PROJECT.TYPE.TITLE' | translate}}:
{{'PROJECT.TYPE.'+item.type | translate}}</span>
<!-- <span class="description" *ngIf="item.type">{{'PROJECT.TYPE.TITLE' | translate}}:
{{'PROJECT.TYPE.'+item.type | translate}}</span> -->
<span *ngIf="item.changeDate" class="created">created on
{{
dateFromTimestamp(item.creationDate) | date: 'EEE dd. MMM, HH:mm'

View File

@@ -3,7 +3,7 @@ import { SelectionModel } from '@angular/cdk/collections';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Router } from '@angular/router';
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
import { Project, ProjectState } from 'src/app/proto/generated/management_pb';
import { GrantedProject, Project, ProjectState } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -45,9 +45,13 @@ export class ProjectGridComponent {
constructor(private router: Router, private projectService: ProjectService, private toast: ToastService) { }
public selectItem(item: Project.AsObject, event?: any): void {
public selectItem(item: GrantedProject.AsObject, event?: any): void {
if (event && !event.target.classList.contains('mat-icon')) {
this.router.navigate(['/projects', item.id]);
if (item.grantId) {
this.router.navigate(['/project-grant', `${item.id}:${item.grantId}`]);
} else {
this.router.navigate(['/projects', item.id]);
}
} else if (!event) {
this.router.navigate(['/projects', item.id]);
}

View File

@@ -7,7 +7,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { Project } from 'src/app/proto/generated/management_pb';
import { GrantedProject, Project } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -37,8 +37,8 @@ import { ToastService } from 'src/app/services/toast.service';
})
export class ProjectListComponent implements OnInit {
public totalResult: number = 0;
public dataSource: MatTableDataSource<Project.AsObject> = new MatTableDataSource<Project.AsObject>();
public projectList: Project.AsObject[] = [];
public dataSource: MatTableDataSource<GrantedProject.AsObject> = new MatTableDataSource<GrantedProject.AsObject>();
public projectList: GrantedProject.AsObject[] = [];
public displayedColumns: string[] = ['select', 'name', 'orgName', 'orgDomain', 'type', 'state', 'creationDate', 'changeDate'];
public selection: SelectionModel<Project.AsObject> = new SelectionModel<Project.AsObject>(true, []);
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
@@ -79,13 +79,16 @@ export class ProjectListComponent implements OnInit {
}
private async getData(limit: number, offset: number): Promise<void> {
console.log('getprojects');
this.loadingSubject.next(true);
this.projectService.SearchProjects(limit, offset).then(res => {
this.projectService.SearchGrantedProjects(limit, offset).then(res => {
this.projectList = res.toObject().resultList;
this.totalResult = res.toObject().totalResult;
this.dataSource.data = this.projectList;
this.loadingSubject.next(false);
console.log(this.projectList);
}).catch(error => {
console.error(error);
this.toast.showError(error.message);
this.loadingSubject.next(false);
});

View File

@@ -1,7 +1,6 @@
import { DataSource } from '@angular/cdk/collections';
import { BehaviorSubject, from, Observable, of } from 'rxjs';
import { catchError, finalize, map } from 'rxjs/operators';
import { Project, ProjectMember, ProjectMemberSearchResponse, ProjectType } from 'src/app/proto/generated/management_pb';
import { BehaviorSubject, Observable } from 'rxjs';
import { Project, ProjectMember } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
/**
@@ -23,24 +22,25 @@ export class ProjectMembersDataSource extends DataSource<ProjectMember.AsObject>
const offset = pageIndex * pageSize;
this.loadingSubject.next(true);
const promise: Promise<ProjectMemberSearchResponse> | undefined =
project.type === ProjectType.PROJECTTYPE_SELF ?
this.projectService.SearchProjectMembers(project.id, pageSize, offset) :
project.type === ProjectType.PROJECTTYPE_GRANTED ?
this.projectService.SearchProjectGrantMembers(project.id, project.grantId, pageSize, offset) : undefined;
if (promise) {
from(promise).pipe(
map(resp => {
this.totalResult = resp.toObject().totalResult;
return resp.toObject().resultList;
}),
catchError(() => of([])),
finalize(() => this.loadingSubject.next(false)),
).subscribe(members => {
this.membersSubject.next(members);
});
}
// TODO
// const promise: Promise<ProjectMemberSearchResponse> | undefined =
// project.type === ProjectType.PROJECTTYPE_OWNED ?
// this.projectService.SearchProjectMembers(project.id, pageSize, offset) :
// project.type === ProjectType.PROJECTTYPE_GRANTED ?
// this.projectService.SearchProjectGrantMembers(project.id,
// project.grantId, pageSize, offset) : undefined;
// if (promise) {
// from(promise).pipe(
// map(resp => {
// this.totalResult = resp.toObject().totalResult;
// return resp.toObject().resultList;
// }),
// catchError(() => of([])),
// finalize(() => this.loadingSubject.next(false)),
// ).subscribe(members => {
// this.membersSubject.next(members);
// });
// }
}

View File

@@ -5,14 +5,10 @@ import { MatPaginator } from '@angular/material/paginator';
import { MatTable } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';
import { tap } from 'rxjs/operators';
import { Project, ProjectMember, ProjectType, User } from 'src/app/proto/generated/management_pb';
import { Project, ProjectMember } from 'src/app/proto/generated/management_pb';
import { ProjectService } from 'src/app/services/project.service';
import { ToastService } from 'src/app/services/toast.service';
import {
CreationType,
ProjectMemberCreateDialogComponent,
} from '../../../modules/add-member-dialog/project-member-create-dialog.component';
import { ProjectMembersDataSource } from './project-members-datasource';
@Component({
@@ -92,31 +88,33 @@ export class ProjectMembersComponent implements AfterViewInit {
}
public openAddMember(): void {
const dialogRef = this.dialog.open(ProjectMemberCreateDialogComponent, {
data: {
creationType: this.project.type ===
ProjectType.PROJECTTYPE_GRANTED ? CreationType.PROJECT_GRANTED :
ProjectType.PROJECTTYPE_SELF ? CreationType.PROJECT_OWNED : undefined,
projectId: this.project.id,
},
width: '400px',
});
dialogRef.afterClosed().subscribe(resp => {
if (resp) {
const users: User.AsObject[] = resp.users;
const roles: string[] = resp.roles;
// TODO
// const dialogRef = this.dialog.open(ProjectMemberCreateDialogComponent, {
// data: {
// creationType: this.project.type ===
// ProjectType.PROJECTTYPE_GRANTED ? CreationType.PROJECT_GRANTED :
// ProjectType.PROJECTTYPE_OWNED ? CreationType.PROJECT_OWNED : undefined,
// projectId: this.project.id,
// },
// width: '400px',
// });
if (users && users.length && roles && roles.length) {
Promise.all(users.map(user => {
return this.projectService.AddProjectMember(this.project.id, user.id, roles);
})).then(() => {
this.toast.showError('members added');
}).catch(error => {
this.toast.showError(error.message);
});
}
}
});
// dialogRef.afterClosed().subscribe(resp => {
// if (resp) {
// const users: User.AsObject[] = resp.users;
// const roles: string[] = resp.roles;
// if (users && users.length && roles && roles.length) {
// Promise.all(users.map(user => {
// return this.projectService.AddProjectMember(this.project.id, user.id, roles);
// })).then(() => {
// this.toast.showError('members added');
// }).catch(error => {
// this.toast.showError(error.message);
// });
// }
// }
// });
}
}

View File

@@ -14,6 +14,11 @@ const routes: Routes = [
path: 'create',
loadChildren: () => import('../project-create/project-create.module').then(m => m.ProjectCreateModule),
},
{
path: ':id/grant/:grantId',
component: ProjectDetailComponent,
data: { animation: 'HomePage' },
},
{
path: ':id',
component: ProjectDetailComponent,

View File

@@ -125,9 +125,11 @@ export class AuthUserDetailComponent implements OnDestroy {
}
public setPassword(): void {
if (this.passwordForm.valid && this.newPassword && this.newPassword.value && this.newPassword.valid) {
if (this.passwordForm.valid && this.currentPassword &&
this.currentPassword.value &&
this.newPassword && this.newPassword.value && this.newPassword.valid) {
this.userService
.SetMyPassword(this.newPassword.value).then((data: any) => {
.ChangeMyPassword(this.currentPassword.value, this.newPassword.value).then((data: any) => {
this.toast.showInfo('Password Set');
this.email = data.toObject();
}).catch(data => {