2020-06-16 14:52:07 +02:00
|
|
|
import { BreakpointObserver } from '@angular/cdk/layout';
|
2020-05-13 14:41:43 +02:00
|
|
|
import { OverlayContainer } from '@angular/cdk/overlay';
|
2020-07-20 15:23:29 +02:00
|
|
|
import { ViewportScroller } from '@angular/common';
|
|
|
|
import { Component, HostBinding, Inject, OnDestroy, ViewChild } from '@angular/core';
|
2020-05-13 14:41:43 +02:00
|
|
|
import { MatIconRegistry } from '@angular/material/icon';
|
|
|
|
import { MatDrawer } from '@angular/material/sidenav';
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
|
import { Router, RouterOutlet } from '@angular/router';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { Observable, of, Subscription } from 'rxjs';
|
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
import { accountCard, navAnimations, routeAnimations, toolbarAnimation } from './animations';
|
2020-07-09 10:54:55 +02:00
|
|
|
import { Org, UserProfileView } from './proto/generated/auth_pb';
|
2020-08-29 10:43:35 +02:00
|
|
|
import { AuthenticationService } from './services/authentication.service';
|
|
|
|
import { GrpcAuthService } from './services/grpc-auth.service';
|
|
|
|
import { ManagementService } from './services/mgmt.service';
|
2020-05-13 14:41:43 +02:00
|
|
|
import { ThemeService } from './services/theme.service';
|
|
|
|
import { ToastService } from './services/toast.service';
|
|
|
|
import { UpdateService } from './services/update.service';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
styleUrls: ['./app.component.scss'],
|
|
|
|
animations: [
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
toolbarAnimation,
|
|
|
|
...navAnimations,
|
|
|
|
accountCard,
|
|
|
|
routeAnimations,
|
2020-05-13 14:41:43 +02:00
|
|
|
],
|
|
|
|
})
|
|
|
|
export class AppComponent implements OnDestroy {
|
2020-08-29 10:43:35 +02:00
|
|
|
@ViewChild('drawer') public drawer!: MatDrawer;
|
2020-05-13 14:41:43 +02:00
|
|
|
public isHandset$: Observable<boolean> = this.breakpointObserver
|
2020-06-16 14:52:07 +02:00
|
|
|
.observe('(max-width: 599px)')
|
2020-05-13 14:41:43 +02:00
|
|
|
.pipe(map(result => {
|
|
|
|
return result.matches;
|
|
|
|
}));
|
|
|
|
@HostBinding('class') public componentCssClass: string = 'dark-theme';
|
|
|
|
|
|
|
|
public showAccount: boolean = false;
|
|
|
|
public org!: Org.AsObject;
|
|
|
|
public orgs: Org.AsObject[] = [];
|
2020-07-09 10:54:55 +02:00
|
|
|
public profile!: UserProfileView.AsObject;
|
2020-05-13 14:41:43 +02:00
|
|
|
public isDarkTheme: Observable<boolean> = of(true);
|
|
|
|
|
|
|
|
public orgLoading: boolean = false;
|
|
|
|
|
|
|
|
public showProjectSection: boolean = false;
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
|
|
|
|
public grantedProjectsCount: number = 0;
|
|
|
|
public ownedProjectsCount: number = 0;
|
|
|
|
|
2020-05-13 14:41:43 +02:00
|
|
|
private authSub: Subscription = new Subscription();
|
|
|
|
private orgSub: Subscription = new Subscription();
|
|
|
|
|
|
|
|
constructor(
|
2020-07-20 15:23:29 +02:00
|
|
|
public viewPortScroller: ViewportScroller,
|
|
|
|
@Inject('windowObject') public window: Window,
|
2020-05-13 14:41:43 +02:00
|
|
|
public translate: TranslateService,
|
2020-08-29 10:43:35 +02:00
|
|
|
public authenticationService: AuthenticationService,
|
|
|
|
public authService: GrpcAuthService,
|
2020-05-13 14:41:43 +02:00
|
|
|
private breakpointObserver: BreakpointObserver,
|
|
|
|
public overlayContainer: OverlayContainer,
|
|
|
|
private themeService: ThemeService,
|
2020-08-29 10:43:35 +02:00
|
|
|
private mgmtService: ManagementService,
|
2020-05-13 14:41:43 +02:00
|
|
|
public matIconRegistry: MatIconRegistry,
|
|
|
|
public domSanitizer: DomSanitizer,
|
|
|
|
private toast: ToastService,
|
|
|
|
private router: Router,
|
|
|
|
update: UpdateService,
|
|
|
|
) {
|
|
|
|
console.log('%cWait!', 'text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; color: #5282c1; font-size: 50px');
|
2020-07-15 09:04:45 +02:00
|
|
|
console.log('%cInserting something here could give attackers access to your zitadel account.', 'color: red; font-size: 18px');
|
2020-05-13 14:41:43 +02:00
|
|
|
console.log('%cIf you don\'t know exactly what you\'re doing, close the window and stay on the safe side', 'font-size: 16px');
|
|
|
|
console.log('%cIf you know exactly what you are doing, you should work for us', 'font-size: 16px');
|
|
|
|
this.setLanguage();
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_account_check_outline',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/account-check-outline.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_account_cancel',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/account-cancel-outline.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_light_on',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/lightbulb-on-outline.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_content_copy',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/content-copy.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_light_off',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/lightbulb-off-outline.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_radar',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/radar.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_lock_question',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/lock-question.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_textbox_password',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/textbox-password.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_lock_reset',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/lock-reset.svg'),
|
|
|
|
);
|
|
|
|
|
2020-07-24 09:48:58 +02:00
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_broom',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/broom.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_pin_outline',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/pin-outline.svg'),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.matIconRegistry.addSvgIcon(
|
|
|
|
'mdi_pin',
|
|
|
|
this.domSanitizer.bypassSecurityTrustResourceUrl('assets/mdi/pin.svg'),
|
|
|
|
);
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
this.getProjectCount();
|
2020-07-24 09:48:58 +02:00
|
|
|
|
2020-05-13 14:41:43 +02:00
|
|
|
this.orgSub = this.authService.activeOrgChanged.subscribe(org => {
|
|
|
|
this.org = org;
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
|
|
|
|
this.getProjectCount();
|
2020-05-13 14:41:43 +02:00
|
|
|
});
|
|
|
|
|
2020-08-29 10:43:35 +02:00
|
|
|
this.authSub = this.authenticationService.authenticationChanged.subscribe((authenticated) => {
|
2020-05-13 14:41:43 +02:00
|
|
|
if (authenticated) {
|
|
|
|
this.authService.GetActiveOrg().then(org => {
|
|
|
|
this.org = org;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const theme = localStorage.getItem('theme');
|
|
|
|
if (theme) {
|
|
|
|
this.overlayContainer.getContainerElement().classList.add(theme);
|
|
|
|
this.componentCssClass = theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isDarkTheme = this.themeService.isDarkTheme;
|
|
|
|
this.isDarkTheme.subscribe(thema => this.onSetTheme(thema ? 'dark-theme' : 'light-theme'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public ngOnDestroy(): void {
|
|
|
|
this.authSub.unsubscribe();
|
|
|
|
this.orgSub.unsubscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
public loadOrgs(): void {
|
|
|
|
this.orgLoading = true;
|
2020-08-29 10:43:35 +02:00
|
|
|
this.authService.SearchMyProjectOrgs(10, 0).then(res => {
|
2020-05-13 14:41:43 +02:00
|
|
|
this.orgs = res.toObject().resultList;
|
|
|
|
this.orgLoading = false;
|
|
|
|
}).catch(error => {
|
2020-07-09 10:54:55 +02:00
|
|
|
this.toast.showError(error);
|
2020-05-13 14:41:43 +02:00
|
|
|
this.orgLoading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public prepareRoute(outlet: RouterOutlet): boolean {
|
|
|
|
return outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public closeAccountCard(): void {
|
|
|
|
if (this.showAccount) {
|
|
|
|
this.showAccount = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public onSetTheme(theme: string): void {
|
|
|
|
localStorage.setItem('theme', theme);
|
|
|
|
this.overlayContainer.getContainerElement().classList.add(theme);
|
|
|
|
this.componentCssClass = theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
private setLanguage(): void {
|
|
|
|
this.translate.addLangs(['en', 'de']);
|
|
|
|
this.translate.setDefaultLang('en');
|
|
|
|
|
|
|
|
this.authService.user.subscribe(userprofile => {
|
|
|
|
this.profile = userprofile;
|
|
|
|
const lang = userprofile.preferredLanguage.match(/en|de/) ? userprofile.preferredLanguage : 'en';
|
|
|
|
this.translate.use(lang);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public setActiveOrg(org: Org.AsObject): void {
|
|
|
|
this.org = org;
|
|
|
|
this.authService.setActiveOrg(org);
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
}
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
|
feat(console): user memberships, generic member create dialog, fix user autocomplete emitter (#606)
* load manager mgmtservice, user service
* add org memberships
* membership component, generic member creation
* refactor member create dialog
* project autocomplete context
* create batch managers in user component
* project context wrapper
* emit on user removal, preselect user on init
* membership avatar style, service
* auth user memberships, navigate to target
* cursor fix, avatar gen
* lint
* i18n fix
* remove role translations
* membership detail page, i18n
* fix role label i18n, after view init loader
* remove projectid from grant remove
* fix iam race condition
* refresh table ts, fix no permission project search
* change membership colors
* refresh table everywhere, replace assets, routing
* fix logo header size
* lint, fix project grant removal
* timestmp for p mem, user list, grants, p list (#615)
* npm audit
* update deps, resolve vulnerability
* fix tslint config
* update lock
* load 20 changes at once
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/en.json
Co-authored-by: Florian Forster <florian@caos.ch>
* membership i18n
Co-authored-by: Florian Forster <florian@caos.ch>
2020-08-24 08:48:47 +02:00
|
|
|
private getProjectCount(): void {
|
|
|
|
this.authService.isAllowed(['project.read']).subscribe((allowed) => {
|
|
|
|
if (allowed) {
|
2020-08-29 10:43:35 +02:00
|
|
|
this.mgmtService.SearchProjects(0, 0).then(res => {
|
feat(console): user memberships, generic member create dialog, fix user autocomplete emitter (#606)
* load manager mgmtservice, user service
* add org memberships
* membership component, generic member creation
* refactor member create dialog
* project autocomplete context
* create batch managers in user component
* project context wrapper
* emit on user removal, preselect user on init
* membership avatar style, service
* auth user memberships, navigate to target
* cursor fix, avatar gen
* lint
* i18n fix
* remove role translations
* membership detail page, i18n
* fix role label i18n, after view init loader
* remove projectid from grant remove
* fix iam race condition
* refresh table ts, fix no permission project search
* change membership colors
* refresh table everywhere, replace assets, routing
* fix logo header size
* lint, fix project grant removal
* timestmp for p mem, user list, grants, p list (#615)
* npm audit
* update deps, resolve vulnerability
* fix tslint config
* update lock
* load 20 changes at once
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/en.json
Co-authored-by: Florian Forster <florian@caos.ch>
* membership i18n
Co-authored-by: Florian Forster <florian@caos.ch>
2020-08-24 08:48:47 +02:00
|
|
|
this.ownedProjectsCount = res.toObject().totalResult;
|
|
|
|
});
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
|
2020-08-29 10:43:35 +02:00
|
|
|
this.mgmtService.SearchGrantedProjects(0, 0).then(res => {
|
feat(console): user memberships, generic member create dialog, fix user autocomplete emitter (#606)
* load manager mgmtservice, user service
* add org memberships
* membership component, generic member creation
* refactor member create dialog
* project autocomplete context
* create batch managers in user component
* project context wrapper
* emit on user removal, preselect user on init
* membership avatar style, service
* auth user memberships, navigate to target
* cursor fix, avatar gen
* lint
* i18n fix
* remove role translations
* membership detail page, i18n
* fix role label i18n, after view init loader
* remove projectid from grant remove
* fix iam race condition
* refresh table ts, fix no permission project search
* change membership colors
* refresh table everywhere, replace assets, routing
* fix logo header size
* lint, fix project grant removal
* timestmp for p mem, user list, grants, p list (#615)
* npm audit
* update deps, resolve vulnerability
* fix tslint config
* update lock
* load 20 changes at once
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/de.json
Co-authored-by: Florian Forster <florian@caos.ch>
* Update console/src/assets/i18n/en.json
Co-authored-by: Florian Forster <florian@caos.ch>
* membership i18n
Co-authored-by: Florian Forster <florian@caos.ch>
2020-08-24 08:48:47 +02:00
|
|
|
this.grantedProjectsCount = res.toObject().totalResult;
|
|
|
|
});
|
|
|
|
}
|
fix(console): hide granted project navigation if none, cache zitadel permissions, emit refresh on org change, cleanup contributors, styling (#511)
* fix iam member model
* fix org member model
* fix auth user loading
* copytoclipboard directive
* directive logs, load bar on init, create user
* typo
* welcome section, contributor spinner
* fix home link
* fix stepper flow
* show dialog on invalid token
* fix app table refresh, pin icons light theme
* cleanup contributor
* inherit parent color, animations
* use localized date pipe everywhere
* cmp styles refactor, dont show granted p if none
* fix navitem desc, fixed header
* change permissions, caching
* roles on org emit, use prom instead of hot obs
* dont calc 100vh
2020-07-28 09:09:18 +02:00
|
|
|
});
|
|
|
|
}
|
2020-05-13 14:41:43 +02:00
|
|
|
}
|
2020-06-25 12:52:57 +02:00
|
|
|
|