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,59 @@
import { Injectable, Injector, OnDestroy, Type } from '@angular/core';
import { GuardsCheckStart, Router, RouterEvent } from '@angular/router';
import { OAuthService } from 'angular-oauth2-oidc';
import { Observable, Subject, throwError } from 'rxjs';
import { filter, map, shareReplay, switchMap, take, takeUntil } from 'rxjs/operators';
import { StatehandlerProcessorService } from './statehandler-processor.service';
export abstract class StatehandlerService {
public abstract createState(): Observable<string | undefined>;
public abstract initStateHandler(): void;
}
@Injectable()
export class StatehandlerServiceImpl
implements StatehandlerService, OnDestroy {
private events?: Observable<string>;
private unsubscribe$: Subject<void> = new Subject();
constructor(
oauthService: OAuthService,
private injector: Injector,
private processor: StatehandlerProcessorService,
) {
oauthService.events
.pipe(
filter(event => event.type === 'token_received'),
map(() => oauthService.state),
takeUntil(this.unsubscribe$),
)
.subscribe(state => processor.restoreState(state));
}
public initStateHandler(): void {
const router = this.injector.get(Router as Type<Router>);
this.events = (router.events as Observable<RouterEvent>).pipe(
filter(event => event instanceof GuardsCheckStart),
map(event => event.url),
shareReplay(1),
);
this.events.pipe(takeUntil(this.unsubscribe$)).subscribe();
}
public createState(): Observable<string | undefined> {
if (this.events === undefined) {
return throwError('no router events');
}
return this.events.pipe(
take(1),
switchMap(url => this.processor.createState(url)),
);
}
public ngOnDestroy(): void {
this.unsubscribe$.next();
}
}