feat(console): integrate frontend (#95)

* feat: console frontend

* chore(dependabot): cycle and npm

* chore: rename citadel to zitadel, remove generated files

* chore: delete go files

* chore(frontend): ci steps

* chore: remove docker and envoy files

* chore: remove docker file

* chore: working dir

* chore: run proto build

* add console start

* chore: restructure folders

* chore: remove gui build

* statikFs

* generate proto for console

* add statik import

* import

* chore: try statik

* chore: path

* chore: path

* chore: script in root

* chore: order build steps

* chore: go get

* chore: folder traversal

* chore: non empty test file

* chore: gitignore

* chore: gitignore

* chore: statik path

* chore: switch to failing FE build

* fix: build

* fix: project-grant-test

* fix: rm test

* add statik.go

* go mod tidy

* chore: place test, seperate test from build

* chore: lint all the world

* chore: ci the world instead

* chore: tune docker

* chore: undo container test

* chore: fix run

* chore: docker build

* chore: test docker build

* chore: go build flags

* finaly

* fix caos_local

* go mod

Co-authored-by: Livio Amstutz <[email protected]>
Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
Florian Forster
2020-05-13 14:41:43 +02:00
committed by GitHub
co-authored by Livio Amstutz Max Peintner
parent 9e32740eb8
commit 92a294f5c8
375 changed files with 97826 additions and 52 deletions
@@ -0,0 +1,32 @@
<div class="card" appOutsideClick (clickOutside)="closeCard($event)">
<mat-icon class="avatar">account_circle</mat-icon>
<span class="u-name">{{profile?.firstName}} {{profile?.lastName}}</span>
<span class="u-email">{{profile?.userName}}</span>
<span class="iamuser" *ngIf="iamuser">IAM USER</span>
<button color="accent" (click)="editUserProfile()" mat-stroked-button>{{'USER.EDITACCOUNT' | translate}}</button>
<div class="l-accounts">
<mat-progress-bar *ngIf="loadingUsers" color="accent" mode="indeterminate"></mat-progress-bar>
<a class="row" *ngFor="let user of users" (click)="selectAccount(user.userName)">
<mat-icon class="small-avatar" svgIcon="mdi_account_circle_outline"></mat-icon>
<div class="col">
<span class="title">{{user.userName}}</span>
<span class="email">{{'USER.STATE.'+user.authState | translate}}</span>
</div>
<span class="fill-space"></span>
<mat-icon>keyboard_arrow_right</mat-icon>
</a>
<a class="row" (click)="selectAccount()">
<div class="icon-wrapper">
<mat-icon>add</mat-icon>
</div>
<span class="col">
<span class="title">{{'USER.ADDACCOUNT' | translate}}</span>
</span>
<span class="fill-space"></span>
<mat-icon>keyboard_arrow_right</mat-icon>
</a>
</div>
<button color="accent" (click)="logout()" mat-stroked-button>logout everywhere</button>
</div>
@@ -0,0 +1,112 @@
.card {
border-radius: .5rem;
z-index: 200;
border: 1px solid #ffffff30;
width: 350px;
display: flex;
flex-direction: column;
align-items: center;
padding: 1rem 0;
.avatar {
height: 80px;
width: 80px;
border-radius: 50%;
line-height: 80px;
font-size: 80px;
margin-bottom: 1rem;
}
.u-name {
font-size: 1rem;
line-height: 1rem;
}
.u-email {
font-size: .8rem;
margin-top: 0;
}
.iamuser {
font-size: 1rem;
background: -webkit-linear-gradient(rgb(240,140,53), rgb(233, 60, 231));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
button {
border-radius: 1rem;
margin: .5rem;
.mat-button-wrapper {
font-size: .8rem;
}
}
.l-accounts {
display: flex;
flex-direction: column;
width: 100%;
border-top: 1px solid #ffffff30;
border-bottom: 1px solid #ffffff30;
padding: .5rem 0;
.row {
padding: .5rem;
display: flex;
align-items: center;
color: inherit;
text-decoration: none;
&:hover {
cursor: pointer;
background-color: #ffffff10;
}
.small-avatar {
height: 35px;
width: 35px;
line-height: 35px;
font-size: 35px;
border-radius: 50%;
margin: 0 1rem;
}
.icon-wrapper {
height: 35px;
width: 35px;
border-radius: 50%;
margin: 0 1rem;
text-align: center;
mat-icon {
margin: auto;
vertical-align: middle;
}
}
.col {
flex: 1;
display: flex;
flex-direction: column;
.title {
font-weight: 500;
font-size: .9rem;
line-height: 1rem;
}
.email {
color: #81868a;
font-size: .8rem;
line-height: 1rem;
}
}
.fill-space {
flex: 1;
}
}
}
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AccountsCardComponent } from './accounts-card.component';
describe('AccountsCardComponent', () => {
let component: AccountsCardComponent;
let fixture: ComponentFixture<AccountsCardComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [AccountsCardComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AccountsCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,66 @@
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 { AuthUserService } from 'src/app/services/auth-user.service';
import { AuthService } from 'src/app/services/auth.service';
@Component({
selector: 'app-accounts-card',
templateUrl: './accounts-card.component.html',
styleUrls: ['./accounts-card.component.scss'],
})
export class AccountsCardComponent implements OnInit {
@Input() public profile!: UserProfile.AsObject;
@Input() public iamuser: boolean = false;
@Output() public close: EventEmitter<void> = new EventEmitter();
public users: UserSessionView.AsObject[] = [];
public loadingUsers: boolean = false;
constructor(public authService: AuthService, private router: Router, private userService: AuthUserService) { }
public ngOnInit(): void {
this.loadingUsers = true;
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);
this.loadingUsers = false;
}).catch(() => {
this.loadingUsers = false;
});
}
public editUserProfile(): void {
this.router.navigate(['user/me']);
this.close.emit();
}
public closeCard(element: HTMLElement): void {
if (!element.classList.contains('dontcloseonclick')) {
this.close.emit();
}
}
public selectAccount(loginHint?: string, idToken?: string): void {
const configWithPrompt: Partial<AuthConfig> = {
customQueryParams: {
prompt: 'select_account',
} as any,
};
if (loginHint) {
(configWithPrompt as any).customQueryParams['login_hint'] = loginHint;
}
if (idToken) {
(configWithPrompt as any).customQueryParams['id_token_hint'] = idToken;
}
this.authService.authenticate(configWithPrompt);
}
public logout(): void {
this.router.navigate(['/']);
this.close.emit();
}
}
@@ -0,0 +1,27 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { TranslateModule } from '@ngx-translate/core';
import { OutsideClickModule } from 'src/app/directives/outside-click/outside-click.module';
import { AccountsCardComponent } from './accounts-card.component';
@NgModule({
declarations: [
AccountsCardComponent,
],
imports: [
CommonModule,
MatIconModule,
MatButtonModule,
MatProgressBarModule,
OutsideClickModule,
TranslateModule,
],
exports: [
AccountsCardComponent,
],
})
export class AccountsCardModule { }