-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from swisstopo/feature/workgroups
Feature: Workgroups
- Loading branch information
Showing
210 changed files
with
5,498 additions
and
2,652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
/node_modules | ||
/tmp | ||
/.idea | ||
/development/volumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,16 @@ | ||
import { inject } from '@angular/core'; | ||
import { CanActivateFn } from '@angular/router'; | ||
import { fromAppShared } from '@asset-sg/client-shared'; | ||
import { ORD } from '@asset-sg/core'; | ||
import { User, isAdmin, isEditor } from '@asset-sg/shared'; | ||
import { isNotNull } from '@asset-sg/core'; | ||
import { User } from '@asset-sg/shared/v2'; | ||
import { Store } from '@ngrx/store'; | ||
import * as E from 'fp-ts/Either'; | ||
import { pipe } from 'fp-ts/function'; | ||
import { map } from 'rxjs'; | ||
import { filter, map } from 'rxjs'; | ||
|
||
import { AppState } from './state/app-state'; | ||
|
||
export const roleGuard = (rolePredicate: (u: User) => boolean) => { | ||
export const roleGuard = (testUser: (u: User) => boolean) => { | ||
const store = inject(Store<AppState>); | ||
return store.select(fromAppShared.selectRDUserProfile).pipe( | ||
ORD.filterIsCompleteEither, | ||
map((user) => | ||
E.isRight( | ||
pipe( | ||
user, | ||
E.filterOrElseW(rolePredicate, () => undefined) | ||
) | ||
) | ||
) | ||
); | ||
return store.select(fromAppShared.selectUser).pipe(filter(isNotNull), map(testUser)); | ||
}; | ||
|
||
export const adminGuard: CanActivateFn = () => roleGuard(isAdmin); | ||
export const editorGuard: CanActivateFn = () => roleGuard(isEditor); | ||
export const adminGuard: CanActivateFn = () => roleGuard((user) => user.isAdmin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
<ng-container *ngIf="errorService.onMessage | async as error; else splashScreen"> | ||
<ng-container *ngIf="errorService.onMessage | async as error; else content"> | ||
<asset-sg-app-bar /> | ||
<div class="error"> | ||
<span>{{ error }}</span> | ||
<button asset-sg-warn (click)="authService.logOut()">Logout</button> | ||
</div> | ||
</ng-container> | ||
|
||
<ng-template #splashScreen> | ||
<ng-container *ngIf="(authService.state$ | async) !== AuthState.Success; else content"> | ||
<ng-template #content> | ||
<ng-container *ngIf="authService.state$ | async as authState"> | ||
@if (authState === AuthState.Success || authState === AuthState.ForbiddenResource) { | ||
<asset-sg-app-bar> | ||
<ng-template [cdkPortalOutlet]="(appPortalService.appBarPortalContent$ | push) ?? ''"></ng-template> | ||
</asset-sg-app-bar> | ||
<asset-sg-menu-bar /> | ||
<div class="router-outlet"> | ||
@if (authState === AuthState.Success) { | ||
<router-outlet /> | ||
} @else { | ||
<div class="forbidden"> | ||
<h1 translate>resourceForbidden</h1> | ||
<p>403 - Forbidden</p> | ||
</div> | ||
} | ||
</div> | ||
<div class="drawer-portal"> | ||
<ng-template [cdkPortalOutlet]="(appPortalService.drawerPortalContent$ | push) ?? ''"></ng-template> | ||
</div> | ||
} @else { | ||
<app-splash-screen /> | ||
} | ||
</ng-container> | ||
</ng-template> | ||
|
||
<ng-template #content> | ||
<asset-sg-app-bar> | ||
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template> | ||
</asset-sg-app-bar> | ||
<asset-sg-menu-bar /> | ||
<div class="router-outlet"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
<div class="drawer-portal"> | ||
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template> | ||
</div> | ||
</ng-template> | ||
|
||
<div class="alerts"> | ||
<ul app-alert-list></ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.