Skip to content

Commit

Permalink
fix: nullable organisation
Browse files Browse the repository at this point in the history
Fix #51
Fix #52
  • Loading branch information
sebbousquet committed Nov 30, 2023
1 parent 50f4fa5 commit bab4ac2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/app/components/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<arlas-top-menu [showAboutButton]="false">
<div left-menu>{{'ARLAS IAM' | translate}}</div>
<div right-menu>
<div right-menu class="right-menu">
<div *ngIf="!domainOrgExist || isSuperAdmin" class="create-org">
<button class="add-org" (click)="addOrg()" mat-flat-button color="accent">{{'Create organisation' |
translate}}</button>
</div>
<div class="orga">
<div class="orga" *ngIf="organisations.length > 0">
{{'Organisation'| translate}}
<mat-select #currentOrg class="current-orga" [value]="currentSelectedOrg"
(selectionChange)="updateCurrentOrga(currentOrg.value)">
Expand All @@ -24,31 +24,31 @@
</span>
<span class="label">{{'Home' | translate}}</span>
</mat-list-item>
<mat-list-item [matTooltip]="'User' | translate" [routerLink]="'user'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'User' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'user'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
person
</span>
<span class="label">{{'Users' | translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Groups' | translate" [routerLink]="'role'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Groups' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'role'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
group
</span>
<span class="label">{{'Groups'| translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Permissions' | translate" [routerLink]="'permission'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Permissions' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'permission'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
verified_user
</span>
<span class="label">{{'Permissions'| translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Rules' | translate" [routerLink]="'rule'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Rules' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'rule'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
rule
Expand Down
35 changes: 25 additions & 10 deletions src/app/components/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@
background-color: $primaryColor !important;
padding: 0 10px !important;
color: white;
.orga {
font-size: medium;
font-weight: 300;
padding-right: 15px;

.current-orga {
width: 150px;
background-color: white;
color: black;
padding: 0 5px;
.right-menu {
display: flex;
align-items: baseline;
gap: 0 5px;
.create-org {
padding-right: 15px;
.add-org {
line-height: 32px;
vertical-align: bottom;
}
}
.orga {
font-size: medium;
font-weight: 300;
padding-right: 15px;

.current-orga {
width: 150px;
background-color: white;
color: black;
padding: 0 5px;
}
}
}
}
Expand Down Expand Up @@ -45,6 +57,9 @@
}
.mat-list-item {
color: #28292b;
&.mat-list-item-disabled {
cursor: not-allowed !important;
}
}
.mat-list-item-content {
margin: 15px !important;
Expand Down
17 changes: 12 additions & 5 deletions src/app/services/startup/startup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,22 @@ export class IamStartupService {
next: loginData => {
if (!!loginData) {
const storedArlasOrganisation = this.arlasIamService.getOrganisation();
const org = !!storedArlasOrganisation ? storedArlasOrganisation : loginData.user?.organisations[0]?.name;
const org = !!storedArlasOrganisation ? storedArlasOrganisation
: (!!loginData.user?.organisations[0] ? loginData.user?.organisations[0].name : null);

this.arlasIamService.setHeaders(org, loginData.accessToken);

const iamHeader = {
Authorization: 'Bearer ' + loginData.accessToken,
};
// Set the org filter only if the organisation is defined
if (!!org) {
// @ts-ignore
iamHeader['arlas-org-filter'] = org;
}

this.managerService.setOptions({
headers: {
Authorization: 'Bearer ' + loginData.accessToken,
'arlas-org-filter': org
}
headers: iamHeader
});
}
return Promise.resolve(data);
Expand Down
2 changes: 1 addition & 1 deletion src/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ authentication:
force_connect: false
use_discovery: false
threshold: 60000
url: https://arlas.crts-staff.local/arlas_iam_server
url: http://localhost:9997/arlas_iam_server

0 comments on commit bab4ac2

Please sign in to comment.