fix(console): toast login handler, show user session loginname, policy value incrementation, accessibility (#413)

* get auth policy, fix increment from 0

* seo, accessibility

* ngsw rem check for update

* organize interceptors

* toast i18n part1

* show loginname

* use primary color

* toast login handler, fix user session type

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

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

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

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

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

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

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

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

* Update console/src/index.html

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

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

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

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

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

Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
Max Peintner
2020-07-09 10:54:55 +02:00
committed by GitHub
co-authored by Florian Forster
parent fa57cc48c1
commit 0721acf605
69 changed files with 796 additions and 675 deletions
@@ -3,8 +3,8 @@
[name]="profile.displayName ? profile.displayName : (profile.firstName + ' '+ profile.lastName)" [size]="80">
</app-avatar>
<span class="u-name">{{profile?.firstName}} {{profile?.lastName}}</span>
<span class="u-email">{{profile?.userName}}</span>
<span class="u-name">{{profile.displayName ? profile.displayName : profile.userName}}</span>
<span class="u-email">{{profile?.preferredLoginName}}</span>
<span class="iamuser" *ngIf="iamuser">IAM USER</span>
<button (click)="editUserProfile()" mat-stroked-button>{{'USER.EDITACCOUNT' | translate}}</button>
@@ -16,7 +16,8 @@
</app-avatar>
<div class="col">
<span class="title">{{user.userName}}</span>
<span class="title">{{user.displayName ? user.displayName : user.userName}} </span>
<span class="loginname">{{user.loginName}}</span>
<span class="email">{{'USER.STATE.'+user.authState | translate}}</span>
</div>
<span class="fill-space"></span>
@@ -90,7 +90,7 @@
line-height: 1rem;
}
.email {
.email, .loginname {
color: #8795a1;
font-size: .8rem;
line-height: 1rem;
@@ -1,7 +1,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';
import { AuthConfig } from 'angular-oauth2-oidc';
import { UserProfile, UserSessionView } from 'src/app/proto/generated/auth_pb';
import { UserProfileView, UserSessionView } from 'src/app/proto/generated/auth_pb';
import { AuthUserService } from 'src/app/services/auth-user.service';
import { AuthService } from 'src/app/services/auth.service';
@@ -11,7 +11,7 @@ import { AuthService } from 'src/app/services/auth.service';
styleUrls: ['./accounts-card.component.scss'],
})
export class AccountsCardComponent implements OnInit {
@Input() public profile!: UserProfile.AsObject;
@Input() public profile!: UserProfileView.AsObject;
@Input() public iamuser: boolean = false;
@Output() public close: EventEmitter<void> = new EventEmitter();
@@ -20,7 +20,6 @@ export class AccountsCardComponent implements OnInit {
constructor(public authService: AuthService, private router: Router, private userService: AuthUserService) {
this.userService.getMyUserSessions().then(sessions => {
this.users = sessions.toObject().userSessionsList;
const index = this.users.findIndex(user => user.userName === this.profile.userName);
this.users.splice(index, 1);
@@ -45,14 +44,14 @@ export class AccountsCardComponent implements OnInit {
}
}
public selectAccount(loginName?: string): void {
public selectAccount(loginHint?: string): void {
const configWithPrompt: Partial<AuthConfig> = {
customQueryParams: {
// prompt: 'select_account',
} as any,
};
if (loginName) {
(configWithPrompt as any).customQueryParams['login_hint'] = loginName;
if (loginHint) {
(configWithPrompt as any).customQueryParams['login_hint'] = loginHint;
}
this.authService.authenticate(configWithPrompt);
}
@@ -37,19 +37,19 @@ export class MemberCreateDialogComponent {
this.projectService.GetProjectGrantMemberRoles().then(resp => {
this.memberRoleOptions = resp.toObject().rolesList;
}).catch(error => {
toastService.showError(error.message);
toastService.showError(error);
});
} else if (this.creationType === CreationType.PROJECT_OWNED) {
this.projectService.GetProjectMemberRoles().then(resp => {
this.memberRoleOptions = resp.toObject().rolesList;
}).catch(error => {
toastService.showError(error.message);
toastService.showError(error);
});
} else if (this.creationType === CreationType.IAM) {
this.adminService.GetIamMemberRoles().then(resp => {
this.memberRoleOptions = resp.toObject().rolesList;
}).catch(error => {
toastService.showError(error.message);
toastService.showError(error);
});
}
}
@@ -105,7 +105,6 @@ export class ChangesComponent implements OnInit {
return from(col).pipe(
tap((res: Changes) => {
let values = res.toObject().changesList;
console.log(values);
// If prepending, reverse the batch order
values = false ? values.reverse() : values;
@@ -58,7 +58,6 @@ export class ProjectContributorsComponent implements OnInit {
finalize(() => this.loadingSubject.next(false)),
).subscribe(members => {
this.membersSubject.next(members);
console.log(members);
});
}
}
@@ -83,7 +82,7 @@ export class ProjectContributorsComponent implements OnInit {
})).then(() => {
this.toast.showError('members added');
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -42,7 +42,6 @@ export class ProjectMembersDataSource extends DataSource<ProjectMember.AsObject>
finalize(() => this.loadingSubject.next(false)),
).subscribe(members => {
this.membersSubject.next(members);
console.log(members);
});
}
}
@@ -42,9 +42,6 @@ export class ProjectMembersComponent implements AfterViewInit {
this.getRoleOptions();
this.route.params.subscribe(params => {
console.log(params);
console.log(this.projectType);
this.projectService.GetProjectById(params.projectid).then(project => {
this.project = project.toObject();
this.dataSource = new ProjectMembersDataSource(this.projectService);
@@ -69,13 +66,13 @@ export class ProjectMembersComponent implements AfterViewInit {
this.projectService.GetProjectGrantMemberRoles().then(resp => {
this.memberRoleOptions = resp.toObject().rolesList;
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
} else if (this.projectType === ProjectType.PROJECTTYPE_OWNED) {
this.projectService.GetProjectMemberRoles().then(resp => {
this.memberRoleOptions = resp.toObject().rolesList;
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -92,18 +89,18 @@ export class ProjectMembersComponent implements AfterViewInit {
public removeProjectMemberSelection(): void {
Promise.all(this.selection.selected.map(member => {
return this.projectService.RemoveProjectMember(this.project.projectId, member.userId).then(() => {
this.toast.showInfo('Removed successfully');
this.toast.showInfo('PROJECT.TOAST.MEMBERREMOVED', true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}));
}
public removeMember(member: ProjectMember.AsObject): void {
this.projectService.RemoveProjectMember(this.project.projectId, member.userId).then(() => {
this.toast.showInfo('Member removed successfully');
this.toast.showInfo('PROJECT.TOAST.MEMBERREMOVED', true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
@@ -137,9 +134,9 @@ export class ProjectMembersComponent implements AfterViewInit {
Promise.all(users.map(user => {
return this.projectService.AddProjectMember(this.project.projectId, user.id, roles);
})).then(() => {
this.toast.showError('members added');
this.toast.showInfo('PROJECT.TOAST.MEMBERSADDED', true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -147,13 +144,11 @@ export class ProjectMembersComponent implements AfterViewInit {
}
updateRoles(member: ProjectMember.AsObject, selectionChange: MatSelectChange): void {
console.log(member, selectionChange.value);
this.projectService.ChangeProjectMember(this.project.projectId, member.userId, selectionChange.value)
.then((newmember: ProjectMember) => {
console.log(newmember.toObject());
this.toast.showInfo('Member updated!');
this.toast.showInfo('PROJECT.TOAST.MEMBERADDED', true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -23,7 +23,6 @@ export class ProjectRoleDetailComponent implements OnInit {
displayName: new FormControl(''),
group: new FormControl(''),
});
console.log(data);
this.formGroup.patchValue(data.role);
}
@@ -35,10 +34,10 @@ export class ProjectRoleDetailComponent implements OnInit {
if (this.formGroup.valid && this.key?.value && this.group?.value && this.displayName?.value) {
this.projectService.ChangeProjectRole(this.projectId, this.key.value, this.key.value, this.group.value)
.then(() => {
this.toast.showInfo('Role updated');
this.toast.showInfo('PROJECT.TOAST.ROLECHANGED', true);
this.dialogRef.close(true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -33,7 +33,6 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
constructor(private projectService: ProjectService, private toast: ToastService, private dialog: MatDialog) { }
public ngOnInit(): void {
console.log(this.projectId);
this.dataSource = new ProjectRolesDataSource(this.projectService);
this.dataSource.loadRoles(this.projectId, 0, 25, 'asc');
@@ -85,7 +84,7 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
return Promise.all(this.selection.selected.map(role => {
return this.projectService.RemoveProjectRole(role.projectId, role.key);
})).then(() => {
this.toast.showInfo('Deleted');
this.toast.showInfo('PROJECT.TOAST.ROLEREMOVED', true);
indexes.forEach(index => {
if (index > -1) {
oldState.splice(index, 1);
@@ -102,7 +101,7 @@ export class ProjectRolesComponent implements AfterViewInit, OnInit {
this.projectService
.RemoveProjectRole(role.projectId, role.key)
.then(() => {
this.toast.showInfo('Role removed');
this.toast.showInfo('PROJECT.TOAST.ROLEREMOVED', true);
this.dataSource.rolesSubject.value.splice(index, 1);
this.dataSource.rolesSubject.next(this.dataSource.rolesSubject.value);
})
@@ -56,7 +56,6 @@ export class SearchProjectAutocompleteComponent {
).subscribe(([granted, owned]) => {
this.isLoading = false;
this.filteredProjects = [...owned.toObject().resultList, ...granted.toObject().resultList];
console.log(this.filteredProjects);
});
}
@@ -102,7 +101,6 @@ export class SearchProjectAutocompleteComponent {
}
public selected(event: MatAutocompleteSelectedEvent): void {
console.log(event.option.value);
if (this.singleOutput) {
this.selectionChanged.emit(event.option.value);
} else {
@@ -140,7 +140,7 @@ export class SearchUserAutocompleteComponent {
this.users = [user.toObject()];
this.selectionChanged.emit(this.users);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}
@@ -77,7 +77,6 @@ export class UserGrantsDataSource extends DataSource<UserGrant.AsObject> {
from(promise).pipe(
map(resp => {
this.totalResult = resp.toObject().totalResult;
console.log(resp.toObject().resultList);
return resp.toObject().resultList;
}),
catchError(() => of([])),
@@ -56,7 +56,6 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
grantId: this.grantId,
userId: this.userId,
};
console.log(this.context);
switch (this.context) {
case UserGrantContext.OWNED_PROJECT:
@@ -78,7 +77,6 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
default:
this.routerLink = ['/grant-create'];
}
console.log(data);
this.dataSource.loadGrants(this.context, 0, 25, data);
}
@@ -129,20 +127,18 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
updateRoles(grant: UserGrant.AsObject, selectionChange: MatSelectChange): void {
this.userService.UpdateUserGrant(grant.id, grant.userId, selectionChange.value)
.then((newmember: UserGrant) => {
this.toast.showInfo('Grant updated!');
.then(() => {
this.toast.showInfo('GRANTS.TOAST.UPDATED', true);
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
deleteGrantSelection(): void {
this.userService.BulkRemoveUserGrant(this.selection.selected.map(grant => grant.id)).then(() => {
this.toast.showInfo('Grants deleted');
this.toast.showInfo('GRANTS.TOAST.BULKREMOVED', true);
const data = this.dataSource.grantsSubject.getValue();
console.log(data);
this.selection.selected.forEach((item) => {
console.log(item);
const index = data.findIndex(i => i.id === item.id);
if (index > -1) {
data.splice(index, 1);
@@ -151,7 +147,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
});
this.selection.clear();
}).catch(error => {
this.toast.showError(error.message);
this.toast.showError(error);
});
}
}